Applies INSTALL_REPLACE_EXISTING outside of while loop

Prior to this change, the default behavior of replacing packages unless
-R was provided would only happen if at least one command line argument
was provided due to the actual setting of the flag happening within the
while loop that parses arguments. This change moves the application
outside of that loop, ensuring it's always set by default, even if no
arguments are provided.

Bug: 133453175
Test: adb install-multi-package ... with existing packages
Change-Id: I6673bb92c318b0a328880a5e9eb7cc6f5ba0ff40
This commit is contained in:
Patrick Baumann
2019-05-29 09:18:58 -07:00
parent 26fdabb9a0
commit dcf19166c3

View File

@@ -2496,9 +2496,9 @@ class PackageManagerShellCommand extends ShellCommand {
default:
throw new IllegalArgumentException("Unknown option " + opt);
}
if (replaceExisting) {
sessionParams.installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
}
}
if (replaceExisting) {
sessionParams.installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
}
return params;
}