[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 15f85c7fa9)
Merged-In: Iba408e536b340ea5d66ab499442c0c4f828fa36f
This commit is contained in:
@@ -657,6 +657,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)) {
|
||||
|
||||
Reference in New Issue
Block a user