Loading packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +4 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import android.os.IBinder; import android.os.IRemoteCallback; import android.os.Looper; import android.os.PatternMatcher; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; Loading Loading @@ -100,6 +99,7 @@ import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.navigationbar.views.NavigationBar; import com.android.systemui.navigationbar.views.NavigationBarView; import com.android.systemui.navigationbar.views.buttons.KeyButtonView; import com.android.systemui.process.ProcessWrapper; import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener; import com.android.systemui.scene.domain.interactor.SceneInteractor; import com.android.systemui.scene.shared.flag.SceneContainerFlag; Loading Loading @@ -675,11 +675,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis DumpManager dumpManager, Optional<UnfoldTransitionProgressForwarder> unfoldTransitionProgressForwarder, BroadcastDispatcher broadcastDispatcher, Optional<BackAnimation> backAnimation Optional<BackAnimation> backAnimation, ProcessWrapper processWrapper ) { // b/241601880: This component should only be running for primary users or // secondaryUsers when visibleBackgroundUsers are supported. boolean isSystemUser = Process.myUserHandle().equals(UserHandle.SYSTEM); boolean isSystemUser = processWrapper.isSystemUser(); boolean isVisibleBackgroundUser = userManager.isVisibleBackgroundUsersSupported() && !userManager.isUserForeground(); if (!isSystemUser && isVisibleBackgroundUser) { Loading packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.kt +31 −53 Original line number Diff line number Diff line Loading @@ -21,14 +21,11 @@ import android.content.Context import android.content.pm.PackageManager import android.content.pm.ResolveInfo import android.os.PowerManager import android.os.Process import android.os.UserHandle import android.os.UserManager import android.testing.TestableContext import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.dx.mockito.inline.extended.ExtendedMockito import com.android.internal.app.AssistUtils import com.android.internal.logging.UiEventLogger import com.android.systemui.SysuiTestCase Loading @@ -42,6 +39,7 @@ import com.android.systemui.model.SysUiState import com.android.systemui.model.sceneContainerPlugin import com.android.systemui.navigationbar.NavigationBarController import com.android.systemui.navigationbar.NavigationModeController import com.android.systemui.process.ProcessWrapper import com.android.systemui.recents.OverviewProxyService.ACTION_QUICKSTEP import com.android.systemui.settings.FakeDisplayTracker import com.android.systemui.settings.UserTracker Loading Loading @@ -92,6 +90,7 @@ class OverviewProxyServiceTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var subject: OverviewProxyService @Mock private val dumpManager = DumpManager() @Mock private val processWrapper = ProcessWrapper() private val displayTracker = FakeDisplayTracker(mContext) private val fakeSystemClock = FakeSystemClock() private val sysUiState = SysUiState(displayTracker, kosmos.sceneContainerPlugin) Loading Loading @@ -146,6 +145,8 @@ class OverviewProxyServiceTest : SysuiTestCase() { mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR) // return isSystemUser as true by default. `when`(processWrapper.isSystemUser).thenReturn(true) subject = createOverviewProxyService(context) } Loading Loading @@ -202,68 +203,44 @@ class OverviewProxyServiceTest : SysuiTestCase() { @Test fun connectToOverviewService_primaryUserNoVisibleBgUsersSupported_expectBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.SYSTEM) `when`(processWrapper.isSystemUser).thenReturn(true) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(false) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, atLeast(1)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } @Test fun connectToOverviewService_nonPrimaryUserNoVisibleBgUsersSupported_expectNoBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.of(12345)) `when`(processWrapper.isSystemUser).thenReturn(false) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(false) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, times(0)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } @Test fun connectToOverviewService_nonPrimaryBgUserVisibleBgUsersSupported_expectBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.of(12345)) `when`(processWrapper.isSystemUser).thenReturn(false) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(true) `when`(userManager.isUserForeground()).thenReturn(false) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, atLeast(1)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } @Test fun connectToOverviewService_nonPrimaryFgUserVisibleBgUsersSupported_expectNoBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.of(12345)) `when`(processWrapper.isSystemUser).thenReturn(false) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(true) `when`(userManager.isUserForeground()).thenReturn(true) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, times(0)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } private fun createOverviewProxyService(ctx: Context): OverviewProxyService { Loading Loading @@ -292,6 +269,7 @@ class OverviewProxyServiceTest : SysuiTestCase() { unfoldTransitionProgressForwarder, broadcastDispatcher, backAnimation, processWrapper, ) } } Loading
packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +4 −3 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import android.os.IBinder; import android.os.IRemoteCallback; import android.os.Looper; import android.os.PatternMatcher; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; Loading Loading @@ -100,6 +99,7 @@ import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.navigationbar.views.NavigationBar; import com.android.systemui.navigationbar.views.NavigationBarView; import com.android.systemui.navigationbar.views.buttons.KeyButtonView; import com.android.systemui.process.ProcessWrapper; import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener; import com.android.systemui.scene.domain.interactor.SceneInteractor; import com.android.systemui.scene.shared.flag.SceneContainerFlag; Loading Loading @@ -675,11 +675,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis DumpManager dumpManager, Optional<UnfoldTransitionProgressForwarder> unfoldTransitionProgressForwarder, BroadcastDispatcher broadcastDispatcher, Optional<BackAnimation> backAnimation Optional<BackAnimation> backAnimation, ProcessWrapper processWrapper ) { // b/241601880: This component should only be running for primary users or // secondaryUsers when visibleBackgroundUsers are supported. boolean isSystemUser = Process.myUserHandle().equals(UserHandle.SYSTEM); boolean isSystemUser = processWrapper.isSystemUser(); boolean isVisibleBackgroundUser = userManager.isVisibleBackgroundUsersSupported() && !userManager.isUserForeground(); if (!isSystemUser && isVisibleBackgroundUser) { Loading
packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.kt +31 −53 Original line number Diff line number Diff line Loading @@ -21,14 +21,11 @@ import android.content.Context import android.content.pm.PackageManager import android.content.pm.ResolveInfo import android.os.PowerManager import android.os.Process import android.os.UserHandle import android.os.UserManager import android.testing.TestableContext import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.dx.mockito.inline.extended.ExtendedMockito import com.android.internal.app.AssistUtils import com.android.internal.logging.UiEventLogger import com.android.systemui.SysuiTestCase Loading @@ -42,6 +39,7 @@ import com.android.systemui.model.SysUiState import com.android.systemui.model.sceneContainerPlugin import com.android.systemui.navigationbar.NavigationBarController import com.android.systemui.navigationbar.NavigationModeController import com.android.systemui.process.ProcessWrapper import com.android.systemui.recents.OverviewProxyService.ACTION_QUICKSTEP import com.android.systemui.settings.FakeDisplayTracker import com.android.systemui.settings.UserTracker Loading Loading @@ -92,6 +90,7 @@ class OverviewProxyServiceTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var subject: OverviewProxyService @Mock private val dumpManager = DumpManager() @Mock private val processWrapper = ProcessWrapper() private val displayTracker = FakeDisplayTracker(mContext) private val fakeSystemClock = FakeSystemClock() private val sysUiState = SysUiState(displayTracker, kosmos.sceneContainerPlugin) Loading Loading @@ -146,6 +145,8 @@ class OverviewProxyServiceTest : SysuiTestCase() { mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR) // return isSystemUser as true by default. `when`(processWrapper.isSystemUser).thenReturn(true) subject = createOverviewProxyService(context) } Loading Loading @@ -202,68 +203,44 @@ class OverviewProxyServiceTest : SysuiTestCase() { @Test fun connectToOverviewService_primaryUserNoVisibleBgUsersSupported_expectBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.SYSTEM) `when`(processWrapper.isSystemUser).thenReturn(true) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(false) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, atLeast(1)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } @Test fun connectToOverviewService_nonPrimaryUserNoVisibleBgUsersSupported_expectNoBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.of(12345)) `when`(processWrapper.isSystemUser).thenReturn(false) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(false) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, times(0)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } @Test fun connectToOverviewService_nonPrimaryBgUserVisibleBgUsersSupported_expectBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.of(12345)) `when`(processWrapper.isSystemUser).thenReturn(false) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(true) `when`(userManager.isUserForeground()).thenReturn(false) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, atLeast(1)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } @Test fun connectToOverviewService_nonPrimaryFgUserVisibleBgUsersSupported_expectNoBindService() { val mockitoSession = ExtendedMockito.mockitoSession().spyStatic(Process::class.java).startMocking() try { `when`(Process.myUserHandle()).thenReturn(UserHandle.of(12345)) `when`(processWrapper.isSystemUser).thenReturn(false) `when`(userManager.isVisibleBackgroundUsersSupported()).thenReturn(true) `when`(userManager.isUserForeground()).thenReturn(true) val spyContext = spy(context) val ops = createOverviewProxyService(spyContext) ops.startConnectionToCurrentUser() verify(spyContext, times(0)).bindServiceAsUser(any(), any(), anyInt(), any()) } finally { mockitoSession.finishMocking() } } private fun createOverviewProxyService(ctx: Context): OverviewProxyService { Loading Loading @@ -292,6 +269,7 @@ class OverviewProxyServiceTest : SysuiTestCase() { unfoldTransitionProgressForwarder, broadcastDispatcher, backAnimation, processWrapper, ) } }