Merge "Disable package verifier for staged installs."
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index e2907e2..6e52b33 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -866,6 +866,14 @@
*/
public static final int INSTALL_ENABLE_ROLLBACK = 0x00040000;
+ /**
+ * Flag parameter for {@link #installPackage} to indicate that package verification should be
+ * disabled for this package.
+ *
+ * @hide
+ */
+ public static final int INSTALL_DISABLE_VERIFICATION = 0x00080000;
+
/** @hide */
@IntDef(flag = true, prefix = { "DONT_KILL_APP" }, value = {
DONT_KILL_APP
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 87a8935..e18da7f 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -13426,6 +13426,10 @@
return false;
}
+ if ((installFlags & PackageManager.INSTALL_DISABLE_VERIFICATION) != 0) {
+ return false;
+ }
+
boolean ensureVerifyAppsEnabled = isUserRestricted(userId, UserManager.ENSURE_VERIFY_APPS);
// Check if installing from ADB
diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java
index 0371663..cc6cfbb 100644
--- a/services/core/java/com/android/server/pm/StagingManager.java
+++ b/services/core/java/com/android/server/pm/StagingManager.java
@@ -186,6 +186,7 @@
private void preRebootVerification(@NonNull PackageInstallerSession session) {
boolean success = true;
+ // STOPSHIP: TODO(b/123753157): Verify APKs through Package Verifier.
if (!sessionContainsApex(session)) {
// TODO: Decide whether we want to fail fast by detecting signature mismatches for APKs,
// right away.
@@ -336,6 +337,7 @@
PackageInstaller.SessionParams params = originalSession.params.copy();
params.isStaged = false;
+ params.installFlags |= PackageManager.INSTALL_DISABLE_VERIFICATION;
int apkSessionId = mPi.createSession(
params, originalSession.getInstallerPackageName(), originalSession.userId);
PackageInstallerSession apkSession = mPi.getSession(apkSessionId);