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

Commit ebd42f9d authored by Evan Severson's avatar Evan Severson Committed by Automerger Merge Worker
Browse files

Merge "Implement permission revoke with reason" into rvc-dev am: cee666eb am: 8ce47284

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11959996

Change-Id: I2578303a50377ab1fc14c8898db666fe66a11574
parents fb53f4d1 8ce47284
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -763,25 +763,26 @@ public class ApplicationPackageManager extends PackageManager {

    @Override
    public void revokeRuntimePermission(String packageName, String permName, UserHandle user) {
        revokeRuntimePermission(packageName, permName, user, null);
    }

    @Override
    public void revokeRuntimePermission(String packageName, String permName, UserHandle user,
            String reason) {
        if (DEBUG_TRACE_PERMISSION_UPDATES
                && shouldTraceGrant(packageName, permName, user.getIdentifier())) {
            Log.i(TAG, "App " + mContext.getPackageName() + " is revoking " + packageName + " "
                    + permName + " for user " + user.getIdentifier(), new RuntimeException());
                    + permName + " for user " + user.getIdentifier() + " with reason " + reason,
                    new RuntimeException());
        }
        try {
            mPermissionManager
                    .revokeRuntimePermission(packageName, permName, user.getIdentifier());
                    .revokeRuntimePermission(packageName, permName, user.getIdentifier(), reason);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    public void revokeRuntimePermission(String packageName, String permName, UserHandle user,
            String reason) {
        // TODO evanseverson: impl
    }

    @Override
    public int getPermissionFlags(String permName, String packageName, UserHandle user) {
        try {
+6 −0
Original line number Diff line number Diff line
@@ -677,4 +677,10 @@ interface IActivityManager {
     * Return whether the app freezer is supported (true) or not (false) by this system.
     */
    boolean isAppFreezerSupported();


    /**
     * Kills uid with the reason of permission change.
     */
    void killUidForPermissionChange(int appId, int userId, String reason);
}
+1 −1
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
        }
        final long identity = Binder.clearCallingIdentity();
        try {
            mPermissionManager.revokeRuntimePermission(packageName, permission, userId);
            mPermissionManager.revokeRuntimePermission(packageName, permission, userId, null);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ interface IPermissionManager {

    void grantRuntimePermission(String packageName, String permName, int userId);

    void revokeRuntimePermission(String packageName, String permName, int userId);
    void revokeRuntimePermission(String packageName, String permName, int userId, String reason);

    void resetRuntimePermissions();

+21 −8
Original line number Diff line number Diff line
@@ -82,8 +82,6 @@ import static android.os.Process.removeAllProcessGroups;
import static android.os.Process.sendSignal;
import static android.os.Process.setThreadPriority;
import static android.os.Process.setThreadScheduler;
import static android.permission.PermissionManager.KILL_APP_REASON_GIDS_CHANGED;
import static android.permission.PermissionManager.KILL_APP_REASON_PERMISSIONS_REVOKED;
import static android.provider.Settings.Global.ALWAYS_FINISH_ACTIVITIES;
import static android.provider.Settings.Global.DEBUG_APP;
import static android.provider.Settings.Global.NETWORK_ACCESS_TIMEOUT_MS;
@@ -9202,16 +9200,31 @@ public class ActivityManagerService extends IActivityManager.Stub
        synchronized (this) {
            final long identity = Binder.clearCallingIdentity();
            try {
                boolean permissionChange = KILL_APP_REASON_PERMISSIONS_REVOKED.equals(reason)
                        || KILL_APP_REASON_GIDS_CHANGED.equals(reason);
                mProcessList.killPackageProcessesLocked(null /* packageName */, appId, userId,
                        ProcessList.PERSISTENT_PROC_ADJ, false /* callerWillRestart */,
                        true /* callerWillRestart */, true /* doit */, true /* evenPersistent */,
                        false /* setRemoved */,
                        permissionChange ? ApplicationExitInfo.REASON_PERMISSION_CHANGE
                        : ApplicationExitInfo.REASON_OTHER,
                        permissionChange ? ApplicationExitInfo.SUBREASON_UNKNOWN
                        : ApplicationExitInfo.SUBREASON_KILL_UID,
                        ApplicationExitInfo.REASON_OTHER,
                        ApplicationExitInfo.SUBREASON_KILL_UID,
                        reason != null ? reason : "kill uid");
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }
    }
    @Override
    public void killUidForPermissionChange(int appId, int userId, String reason) {
        enforceCallingPermission(Manifest.permission.KILL_UID, "killUid");
        synchronized (this) {
            final long identity = Binder.clearCallingIdentity();
            try {
                mProcessList.killPackageProcessesLocked(null /* packageName */, appId, userId,
                        ProcessList.PERSISTENT_PROC_ADJ, false /* callerWillRestart */,
                        true /* callerWillRestart */, true /* doit */, true /* evenPersistent */,
                        false /* setRemoved */,
                        ApplicationExitInfo.REASON_PERMISSION_CHANGE,
                        ApplicationExitInfo.SUBREASON_UNKNOWN,
                        reason != null ? reason : "kill uid");
            } finally {
                Binder.restoreCallingIdentity(identity);
Loading