Loading packages/SystemUI/src/com/android/keyguard/LockIconView.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,7 @@ public class LockIconView extends FrameLayout implements Dumpable { private ImageView mBgView; private ImageView mBgView; private int mLockIconColor; private int mLockIconColor; private boolean mUseBackground = false; public LockIconView(Context context, AttributeSet attrs) { public LockIconView(Context context, AttributeSet attrs) { super(context, attrs); super(context, attrs); Loading @@ -61,8 +62,8 @@ public class LockIconView extends FrameLayout implements Dumpable { mBgView = findViewById(R.id.lock_icon_bg); mBgView = findViewById(R.id.lock_icon_bg); } } void updateColorAndBackgroundVisibility(boolean useBackground) { void updateColorAndBackgroundVisibility() { if (useBackground && mLockIcon.getDrawable() != null) { if (mUseBackground && mLockIcon.getDrawable() != null) { mLockIconColor = Utils.getColorAttrDefaultColor(getContext(), mLockIconColor = Utils.getColorAttrDefaultColor(getContext(), android.R.attr.textColorPrimary); android.R.attr.textColorPrimary); mBgView.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg)); mBgView.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg)); Loading @@ -78,6 +79,9 @@ public class LockIconView extends FrameLayout implements Dumpable { void setImageDrawable(Drawable drawable) { void setImageDrawable(Drawable drawable) { mLockIcon.setImageDrawable(drawable); mLockIcon.setImageDrawable(drawable); if (!mUseBackground) return; if (drawable == null) { if (drawable == null) { mBgView.setVisibility(View.INVISIBLE); mBgView.setVisibility(View.INVISIBLE); } else { } else { Loading @@ -85,6 +89,14 @@ public class LockIconView extends FrameLayout implements Dumpable { } } } } /** * Whether or not to render the lock icon background. Mainly used for UDPFS. */ public void setUseBackground(boolean useBackground) { mUseBackground = useBackground; updateColorAndBackgroundVisibility(); } /** /** * Set the location of the lock icon. * Set the location of the lock icon. */ */ Loading packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -345,7 +345,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme } } private void updateColors() { private void updateColors() { mView.updateColorAndBackgroundVisibility(mUdfpsSupported); mView.updateColorAndBackgroundVisibility(); } } private void updateConfiguration() { private void updateConfiguration() { Loading Loading @@ -425,6 +425,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme boolean wasUdfpsEnrolled = mUdfpsEnrolled; boolean wasUdfpsEnrolled = mUdfpsEnrolled; mUdfpsSupported = mAuthController.getUdfpsSensorLocation() != null; mUdfpsSupported = mAuthController.getUdfpsSensorLocation() != null; mView.setUseBackground(mUdfpsSupported); mUdfpsEnrolled = mKeyguardUpdateMonitor.isUdfpsEnrolled(); mUdfpsEnrolled = mKeyguardUpdateMonitor.isUdfpsEnrolled(); if (wasUdfpsSupported != mUdfpsSupported || wasUdfpsEnrolled != mUdfpsEnrolled) { if (wasUdfpsSupported != mUdfpsSupported || wasUdfpsEnrolled != mUdfpsEnrolled) { updateVisibility(); updateVisibility(); Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java +46 −21 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Vibrator; import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.testing.TestableLooper; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.Pair; import android.view.View; import android.view.View; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager; Loading Loading @@ -127,19 +128,7 @@ public class LockIconViewControllerTest extends SysuiTestCase { @Test @Test public void testUpdateFingerprintLocationOnInit() { public void testUpdateFingerprintLocationOnInit() { // GIVEN fp sensor location is available pre-attached // GIVEN fp sensor location is available pre-attached final PointF udfpsLocation = new PointF(50, 75); Pair<Integer, PointF> udfps = setupUdfps(); final int radius = 33; final FingerprintSensorPropertiesInternal fpProps = new FingerprintSensorPropertiesInternal( /* sensorId */ 0, /* strength */ 0, /* max enrollments per user */ 5, /* component info */ new ArrayList<>(), /* sensorType */ 3, /* resetLockoutRequiresHwToken */ false, (int) udfpsLocation.x, (int) udfpsLocation.y, radius); when(mAuthController.getUdfpsSensorLocation()).thenReturn(udfpsLocation); when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps)); // WHEN lock icon view controller is initialized and attached // WHEN lock icon view controller is initialized and attached mLockIconViewController.init(); mLockIconViewController.init(); Loading @@ -147,8 +136,8 @@ public class LockIconViewControllerTest extends SysuiTestCase { mAttachListener.onViewAttachedToWindow(mLockIconView); mAttachListener.onViewAttachedToWindow(mLockIconView); // THEN lock icon view location is updated with the same coordinates as fpProps // THEN lock icon view location is updated with the same coordinates as fpProps verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(radius)); verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(udfps.first)); assertEquals(udfpsLocation, mPointCaptor.getValue()); assertEquals(udfps.second, mPointCaptor.getValue()); } } @Test @Test Loading @@ -162,6 +151,47 @@ public class LockIconViewControllerTest extends SysuiTestCase { // GIVEN fp sensor location is available post-atttached // GIVEN fp sensor location is available post-atttached captureAuthControllerCallback(); captureAuthControllerCallback(); Pair<Integer, PointF> udfps = setupUdfps(); // WHEN all authenticators are registered mAuthControllerCallback.onAllAuthenticatorsRegistered(); // THEN lock icon view location is updated with the same coordinates as fpProps verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(udfps.first)); assertEquals(udfps.second, mPointCaptor.getValue()); } @Test public void testLockIconViewBackgroundEnabledWhenUdfpsIsAvailable() { // GIVEN Udpfs sensor location is available setupUdfps(); mLockIconViewController.init(); captureAttachListener(); // WHEN the view is attached mAttachListener.onViewAttachedToWindow(mLockIconView); // THEN the lock icon view background should be enabled verify(mLockIconView).setUseBackground(true); } @Test public void testLockIconViewBackgroundDisabledWhenUdfpsIsUnavailable() { // GIVEN Udfps sensor location is not available when(mAuthController.getUdfpsSensorLocation()).thenReturn(null); mLockIconViewController.init(); captureAttachListener(); // WHEN the view is attached mAttachListener.onViewAttachedToWindow(mLockIconView); // THEN the lock icon view background should be disabled verify(mLockIconView).setUseBackground(false); } private Pair<Integer, PointF> setupUdfps() { final PointF udfpsLocation = new PointF(50, 75); final PointF udfpsLocation = new PointF(50, 75); final int radius = 33; final int radius = 33; final FingerprintSensorPropertiesInternal fpProps = final FingerprintSensorPropertiesInternal fpProps = Loading @@ -176,12 +206,7 @@ public class LockIconViewControllerTest extends SysuiTestCase { when(mAuthController.getUdfpsSensorLocation()).thenReturn(udfpsLocation); when(mAuthController.getUdfpsSensorLocation()).thenReturn(udfpsLocation); when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps)); when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps)); // WHEN all authenticators are registered return new Pair(radius, udfpsLocation); mAuthControllerCallback.onAllAuthenticatorsRegistered(); // THEN lock icon view location is updated with the same coordinates as fpProps verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(radius)); assertEquals(udfpsLocation, mPointCaptor.getValue()); } } private void captureAuthControllerCallback() { private void captureAuthControllerCallback() { Loading Loading
packages/SystemUI/src/com/android/keyguard/LockIconView.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,7 @@ public class LockIconView extends FrameLayout implements Dumpable { private ImageView mBgView; private ImageView mBgView; private int mLockIconColor; private int mLockIconColor; private boolean mUseBackground = false; public LockIconView(Context context, AttributeSet attrs) { public LockIconView(Context context, AttributeSet attrs) { super(context, attrs); super(context, attrs); Loading @@ -61,8 +62,8 @@ public class LockIconView extends FrameLayout implements Dumpable { mBgView = findViewById(R.id.lock_icon_bg); mBgView = findViewById(R.id.lock_icon_bg); } } void updateColorAndBackgroundVisibility(boolean useBackground) { void updateColorAndBackgroundVisibility() { if (useBackground && mLockIcon.getDrawable() != null) { if (mUseBackground && mLockIcon.getDrawable() != null) { mLockIconColor = Utils.getColorAttrDefaultColor(getContext(), mLockIconColor = Utils.getColorAttrDefaultColor(getContext(), android.R.attr.textColorPrimary); android.R.attr.textColorPrimary); mBgView.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg)); mBgView.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg)); Loading @@ -78,6 +79,9 @@ public class LockIconView extends FrameLayout implements Dumpable { void setImageDrawable(Drawable drawable) { void setImageDrawable(Drawable drawable) { mLockIcon.setImageDrawable(drawable); mLockIcon.setImageDrawable(drawable); if (!mUseBackground) return; if (drawable == null) { if (drawable == null) { mBgView.setVisibility(View.INVISIBLE); mBgView.setVisibility(View.INVISIBLE); } else { } else { Loading @@ -85,6 +89,14 @@ public class LockIconView extends FrameLayout implements Dumpable { } } } } /** * Whether or not to render the lock icon background. Mainly used for UDPFS. */ public void setUseBackground(boolean useBackground) { mUseBackground = useBackground; updateColorAndBackgroundVisibility(); } /** /** * Set the location of the lock icon. * Set the location of the lock icon. */ */ Loading
packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -345,7 +345,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme } } private void updateColors() { private void updateColors() { mView.updateColorAndBackgroundVisibility(mUdfpsSupported); mView.updateColorAndBackgroundVisibility(); } } private void updateConfiguration() { private void updateConfiguration() { Loading Loading @@ -425,6 +425,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme boolean wasUdfpsEnrolled = mUdfpsEnrolled; boolean wasUdfpsEnrolled = mUdfpsEnrolled; mUdfpsSupported = mAuthController.getUdfpsSensorLocation() != null; mUdfpsSupported = mAuthController.getUdfpsSensorLocation() != null; mView.setUseBackground(mUdfpsSupported); mUdfpsEnrolled = mKeyguardUpdateMonitor.isUdfpsEnrolled(); mUdfpsEnrolled = mKeyguardUpdateMonitor.isUdfpsEnrolled(); if (wasUdfpsSupported != mUdfpsSupported || wasUdfpsEnrolled != mUdfpsEnrolled) { if (wasUdfpsSupported != mUdfpsSupported || wasUdfpsEnrolled != mUdfpsEnrolled) { updateVisibility(); updateVisibility(); Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java +46 −21 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Vibrator; import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.testing.TestableLooper; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.Pair; import android.view.View; import android.view.View; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager; Loading Loading @@ -127,19 +128,7 @@ public class LockIconViewControllerTest extends SysuiTestCase { @Test @Test public void testUpdateFingerprintLocationOnInit() { public void testUpdateFingerprintLocationOnInit() { // GIVEN fp sensor location is available pre-attached // GIVEN fp sensor location is available pre-attached final PointF udfpsLocation = new PointF(50, 75); Pair<Integer, PointF> udfps = setupUdfps(); final int radius = 33; final FingerprintSensorPropertiesInternal fpProps = new FingerprintSensorPropertiesInternal( /* sensorId */ 0, /* strength */ 0, /* max enrollments per user */ 5, /* component info */ new ArrayList<>(), /* sensorType */ 3, /* resetLockoutRequiresHwToken */ false, (int) udfpsLocation.x, (int) udfpsLocation.y, radius); when(mAuthController.getUdfpsSensorLocation()).thenReturn(udfpsLocation); when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps)); // WHEN lock icon view controller is initialized and attached // WHEN lock icon view controller is initialized and attached mLockIconViewController.init(); mLockIconViewController.init(); Loading @@ -147,8 +136,8 @@ public class LockIconViewControllerTest extends SysuiTestCase { mAttachListener.onViewAttachedToWindow(mLockIconView); mAttachListener.onViewAttachedToWindow(mLockIconView); // THEN lock icon view location is updated with the same coordinates as fpProps // THEN lock icon view location is updated with the same coordinates as fpProps verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(radius)); verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(udfps.first)); assertEquals(udfpsLocation, mPointCaptor.getValue()); assertEquals(udfps.second, mPointCaptor.getValue()); } } @Test @Test Loading @@ -162,6 +151,47 @@ public class LockIconViewControllerTest extends SysuiTestCase { // GIVEN fp sensor location is available post-atttached // GIVEN fp sensor location is available post-atttached captureAuthControllerCallback(); captureAuthControllerCallback(); Pair<Integer, PointF> udfps = setupUdfps(); // WHEN all authenticators are registered mAuthControllerCallback.onAllAuthenticatorsRegistered(); // THEN lock icon view location is updated with the same coordinates as fpProps verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(udfps.first)); assertEquals(udfps.second, mPointCaptor.getValue()); } @Test public void testLockIconViewBackgroundEnabledWhenUdfpsIsAvailable() { // GIVEN Udpfs sensor location is available setupUdfps(); mLockIconViewController.init(); captureAttachListener(); // WHEN the view is attached mAttachListener.onViewAttachedToWindow(mLockIconView); // THEN the lock icon view background should be enabled verify(mLockIconView).setUseBackground(true); } @Test public void testLockIconViewBackgroundDisabledWhenUdfpsIsUnavailable() { // GIVEN Udfps sensor location is not available when(mAuthController.getUdfpsSensorLocation()).thenReturn(null); mLockIconViewController.init(); captureAttachListener(); // WHEN the view is attached mAttachListener.onViewAttachedToWindow(mLockIconView); // THEN the lock icon view background should be disabled verify(mLockIconView).setUseBackground(false); } private Pair<Integer, PointF> setupUdfps() { final PointF udfpsLocation = new PointF(50, 75); final PointF udfpsLocation = new PointF(50, 75); final int radius = 33; final int radius = 33; final FingerprintSensorPropertiesInternal fpProps = final FingerprintSensorPropertiesInternal fpProps = Loading @@ -176,12 +206,7 @@ public class LockIconViewControllerTest extends SysuiTestCase { when(mAuthController.getUdfpsSensorLocation()).thenReturn(udfpsLocation); when(mAuthController.getUdfpsSensorLocation()).thenReturn(udfpsLocation); when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps)); when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps)); // WHEN all authenticators are registered return new Pair(radius, udfpsLocation); mAuthControllerCallback.onAllAuthenticatorsRegistered(); // THEN lock icon view location is updated with the same coordinates as fpProps verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(radius)); assertEquals(udfpsLocation, mPointCaptor.getValue()); } } private void captureAuthControllerCallback() { private void captureAuthControllerCallback() { Loading