Merge "Don't re-trigger face auth from notification shade" into rvc-dev

This commit is contained in:
Curtis Belmonte
2020-05-11 21:51:10 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 5 deletions

View File

@@ -94,8 +94,10 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.util.Assert; import com.android.systemui.util.Assert;
import com.android.systemui.util.RingerModeTracker; import com.android.systemui.util.RingerModeTracker;
@@ -219,6 +221,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private final Context mContext; private final Context mContext;
private final boolean mIsPrimaryUser; private final boolean mIsPrimaryUser;
private final StatusBarStateController mStatusBarStateController;
HashMap<Integer, SimData> mSimDatas = new HashMap<>(); HashMap<Integer, SimData> mSimDatas = new HashMap<>();
HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>(); HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();
@@ -1521,7 +1524,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
BroadcastDispatcher broadcastDispatcher, BroadcastDispatcher broadcastDispatcher,
DumpManager dumpManager, DumpManager dumpManager,
RingerModeTracker ringerModeTracker, RingerModeTracker ringerModeTracker,
@Background Executor backgroundExecutor) { @Background Executor backgroundExecutor,
StatusBarStateController statusBarStateController) {
mContext = context; mContext = context;
mSubscriptionManager = SubscriptionManager.from(context); mSubscriptionManager = SubscriptionManager.from(context);
mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
@@ -1529,6 +1533,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
mBackgroundExecutor = backgroundExecutor; mBackgroundExecutor = backgroundExecutor;
mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher;
mRingerModeTracker = ringerModeTracker; mRingerModeTracker = ringerModeTracker;
mStatusBarStateController = statusBarStateController;
dumpManager.registerDumpable(getClass().getName(), this); dumpManager.registerDumpable(getClass().getName(), this);
mHandler = new Handler(mainLooper) { mHandler = new Handler(mainLooper) {
@@ -1855,8 +1860,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
boolean shouldListenForFace = shouldListenForFace(); boolean shouldListenForFace = shouldListenForFace();
if (mFaceRunningState == BIOMETRIC_STATE_RUNNING && !shouldListenForFace) { if (mFaceRunningState == BIOMETRIC_STATE_RUNNING && !shouldListenForFace) {
stopListeningForFace(); stopListeningForFace();
} else if (mFaceRunningState != BIOMETRIC_STATE_RUNNING } else if (mFaceRunningState != BIOMETRIC_STATE_RUNNING && shouldListenForFace) {
&& shouldListenForFace) {
startListeningForFace(); startListeningForFace();
} }
} }
@@ -1894,7 +1898,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
* If face auth is allows to scan on this exact moment. * If face auth is allows to scan on this exact moment.
*/ */
public boolean shouldListenForFace() { public boolean shouldListenForFace() {
final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep; final boolean statusBarShadeLocked =
mStatusBarStateController.getState() == StatusBarState.SHADE_LOCKED;
final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep
&& !statusBarShadeLocked;
final int user = getCurrentUser(); final int user = getCurrentUser();
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user); final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user);
final boolean isLockDown = final boolean isLockDown =

View File

@@ -76,6 +76,8 @@ import com.android.keyguard.KeyguardUpdateMonitor.BiometricAuthenticated;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.util.RingerModeTracker; import com.android.systemui.util.RingerModeTracker;
@@ -141,6 +143,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
private RingerModeTracker mRingerModeTracker; private RingerModeTracker mRingerModeTracker;
@Mock @Mock
private LiveData<Integer> mRingerModeLiveData; private LiveData<Integer> mRingerModeLiveData;
@Mock
private StatusBarStateController mStatusBarStateController;
// Direct executor // Direct executor
private Executor mBackgroundExecutor = Runnable::run; private Executor mBackgroundExecutor = Runnable::run;
private TestableLooper mTestableLooper; private TestableLooper mTestableLooper;
@@ -417,6 +421,16 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt());
} }
@Test
public void skipsAuthentication_whenStatusBarShadeLocked() {
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE_LOCKED);
mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true);
verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt());
}
@Test @Test
public void skipsAuthentication_whenEncryptedKeyguard() { public void skipsAuthentication_whenEncryptedKeyguard() {
when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn(
@@ -715,7 +729,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
super(context, super(context,
TestableLooper.get(KeyguardUpdateMonitorTest.this).getLooper(), TestableLooper.get(KeyguardUpdateMonitorTest.this).getLooper(),
mBroadcastDispatcher, mDumpManager, mBroadcastDispatcher, mDumpManager,
mRingerModeTracker, mBackgroundExecutor); mRingerModeTracker, mBackgroundExecutor, mStatusBarStateController);
mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker; mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker;
} }