summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Priyanka Advani (xWF) <padvani@google.com> 2025-01-23 15:49:47 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-23 15:49:47 -0800
commit5635c38be62c7dee96398ae07badc83bb686cf93 (patch)
tree7630213e65a2b182d3677fd39b0ce0b2fb023893
parentade1a87ef1a84acda0a6cde0eb3167e642187a43 (diff)
parent218a42f6040482e704daf146cd0cf5ff655cba1e (diff)
Merge "Revert "Prevent calls into IStatusBarService if they come from visible background users"" into main
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/StatusBarUserChipViewModelTest.kt2
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/user/ui/viewmodel/UserSwitcherViewModelTest.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StatusBarDisableFlagsInteractor.kt26
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/SessionTracker.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java12
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessKosmos.kt5
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/process/ProcessWrapperFake.kt3
8 files changed, 18 insertions, 52 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 aa48c29de028..99cdf731a765 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
@@ -265,7 +265,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
guestUserInteractor = guestUserInteractor,
uiEventLogger = uiEventLogger,
userRestrictionChecker = mock(),
- processWrapper = ProcessWrapperFake(activityManager)
+ processWrapper = ProcessWrapperFake()
)
)
}
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 bcf964fa6832..917df619467d 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
@@ -177,7 +177,7 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
guestUserInteractor = guestUserInteractor,
uiEventLogger = uiEventLogger,
userRestrictionChecker = mock(),
- processWrapper = ProcessWrapperFake(activityManager)
+ processWrapper = ProcessWrapperFake()
),
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 cfac965ebb1b..5baef915ea01 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -3594,13 +3594,12 @@ 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.isForegroundUserOrProfile()) {
- // TODO(b/341604160): Support visible background users properly.
+ && !mProcessWrapper.isSystemUser() && !mProcessWrapper.isForegroundUser()) {
+ // TODO: b/341604160 - Support visible background users properly.
if (DEBUG) {
Log.d(TAG, "Status bar manager is disabled for visible background users");
}
@@ -3636,9 +3635,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
if (!SceneContainerFlag.isEnabled()) {
if (UserManager.isVisibleBackgroundUsersEnabled()
- && !mProcessWrapper.isSystemUser()
- && !mProcessWrapper.isForegroundUserOrProfile()) {
- // TODO(b/341604160): Support visible background users properly.
+ && !mProcessWrapper.isSystemUser() && !mProcessWrapper.isForegroundUser()) {
+ // 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 cb602f1287f7..d6a110a8fd55 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,10 +22,7 @@ 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
@@ -42,7 +39,6 @@ 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
@@ -53,10 +49,9 @@ 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.
@@ -72,7 +67,6 @@ constructor(
@Background private val backgroundDispatcher: CoroutineDispatcher,
private val deviceEntryFaceAuthInteractor: DeviceEntryFaceAuthInteractor,
private val statusBarService: IStatusBarService,
- private val processWrapper: ProcessWrapper,
keyguardTransitionInteractor: KeyguardTransitionInteractor,
selectedUserInteractor: SelectedUserInteractor,
deviceConfigInteractor: DeviceConfigInteractor,
@@ -147,24 +141,6 @@ 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 ad306694346e..e8ded03e3b38 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.isForegroundUserOrProfile()) {
- // TODO(b/341604160): Support visible background users properly.
+ && !mProcessWrapper.isForegroundUser()) {
+ // 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.isForegroundUserOrProfile()) {
- // TODO(b/341604160): Support visible background users properly.
+ && !mProcessWrapper.isForegroundUser()) {
+ // 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 f3a3a3a2ac4c..294d0c75167a 100644
--- a/packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/process/ProcessWrapper.java
@@ -27,12 +27,8 @@ import javax.inject.Inject;
* providing a mockable target around these details.
*/
public class ProcessWrapper {
- private final ActivityManager mActivityManager;
-
@Inject
- public ProcessWrapper(ActivityManager activityManager) {
- mActivityManager = activityManager;
- }
+ public ProcessWrapper() {}
/**
* Returns {@code true} if System User is running the current process.
@@ -42,10 +38,10 @@ public class ProcessWrapper {
}
/**
- * Returns {@code true} if the foreground user or profile is running the current process.
+ * Returns {@code true} if the foreground user is running the current process.
*/
- public boolean isForegroundUserOrProfile() {
- return mActivityManager.isProfileForeground(myUserHandle());
+ public boolean isForegroundUser() {
+ return ActivityManager.getCurrentUser() == myUserHandle().getIdentifier();
}
/**
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 4d1e0a8c025a..79167f840f60 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,9 +16,6 @@
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(mock<ActivityManager>()) }
+val Kosmos.processWrapper: ProcessWrapperFake by Kosmos.Fixture { ProcessWrapperFake() }
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 152cc3019d85..dee3644e95bd 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,10 +16,9 @@
package com.android.systemui.process
-import android.app.ActivityManager
import android.os.UserHandle
-class ProcessWrapperFake(activityManager: ActivityManager) : ProcessWrapper(activityManager) {
+class ProcessWrapperFake : ProcessWrapper() {
var systemUser: Boolean = false