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

Commit 53865416 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: Iba408e536b340ea5d66ab499442c0c4f828fa36f
(cherry picked from commit 15f85c7f)
Merged-In: Iba408e536b340ea5d66ab499442c0c4f828fa36f
parent b2434072
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -18207,6 +18207,20 @@ public class PackageManagerService extends IPackageManager.Stub
        final String packageName = versionedPackage.getPackageName();
        final long versionCode = versionedPackage.getLongVersionCode();
        if (mProtectedPackages.isPackageStateProtected(userId, packageName)) {
            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;
        }
        final String internalPackageName;
        try {