[RESTRICT AUTOMERGE][pm] still allow debuggable for system app downgrades

Turns out we do have internal tests that downgrades system apps, so adding this exception to allow for that.

BUG: 267232653
BUG: 256202273

Test: manual
Change-Id: Ie281bbdc8788ee64ff99a7c5150da7ce7926235e
(cherry picked from commit ceeca68b8c)
This commit is contained in:
Songchun Fan
2023-02-02 10:35:56 -08:00
committed by Song Chun Fan
parent 245ddb614a
commit 636cdf22b9

View File

@@ -26757,14 +26757,18 @@ public class PackageManagerService extends IPackageManager.Stub
if (disabledPs != null) { if (disabledPs != null) {
dataOwnerPkg = disabledPs.getPkg(); dataOwnerPkg = disabledPs.getPkg();
} }
try { if (!Build.IS_DEBUGGABLE && !dataOwnerPkg.isDebuggable()) {
checkDowngrade(dataOwnerPkg, pkgLite); // Only restrict non-debuggable builds and non-debuggable version of the app
} catch (PackageManagerException e) { try {
String errorMsg = "System app: " + packageName + " cannot be downgraded to" checkDowngrade(dataOwnerPkg, pkgLite);
+ " older than its preloaded version on the system image. " } catch (PackageManagerException e) {
+ e.getMessage(); String errorMsg = "System app: " + packageName
Slog.w(TAG, errorMsg); + " cannot be downgraded to"
return PackageManager.INSTALL_FAILED_VERSION_DOWNGRADE; + " older than its preloaded version on the system image. "
+ e.getMessage();
Slog.w(TAG, errorMsg);
return PackageManager.INSTALL_FAILED_VERSION_DOWNGRADE;
}
} }
} }
} }