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

Commit 15f85c7f authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] forbid deletion of protected packages

BUG: 242996180
Test: adb shell pm uninstall --user 0 com.google.android.apps.work.oobconfig
Test: Verified with the command above. Before this CL, the package can
be deleted. After this CL, the deletion will fail.
Change-Id: I986e4d9661a645da28537a5390214cae837c77d5

Change-Id: Iba408e536b340ea5d66ab499442c0c4f828fa36f
parent 71a04578
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -673,6 +673,18 @@ final class DeletePackageHelper {
        final String packageName = versionedPackage.getPackageName();
        final long versionCode = versionedPackage.getLongVersionCode();

        if (mPm.mProtectedPackages.isPackageDataProtected(userId, packageName)) {
            mPm.mHandler.post(() -> {
                try {
                    Slog.w(TAG, "Attempted to delete protected package: " + packageName);
                    observer.onPackageDeleted(packageName,
                            PackageManager.DELETE_FAILED_INTERNAL_ERROR, null);
                } catch (RemoteException re) {
                }
            });
            return;
        }

        try {
            if (mPm.mInjector.getLocalService(ActivityTaskManagerInternal.class)
                    .isBaseOfLockedTask(packageName)) {