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

Commit b295ac47 authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix role granting flow.

This change fixes various issues realted to the role granting
flow, including allowing permission controller to be granted
SET_PREFERRED_APPLICATIONS for roles, granting
MANAGE_ROLE_HOLDERS permission to shell, and improving
RoleUserState XML parsing.

Bug: 110557011
Test: build
Change-Id: Ia095580ad497af9cf7b29e6bedab70046b09d542
parent 235c7199
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.annotation.SystemService;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -189,7 +190,7 @@ public final class RoleManager {
    @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
    @SystemApi
    public List<String> getRoleHolders(@NonNull String roleName) {
        return getRoleHoldersAsUser(roleName, UserHandle.of(UserHandle.getCallingUserId()));
        return getRoleHoldersAsUser(roleName, Process.myUserHandle());
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -93,8 +93,8 @@ public abstract class RoleControllerService extends Service {
            @Override
            public void onGrantDefaultRoles(IRoleManagerCallback callback) {
                Preconditions.checkNotNull(callback, "callback cannot be null");
                RoleControllerService.this.onGrantDefaultRoles(
                        new RoleManagerCallbackDelegate(callback));
                RoleControllerService.this.onGrantDefaultRoles(new RoleManagerCallbackDelegate(
                        callback));
            }
        };
    }
+1 −1
Original line number Diff line number Diff line
@@ -2495,7 +2495,7 @@
         {@link android.content.pm.PackageManager#addPackageToPreferred}
         for details. -->
    <permission android:name="android.permission.SET_PREFERRED_APPLICATIONS"
        android:protectionLevel="signature|verifier" />
        android:protectionLevel="signature|installer|verifier" />

    <!-- Allows an application to receive the
         {@link android.content.Intent#ACTION_BOOT_COMPLETED} that is
+1 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@
    <uses-permission android:name="android.permission.SET_TIME" />
    <uses-permission android:name="android.permission.SET_TIME_ZONE" />
    <uses-permission android:name="android.permission.DISABLE_HIDDEN_API_CHECKS" />
    <uses-permission android:name="android.permission.MANAGE_ROLE_HOLDERS" />
    <!-- Permission needed to rename bugreport notifications (so they're not shown as Shell) -->
    <uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />
    <!-- Permission needed to hold a wakelock in dumpstate.cpp (drop_root_user()) -->
+7 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class RemoteRoleControllerService {
            private final IRoleManagerCallback mCallback;

            @NonNull
            private final Runnable mTimeoutRunnable = () -> notifyCallback(false);
            private final Runnable mTimeoutRunnable = this::notifyTimeout;

            private boolean mCallbackNotified;

@@ -243,6 +243,12 @@ public class RemoteRoleControllerService {
                }
            }

            @WorkerThread
            private void notifyTimeout() {
                Slog.e(LOG_TAG, "Call timed out, calling onFailure()");
                notifyCallback(false);
            }

            @WorkerThread
            private void notifyCallback(boolean success) {
                if (mCallbackNotified) {
Loading