Use cached KeyguardUpdateMonitor#isUdfpsEnrolled

Test: atest SystemUITests, manual
Bug: 172053030
Change-Id: Id23fa9b3660e8fdf6edd43610b5a7977853de62c
This commit is contained in:
Beverly
2020-11-03 13:23:15 -05:00
parent 5434c0b2dc
commit 3163ffad18
8 changed files with 45 additions and 32 deletions

View File

@@ -289,6 +289,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private final DevicePolicyManager mDevicePolicyManager;
private final BroadcastDispatcher mBroadcastDispatcher;
private boolean mLogoutEnabled;
// cached value to avoid IPCs
private boolean mIsUdfpsEnrolled;
// If the user long pressed the lock icon, disabling face auth for the current session.
private boolean mLockIconPressed;
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -1857,7 +1859,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private void updateLockScreenMode() {
mLockScreenMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SHOW_NEW_LOCKSCREEN, mAuthController.isUdfpsEnrolled() ? 1 : 0);
Settings.Global.SHOW_NEW_LOCKSCREEN,
isUdfpsEnrolled() ? 1 : 0);
}
private void updateUdfpsEnrolled(int userId) {
mIsUdfpsEnrolled = mAuthController.isUdfpsEnrolled(userId);
}
public boolean isUdfpsEnrolled() {
return mIsUdfpsEnrolled;
}
private final UserSwitchObserver mUserSwitchObserver = new UserSwitchObserver() {
@@ -2098,6 +2108,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
}
if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
int userId = getCurrentUser();
updateUdfpsEnrolled(userId);
if (isUnlockWithFingerprintPossible(userId)) {
if (mFingerprintCancelSignal != null) {
mFingerprintCancelSignal.cancel();
@@ -3069,6 +3080,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
+ " expected=" + (shouldListenForFingerprint() ? 1 : 0));
pw.println(" strongAuthFlags=" + Integer.toHexString(strongAuthFlags));
pw.println(" trustManaged=" + getUserTrustIsManaged(userId));
pw.println(" udfpsEnrolled=" + isUdfpsEnrolled());
}
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
final int userId = ActivityManager.getCurrentUser();

View File

@@ -56,6 +56,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
@@ -81,6 +82,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
@Nullable private final List<FingerprintSensorPropertiesInternal> mFpProps;
@Nullable private final List<FaceSensorPropertiesInternal> mFaceProps;
@Nullable private final List<FingerprintSensorPropertiesInternal> mUdfpsProps;
// TODO: These should just be saved from onSaveState
private SomeArgs mCurrentDialogArgs;
@@ -314,6 +316,16 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
: null;
mFaceProps = mFaceManager != null ? mFaceManager.getSensorPropertiesInternal() : null;
List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
if (mFpProps != null) {
for (FingerprintSensorPropertiesInternal props : mFpProps) {
if (props.isAnyUdfpsType()) {
udfpsProps.add(props);
}
}
}
mUdfpsProps = !udfpsProps.isEmpty() ? udfpsProps : null;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
@@ -326,15 +338,9 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
mCommandQueue.addCallback(this);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()) {
final List<FingerprintSensorPropertiesInternal> fingerprintSensorProperties =
mFingerprintManager.getSensorPropertiesInternal();
for (FingerprintSensorPropertiesInternal props : fingerprintSensorProperties) {
if (props.isAnyUdfpsType()) {
mUdfpsController = mUdfpsControllerFactory.get();
break;
}
}
if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()
&& mUdfpsProps != null) {
mUdfpsController = mUdfpsControllerFactory.get();
}
try {
@@ -484,12 +490,14 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
}
/**
* Whether the current user has a UDFP enrolled.
* Whether the passed userId has enrolled UDFPS.
*/
public boolean isUdfpsEnrolled() {
// TODO: (b/171392825) right now only checks whether the UDFPS sensor exists on this device
// but not whether user has enrolled or not
return mUdfpsController != null;
public boolean isUdfpsEnrolled(int userId) {
if (mUdfpsController == null) {
return false;
}
return mFingerprintManager.hasEnrolledTemplatesForAnySensor(userId, mUdfpsProps);
}
private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {

View File

@@ -44,6 +44,7 @@ import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.UiEventLoggerImpl;
import com.android.internal.logging.nano.MetricsProto;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.plugins.SensorManagerPlugin;
import com.android.systemui.statusbar.phone.DozeParameters;
@@ -156,7 +157,7 @@ public class DozeSensors {
findSensorWithType(config.udfpsLongPressSensorType()),
"doze_pulse_on_auth",
true /* settingDef */,
authController.isUdfpsEnrolled() /* configured */,
authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser()),
DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS,
true /* reports touch coordinates */,
true /* touchscreen */,

View File

@@ -39,7 +39,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager;
@@ -77,7 +76,6 @@ public class LockscreenLockIconController {
private final KeyguardStateController mKeyguardStateController;
private final Resources mResources;
private final HeadsUpManagerPhone mHeadsUpManagerPhone;
private final AuthController mAuthController;
private boolean mKeyguardShowing;
private boolean mKeyguardJustShown;
private boolean mBlockUpdates;
@@ -326,8 +324,7 @@ public class LockscreenLockIconController {
@Nullable DockManager dockManager,
KeyguardStateController keyguardStateController,
@Main Resources resources,
HeadsUpManagerPhone headsUpManagerPhone,
AuthController authController) {
HeadsUpManagerPhone headsUpManagerPhone) {
mLockscreenGestureLogger = lockscreenGestureLogger;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mLockPatternUtils = lockPatternUtils;
@@ -342,7 +339,6 @@ public class LockscreenLockIconController {
mKeyguardStateController = keyguardStateController;
mResources = resources;
mHeadsUpManagerPhone = headsUpManagerPhone;
mAuthController = authController;
mKeyguardIndicationController.setLockIconController(this);
}
@@ -508,7 +504,7 @@ public class LockscreenLockIconController {
* @return true if the visibility changed
*/
private boolean updateIconVisibility() {
if (mAuthController.isUdfpsEnrolled()) {
if (mKeyguardUpdateMonitor.isUdfpsEnrolled()) {
boolean changed = mLockIcon.getVisibility() == GONE;
mLockIcon.setVisibility(GONE);
return changed;

View File

@@ -873,7 +873,7 @@ public class NotificationPanelViewController extends PanelViewController {
clockPreferredY, hasCustomClock(),
hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount,
bypassEnabled, getUnlockedStackScrollerPadding(),
mAuthController.isUdfpsEnrolled());
mUpdateMonitor.isUdfpsEnrolled());
mClockPositionAlgorithm.run(mClockPositionResult);
mKeyguardStatusViewController.updatePosition(
mClockPositionResult.clockX, mClockPositionResult.clockY, animateClock);
@@ -914,7 +914,7 @@ public class NotificationPanelViewController extends PanelViewController {
- Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)
- mKeyguardStatusViewController.getLogoutButtonHeight();
if (mAuthController.isUdfpsEnrolled()) {
if (mUpdateMonitor.isUdfpsEnrolled()) {
availableSpace = mNotificationStackScrollLayoutController.getHeight()
- minPadding - shelfSize
- (mStatusBar.getDisplayHeight() - mAuthController.getUdfpsRegion().top);

View File

@@ -201,7 +201,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
when(mTelephonyManager.getServiceStateForSubscriber(anyInt()))
.thenReturn(new ServiceState());
when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
when(mAuthController.isUdfpsEnrolled()).thenReturn(false);
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager);
mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager);
mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager);

View File

@@ -32,7 +32,6 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.dock.DockManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -81,25 +80,21 @@ public class LockscreenIconControllerTest extends SysuiTestCase {
private Resources mResources;
@Mock
private HeadsUpManagerPhone mHeadsUpManagerPhone;
@Mock
private AuthController mAuthController;
private LockscreenLockIconController mLockIconController;
private OnAttachStateChangeListener mOnAttachStateChangeListener;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mAuthController.isUdfpsEnrolled()).thenReturn(false);
when(mLockIcon.getContext()).thenReturn(mContext);
mLockIconController = new LockscreenLockIconController(
mLockscreenGestureLogger, mKeyguardUpdateMonitor, mLockPatternUtils,
mShadeController, mAccessibilityController, mKeyguardIndicationController,
mStatusBarStateController, mConfigurationController, mNotificationWakeUpCoordinator,
mKeyguardBypassController, mDockManager, mKeyguardStateController, mResources,
mHeadsUpManagerPhone, mAuthController);
mHeadsUpManagerPhone);
ArgumentCaptor<OnAttachStateChangeListener> onAttachStateChangeListenerArgumentCaptor =
ArgumentCaptor.forClass(OnAttachStateChangeListener.class);

View File

@@ -21,6 +21,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
@@ -204,7 +205,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(mAuthController.isUdfpsEnrolled()).thenReturn(false);
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
when(mHeadsUpCallback.getContext()).thenReturn(mContext);
when(mView.getResources()).thenReturn(mResources);
when(mResources.getConfiguration()).thenReturn(mConfiguration);