Loading core/java/android/app/IUserSwitchObserver.aidl +6 −6 Original line number Diff line number Diff line Loading @@ -19,10 +19,10 @@ package android.app; import android.os.IRemoteCallback; /** {@hide} */ oneway interface IUserSwitchObserver { void onBeforeUserSwitching(int newUserId, IRemoteCallback reply); void onUserSwitching(int newUserId, IRemoteCallback reply); void onUserSwitchComplete(int newUserId); void onForegroundProfileSwitch(int newProfileId); void onLockedBootComplete(int newUserId); interface IUserSwitchObserver { void onBeforeUserSwitching(int newUserId); oneway void onUserSwitching(int newUserId, IRemoteCallback reply); oneway void onUserSwitchComplete(int newUserId); oneway void onForegroundProfileSwitch(int newProfileId); oneway void onLockedBootComplete(int newUserId); } core/java/android/app/UserSwitchObserver.java +1 −5 Original line number Diff line number Diff line Loading @@ -30,11 +30,7 @@ public class UserSwitchObserver extends IUserSwitchObserver.Stub { } @Override public void onBeforeUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { if (reply != null) { reply.sendResult(null); } } public void onBeforeUserSwitching(int newUserId) throws RemoteException {} @Override public void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { Loading packages/SystemUI/src/com/android/systemui/settings/UserTracker.kt +1 −10 Original line number Diff line number Diff line Loading @@ -61,17 +61,8 @@ interface UserTracker : UserContentResolverProvider, UserContextProvider { /** Callback for notifying of changes. */ @WeaklyReferencedCallback interface Callback { /** * Same as {@link onBeforeUserSwitching(Int, Runnable)} but the callback will be called * automatically after the completion of this method. */ fun onBeforeUserSwitching(newUser: Int) {} /** Notifies that the current user will be changed. */ fun onBeforeUserSwitching(newUser: Int, resultCallback: Runnable) { onBeforeUserSwitching(newUser) resultCallback.run() } fun onBeforeUserSwitching(newUser: Int) {} /** * Same as {@link onUserChanging(Int, Context, Runnable)} but the callback will be called Loading packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt +3 −3 Original line number Diff line number Diff line Loading @@ -196,9 +196,8 @@ internal constructor( private fun registerUserSwitchObserver() { iActivityManager.registerUserSwitchObserver( object : UserSwitchObserver() { override fun onBeforeUserSwitching(newUserId: Int, reply: IRemoteCallback?) { override fun onBeforeUserSwitching(newUserId: Int) { handleBeforeUserSwitching(newUserId) reply?.sendResult(null) } override fun onUserSwitching(newUserId: Int, reply: IRemoteCallback?) { Loading Loading @@ -237,7 +236,8 @@ internal constructor( setUserIdInternal(newUserId) notifySubscribers { callback, resultCallback -> callback.onBeforeUserSwitching(newUserId, resultCallback) callback.onBeforeUserSwitching(newUserId) resultCallback.run() } .await() } Loading packages/SystemUI/tests/src/com/android/systemui/settings/UserTrackerImplTest.kt +3 −15 Original line number Diff line number Diff line Loading @@ -76,8 +76,6 @@ class UserTrackerImplTest : SysuiTestCase() { @Mock private lateinit var iActivityManager: IActivityManager @Mock private lateinit var beforeUserSwitchingReply: IRemoteCallback @Mock private lateinit var userSwitchingReply: IRemoteCallback @Mock(stubOnly = true) private lateinit var dumpManager: DumpManager Loading Loading @@ -201,10 +199,9 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, beforeUserSwitchingReply) captor.value.onBeforeUserSwitching(newID) captor.value.onUserSwitching(newID, userSwitchingReply) runCurrent() verify(beforeUserSwitchingReply).sendResult(any()) verify(userSwitchingReply).sendResult(any()) verify(userManager).getProfiles(newID) Loading Loading @@ -344,11 +341,10 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, beforeUserSwitchingReply) captor.value.onBeforeUserSwitching(newID) captor.value.onUserSwitching(newID, userSwitchingReply) runCurrent() verify(beforeUserSwitchingReply).sendResult(any()) verify(userSwitchingReply).sendResult(any()) assertThat(callback.calledOnUserChanging).isEqualTo(1) assertThat(callback.lastUser).isEqualTo(newID) Loading Loading @@ -399,7 +395,7 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, any()) captor.value.onBeforeUserSwitching(newID) captor.value.onUserSwitchComplete(newID) runCurrent() Loading Loading @@ -457,10 +453,8 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, beforeUserSwitchingReply) captor.value.onUserSwitching(newID, userSwitchingReply) runCurrent() verify(beforeUserSwitchingReply).sendResult(any()) verify(userSwitchingReply).sendResult(any()) captor.value.onUserSwitchComplete(newID) Loading Loading @@ -494,7 +488,6 @@ class UserTrackerImplTest : SysuiTestCase() { } private class TestCallback : UserTracker.Callback { var calledOnBeforeUserChanging = 0 var calledOnUserChanging = 0 var calledOnUserChanged = 0 var calledOnProfilesChanged = 0 Loading @@ -502,11 +495,6 @@ class UserTrackerImplTest : SysuiTestCase() { var lastUserContext: Context? = null var lastUserProfiles = emptyList<UserInfo>() override fun onBeforeUserSwitching(newUser: Int) { calledOnBeforeUserChanging++ lastUser = newUser } override fun onUserChanging(newUser: Int, userContext: Context) { calledOnUserChanging++ lastUser = newUser Loading Loading
core/java/android/app/IUserSwitchObserver.aidl +6 −6 Original line number Diff line number Diff line Loading @@ -19,10 +19,10 @@ package android.app; import android.os.IRemoteCallback; /** {@hide} */ oneway interface IUserSwitchObserver { void onBeforeUserSwitching(int newUserId, IRemoteCallback reply); void onUserSwitching(int newUserId, IRemoteCallback reply); void onUserSwitchComplete(int newUserId); void onForegroundProfileSwitch(int newProfileId); void onLockedBootComplete(int newUserId); interface IUserSwitchObserver { void onBeforeUserSwitching(int newUserId); oneway void onUserSwitching(int newUserId, IRemoteCallback reply); oneway void onUserSwitchComplete(int newUserId); oneway void onForegroundProfileSwitch(int newProfileId); oneway void onLockedBootComplete(int newUserId); }
core/java/android/app/UserSwitchObserver.java +1 −5 Original line number Diff line number Diff line Loading @@ -30,11 +30,7 @@ public class UserSwitchObserver extends IUserSwitchObserver.Stub { } @Override public void onBeforeUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { if (reply != null) { reply.sendResult(null); } } public void onBeforeUserSwitching(int newUserId) throws RemoteException {} @Override public void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { Loading
packages/SystemUI/src/com/android/systemui/settings/UserTracker.kt +1 −10 Original line number Diff line number Diff line Loading @@ -61,17 +61,8 @@ interface UserTracker : UserContentResolverProvider, UserContextProvider { /** Callback for notifying of changes. */ @WeaklyReferencedCallback interface Callback { /** * Same as {@link onBeforeUserSwitching(Int, Runnable)} but the callback will be called * automatically after the completion of this method. */ fun onBeforeUserSwitching(newUser: Int) {} /** Notifies that the current user will be changed. */ fun onBeforeUserSwitching(newUser: Int, resultCallback: Runnable) { onBeforeUserSwitching(newUser) resultCallback.run() } fun onBeforeUserSwitching(newUser: Int) {} /** * Same as {@link onUserChanging(Int, Context, Runnable)} but the callback will be called Loading
packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt +3 −3 Original line number Diff line number Diff line Loading @@ -196,9 +196,8 @@ internal constructor( private fun registerUserSwitchObserver() { iActivityManager.registerUserSwitchObserver( object : UserSwitchObserver() { override fun onBeforeUserSwitching(newUserId: Int, reply: IRemoteCallback?) { override fun onBeforeUserSwitching(newUserId: Int) { handleBeforeUserSwitching(newUserId) reply?.sendResult(null) } override fun onUserSwitching(newUserId: Int, reply: IRemoteCallback?) { Loading Loading @@ -237,7 +236,8 @@ internal constructor( setUserIdInternal(newUserId) notifySubscribers { callback, resultCallback -> callback.onBeforeUserSwitching(newUserId, resultCallback) callback.onBeforeUserSwitching(newUserId) resultCallback.run() } .await() } Loading
packages/SystemUI/tests/src/com/android/systemui/settings/UserTrackerImplTest.kt +3 −15 Original line number Diff line number Diff line Loading @@ -76,8 +76,6 @@ class UserTrackerImplTest : SysuiTestCase() { @Mock private lateinit var iActivityManager: IActivityManager @Mock private lateinit var beforeUserSwitchingReply: IRemoteCallback @Mock private lateinit var userSwitchingReply: IRemoteCallback @Mock(stubOnly = true) private lateinit var dumpManager: DumpManager Loading Loading @@ -201,10 +199,9 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, beforeUserSwitchingReply) captor.value.onBeforeUserSwitching(newID) captor.value.onUserSwitching(newID, userSwitchingReply) runCurrent() verify(beforeUserSwitchingReply).sendResult(any()) verify(userSwitchingReply).sendResult(any()) verify(userManager).getProfiles(newID) Loading Loading @@ -344,11 +341,10 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, beforeUserSwitchingReply) captor.value.onBeforeUserSwitching(newID) captor.value.onUserSwitching(newID, userSwitchingReply) runCurrent() verify(beforeUserSwitchingReply).sendResult(any()) verify(userSwitchingReply).sendResult(any()) assertThat(callback.calledOnUserChanging).isEqualTo(1) assertThat(callback.lastUser).isEqualTo(newID) Loading Loading @@ -399,7 +395,7 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, any()) captor.value.onBeforeUserSwitching(newID) captor.value.onUserSwitchComplete(newID) runCurrent() Loading Loading @@ -457,10 +453,8 @@ class UserTrackerImplTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(IUserSwitchObserver::class.java) verify(iActivityManager).registerUserSwitchObserver(capture(captor), anyString()) captor.value.onBeforeUserSwitching(newID, beforeUserSwitchingReply) captor.value.onUserSwitching(newID, userSwitchingReply) runCurrent() verify(beforeUserSwitchingReply).sendResult(any()) verify(userSwitchingReply).sendResult(any()) captor.value.onUserSwitchComplete(newID) Loading Loading @@ -494,7 +488,6 @@ class UserTrackerImplTest : SysuiTestCase() { } private class TestCallback : UserTracker.Callback { var calledOnBeforeUserChanging = 0 var calledOnUserChanging = 0 var calledOnUserChanged = 0 var calledOnProfilesChanged = 0 Loading @@ -502,11 +495,6 @@ class UserTrackerImplTest : SysuiTestCase() { var lastUserContext: Context? = null var lastUserProfiles = emptyList<UserInfo>() override fun onBeforeUserSwitching(newUser: Int) { calledOnBeforeUserChanging++ lastUser = newUser } override fun onUserChanging(newUser: Int, userContext: Context) { calledOnUserChanging++ lastUser = newUser Loading