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

Commit 9ead725a authored by Xiang Wang's avatar Xiang Wang Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Prevent calls into IStatusBarService if they come from...

Merge "Revert^2 "Prevent calls into IStatusBarService if they come from visible background users"" into main
parents 3316696b 1e40dd5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
                    guestUserInteractor = guestUserInteractor,
                    uiEventLogger = uiEventLogger,
                    userRestrictionChecker = mock(),
                    processWrapper = ProcessWrapperFake()
                    processWrapper = ProcessWrapperFake(activityManager)
                )
        )
    }
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
                        guestUserInteractor = guestUserInteractor,
                        uiEventLogger = uiEventLogger,
                        userRestrictionChecker = mock(),
                        processWrapper = ProcessWrapperFake()
                        processWrapper = ProcessWrapperFake(activityManager)
                    ),
                guestUserInteractor = guestUserInteractor,
            )
+7 −5
Original line number Diff line number Diff line
@@ -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");
                    }
+25 −1
Original line number Diff line number Diff line
@@ -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) {
+4 −4
Original line number Diff line number Diff line
@@ -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");
                }
Loading