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

Commit caa41648 authored by Svetoslav's avatar Svetoslav Committed by Android (Google) Code Review
Browse files

Merge "Allow only system signed apps to grant permissions at install"

parents c5d8d88b 805b63e2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3021,6 +3021,12 @@
        android:description="@string/permdesc_accessVoiceInteractionService"
        android:label="@string/permlab_accessVoiceInteractionService" />

    <!-- Allows an app that has this permission and a permissions to install packages
         to request all runtime permissions to be granted at installation.
     @hide -->
    <permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"
        android:protectionLevel="signature" />

    <!-- The system process is explicitly the only one allowed to launch the
         confirmation UI for full backup/restore -->
    <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@
    <uses-permission android:name="android.permission.BIND_APPWIDGET" />
    <uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
    <uses-permission android:name="android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS"/>
    <uses-permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS" />

    <application android:label="@string/app_label">
        <provider
+10 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.internal.util.XmlUtils.writeUriAttribute;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG;

import android.Manifest;
import android.app.ActivityManager;
import android.app.AppGlobals;
import android.app.AppOpsManager;
@@ -528,6 +529,15 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
            params.installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
        }

        // Only system components can circumvent runtime permissions when installing.
        if ((params.installFlags & PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS) != 0
                && mContext.checkCallingOrSelfPermission(Manifest.permission
                .INSTALL_GRANT_RUNTIME_PERMISSIONS) == PackageManager.PERMISSION_DENIED) {
            throw new SecurityException("You need the "
                    + "android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission "
                    + "to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag");
        }

        // Defensively resize giant app icons
        if (params.appIcon != null) {
            final ActivityManager am = (ActivityManager) mContext.getSystemService(
+9 −1
Original line number Diff line number Diff line
@@ -8612,6 +8612,15 @@ public class PackageManagerService extends IPackageManager.Stub {
            user = new UserHandle(userId);
        }
        // Only system components can circumvent runtime permissions when installing.
        if ((installFlags & PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS) != 0
                && mContext.checkCallingOrSelfPermission(Manifest.permission
                .INSTALL_GRANT_RUNTIME_PERMISSIONS) == PackageManager.PERMISSION_DENIED) {
            throw new SecurityException("You need the "
                    + "android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission "
                    + "to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag");
        }
        verificationParams.setInstallerUid(callingUid);
        final File originFile = new File(originPath);
@@ -8769,7 +8778,6 @@ public class PackageManagerService extends IPackageManager.Stub {
        long callingId = Binder.clearCallingIdentity();
        try {
            boolean sendAdded = false;
            Bundle extras = new Bundle(1);
            // writer
            synchronized (mPackages) {