mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-24 03:35:50 +01:00
Super tiny code improvements
This commit is contained in:
parent
cbef592f8d
commit
6370dcf9dd
@ -140,7 +140,7 @@ public class Credential extends AutoSafeParcelable {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || !(o instanceof Credential)) return false;
|
||||
if (!(o instanceof Credential)) return false;
|
||||
|
||||
Credential that = (Credential) o;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class CredentialPickerConfig extends AutoSafeParcelable {
|
||||
return showCancelButton;
|
||||
}
|
||||
|
||||
public class Builder {
|
||||
public static class Builder {
|
||||
private boolean showAddAccountButton;
|
||||
private boolean showCancelButton;
|
||||
private boolean forNewAccount;
|
||||
|
@ -83,18 +83,17 @@ public class PlayLoggerContext extends AutoSafeParcelable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("PlayLoggerContext[").append(versionCode);
|
||||
sb.append(", package=").append(packageName);
|
||||
sb.append(", packageVersionCode=").append(packageVersionCode);
|
||||
sb.append(", logSource=").append(logSource);
|
||||
sb.append(", uploadAccount=").append(uploadAccount);
|
||||
sb.append(", loggingId=").append(loggingId);
|
||||
sb.append(", logAndroidId=").append(logAndroidId);
|
||||
sb.append(", logSourceName=").append(logSourceName);
|
||||
sb.append(", isAnonymous=").append(isAnonymous);
|
||||
sb.append(", qosTier=").append(qosTier);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
return "PlayLoggerContext[" + versionCode +
|
||||
", package=" + packageName +
|
||||
", packageVersionCode=" + packageVersionCode +
|
||||
", logSource=" + logSource +
|
||||
", uploadAccount=" + uploadAccount +
|
||||
", loggingId=" + loggingId +
|
||||
", logAndroidId=" + logAndroidId +
|
||||
", logSourceName=" + logSourceName +
|
||||
", isAnonymous=" + isAnonymous +
|
||||
", qosTier=" + qosTier +
|
||||
']';
|
||||
}
|
||||
|
||||
public static Creator<PlayLoggerContext> CREATOR = new AutoCreator<>(PlayLoggerContext.class);
|
||||
|
@ -223,7 +223,7 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
||||
windows.add(current);
|
||||
if (!current.allocRow()) {
|
||||
windows.remove(current);
|
||||
return windows.toArray(new CursorWindow[windows.size()]);
|
||||
return windows.toArray(new CursorWindow[0]);
|
||||
}
|
||||
}
|
||||
for (int columnIndex = 0; columnIndex < builder.columns.length; columnIndex++) {
|
||||
@ -256,7 +256,7 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return windows.toArray(new CursorWindow[windows.size()]);
|
||||
return windows.toArray(new CursorWindow[0]);
|
||||
}
|
||||
|
||||
private static CursorWindow[] createCursorWindows(Cursor cursor) {
|
||||
@ -272,7 +272,7 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
||||
windows.add(current);
|
||||
if (!current.allocRow()) {
|
||||
windows.remove(current);
|
||||
return windows.toArray(new CursorWindow[windows.size()]);
|
||||
return windows.toArray(new CursorWindow[0]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
||||
@ -297,7 +297,7 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
||||
rowIndex++;
|
||||
}
|
||||
cursor.close();
|
||||
return windows.toArray(new CursorWindow[windows.size()]);
|
||||
return windows.toArray(new CursorWindow[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +105,7 @@ public abstract class AbstractAboutFragment extends Fragment {
|
||||
List<Library> libraries = new ArrayList<>();
|
||||
collectLibraries(libraries);
|
||||
Collections.sort(libraries);
|
||||
((ListView) aboutRoot.findViewById(android.R.id.list)).setAdapter(new LibraryAdapter(getContext(), libraries.toArray(new Library[libraries.size()])));
|
||||
((ListView) aboutRoot.findViewById(android.R.id.list)).setAdapter(new LibraryAdapter(getContext(), libraries.toArray(new Library[0])));
|
||||
|
||||
return aboutRoot;
|
||||
}
|
||||
|
@ -118,10 +118,7 @@ public class AuthManager {
|
||||
}
|
||||
}
|
||||
String perm = getUserData(buildPermKey());
|
||||
if (!"1".equals(perm)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return "1".equals(perm);
|
||||
}
|
||||
|
||||
public void setExpiry(long expiry) {
|
||||
|
@ -147,8 +147,10 @@ class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
if (services != null) {
|
||||
List<String> servicesList = Arrays.asList(services.split(","));
|
||||
for (String feature : features) {
|
||||
if (feature.startsWith("service_") && !servicesList.contains(feature.substring(8)))
|
||||
if (feature.startsWith("service_") && !servicesList.contains(feature.substring(8))) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = false;
|
||||
|
@ -119,8 +119,6 @@ public class CastDeviceControllerImpl extends ICastDeviceController.Stub impleme
|
||||
@Override
|
||||
public void spontaneousEventReceived(ChromeCastSpontaneousEvent event) {
|
||||
switch (event.getType()) {
|
||||
case MEDIA_STATUS:
|
||||
break;
|
||||
case STATUS:
|
||||
su.litvak.chromecast.api.v2.Status status = (su.litvak.chromecast.api.v2.Status)event.getData();
|
||||
Application app = status.getRunningApp();
|
||||
@ -132,11 +130,11 @@ public class CastDeviceControllerImpl extends ICastDeviceController.Stub impleme
|
||||
int standbyState = status.standBy ? 1 : 0;
|
||||
this.onDeviceStatusChanged(new CastDeviceStatus(status.volume.level, status.volume.muted, activeInputState, metadata, standbyState));
|
||||
break;
|
||||
case APPEVENT:
|
||||
break;
|
||||
case CLOSE:
|
||||
this.onApplicationDisconnected(CommonStatusCodes.SUCCESS);
|
||||
break;
|
||||
case MEDIA_STATUS:
|
||||
case APPEVENT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -165,7 +163,6 @@ public class CastDeviceControllerImpl extends ICastDeviceController.Stub impleme
|
||||
this.chromecast.disconnect();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error disconnecting chromecast: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +173,6 @@ public class CastDeviceControllerImpl extends ICastDeviceController.Stub impleme
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Error sending cast message: " + e.getMessage());
|
||||
this.onSendMessageFailure("", requestId, CommonStatusCodes.NETWORK_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,6 @@ public class CastMediaRouteProvider extends MediaRouteProvider {
|
||||
onChromeCastDiscovered(id, name, host, port, deviceVersion, friendlyName, modelName, iconPath, status);
|
||||
} catch (NullPointerException ex) {
|
||||
Log.e(TAG, "Error getting cast details from DNS-SD response", ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -151,8 +151,8 @@ public class CheckinClient {
|
||||
}
|
||||
if (builder.accountCookie.isEmpty()) builder.accountCookie.add("");
|
||||
if (deviceIdent.wifiMac != null) {
|
||||
builder.macAddress(Arrays.asList(deviceIdent.wifiMac))
|
||||
.macAddressType(Arrays.asList("wifi"));
|
||||
builder.macAddress(Collections.singletonList(deviceIdent.wifiMac))
|
||||
.macAddressType(Collections.singletonList("wifi"));
|
||||
}
|
||||
if (checkinInfo.securityToken != 0) {
|
||||
builder.securityToken(checkinInfo.securityToken)
|
||||
|
@ -44,10 +44,12 @@ public class Build {
|
||||
}
|
||||
|
||||
private String generateSerialNumber() {
|
||||
String serial = "008741";
|
||||
String serial;
|
||||
Random rand = new Random();
|
||||
StringBuilder serialBuilder = new StringBuilder("008741");
|
||||
for (int i = 0; i < 10; i++)
|
||||
serial += Integer.toString(rand.nextInt(16), 16);
|
||||
serialBuilder.append(Integer.toString(rand.nextInt(16), 16));
|
||||
serial = serialBuilder.toString();
|
||||
serial = serial.toUpperCase(Locale.US);
|
||||
return serial;
|
||||
}
|
||||
|
@ -25,22 +25,24 @@ public class DeviceIdentifier {
|
||||
|
||||
|
||||
private static String randomMacAddress() {
|
||||
String mac = "b407f9";
|
||||
StringBuilder mac = new StringBuilder("b407f9");
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
mac += Integer.toString(rand.nextInt(16), 16);
|
||||
mac.append(Integer.toString(rand.nextInt(16), 16));
|
||||
}
|
||||
return mac;
|
||||
return mac.toString();
|
||||
}
|
||||
|
||||
private static String randomMeid() {
|
||||
// http://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity
|
||||
// We start with a known base, and generate random MEID
|
||||
String meid = "35503104";
|
||||
String meid;
|
||||
Random rand = new Random();
|
||||
StringBuilder meidBuilder = new StringBuilder("35503104");
|
||||
for (int i = 0; i < 6; i++) {
|
||||
meid += Integer.toString(rand.nextInt(10));
|
||||
meidBuilder.append(rand.nextInt(10));
|
||||
}
|
||||
meid = meidBuilder.toString();
|
||||
|
||||
// Luhn algorithm (check digit)
|
||||
int sum = 0;
|
||||
|
@ -24,7 +24,7 @@ class ProvisionService : LifecycleService() {
|
||||
super.onStartCommand(intent, flags, startId)
|
||||
lifecycleScope.launchWhenStarted {
|
||||
intent?.extras?.let {
|
||||
val s = it.keySet().map { key -> "$key = ${it[key]}" }.joinToString(", ")
|
||||
val s = it.keySet().joinToString(", ") { key -> "$key = ${it[key]}" }
|
||||
Log.d(TAG, "Provisioning: $s")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user