Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.systemui.statusbar.notification.NotificationUtils.inte import android.content.res.Resources; import android.content.res.Resources; import android.util.MathUtils; import android.util.MathUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.Interpolators; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.R; Loading Loading @@ -229,6 +230,11 @@ public class KeyguardClockPositionAlgorithm { - mBurnInPreventionOffsetX; - mBurnInPreventionOffsetX; } } @VisibleForTesting void setPulsingPadding(int padding) { mPulsingPadding = padding; } public static class Result { public static class Result { /** /** Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +152 −2 Original line number Original line Diff line number Diff line Loading @@ -37,7 +37,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private static final int EMPTY_MARGIN = 0; private static final int EMPTY_MARGIN = 0; private static final int EMPTY_HEIGHT = 0; private static final int EMPTY_HEIGHT = 0; private static final boolean SECURE_LOCKED = false; private static final boolean SECURE_LOCKED = false; private static final boolean PULSING_NO = false; private static final float ZERO_DRAG = 0.f; private static final float ZERO_DRAG = 0.f; private static final float OPAQUE = 1.f; private static final float OPAQUE = 1.f; private static final float TRANSPARENT = 0.f; private static final float TRANSPARENT = 0.f; Loading @@ -48,6 +47,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private float mPanelExpansion; private float mPanelExpansion; private int mKeyguardStatusHeight; private int mKeyguardStatusHeight; private float mDark; private float mDark; private boolean mPulsing; @Before @Before public void setUp() { public void setUp() { Loading Loading @@ -171,6 +171,156 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); } } @Test public void notifPositionMiddleOfScreenOnAOD() { // GIVEN on AOD and both stack scroll and clock have 0 height givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() { // GIVEN on AOD and clock has a nonzero height givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = 100; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionWithLargeClockOnAOD() { // GIVEN on AOD and clock has a nonzero height givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = SCREEN_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is, unfortunately, the entire screen. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT); } @Test public void notifPositionWhilePulsingOnAOD() { // GIVEN on AOD and pulsing givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; mPulsing = true; mClockPositionAlgorithm.setPulsingPadding(200); // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding doesn't adjust for pulsing. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionMiddleOfScreenOnLockScreen() { // GIVEN on lock screen and both stack scroll and clock have 0 height givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionAdjustsForStackHeightOnLockScreen() { // GIVEN on lock screen and stack scroller has a nonzero height givenLockScreen(); mNotificationStackHeight = 500; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding adjusts for the expanded notif stack. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(750); } @Test public void notifPositionAdjustsForClockHeightOnLockScreen() { // GIVEN on lock screen and stack scroller has a nonzero height givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = 200; // WHEN the position algorithm is run positionClock(); // THEN the notif padding adjusts for both clock and notif stack. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionAdjustsForStackHeightAndClockHeightOnLockScreen() { // GIVEN on lock screen and stack scroller has a nonzero height givenLockScreen(); mNotificationStackHeight = 500; mKeyguardStatusHeight = 200; // WHEN the position algorithm is run positionClock(); // THEN the notif padding adjusts for both clock and notif stack. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(810); } @Test public void notifPositionWithLargeClockOnLockScreen() { // GIVEN on lock screen and clock has a nonzero height givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = SCREEN_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionWithFullDragOnLockScreen() { // GIVEN the lock screen is dragged up givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; mPanelExpansion = 0.f; // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding is zero. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } @Test public void notifPositionWithLargeClockFullDragOnLockScreen() { // GIVEN the lock screen is dragged up and a full screen clock givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = SCREEN_HEIGHT; mPanelExpansion = 0.f; // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding is zero. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } @Test public void notifPositionWhilePulsingOnLockScreen() { // GIVEN on lock screen and pulsing givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; mPulsing = true; mClockPositionAlgorithm.setPulsingPadding(200); // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding adjusts for pulsing. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1200); } private void givenAOD() { private void givenAOD() { mPanelExpansion = 1.f; mPanelExpansion = 1.f; mDark = 1.f; mDark = 1.f; Loading @@ -184,7 +334,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private void positionClock() { private void positionClock() { mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight, mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight, mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mDark, SECURE_LOCKED, mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mDark, SECURE_LOCKED, PULSING_NO, ZERO_DRAG); mPulsing, ZERO_DRAG); mClockPositionAlgorithm.run(mClockPosition); mClockPositionAlgorithm.run(mClockPosition); } } } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.systemui.statusbar.notification.NotificationUtils.inte import android.content.res.Resources; import android.content.res.Resources; import android.util.MathUtils; import android.util.MathUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.Interpolators; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.R; Loading Loading @@ -229,6 +230,11 @@ public class KeyguardClockPositionAlgorithm { - mBurnInPreventionOffsetX; - mBurnInPreventionOffsetX; } } @VisibleForTesting void setPulsingPadding(int padding) { mPulsingPadding = padding; } public static class Result { public static class Result { /** /** Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +152 −2 Original line number Original line Diff line number Diff line Loading @@ -37,7 +37,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private static final int EMPTY_MARGIN = 0; private static final int EMPTY_MARGIN = 0; private static final int EMPTY_HEIGHT = 0; private static final int EMPTY_HEIGHT = 0; private static final boolean SECURE_LOCKED = false; private static final boolean SECURE_LOCKED = false; private static final boolean PULSING_NO = false; private static final float ZERO_DRAG = 0.f; private static final float ZERO_DRAG = 0.f; private static final float OPAQUE = 1.f; private static final float OPAQUE = 1.f; private static final float TRANSPARENT = 0.f; private static final float TRANSPARENT = 0.f; Loading @@ -48,6 +47,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private float mPanelExpansion; private float mPanelExpansion; private int mKeyguardStatusHeight; private int mKeyguardStatusHeight; private float mDark; private float mDark; private boolean mPulsing; @Before @Before public void setUp() { public void setUp() { Loading Loading @@ -171,6 +171,156 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); } } @Test public void notifPositionMiddleOfScreenOnAOD() { // GIVEN on AOD and both stack scroll and clock have 0 height givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() { // GIVEN on AOD and clock has a nonzero height givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = 100; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionWithLargeClockOnAOD() { // GIVEN on AOD and clock has a nonzero height givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = SCREEN_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is, unfortunately, the entire screen. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT); } @Test public void notifPositionWhilePulsingOnAOD() { // GIVEN on AOD and pulsing givenAOD(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; mPulsing = true; mClockPositionAlgorithm.setPulsingPadding(200); // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding doesn't adjust for pulsing. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionMiddleOfScreenOnLockScreen() { // GIVEN on lock screen and both stack scroll and clock have 0 height givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionAdjustsForStackHeightOnLockScreen() { // GIVEN on lock screen and stack scroller has a nonzero height givenLockScreen(); mNotificationStackHeight = 500; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding adjusts for the expanded notif stack. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(750); } @Test public void notifPositionAdjustsForClockHeightOnLockScreen() { // GIVEN on lock screen and stack scroller has a nonzero height givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = 200; // WHEN the position algorithm is run positionClock(); // THEN the notif padding adjusts for both clock and notif stack. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionAdjustsForStackHeightAndClockHeightOnLockScreen() { // GIVEN on lock screen and stack scroller has a nonzero height givenLockScreen(); mNotificationStackHeight = 500; mKeyguardStatusHeight = 200; // WHEN the position algorithm is run positionClock(); // THEN the notif padding adjusts for both clock and notif stack. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(810); } @Test public void notifPositionWithLargeClockOnLockScreen() { // GIVEN on lock screen and clock has a nonzero height givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = SCREEN_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is half of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1000); } @Test public void notifPositionWithFullDragOnLockScreen() { // GIVEN the lock screen is dragged up givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; mPanelExpansion = 0.f; // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding is zero. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } @Test public void notifPositionWithLargeClockFullDragOnLockScreen() { // GIVEN the lock screen is dragged up and a full screen clock givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = SCREEN_HEIGHT; mPanelExpansion = 0.f; // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding is zero. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } @Test public void notifPositionWhilePulsingOnLockScreen() { // GIVEN on lock screen and pulsing givenLockScreen(); mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; mPulsing = true; mClockPositionAlgorithm.setPulsingPadding(200); // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding adjusts for pulsing. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(1200); } private void givenAOD() { private void givenAOD() { mPanelExpansion = 1.f; mPanelExpansion = 1.f; mDark = 1.f; mDark = 1.f; Loading @@ -184,7 +334,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private void positionClock() { private void positionClock() { mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight, mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight, mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mDark, SECURE_LOCKED, mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mDark, SECURE_LOCKED, PULSING_NO, ZERO_DRAG); mPulsing, ZERO_DRAG); mClockPositionAlgorithm.run(mClockPosition); mClockPositionAlgorithm.run(mClockPosition); } } } }