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

Commit fc9264b4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add RollbackImpactLevel options to PackageManagerShellCommand." into main

parents 5f3137bd d42788a9
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -3387,6 +3387,18 @@ class PackageManagerShellCommand extends ShellCommand {
                    }
                    sessionParams.setEnableRollback(true, rollbackStrategy);
                    break;
                case "--rollback-impact-level":
                    if (!Flags.recoverabilityDetection()) {
                        throw new IllegalArgumentException("Unknown option " + opt);
                    }
                    int rollbackImpactLevel = Integer.parseInt(peekNextArg());
                    if (rollbackImpactLevel < PackageManager.ROLLBACK_USER_IMPACT_LOW
                            || rollbackImpactLevel
                                    > PackageManager.ROLLBACK_USER_IMPACT_ONLY_MANUAL) {
                        throw new IllegalArgumentException(
                            rollbackImpactLevel + " is not a valid rollback impact level.");
                    }
                    sessionParams.setRollbackImpactLevel(rollbackImpactLevel);
                case "--staged-ready-timeout":
                    params.stagedReadyTimeoutMs = Long.parseLong(getNextArgRequired());
                    break;
@@ -4571,6 +4583,11 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("      --full: cause the app to be installed as a non-ephemeral full app");
        pw.println("      --enable-rollback: enable rollbacks for the upgrade.");
        pw.println("          0=restore (default), 1=wipe, 2=retain");
        if (Flags.recoverabilityDetection()) {
            pw.println(
                    "      --rollback-impact-level: set device impact required for rollback.");
            pw.println("          0=low (default), 1=high, 2=manual only");
        }
        pw.println("      --install-location: force the install location:");
        pw.println("          0=auto, 1=internal only, 2=prefer external");
        pw.println("      --install-reason: indicates why the app is being installed:");
+13 −0
Original line number Diff line number Diff line
@@ -203,6 +203,15 @@ a different `RollbackDataPolicy`, like `ROLLBACK_DATA_POLICY_RETAIN` (1) or
$ adb install --enable-rollback 1 FooV2.apk
```

### Setting Rollback Impact Level

The `adb install` command accepts the `--rollback-impact-level [0/1/2]` flag to control
when a rollback can be performed by `PackageWatchdog`.

The default rollback impact level is `ROLLBACK_USER_IMPACT_LOW` (0). To use a
different impact level, use `ROLLBACK_USER_IMPACT_HIGH` (1) or `ROLLBACK_USER_IMPACT_ONLY_MANUAL`
(2).

### Triggering Rollback Manually

If rollback is available for an application, the pm command can be used to
@@ -225,6 +234,8 @@ $ adb shell dumpsys rollback
469808841:
  -state: committed
  -timestamp: 2019-04-23T14:57:35.944Z
  -rollbackLifetimeMillis: 0
  -rollbackUserImpact: 1
  -packages:
    com.android.tests.rollback.testapp.B 2 -> 1 [0]
  -causePackages:
@@ -232,6 +243,8 @@ $ adb shell dumpsys rollback
649899517:
  -state: committed
  -timestamp: 2019-04-23T12:55:21.342Z
  -rollbackLifetimeMillis: 0
  -rollbackUserImpact: 0
  -stagedSessionId: 343374391
  -packages:
    com.android.tests.rollback.testapex 2 -> 1 [0]
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.annotation.WorkerThread;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.Flags;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
@@ -960,6 +961,9 @@ class Rollback {
        ipw.println("-stateDescription: " + mStateDescription);
        ipw.println("-timestamp: " + getTimestamp());
        ipw.println("-rollbackLifetimeMillis: " + getRollbackLifetimeMillis());
        if (Flags.recoverabilityDetection()) {
            ipw.println("-rollbackImpactLevel: " + info.getRollbackImpactLevel());
        }
        ipw.println("-isStaged: " + isStaged());
        ipw.println("-originalSessionId: " + getOriginalSessionId());
        ipw.println("-packages:");