Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 839eb339 authored by Xiaowen Lei's avatar Xiaowen Lei Committed by Automerger Merge Worker
Browse files

Merge "Log event for bouncer fully visible after dream swiped up." into tm-dev...

Merge "Log event for bouncer fully visible after dream swiped up." into tm-dev am: f52220af am: 2a4650aa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17629040



Change-Id: I4a30b19bce47e13fbe9930b3c03cad3f68c93c13
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6f840d84 2a4650aa
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.SWIPE_
import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_OPENING;
import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.SWIPE_TO_BOUNCER_START_REGION;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.graphics.Region;
@@ -151,7 +153,10 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
    @VisibleForTesting
    public enum DreamEvent implements UiEventLogger.UiEventEnum {
        @UiEvent(doc = "The screensaver has been swiped up.")
        DREAM_SWIPED(988);
        DREAM_SWIPED(988),

        @UiEvent(doc = "The bouncer has become fully visible over dream.")
        DREAM_BOUNCER_FULLY_VISIBLE(1056);

        private final int mId;

@@ -281,6 +286,15 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
                animation -> {
                    setPanelExpansion((float) animation.getAnimatedValue());
                });
        if (!mBouncerInitiallyShowing && targetExpansion == KeyguardBouncer.EXPANSION_VISIBLE) {
            animator.addListener(
                    new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            mUiEventLogger.log(DreamEvent.DREAM_BOUNCER_FULLY_VISIBLE);
                        }
                    });
        }
        return animator;
    }

+25 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.graphics.Region;
@@ -71,7 +72,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
    @Mock
    FlingAnimationUtils mFlingAnimationUtils;


    @Mock
    FlingAnimationUtils mFlingAnimationUtilsClosing;

@@ -323,6 +323,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        swipeToPosition(swipeUpPercentage, Direction.UP, velocityY);

        verify(mValueAnimatorCreator).create(eq(expansion), eq(KeyguardBouncer.EXPANSION_HIDDEN));
        verify(mValueAnimator, never()).addListener(any());

        verify(mFlingAnimationUtilsClosing).apply(eq(mValueAnimator),
                eq(SCREEN_HEIGHT_PX * expansion),
                eq(SCREEN_HEIGHT_PX * KeyguardBouncer.EXPANSION_HIDDEN),
@@ -343,11 +345,20 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        swipeToPosition(swipeUpPercentage, Direction.UP, velocityY);

        verify(mValueAnimatorCreator).create(eq(expansion), eq(KeyguardBouncer.EXPANSION_VISIBLE));

        ArgumentCaptor<AnimatorListenerAdapter> endAnimationListenerCaptor =
                ArgumentCaptor.forClass(AnimatorListenerAdapter.class);
        verify(mValueAnimator).addListener(endAnimationListenerCaptor.capture());
        AnimatorListenerAdapter endAnimationListener = endAnimationListenerCaptor.getValue();

        verify(mFlingAnimationUtils).apply(eq(mValueAnimator), eq(SCREEN_HEIGHT_PX * expansion),
                eq(SCREEN_HEIGHT_PX * KeyguardBouncer.EXPANSION_VISIBLE),
                eq(velocityY), eq((float) SCREEN_HEIGHT_PX));
        verify(mValueAnimator).start();
        verify(mUiEventLogger).log(BouncerSwipeTouchHandler.DreamEvent.DREAM_SWIPED);

        endAnimationListener.onAnimationEnd(mValueAnimator);
        verify(mUiEventLogger).log(BouncerSwipeTouchHandler.DreamEvent.DREAM_BOUNCER_FULLY_VISIBLE);
    }

    /**
@@ -365,6 +376,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {

        verify(mValueAnimatorCreator).create(eq(swipeDownPercentage),
                eq(KeyguardBouncer.EXPANSION_VISIBLE));
        verify(mValueAnimator, never()).addListener(any());

        verify(mFlingAnimationUtils).apply(eq(mValueAnimator),
                eq(SCREEN_HEIGHT_PX * swipeDownPercentage),
                eq(SCREEN_HEIGHT_PX * KeyguardBouncer.EXPANSION_VISIBLE),
@@ -389,6 +402,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {

        verify(mValueAnimatorCreator).create(eq(swipeDownPercentage),
                eq(KeyguardBouncer.EXPANSION_HIDDEN));
        verify(mValueAnimator, never()).addListener(any());

        verify(mFlingAnimationUtilsClosing).apply(eq(mValueAnimator),
                eq(SCREEN_HEIGHT_PX * swipeDownPercentage),
                eq(SCREEN_HEIGHT_PX * KeyguardBouncer.EXPANSION_HIDDEN),
@@ -411,11 +426,20 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        swipeToPosition(swipeUpPercentage, Direction.UP, velocityY);

        verify(mValueAnimatorCreator).create(eq(expansion), eq(KeyguardBouncer.EXPANSION_VISIBLE));

        ArgumentCaptor<AnimatorListenerAdapter> endAnimationListenerCaptor =
                ArgumentCaptor.forClass(AnimatorListenerAdapter.class);
        verify(mValueAnimator).addListener(endAnimationListenerCaptor.capture());
        AnimatorListenerAdapter endAnimationListener = endAnimationListenerCaptor.getValue();

        verify(mFlingAnimationUtils).apply(eq(mValueAnimator), eq(SCREEN_HEIGHT_PX * expansion),
                eq(SCREEN_HEIGHT_PX * KeyguardBouncer.EXPANSION_VISIBLE),
                eq(velocityY), eq((float) SCREEN_HEIGHT_PX));
        verify(mValueAnimator).start();
        verify(mUiEventLogger).log(BouncerSwipeTouchHandler.DreamEvent.DREAM_SWIPED);

        endAnimationListener.onAnimationEnd(mValueAnimator);
        verify(mUiEventLogger).log(BouncerSwipeTouchHandler.DreamEvent.DREAM_BOUNCER_FULLY_VISIBLE);
    }

    private void swipeToPosition(float percent, Direction direction, float velocityY) {