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

Commit 6d492272 authored by Eugene Susla's avatar Eugene Susla
Browse files

Add RoleManagerService as a boot phase

For now it just reads the xml config file on boot

Test: adb logcat | grep -n20 Role # during boot
Change-Id: Iad907fe9bf52f5ed15066484aec60b3a9f51568a
parent 3c91545b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -104,12 +104,18 @@ public class RoleManagerService extends SystemService {
    @Override
    public void onStart() {
        publishBinderService(Context.ROLE_SERVICE, new Stub());
        //TODO add watch for new user creation and run default grants for them
    }

    @Override
    public void onStartUser(@UserIdInt int userId) {
        synchronized (mLock) {
            //TODO only call into PermissionController if it or system upgreaded (for boot time)
            // (add package changes watch;
            //     we can detect upgrade using build fingerprint and app version)
            getUserStateLocked(userId);
            //TODO call permission grant policy here
            Slog.i(LOG_TAG, "Granting default permissions...");
        }
    }

+3 −2
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class RoleUserState {
     * Maps role names to its holders' package names. The values should never be null.
     */
    @GuardedBy("RoleManagerService.mLock")
    private ArrayMap<String, ArraySet<String>> mRoles = new ArrayMap<>();
    private ArrayMap<String, ArraySet<String>> mRoles = null;

    @GuardedBy("RoleManagerService.mLock")
    private boolean mDestroyed;
@@ -188,7 +188,8 @@ public class RoleUserState {
            roles.put(roleName, roleHolders);
        }
        mWriteHandler.removeCallbacksAndMessages(null);
        mWriteHandler.sendMessage(PooledLambda.obtainMessage(this::writeSync, version, roles));
        mWriteHandler.sendMessage(PooledLambda.obtainMessage(
                RoleUserState::writeSync, this, version, roles));
    }

    @WorkerThread
+6 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ import com.android.server.power.PowerManagerService;
import com.android.server.power.ShutdownThread;
import com.android.server.power.ThermalManagerService;
import com.android.server.restrictions.RestrictionsManagerService;
import com.android.server.role.RoleManagerService;
import com.android.server.security.KeyAttestationApplicationIdProviderService;
import com.android.server.security.KeyChainSystemService;
import com.android.server.soundtrigger.SoundTriggerService;
@@ -1905,6 +1906,11 @@ public final class SystemServer {
            }
            traceEnd();

            // Grants default permissions and defines roles
            traceBeginAndSlog("StartRoleManagerService");
            mSystemServiceManager.startService(RoleManagerService.class);
            traceEnd();

            // No dependency on Webview preparation in system server. But this should
            // be completed before allowing 3rd party
            final String WEBVIEW_PREPARATION = "WebViewFactoryPreparation";