Update burn-in offsets for the lock icon on AoD => LS
The translation needs to be updated to 0 for the view when the device isn't in AoD. Previously, the burn-in offset would be set on the view and wouldn't be updated after the icon changed to a non-aod icon. Test: atest LockIconViewControllerTest Test: 1. enable Aod and enroll a FP 2. reboot device 3. observe lock icon on the keyguard 4. observe lock icon on AoD Check sytemui dumpsys that the burn-in offsets for the lock icon don't propogate to the keyguard. Fixes: 208891368 Change-Id: I772125f8bc848e89034665213cff53057c30f470
This commit is contained in:
@@ -218,11 +218,14 @@ public class LockIconView extends FrameLayout implements Dumpable {
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
pw.println("Center in px (x, y)= (" + mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
||||
pw.println("Radius in pixels: " + mRadius);
|
||||
pw.println("topLeft= (" + getX() + ", " + getY() + ")");
|
||||
pw.println("topLeft= (" + getX() + ", " + getY() + ")");
|
||||
pw.println("mIconType=" + typeToString(mIconType));
|
||||
pw.println("mAod=" + mAod);
|
||||
pw.println("Lock Icon View Parameters:");
|
||||
pw.println(" Center in px (x, y)= ("
|
||||
+ mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
||||
pw.println(" Radius in pixels: " + mRadius);
|
||||
pw.println(" mIconType=" + typeToString(mIconType));
|
||||
pw.println(" mAod=" + mAod);
|
||||
pw.println("Lock Icon View actual measurements:");
|
||||
pw.println(" topLeft= (" + getX() + ", " + getY() + ")");
|
||||
pw.println(" width=" + getWidth() + " height=" + getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,10 +425,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
||||
mAodFp.setAlpha(255 * mInterpolatedDarkAmount);
|
||||
}
|
||||
|
||||
if (mShowAodLockIcon) {
|
||||
mView.setTranslationX(offsetX);
|
||||
mView.setTranslationY(offsetY);
|
||||
}
|
||||
mView.setTranslationX(offsetX);
|
||||
mView.setTranslationY(offsetY);
|
||||
}
|
||||
|
||||
private void updateIsUdfpsEnrolled() {
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
|
||||
package com.android.systemui.keyguard;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
|
||||
import static com.android.keyguard.LockIconView.ICON_LOCK;
|
||||
import static com.android.keyguard.LockIconView.ICON_UNLOCK;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyBoolean;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -57,6 +59,7 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.biometrics.AuthRippleController;
|
||||
import com.android.systemui.doze.util.BurnInHelperKt;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
@@ -68,6 +71,7 @@ import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -76,6 +80,8 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.MockitoSession;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -86,6 +92,8 @@ import java.util.List;
|
||||
public class LockIconViewControllerTest extends SysuiTestCase {
|
||||
private static final String UNLOCKED_LABEL = "unlocked";
|
||||
|
||||
private MockitoSession mStaticMockSession;
|
||||
|
||||
private @Mock LockIconView mLockIconView;
|
||||
private @Mock AnimatedStateListDrawable mIconDrawable;
|
||||
private @Mock Context mContext;
|
||||
@@ -133,6 +141,10 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mStaticMockSession = mockitoSession()
|
||||
.mockStatic(BurnInHelperKt.class)
|
||||
.strictness(Strictness.LENIENT)
|
||||
.startMocking();
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mLockIconView.getResources()).thenReturn(mResources);
|
||||
@@ -169,6 +181,11 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mStaticMockSession.finishMocking();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreUdfpsWhenNotSupported() {
|
||||
// GIVEN Udpfs sensor is NOT available
|
||||
@@ -369,6 +386,42 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
||||
verify(mLockIconView).updateIcon(ICON_LOCK, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBurnInOffsetsUpdated_onDozeAmountChanged() {
|
||||
// GIVEN udfps enrolled
|
||||
setupUdfps();
|
||||
when(mKeyguardUpdateMonitor.isUdfpsEnrolled()).thenReturn(true);
|
||||
|
||||
// GIVEN burn-in offset = 5
|
||||
int burnInOffset = 5;
|
||||
when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).thenReturn(burnInOffset);
|
||||
|
||||
// GIVEN starting state for the lock icon (keyguard)
|
||||
setupShowLockIcon();
|
||||
mLockIconViewController.init();
|
||||
captureAttachListener();
|
||||
mAttachListener.onViewAttachedToWindow(mLockIconView);
|
||||
captureStatusBarStateListener();
|
||||
reset(mLockIconView);
|
||||
|
||||
// WHEN dozing updates
|
||||
mStatusBarStateListener.onDozingChanged(true /* isDozing */);
|
||||
mStatusBarStateListener.onDozeAmountChanged(1f, 1f);
|
||||
|
||||
// THEN the view's translation is updated to use the AoD burn-in offsets
|
||||
verify(mLockIconView).setTranslationY(burnInOffset);
|
||||
verify(mLockIconView).setTranslationX(burnInOffset);
|
||||
reset(mLockIconView);
|
||||
|
||||
// WHEN the device is no longer dozing
|
||||
mStatusBarStateListener.onDozingChanged(false /* isDozing */);
|
||||
mStatusBarStateListener.onDozeAmountChanged(0f, 0f);
|
||||
|
||||
// THEN the view is updated to NO translation (no burn-in offsets anymore)
|
||||
verify(mLockIconView).setTranslationY(0);
|
||||
verify(mLockIconView).setTranslationX(0);
|
||||
|
||||
}
|
||||
private Pair<Integer, PointF> setupUdfps() {
|
||||
when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true);
|
||||
final PointF udfpsLocation = new PointF(50, 75);
|
||||
|
||||
Reference in New Issue
Block a user