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

Commit 07201a79 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enforce REQUEST_DELETE_PACKAGES for PackageInstaller.uninstall()"

parents 38ca5ccb d9bb39ab
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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";
+6 −0
Original line number Diff line number Diff line
@@ -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);
    }
@@ -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);
+3 −2
Original line number Diff line number Diff line
@@ -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"
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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));