diff options
9 files changed, 53 insertions, 19 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt index 1c40cd06c119..5d51c6d16c5a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt @@ -263,7 +263,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() { guestUserInteractor = guestUserInteractor, uiEventLogger = uiEventLogger, userRestrictionChecker = mock(), - processWrapper = ProcessWrapperFake() + processWrapper = ProcessWrapperFake(activityManager) ) ) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt index e1d1057ea249..8ff088f5d29b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt @@ -175,7 +175,7 @@ class UserSwitcherViewModelTest : SysuiTestCase() { guestUserInteractor = guestUserInteractor, uiEventLogger = uiEventLogger, userRestrictionChecker = mock(), - processWrapper = ProcessWrapperFake() + processWrapper = ProcessWrapperFake(activityManager) ), guestUserInteractor = guestUserInteractor, ) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index fd50485fc3a3..372fdca20ed9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -3728,12 +3728,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, // windows that appear on top, ever int flags = StatusBarManager.DISABLE_NONE; - // TODO (b/155663717) After restart, status bar will not properly hide home button + // TODO(b/155663717): After restart, status bar will not properly hide home button // unless disable is called to show un-hide it once first if (forceClearFlags) { if (UserManager.isVisibleBackgroundUsersEnabled() - && !mProcessWrapper.isSystemUser() && !mProcessWrapper.isForegroundUser()) { - // TODO: b/341604160 - Support visible background users properly. + && !mProcessWrapper.isSystemUser() + && !mProcessWrapper.isForegroundUserOrProfile()) { + // TODO(b/341604160): Support visible background users properly. if (DEBUG) { Log.d(TAG, "Status bar manager is disabled for visible background users"); } @@ -3769,8 +3770,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, if (!SceneContainerFlag.isEnabled()) { if (UserManager.isVisibleBackgroundUsersEnabled() - && !mProcessWrapper.isSystemUser() && !mProcessWrapper.isForegroundUser()) { - // TODO: b/341604160 - Support visible background users properly. + && !mProcessWrapper.isSystemUser() + && !mProcessWrapper.isForegroundUserOrProfile()) { + // TODO(b/341604160): Support visible background users properly. if (DEBUG) { Log.d(TAG, "Status bar manager is disabled for visible background users"); } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StatusBarDisableFlagsInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StatusBarDisableFlagsInteractor.kt index d6a110a8fd55..cb602f1287f7 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StatusBarDisableFlagsInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StatusBarDisableFlagsInteractor.kt @@ -22,7 +22,10 @@ import android.content.Context import android.os.Binder import android.os.IBinder import android.os.RemoteException +import android.os.UserManager import android.provider.DeviceConfig +import android.util.Log +import com.android.app.tracing.coroutines.launchTraced as launch import com.android.internal.config.sysui.SystemUiDeviceConfigFlags import com.android.internal.statusbar.IStatusBarService import com.android.systemui.CoreStartable @@ -39,6 +42,7 @@ import com.android.systemui.navigation.domain.interactor.NavigationInteractor import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.power.shared.model.WakeSleepReason import com.android.systemui.power.shared.model.WakefulnessModel +import com.android.systemui.process.ProcessWrapper import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.user.domain.interactor.SelectedUserInteractor @@ -49,9 +53,10 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map -import com.android.app.tracing.coroutines.launchTraced as launch import kotlinx.coroutines.withContext +private val TAG = StatusBarDisableFlagsInteractor::class.simpleName + /** * Logic around StatusBarService#disableForUser, which is used to disable the home and recents * button in certain device states. @@ -67,6 +72,7 @@ constructor( @Background private val backgroundDispatcher: CoroutineDispatcher, private val deviceEntryFaceAuthInteractor: DeviceEntryFaceAuthInteractor, private val statusBarService: IStatusBarService, + private val processWrapper: ProcessWrapper, keyguardTransitionInteractor: KeyguardTransitionInteractor, selectedUserInteractor: SelectedUserInteractor, deviceConfigInteractor: DeviceConfigInteractor, @@ -141,6 +147,24 @@ constructor( return } + // TODO(b/341604160): Remove this blocking logic once StatusBarManagerService supports + // visible background users properly. + if ( + UserManager.isVisibleBackgroundUsersEnabled() && + !processWrapper.isSystemUser() && + !processWrapper.isForegroundUserOrProfile() + ) { + // Currently, only one SysUI process can register with IStatusBarService to listen + // for the CommandQueue events. + // In the Multi Display configuration with concurrent multi users (primarily used + // in Automotive), a visible background user (Automotive Multi Display passengers) + // could also access this code path. Given this limitation and we only allow the + // current user's SysUI process to register with IStatusBarService, we need to prevent + // calls into IStatusBarService from visible background users. + Log.d(TAG, "Status bar manager is disabled for visible background users") + return + } + scope.launch { disableFlagsForUserId.collect { (selectedUserId, flags) -> if (context.getSystemService(Context.STATUS_BAR_SERVICE) == null) { diff --git a/packages/SystemUI/src/com/android/systemui/log/SessionTracker.java b/packages/SystemUI/src/com/android/systemui/log/SessionTracker.java index e8ded03e3b38..ad306694346e 100644 --- a/packages/SystemUI/src/com/android/systemui/log/SessionTracker.java +++ b/packages/SystemUI/src/com/android/systemui/log/SessionTracker.java @@ -116,8 +116,8 @@ public class SessionTracker implements CoreStartable { mSessionToInstanceId.put(type, instanceId); if (UserManager.isVisibleBackgroundUsersEnabled() && !mProcessWrapper.isSystemUser() - && !mProcessWrapper.isForegroundUser()) { - // TODO: b/341604160 - Support visible background users properly. + && !mProcessWrapper.isForegroundUserOrProfile()) { + // TODO(b/341604160): Support visible background users properly. if (DEBUG) { Log.d(TAG, "Status bar manager is disabled for visible background users"); } @@ -155,8 +155,8 @@ public class SessionTracker implements CoreStartable { mUiEventLogger.log(endSessionUiEvent, instanceId); } if (UserManager.isVisibleBackgroundUsersEnabled() && !mProcessWrapper.isSystemUser() - && !mProcessWrapper.isForegroundUser()) { - // TODO: b/341604160 - Support visible background users properly. + && !mProcessWrapper.isForegroundUserOrProfile()) { + // TODO(b/341604160): Support visible background users properly. if (DEBUG) { Log.d(TAG, "Status bar manager is disabled for visible background users"); } diff --git a/packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java b/packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java index 294d0c75167a..f3a3a3a2ac4c 100644 --- a/packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java @@ -27,8 +27,12 @@ import javax.inject.Inject; * providing a mockable target around these details. */ public class ProcessWrapper { + private final ActivityManager mActivityManager; + @Inject - public ProcessWrapper() {} + public ProcessWrapper(ActivityManager activityManager) { + mActivityManager = activityManager; + } /** * Returns {@code true} if System User is running the current process. @@ -38,10 +42,10 @@ public class ProcessWrapper { } /** - * Returns {@code true} if the foreground user is running the current process. + * Returns {@code true} if the foreground user or profile is running the current process. */ - public boolean isForegroundUser() { - return ActivityManager.getCurrentUser() == myUserHandle().getIdentifier(); + public boolean isForegroundUserOrProfile() { + return mActivityManager.isProfileForeground(myUserHandle()); } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt index 69b762b470b7..40547c2787ac 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/recents/LauncherProxyServiceTest.kt @@ -90,7 +90,7 @@ class LauncherProxyServiceTest : SysuiTestCase() { private val kosmos = testKosmos() private lateinit var subject: LauncherProxyService @Mock private val dumpManager = DumpManager() - @Mock private val processWrapper = ProcessWrapper() + @Mock private lateinit var processWrapper: ProcessWrapper private val displayTracker = FakeDisplayTracker(mContext) private val fakeSystemClock = FakeSystemClock() private val sysUiState = SysUiState(displayTracker, kosmos.sceneContainerPlugin) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessKosmos.kt index 79167f840f60..4d1e0a8c025a 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessKosmos.kt @@ -16,6 +16,9 @@ package com.android.systemui.process +import android.app.ActivityManager + import com.android.systemui.kosmos.Kosmos +import com.android.systemui.util.mockito.mock -val Kosmos.processWrapper: ProcessWrapperFake by Kosmos.Fixture { ProcessWrapperFake() } +val Kosmos.processWrapper: ProcessWrapperFake by Kosmos.Fixture { ProcessWrapperFake(mock<ActivityManager>()) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessWrapperFake.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessWrapperFake.kt index dee3644e95bd..152cc3019d85 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessWrapperFake.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessWrapperFake.kt @@ -16,9 +16,10 @@ package com.android.systemui.process +import android.app.ActivityManager import android.os.UserHandle -class ProcessWrapperFake : ProcessWrapper() { +class ProcessWrapperFake(activityManager: ActivityManager) : ProcessWrapper(activityManager) { var systemUser: Boolean = false |