Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3babaf38 authored by Neil Fuller's avatar Neil Fuller Committed by android-build-merger
Browse files

Merge "Merge "Merge "Tidy up RulesManagerService code" am: d5517c39 am:...

Merge "Merge "Merge "Tidy up RulesManagerService code" am: d5517c39 am: ef21b72d am: c2f58098" into oc-dr1-dev-plus-aosp am: 224980cd" into oc-mr1-dev-plus-aosp
am: 55ce3e46

Change-Id: Iedfc845f2764ebf21b424922a3f1bc51f44e066b
parents d19858b8 55ce3e46
Loading
Loading
Loading
Loading
+63 −33
Original line number Diff line number Diff line
@@ -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_UNKNOWN;

// TODO(nfuller) Check error handling best practices in the system server.
public final class RulesManagerService extends IRulesManager.Stub {

    private static final String TAG = "timezone.RulesManagerService";
@@ -336,7 +335,7 @@ public final class RulesManagerService extends IRulesManager.Stub {
        private final CheckToken mCheckToken;
        private final ICallback mCallback;

        public UninstallRunnable(CheckToken checkToken, ICallback callback) {
        UninstallRunnable(CheckToken checkToken, ICallback callback) {
            mCheckToken = checkToken;
            mCallback = callback;
        }
@@ -401,56 +400,87 @@ public final class RulesManagerService extends IRulesManager.Stub {
            if ("-format_state".equals(args[0]) && args[1] != null) {
                for (char c : args[1].toCharArray()) {
                    switch (c) {
                        case 'p': // Report operation in progress
                            pw.println("Operation in progress: "
                                    + rulesState.isOperationInProgress());
                        case 'p': {
                            // Report operation in progress
                            String value = "Unknown";
                            if (rulesState != null) {
                                value = Boolean.toString(rulesState.isOperationInProgress());
                            }
                            pw.println("Operation in progress: " + value);
                            break;
                        case 's': // Report system image rules version
                            pw.println("System rules version: "
                                    + rulesState.getSystemRulesVersion());
                        }
                        case 's': {
                            // Report system image rules version
                            String value = "Unknown";
                            if (rulesState != null) {
                                value = rulesState.getSystemRulesVersion();
                            }
                            pw.println("System rules version: " + value);
                            break;
                        case 'c': // Report current installation state
                            pw.println("Current install state: "
                                    + distroStatusToString(rulesState.getDistroStatus()));
                        }
                        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
                        }
                        case 'i': {
                            // Report currently installed version
                            String value = "Unknown";
                            if (rulesState != null) {
                                DistroRulesVersion installedRulesVersion =
                                        rulesState.getInstalledDistroRulesVersion();
                            pw.print("Installed rules version: ");
                                if (installedRulesVersion == null) {
                                pw.println("<None>");
                                    value = "<None>";
                                } else {
                                pw.println(installedRulesVersion.toDumpString());
                                    value = installedRulesVersion.toDumpString();
                                }
                            }
                            pw.println("Installed rules version: " + value);
                            break;
                        case 'o': // Report staged operation type
                        }
                        case 'o': {
                            // Report staged operation type
                            String value = "Unknown";
                            if (rulesState != null) {
                                int stagedOperationType = rulesState.getStagedOperationType();
                            pw.println("Staged operation: "
                                    + stagedOperationToString(stagedOperationType));
                                value = stagedOperationToString(stagedOperationType);
                            }
                            pw.println("Staged operation: " + value);
                            break;
                        case 't':
                        }
                        case 't': {
                            // Report staged version (i.e. the one that will be installed next boot
                            // if the staged operation is an install).
                            pw.print("Staged rules version: ");
                            String value = "Unknown";
                            if (rulesState != null) {
                                DistroRulesVersion stagedDistroRulesVersion =
                                        rulesState.getStagedDistroRulesVersion();
                                if (stagedDistroRulesVersion == null) {
                                pw.println("<None>");
                                    value = "<None>";
                                } else {
                                pw.println(stagedDistroRulesVersion.toDumpString());
                                    value = stagedDistroRulesVersion.toDumpString();
                                }
                            }
                            pw.println("Staged rules version: " + value);
                            break;
                        case 'a':
                        }
                        case 'a': {
                            // Report the active rules version (i.e. the rules in use by the current
                            // process).
                            pw.println("Active rules version (ICU, libcore): "
                                    + ICU.getTZDataVersion() + ","
                                    + ZoneInfoDB.getInstance().getVersion());
                            break;
                        default:
                        }
                        default: {
                            pw.println("Unknown option: " + c);
                        }
                    }
                }
                return;
            }
        }