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

Commit 0a9b6a52 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android Git Automerger
Browse files

am 5d21f416: Merge "Dispatch onUserSwitched callbacks on handler thread" into mnc-dev

* commit '5d21f416':
  Dispatch onUserSwitched callbacks on handler thread
parents e6991a13 5d21f416
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -1353,6 +1353,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final int FOREGROUND_PROFILE_CHANGED_MSG = 53;
    static final int DISPATCH_UIDS_CHANGED_MSG = 54;
    static final int REPORT_TIME_TRACKER_MSG = 55;
    static final int REPORT_USER_SWITCH_COMPLETE_MSG = 56;
    static final int FIRST_ACTIVITY_STACK_MSG = 100;
    static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -2014,6 +2015,9 @@ public final class ActivityManagerService extends ActivityManagerNative
                AppTimeTracker tracker = (AppTimeTracker)msg.obj;
                tracker.deliverResult(mContext);
            } break;
            case REPORT_USER_SWITCH_COMPLETE_MSG: {
                dispatchUserSwitchComplete(msg.arg1);
            } break;
            }
        }
    };
@@ -19910,7 +19914,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
        }
        completeSwitchAndInitalize(uss, newUserId, true, false);
        completeSwitchAndInitialize(uss, newUserId, true, false);
    }
    void moveUserToForeground(UserState uss, int oldUserId, int newUserId) {
@@ -19926,10 +19930,10 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    void continueUserSwitch(UserState uss, int oldUserId, int newUserId) {
        completeSwitchAndInitalize(uss, newUserId, false, true);
        completeSwitchAndInitialize(uss, newUserId, false, true);
    }
    void completeSwitchAndInitalize(UserState uss, int newUserId,
    void completeSwitchAndInitialize(UserState uss, int newUserId,
            boolean clearInitializing, boolean clearSwitching) {
        boolean unfrozen = false;
        synchronized (this) {
@@ -19946,17 +19950,24 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
        }
        if (unfrozen) {
            final int N = mUserSwitchObservers.beginBroadcast();
            for (int i=0; i<N; i++) {
            mHandler.removeMessages(REPORT_USER_SWITCH_COMPLETE_MSG);
            mHandler.sendMessage(mHandler.obtainMessage(REPORT_USER_SWITCH_COMPLETE_MSG,
                    newUserId, 0));
        }
        stopGuestUserIfBackground();
    }
    /** Called on handler thread */
    void dispatchUserSwitchComplete(int userId) {
        final int observerCount = mUserSwitchObservers.beginBroadcast();
        for (int i = 0; i < observerCount; i++) {
            try {
                    mUserSwitchObservers.getBroadcastItem(i).onUserSwitchComplete(newUserId);
                mUserSwitchObservers.getBroadcastItem(i).onUserSwitchComplete(userId);
            } catch (RemoteException e) {
            }
        }
        mUserSwitchObservers.finishBroadcast();
    }
        stopGuestUserIfBackground();
    }
    /**
     * Stops the guest user if it has gone to the background.