Loading core/java/com/android/internal/widget/LockPatternUtils.java +7 −3 Original line number Original line Diff line number Diff line Loading @@ -1369,7 +1369,7 @@ public class LockPatternUtils { public void registerStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { public void registerStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { try { try { getLockSettings().registerStrongAuthTracker(strongAuthTracker.mStub); getLockSettings().registerStrongAuthTracker(strongAuthTracker.getStub()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Could not register StrongAuthTracker"); throw new RuntimeException("Could not register StrongAuthTracker"); } } Loading @@ -1377,7 +1377,7 @@ public class LockPatternUtils { public void unregisterStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { public void unregisterStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { try { try { getLockSettings().unregisterStrongAuthTracker(strongAuthTracker.mStub); getLockSettings().unregisterStrongAuthTracker(strongAuthTracker.getStub()); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Could not unregister StrongAuthTracker", e); Log.e(TAG, "Could not unregister StrongAuthTracker", e); } } Loading Loading @@ -1740,7 +1740,7 @@ public class LockPatternUtils { } } } } protected final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() { private final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() { @Override @Override public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags, public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags, int userId) { int userId) { Loading @@ -1755,6 +1755,10 @@ public class LockPatternUtils { } } }; }; public IStrongAuthTracker.Stub getStub() { return mStub; } private class H extends Handler { private class H extends Handler { static final int MSG_ON_STRONG_AUTH_REQUIRED_CHANGED = 1; static final int MSG_ON_STRONG_AUTH_REQUIRED_CHANGED = 1; static final int MSG_ON_IS_NON_STRONG_BIOMETRIC_ALLOWED_CHANGED = 2; static final int MSG_ON_IS_NON_STRONG_BIOMETRIC_ALLOWED_CHANGED = 2; Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +20 −5 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import static com.android.systemui.DejankUtils.whitelistIpcs; import android.annotation.AnyThread; import android.annotation.AnyThread; import android.annotation.MainThread; import android.annotation.MainThread; import android.annotation.NonNull; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.app.ActivityTaskManager; import android.app.AlarmManager; import android.app.AlarmManager; Loading Loading @@ -247,8 +248,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // Battery status // Battery status private BatteryStatus mBatteryStatus; private BatteryStatus mBatteryStatus; @VisibleForTesting private StrongAuthTracker mStrongAuthTracker; protected StrongAuthTracker mStrongAuthTracker; private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>> private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>> mCallbacks = Lists.newArrayList(); mCallbacks = Lists.newArrayList(); Loading Loading @@ -1512,6 +1512,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mUserTrustIsUsuallyManaged.delete(userId); mUserTrustIsUsuallyManaged.delete(userId); } } @VisibleForTesting protected void setStrongAuthTracker(@NonNull StrongAuthTracker tracker) { if (mStrongAuthTracker != null) { mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker); } mStrongAuthTracker = tracker; mLockPatternUtils.registerStrongAuthTracker(mStrongAuthTracker); } private void registerRingerTracker() { private void registerRingerTracker() { mRingerModeTracker.getRingerMode().observeForever(mRingerModeObserver); mRingerModeTracker.getRingerMode().observeForever(mRingerModeObserver); } } Loading @@ -1525,7 +1535,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab DumpManager dumpManager, DumpManager dumpManager, RingerModeTracker ringerModeTracker, RingerModeTracker ringerModeTracker, @Background Executor backgroundExecutor, @Background Executor backgroundExecutor, StatusBarStateController statusBarStateController) { StatusBarStateController statusBarStateController, LockPatternUtils lockPatternUtils) { mContext = context; mContext = context; mSubscriptionManager = SubscriptionManager.from(context); mSubscriptionManager = SubscriptionManager.from(context); mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); Loading @@ -1534,6 +1545,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher; mRingerModeTracker = ringerModeTracker; mRingerModeTracker = ringerModeTracker; mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController; mLockPatternUtils = lockPatternUtils; dumpManager.registerDumpable(getClass().getName(), this); dumpManager.registerDumpable(getClass().getName(), this); mHandler = new Handler(mainLooper) { mHandler = new Handler(mainLooper) { Loading Loading @@ -1702,8 +1714,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mTrustManager = context.getSystemService(TrustManager.class); mTrustManager = context.getSystemService(TrustManager.class); mTrustManager.registerTrustListener(this); mTrustManager.registerTrustListener(this); mLockPatternUtils = new LockPatternUtils(context); mLockPatternUtils.registerStrongAuthTracker(mStrongAuthTracker); setStrongAuthTracker(mStrongAuthTracker); mDreamManager = IDreamManager.Stub.asInterface( mDreamManager = IDreamManager.Stub.asInterface( ServiceManager.getService(DreamService.DREAM_SERVICE)); ServiceManager.getService(DreamService.DREAM_SERVICE)); Loading Loading @@ -2847,6 +2859,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mBroadcastDispatcher.unregisterReceiver(mBroadcastAllReceiver); mBroadcastDispatcher.unregisterReceiver(mBroadcastAllReceiver); mRingerModeTracker.getRingerMode().removeObserver(mRingerModeObserver); mRingerModeTracker.getRingerMode().removeObserver(mRingerModeObserver); mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker); mTrustManager.unregisterTrustListener(this); mHandler.removeCallbacksAndMessages(null); mHandler.removeCallbacksAndMessages(null); } } Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +12 −3 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager; import android.app.trust.IStrongAuthTracker; import android.app.trust.TrustManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; Loading Loading @@ -72,6 +73,8 @@ import androidx.lifecycle.Observer; import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.widget.ILockSettings; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor.BiometricAuthenticated; 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; Loading Loading @@ -120,6 +123,10 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Mock @Mock private TrustManager mTrustManager; private TrustManager mTrustManager; @Mock @Mock private LockPatternUtils mLockPatternUtils; @Mock private ILockSettings mLockSettings; @Mock private FingerprintManager mFingerprintManager; private FingerprintManager mFingerprintManager; @Mock @Mock private FaceManager mFaceManager; private FaceManager mFaceManager; Loading Loading @@ -169,12 +176,13 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true); when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true); when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true); when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true); when(mUserManager.isPrimaryUser()).thenReturn(true); when(mUserManager.isPrimaryUser()).thenReturn(true); when(mStrongAuthTracker.getStub()).thenReturn(mock(IStrongAuthTracker.Stub.class)); when(mStrongAuthTracker when(mStrongAuthTracker .isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */)) .isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */)) .thenReturn(true); .thenReturn(true); when(mTelephonyManager.getServiceStateForSubscriber(anyInt())) when(mTelephonyManager.getServiceStateForSubscriber(anyInt())) .thenReturn(new ServiceState()); .thenReturn(new ServiceState()); when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings); mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager); mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager); mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager); mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager); mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager); mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager); Loading Loading @@ -729,8 +737,9 @@ 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, mStatusBarStateController); mRingerModeTracker, mBackgroundExecutor, mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker; mStatusBarStateController, mLockPatternUtils); setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker); } } public boolean hasSimStateJustChanged() { public boolean hasSimStateJustChanged() { Loading services/core/java/com/android/server/locksettings/LockSettingsService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -312,7 +312,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } void register(LockSettingsStrongAuth strongAuth) { void register(LockSettingsStrongAuth strongAuth) { strongAuth.registerStrongAuthTracker(this.mStub); strongAuth.registerStrongAuthTracker(getStub()); } } } } Loading Loading
core/java/com/android/internal/widget/LockPatternUtils.java +7 −3 Original line number Original line Diff line number Diff line Loading @@ -1369,7 +1369,7 @@ public class LockPatternUtils { public void registerStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { public void registerStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { try { try { getLockSettings().registerStrongAuthTracker(strongAuthTracker.mStub); getLockSettings().registerStrongAuthTracker(strongAuthTracker.getStub()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Could not register StrongAuthTracker"); throw new RuntimeException("Could not register StrongAuthTracker"); } } Loading @@ -1377,7 +1377,7 @@ public class LockPatternUtils { public void unregisterStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { public void unregisterStrongAuthTracker(final StrongAuthTracker strongAuthTracker) { try { try { getLockSettings().unregisterStrongAuthTracker(strongAuthTracker.mStub); getLockSettings().unregisterStrongAuthTracker(strongAuthTracker.getStub()); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Could not unregister StrongAuthTracker", e); Log.e(TAG, "Could not unregister StrongAuthTracker", e); } } Loading Loading @@ -1740,7 +1740,7 @@ public class LockPatternUtils { } } } } protected final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() { private final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() { @Override @Override public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags, public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags, int userId) { int userId) { Loading @@ -1755,6 +1755,10 @@ public class LockPatternUtils { } } }; }; public IStrongAuthTracker.Stub getStub() { return mStub; } private class H extends Handler { private class H extends Handler { static final int MSG_ON_STRONG_AUTH_REQUIRED_CHANGED = 1; static final int MSG_ON_STRONG_AUTH_REQUIRED_CHANGED = 1; static final int MSG_ON_IS_NON_STRONG_BIOMETRIC_ALLOWED_CHANGED = 2; static final int MSG_ON_IS_NON_STRONG_BIOMETRIC_ALLOWED_CHANGED = 2; Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +20 −5 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import static com.android.systemui.DejankUtils.whitelistIpcs; import android.annotation.AnyThread; import android.annotation.AnyThread; import android.annotation.MainThread; import android.annotation.MainThread; import android.annotation.NonNull; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.app.ActivityTaskManager; import android.app.AlarmManager; import android.app.AlarmManager; Loading Loading @@ -247,8 +248,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // Battery status // Battery status private BatteryStatus mBatteryStatus; private BatteryStatus mBatteryStatus; @VisibleForTesting private StrongAuthTracker mStrongAuthTracker; protected StrongAuthTracker mStrongAuthTracker; private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>> private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>> mCallbacks = Lists.newArrayList(); mCallbacks = Lists.newArrayList(); Loading Loading @@ -1512,6 +1512,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mUserTrustIsUsuallyManaged.delete(userId); mUserTrustIsUsuallyManaged.delete(userId); } } @VisibleForTesting protected void setStrongAuthTracker(@NonNull StrongAuthTracker tracker) { if (mStrongAuthTracker != null) { mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker); } mStrongAuthTracker = tracker; mLockPatternUtils.registerStrongAuthTracker(mStrongAuthTracker); } private void registerRingerTracker() { private void registerRingerTracker() { mRingerModeTracker.getRingerMode().observeForever(mRingerModeObserver); mRingerModeTracker.getRingerMode().observeForever(mRingerModeObserver); } } Loading @@ -1525,7 +1535,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab DumpManager dumpManager, DumpManager dumpManager, RingerModeTracker ringerModeTracker, RingerModeTracker ringerModeTracker, @Background Executor backgroundExecutor, @Background Executor backgroundExecutor, StatusBarStateController statusBarStateController) { StatusBarStateController statusBarStateController, LockPatternUtils lockPatternUtils) { mContext = context; mContext = context; mSubscriptionManager = SubscriptionManager.from(context); mSubscriptionManager = SubscriptionManager.from(context); mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); Loading @@ -1534,6 +1545,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher; mRingerModeTracker = ringerModeTracker; mRingerModeTracker = ringerModeTracker; mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController; mLockPatternUtils = lockPatternUtils; dumpManager.registerDumpable(getClass().getName(), this); dumpManager.registerDumpable(getClass().getName(), this); mHandler = new Handler(mainLooper) { mHandler = new Handler(mainLooper) { Loading Loading @@ -1702,8 +1714,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mTrustManager = context.getSystemService(TrustManager.class); mTrustManager = context.getSystemService(TrustManager.class); mTrustManager.registerTrustListener(this); mTrustManager.registerTrustListener(this); mLockPatternUtils = new LockPatternUtils(context); mLockPatternUtils.registerStrongAuthTracker(mStrongAuthTracker); setStrongAuthTracker(mStrongAuthTracker); mDreamManager = IDreamManager.Stub.asInterface( mDreamManager = IDreamManager.Stub.asInterface( ServiceManager.getService(DreamService.DREAM_SERVICE)); ServiceManager.getService(DreamService.DREAM_SERVICE)); Loading Loading @@ -2847,6 +2859,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mBroadcastDispatcher.unregisterReceiver(mBroadcastAllReceiver); mBroadcastDispatcher.unregisterReceiver(mBroadcastAllReceiver); mRingerModeTracker.getRingerMode().removeObserver(mRingerModeObserver); mRingerModeTracker.getRingerMode().removeObserver(mRingerModeObserver); mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker); mTrustManager.unregisterTrustListener(this); mHandler.removeCallbacksAndMessages(null); mHandler.removeCallbacksAndMessages(null); } } Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +12 −3 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager; import android.app.trust.IStrongAuthTracker; import android.app.trust.TrustManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; Loading Loading @@ -72,6 +73,8 @@ import androidx.lifecycle.Observer; import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.widget.ILockSettings; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor.BiometricAuthenticated; 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; Loading Loading @@ -120,6 +123,10 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Mock @Mock private TrustManager mTrustManager; private TrustManager mTrustManager; @Mock @Mock private LockPatternUtils mLockPatternUtils; @Mock private ILockSettings mLockSettings; @Mock private FingerprintManager mFingerprintManager; private FingerprintManager mFingerprintManager; @Mock @Mock private FaceManager mFaceManager; private FaceManager mFaceManager; Loading Loading @@ -169,12 +176,13 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true); when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true); when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true); when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true); when(mUserManager.isPrimaryUser()).thenReturn(true); when(mUserManager.isPrimaryUser()).thenReturn(true); when(mStrongAuthTracker.getStub()).thenReturn(mock(IStrongAuthTracker.Stub.class)); when(mStrongAuthTracker when(mStrongAuthTracker .isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */)) .isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */)) .thenReturn(true); .thenReturn(true); when(mTelephonyManager.getServiceStateForSubscriber(anyInt())) when(mTelephonyManager.getServiceStateForSubscriber(anyInt())) .thenReturn(new ServiceState()); .thenReturn(new ServiceState()); when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings); mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager); mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager); mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager); mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager); mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager); mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager); Loading Loading @@ -729,8 +737,9 @@ 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, mStatusBarStateController); mRingerModeTracker, mBackgroundExecutor, mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker; mStatusBarStateController, mLockPatternUtils); setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker); } } public boolean hasSimStateJustChanged() { public boolean hasSimStateJustChanged() { Loading
services/core/java/com/android/server/locksettings/LockSettingsService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -312,7 +312,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } void register(LockSettingsStrongAuth strongAuth) { void register(LockSettingsStrongAuth strongAuth) { strongAuth.registerStrongAuthTracker(this.mStub); strongAuth.registerStrongAuthTracker(getStub()); } } } } Loading