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

Commit 697cfd80 authored by Winson Chung's avatar Winson Chung
Browse files

Fix issue with disable flags being set for the wrong user

- The default status bar manager disable() calls use the binder's
  calling user (which is always the primary user), so when the
  bouncer is showing for a secondary user, the flags would be
  propagated to the non-running primary user.  This CL switches
  to the specific user call to apply the flags to the current user.
  A separate token is Ok because we also don't want these particular
  disable calls to clobber disable calls from other parts of SysUI
  (they will be coalesced into one set of flags when sent so final
  state is the same)

Bug: 264638487
Test: atest SystemUITests
Test: Create secondary user, switch to 3 button and show the bouncer
      to verify the right buttons show then and after unlocking
Change-Id: I26371352a2d7e327e499faf19535769ee72175e4
parent 3528f212
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.hardware.biometrics.BiometricSourceType;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Binder;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.Handler;
@@ -66,6 +67,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
@@ -101,6 +103,7 @@ import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardConstants;
@@ -269,6 +272,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    private AlarmManager mAlarmManager;
    private AudioManager mAudioManager;
    private StatusBarManager mStatusBarManager;
    private final IStatusBarService mStatusBarService;
    private final IBinder mStatusBarDisableToken = new Binder();
    private final UserTracker mUserTracker;
    private final SysuiStatusBarStateController mStatusBarStateController;
    private final Executor mUiBgExecutor;
@@ -1211,6 +1216,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        mPM = powerManager;
        mTrustManager = trustManager;
        mUserSwitcherController = userSwitcherController;
        mStatusBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mKeyguardDisplayManager = keyguardDisplayManager;
        mShadeController = shadeControllerLazy;
        dumpManager.registerDumpable(getClass().getName(), this);
@@ -2931,7 +2938,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            // 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) {
                mStatusBarManager.disable(flags);
                try {
                    mStatusBarService.disableForUser(flags, mStatusBarDisableToken,
                            mContext.getPackageName(), mUserTracker.getUserId());
                } catch (RemoteException e) {
                    Log.d(TAG, "Failed to force clear flags", e);
                }
            }

            if (forceHideHomeRecentsButtons || isShowingAndNotOccluded()) {
@@ -2947,7 +2959,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                        +  " --> flags=0x" + Integer.toHexString(flags));
            }

            mStatusBarManager.disable(flags);
            try {
                mStatusBarService.disableForUser(flags, mStatusBarDisableToken,
                        mContext.getPackageName(), mUserTracker.getUserId());
            } catch (RemoteException e) {
                Log.d(TAG, "Failed to set disable flags: " + flags, e);
            }
        }
    }