Merge "Tidy up RulesManagerService code"
This commit is contained in:
@@ -57,7 +57,6 @@ import static android.app.timezone.RulesState.STAGED_OPERATION_NONE;
|
|||||||
import static android.app.timezone.RulesState.STAGED_OPERATION_UNINSTALL;
|
import static android.app.timezone.RulesState.STAGED_OPERATION_UNINSTALL;
|
||||||
import static android.app.timezone.RulesState.STAGED_OPERATION_UNKNOWN;
|
import static android.app.timezone.RulesState.STAGED_OPERATION_UNKNOWN;
|
||||||
|
|
||||||
// TODO(nfuller) Check error handling best practices in the system server.
|
|
||||||
public final class RulesManagerService extends IRulesManager.Stub {
|
public final class RulesManagerService extends IRulesManager.Stub {
|
||||||
|
|
||||||
private static final String TAG = "timezone.RulesManagerService";
|
private static final String TAG = "timezone.RulesManagerService";
|
||||||
@@ -336,7 +335,7 @@ public final class RulesManagerService extends IRulesManager.Stub {
|
|||||||
private final CheckToken mCheckToken;
|
private final CheckToken mCheckToken;
|
||||||
private final ICallback mCallback;
|
private final ICallback mCallback;
|
||||||
|
|
||||||
public UninstallRunnable(CheckToken checkToken, ICallback callback) {
|
UninstallRunnable(CheckToken checkToken, ICallback callback) {
|
||||||
mCheckToken = checkToken;
|
mCheckToken = checkToken;
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
@@ -401,54 +400,85 @@ public final class RulesManagerService extends IRulesManager.Stub {
|
|||||||
if ("-format_state".equals(args[0]) && args[1] != null) {
|
if ("-format_state".equals(args[0]) && args[1] != null) {
|
||||||
for (char c : args[1].toCharArray()) {
|
for (char c : args[1].toCharArray()) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'p': // Report operation in progress
|
case 'p': {
|
||||||
pw.println("Operation in progress: "
|
// Report operation in progress
|
||||||
+ rulesState.isOperationInProgress());
|
String value = "Unknown";
|
||||||
break;
|
if (rulesState != null) {
|
||||||
case 's': // Report system image rules version
|
value = Boolean.toString(rulesState.isOperationInProgress());
|
||||||
pw.println("System rules version: "
|
|
||||||
+ rulesState.getSystemRulesVersion());
|
|
||||||
break;
|
|
||||||
case 'c': // Report current installation state
|
|
||||||
pw.println("Current install state: "
|
|
||||||
+ distroStatusToString(rulesState.getDistroStatus()));
|
|
||||||
break;
|
|
||||||
case 'i': // Report currently installed version
|
|
||||||
DistroRulesVersion installedRulesVersion =
|
|
||||||
rulesState.getInstalledDistroRulesVersion();
|
|
||||||
pw.print("Installed rules version: ");
|
|
||||||
if (installedRulesVersion == null) {
|
|
||||||
pw.println("<None>");
|
|
||||||
} else {
|
|
||||||
pw.println(installedRulesVersion.toDumpString());
|
|
||||||
}
|
}
|
||||||
|
pw.println("Operation in progress: " + value);
|
||||||
break;
|
break;
|
||||||
case 'o': // Report staged operation type
|
}
|
||||||
int stagedOperationType = rulesState.getStagedOperationType();
|
case 's': {
|
||||||
pw.println("Staged operation: "
|
// Report system image rules version
|
||||||
+ stagedOperationToString(stagedOperationType));
|
String value = "Unknown";
|
||||||
|
if (rulesState != null) {
|
||||||
|
value = rulesState.getSystemRulesVersion();
|
||||||
|
}
|
||||||
|
pw.println("System rules version: " + value);
|
||||||
break;
|
break;
|
||||||
case 't':
|
}
|
||||||
|
case 'c': {
|
||||||
|
// Report current installation state
|
||||||
|
String value = "Unknown";
|
||||||
|
if (rulesState != null) {
|
||||||
|
value = distroStatusToString(rulesState.getDistroStatus());
|
||||||
|
}
|
||||||
|
pw.println("Current install state: " + value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'i': {
|
||||||
|
// Report currently installed version
|
||||||
|
String value = "Unknown";
|
||||||
|
if (rulesState != null) {
|
||||||
|
DistroRulesVersion installedRulesVersion =
|
||||||
|
rulesState.getInstalledDistroRulesVersion();
|
||||||
|
if (installedRulesVersion == null) {
|
||||||
|
value = "<None>";
|
||||||
|
} else {
|
||||||
|
value = installedRulesVersion.toDumpString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pw.println("Installed rules version: " + value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'o': {
|
||||||
|
// Report staged operation type
|
||||||
|
String value = "Unknown";
|
||||||
|
if (rulesState != null) {
|
||||||
|
int stagedOperationType = rulesState.getStagedOperationType();
|
||||||
|
value = stagedOperationToString(stagedOperationType);
|
||||||
|
}
|
||||||
|
pw.println("Staged operation: " + value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 't': {
|
||||||
// Report staged version (i.e. the one that will be installed next boot
|
// Report staged version (i.e. the one that will be installed next boot
|
||||||
// if the staged operation is an install).
|
// if the staged operation is an install).
|
||||||
pw.print("Staged rules version: ");
|
String value = "Unknown";
|
||||||
DistroRulesVersion stagedDistroRulesVersion =
|
if (rulesState != null) {
|
||||||
rulesState.getStagedDistroRulesVersion();
|
DistroRulesVersion stagedDistroRulesVersion =
|
||||||
if (stagedDistroRulesVersion == null) {
|
rulesState.getStagedDistroRulesVersion();
|
||||||
pw.println("<None>");
|
if (stagedDistroRulesVersion == null) {
|
||||||
} else {
|
value = "<None>";
|
||||||
pw.println(stagedDistroRulesVersion.toDumpString());
|
} else {
|
||||||
|
value = stagedDistroRulesVersion.toDumpString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pw.println("Staged rules version: " + value);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
}
|
||||||
|
case 'a': {
|
||||||
// Report the active rules version (i.e. the rules in use by the current
|
// Report the active rules version (i.e. the rules in use by the current
|
||||||
// process).
|
// process).
|
||||||
pw.println("Active rules version (ICU, libcore): "
|
pw.println("Active rules version (ICU, libcore): "
|
||||||
+ ICU.getTZDataVersion() + ","
|
+ ICU.getTZDataVersion() + ","
|
||||||
+ ZoneInfoDB.getInstance().getVersion());
|
+ ZoneInfoDB.getInstance().getVersion());
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
pw.println("Unknown option: " + c);
|
pw.println("Unknown option: " + c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user