Loading core/java/android/content/Intent.java +3 −0 Original line number Diff line number Diff line Loading @@ -1728,6 +1728,9 @@ public class Intent implements Parcelable, Cloneable { * <p> * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install * succeeded. * <p> * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} * since {@link Build.VERSION_CODES#P}. */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; Loading core/java/android/content/pm/PackageInstaller.java +6 −0 Original line number Diff line number Diff line Loading @@ -444,6 +444,9 @@ public class PackageInstaller { * @param packageName The package to uninstall. * @param statusReceiver Where to deliver the result. */ @RequiresPermission(anyOf = { Manifest.permission.DELETE_PACKAGES, Manifest.permission.REQUEST_DELETE_PACKAGES}) public void uninstall(@NonNull String packageName, @NonNull IntentSender statusReceiver) { uninstall(packageName, 0 /*flags*/, statusReceiver); } Loading Loading @@ -476,6 +479,9 @@ public class PackageInstaller { * @param versionedPackage The versioned package to uninstall. * @param statusReceiver Where to deliver the result. */ @RequiresPermission(anyOf = { Manifest.permission.DELETE_PACKAGES, Manifest.permission.REQUEST_DELETE_PACKAGES}) public void uninstall(@NonNull VersionedPackage versionedPackage, @NonNull IntentSender statusReceiver) { uninstall(versionedPackage, 0 /*flags*/, statusReceiver); Loading core/res/AndroidManifest.xml +3 −2 Original line number Diff line number Diff line Loading @@ -2778,8 +2778,9 @@ android:protectionLevel="signature|appop" /> <!-- Allows an application to request deleting packages. Apps targeting APIs greater than 25 must hold this permission in order to use {@link android.content.Intent#ACTION_UNINSTALL_PACKAGE}. targeting APIs {@link android.os.Build.VERSION_CODES#P} or greater must hold this permission in order to use {@link android.content.Intent#ACTION_UNINSTALL_PACKAGE} or {@link android.content.pm.PackageInstaller#uninstall}. <p>Protection level: normal --> <permission android:name="android.permission.REQUEST_DELETE_PACKAGES" Loading services/core/java/com/android/server/pm/PackageInstallerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender.SendIntentException; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageInstallerCallback; import android.content.pm.IPackageInstallerSession; Loading @@ -45,6 +46,7 @@ import android.content.pm.VersionedPackage; import android.graphics.Bitmap; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; Loading Loading @@ -724,6 +726,12 @@ public class PackageInstallerService extends IPackageInstaller.Stub { Binder.restoreCallingIdentity(ident); } } else { ApplicationInfo appInfo = mPm.getApplicationInfo(callerPackageName, 0, userId); if (appInfo.targetSdkVersion >= Build.VERSION_CODES.P) { mContext.enforceCallingOrSelfPermission(Manifest.permission.REQUEST_DELETE_PACKAGES, null); } // Take a short detour to confirm with user final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.fromParts("package", versionedPackage.getPackageName(), null)); Loading Loading
core/java/android/content/Intent.java +3 −0 Original line number Diff line number Diff line Loading @@ -1728,6 +1728,9 @@ public class Intent implements Parcelable, Cloneable { * <p> * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install * succeeded. * <p> * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} * since {@link Build.VERSION_CODES#P}. */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; Loading
core/java/android/content/pm/PackageInstaller.java +6 −0 Original line number Diff line number Diff line Loading @@ -444,6 +444,9 @@ public class PackageInstaller { * @param packageName The package to uninstall. * @param statusReceiver Where to deliver the result. */ @RequiresPermission(anyOf = { Manifest.permission.DELETE_PACKAGES, Manifest.permission.REQUEST_DELETE_PACKAGES}) public void uninstall(@NonNull String packageName, @NonNull IntentSender statusReceiver) { uninstall(packageName, 0 /*flags*/, statusReceiver); } Loading Loading @@ -476,6 +479,9 @@ public class PackageInstaller { * @param versionedPackage The versioned package to uninstall. * @param statusReceiver Where to deliver the result. */ @RequiresPermission(anyOf = { Manifest.permission.DELETE_PACKAGES, Manifest.permission.REQUEST_DELETE_PACKAGES}) public void uninstall(@NonNull VersionedPackage versionedPackage, @NonNull IntentSender statusReceiver) { uninstall(versionedPackage, 0 /*flags*/, statusReceiver); Loading
core/res/AndroidManifest.xml +3 −2 Original line number Diff line number Diff line Loading @@ -2778,8 +2778,9 @@ android:protectionLevel="signature|appop" /> <!-- Allows an application to request deleting packages. Apps targeting APIs greater than 25 must hold this permission in order to use {@link android.content.Intent#ACTION_UNINSTALL_PACKAGE}. targeting APIs {@link android.os.Build.VERSION_CODES#P} or greater must hold this permission in order to use {@link android.content.Intent#ACTION_UNINSTALL_PACKAGE} or {@link android.content.pm.PackageInstaller#uninstall}. <p>Protection level: normal --> <permission android:name="android.permission.REQUEST_DELETE_PACKAGES" Loading
services/core/java/com/android/server/pm/PackageInstallerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender.SendIntentException; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageInstallerCallback; import android.content.pm.IPackageInstallerSession; Loading @@ -45,6 +46,7 @@ import android.content.pm.VersionedPackage; import android.graphics.Bitmap; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; Loading Loading @@ -724,6 +726,12 @@ public class PackageInstallerService extends IPackageInstaller.Stub { Binder.restoreCallingIdentity(ident); } } else { ApplicationInfo appInfo = mPm.getApplicationInfo(callerPackageName, 0, userId); if (appInfo.targetSdkVersion >= Build.VERSION_CODES.P) { mContext.enforceCallingOrSelfPermission(Manifest.permission.REQUEST_DELETE_PACKAGES, null); } // Take a short detour to confirm with user final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.fromParts("package", versionedPackage.getPackageName(), null)); Loading