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

Commit 284511fd authored by Hai Zhang's avatar Hai Zhang
Browse files

Add RoleBehavior.grant()/revoke().

Some roles (e.g. notification assistant) need to grant/revoke specific
privileges, so let them customize that with RoleBehavior.

Bug: 110557011
Test: manual
Change-Id: I39dc2ea462fec09501c811c9aebb9d18f7a2af4d
parent 09f3797a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -417,6 +417,10 @@ public class Role {
            preferredActivity.configure(packageName, context);
        }

        if (mBehavior != null) {
            mBehavior.grant(this, packageName, context);
        }

        if (mayKillApp && !Permissions.isRuntimePermissionsSupported(packageName, context)
                && permissionOrAppOpChanged) {
            killApp(packageName, context);
@@ -462,6 +466,10 @@ public class Role {

        // TODO: STOPSHIP: Revoke preferred activities?

        if (mBehavior != null) {
            mBehavior.revoke(this, packageName, context);
        }

        if (mayKillApp && permissionOrAppOpChanged) {
            killApp(packageName, context);
        }
+11 −0
Original line number Diff line number Diff line
@@ -80,4 +80,15 @@ public interface RoleBehavior {
            @NonNull Context context) {
        return null;
    }

    /**
     * @see Role#grant(String, boolean, boolean, boolean, Context)
     */
    default void grant(@NonNull Role role, @NonNull String packageName, @NonNull Context context) {}

    /**
     * @see Role#revoke(String, boolean, boolean, Context)
     */
    default void revoke(@NonNull Role role, @NonNull String packageName,
            @NonNull Context context) {}
}