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

Commit f63b89c0 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

UserController refactoring

Addressed comments from the previous cl. Added getters for UserController
fields, direct access is no longer allowed. Moved the following methods:
 - getUserManagerLocked. Became getUserManager() - because locking is not
   necessary, double checked locking will suffice.
 - startUserInForeground /showUserSwitchDialog/sendUserSwitchBroadcastsLocked
 - handleIncomingUser/unsafeConvertIncomingUserLocked/isUserRunningLocked/
   getUsers/getProfileIds

Bug: 24745840
Change-Id: Id5a5cfb9604e08add29bd9a03c8fe5200bc51fef
parent 78031818
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ public final class ActiveServices {

        ServiceRecord r = res.record;

        if (!mAm.getUserManagerLocked().exists(r.userId)) {
        if (!mAm.mUserController.exists(r.userId)) {
            Slog.d(TAG, "Trying to start service with non-existent user! " + r.userId);
            return null;
        }
@@ -1030,8 +1030,8 @@ public final class ActiveServices {
        if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "retrieveServiceLocked: " + service
                + " type=" + resolvedType + " callingUid=" + callingUid);

        userId = mAm.handleIncomingUser(callingPid, callingUid, userId,
                false, ActivityManagerService.ALLOW_NON_FULL_IN_PROFILE, "service", null);
        userId = mAm.mUserController.handleIncomingUser(callingPid, callingUid, userId, false,
                ActivityManagerService.ALLOW_NON_FULL_IN_PROFILE, "service", null);

        ServiceMap smap = getServiceMap(userId);
        final ComponentName comp = service.getComponent();
@@ -2333,7 +2333,8 @@ public final class ActiveServices {
                EventLog.writeEvent(EventLogTags.AM_SERVICE_CRASHED_TOO_MUCH,
                        sr.userId, sr.crashCount, sr.shortName, app.pid);
                bringDownServiceLocked(sr);
            } else if (!allowRestart || !mAm.isUserRunningLocked(sr.userId, false)) {
            } else if (!allowRestart
                    || !mAm.mUserController.isUserRunningLocked(sr.userId, false)) {
                bringDownServiceLocked(sr);
            } else {
                boolean canceled = scheduleServiceRestartLocked(sr, true);
@@ -2446,7 +2447,7 @@ public final class ActiveServices {
            if (ActivityManager.checkUidPermission(
                    android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                    uid) == PackageManager.PERMISSION_GRANTED) {
                int[] users = mAm.getUsersLocked();
                int[] users = mAm.mUserController.getUsers();
                for (int ui=0; ui<users.length && res.size() < maxNum; ui++) {
                    ArrayMap<ComponentName, ServiceRecord> alls = getServices(users[ui]);
                    for (int i=0; i<alls.size() && res.size() < maxNum; i++) {
@@ -2580,7 +2581,7 @@ public final class ActiveServices {
                pw.print(mLastAnrDump);
                pw.println();
            }
            int[] users = mAm.getUsersLocked();
            int[] users = mAm.mUserController.getUsers();
            for (int user : users) {
                ServiceMap smap = getServiceMap(user);
                boolean printed = false;
@@ -2817,7 +2818,7 @@ public final class ActiveServices {
        ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();

        synchronized (mAm) {
            int[] users = mAm.getUsersLocked();
            int[] users = mAm.mUserController.getUsers();
            if ("all".equals(name)) {
                for (int user : users) {
                    ServiceMap smap = mServiceMap.get(user);
+61 −252

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ final class ActivityStack {
        mHandler = new ActivityStackHandler(mService.mHandler.getLooper());
        mWindowManager = mService.mWindowManager;
        mStackId = activityContainer.mStackId;
        mCurrentUser = mService.mUserController.mCurrentUserId;
        mCurrentUser = mService.mUserController.getCurrentUserIdLocked();
        mRecentTasks = recentTasks;
        mTaskPositioner = mStackId == FREEFORM_WORKSPACE_STACK_ID
                ? new LaunchingTaskPositioner() : null;
+2 −2
Original line number Diff line number Diff line
@@ -4659,7 +4659,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        @Override
        public final int startActivity(Intent intent) {
            mService.enforceNotIsolatedCaller("ActivityContainer.startActivity");
            final int userId = mService.handleIncomingUser(Binder.getCallingPid(),
            final int userId = mService.mUserController.handleIncomingUser(Binder.getCallingPid(),
                    Binder.getCallingUid(), mCurrentUser, false,
                    ActivityManagerService.ALLOW_FULL_ONLY, "ActivityContainer", null);

@@ -4685,7 +4685,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                throw new IllegalArgumentException("Bad PendingIntent object");
            }

            final int userId = mService.handleIncomingUser(Binder.getCallingPid(),
            final int userId = mService.mUserController.handleIncomingUser(Binder.getCallingPid(),
                    Binder.getCallingUid(), mCurrentUser, false,
                    ActivityManagerService.ALLOW_FULL_ONLY, "ActivityContainer", null);

+1 −1
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ final class PendingIntentRecord extends IIntentSender.Stub {
                boolean sendFinish = finishedReceiver != null;
                int userId = key.userId;
                if (userId == UserHandle.USER_CURRENT) {
                    userId = owner.mUserController.getCurrentUserIdLocked();
                    userId = owner.mUserController.getCurrentOrTargetUserIdLocked();
                }
                switch (key.type) {
                    case ActivityManager.INTENT_SENDER_ACTIVITY:
Loading