PackageManagerShellCommand: implicitly add --wait for staged installs
Add --no-wait flag to opt-out from the waiting logic. Also changed the prompt to remind developer to reboot a device to apply an install. Test: adb install system/apex/shim/com.android.apex.cts.shim.v2.apex Test: adb shell pm install-abandon Test: adb install --no-wait system/apex/shim/com.android.apex.cts.shim.v2.apex Bug: 147694315 Change-Id: Ic79905422935d85308d6d57a44005e71a706f2d3
This commit is contained in:
@@ -1159,7 +1159,7 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
}
|
||||
abandonSession = false;
|
||||
|
||||
if (!params.sessionParams.isStaged || !params.waitForStagedSessionReady) {
|
||||
if (!params.sessionParams.isStaged || !params.mWaitForStagedSessionReady) {
|
||||
pw.println("Success");
|
||||
return 0;
|
||||
}
|
||||
@@ -1197,7 +1197,7 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
+ si.getStagedSessionErrorMessage() + "]");
|
||||
return 1;
|
||||
}
|
||||
pw.println("Success");
|
||||
pw.println("Success. Reboot device to apply staged session");
|
||||
return 0;
|
||||
} finally {
|
||||
if (abandonSession) {
|
||||
@@ -2487,7 +2487,7 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
SessionParams sessionParams;
|
||||
String installerPackageName;
|
||||
int userId = UserHandle.USER_ALL;
|
||||
boolean waitForStagedSessionReady = false;
|
||||
boolean mWaitForStagedSessionReady = true;
|
||||
long timeoutMs = DEFAULT_WAIT_MS;
|
||||
}
|
||||
|
||||
@@ -2615,13 +2615,16 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
sessionParams.installFlags |= PackageManager.INSTALL_ENABLE_ROLLBACK;
|
||||
break;
|
||||
case "--wait":
|
||||
params.waitForStagedSessionReady = true;
|
||||
params.mWaitForStagedSessionReady = true;
|
||||
try {
|
||||
params.timeoutMs = Long.parseLong(peekNextArg());
|
||||
getNextArg();
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
break;
|
||||
case "--no-wait":
|
||||
params.mWaitForStagedSessionReady = false;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown option " + opt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user