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

Commit cdc9d924 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android Build Coastguard Worker
Browse files

[NSSL] Log Swipe out events coming from SwipeHelper

Bug: 415279408
Test: Presubmit && check NSSL logs
Flag: EXEMPT new information is added to the logs.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:77ad9ebd4268004d87db3bcca7ca224ff1eaf05b)
Merged-In: I1751e6e6a66f4e4dfb3ecaacaea2e185317da6fc
Change-Id: I1751e6e6a66f4e4dfb3ecaacaea2e185317da6fc
parent 2d2edfbf
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -596,7 +596,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    @Test
    public void callSwipeCallbacksDuringClearAll() {
        initController(/* viewIsAttached= */ true);
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        ExpandableNotificationRow row =
                createExpandableNotificationRow();
        NotificationCallback notificationCallback = mController.mNotificationCallback;

        when(mNotificationStackScrollLayout.getClearAllInProgress()).thenReturn(true);
@@ -611,7 +612,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    @Test
    public void callSwipeCallbacksDuringClearNotification() {
        initController(/* viewIsAttached= */ true);
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        ExpandableNotificationRow row =
                createExpandableNotificationRow();
        NotificationCallback notificationCallback = mController.mNotificationCallback;

        when(mNotificationStackScrollLayout.getClearAllInProgress()).thenReturn(false);
@@ -868,6 +870,13 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                mSectionsManager);
    }


    private static ExpandableNotificationRow createExpandableNotificationRow() {
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        when(row.getLoggingKey()).thenReturn("ENR_loggingKey");
        return row;
    }

    static class LogMatcher implements ArgumentMatcher<LogMaker> {
        private final int mCategory, mType;

+16 −0
Original line number Diff line number Diff line
@@ -498,6 +498,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                mCallback.onBeginDrag(animView);
                mCallback.onSwipeOutAnimStart(animView);
            }

            @Override
@@ -519,7 +520,10 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                if (!mCancelled || wasRemoved) {
                    mCallback.onChildDismissed(animView);
                    resetViewIfSwiping(animView);
                } else {
                    mCallback.onChildNotDismissed(animView, mCancelled, wasRemoved);
                }

                if (endAction != null) {
                    endAction.accept(mCancelled);
                }
@@ -988,6 +992,11 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {

        void onBeginDrag(View v);

        /**
         * Called on swipe out animation starts.
         * Note that: it is added for logging.
         */
        default void onSwipeOutAnimStart(View v) {}
        /**
         * Set magnetic and roundable targets for a view.
         */
@@ -1080,5 +1089,12 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {

        /** The density scale has changed */
        void onDensityScaleChange(float density);

        /**
         * Called when child dismissal fails.
         * Note that: it is added for logging.
         */
        default void onChildNotDismissed(
                View v, boolean animationCancelled, boolean viewWasRemoved) {}
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -6046,9 +6046,16 @@ public class NotificationStackScrollLayout
    }

    void addSwipedOutView(View v) {
        logAddSwipedOutView(v);
        mSwipedOutViews.add(v);
    }

    private void logAddSwipedOutView(View v) {
        if (mLogger != null && v instanceof ExpandableNotificationRow row) {
            mLogger.logAddSwipedOutView(row.getLoggingKey(), mClearAllInProgress);
        }
    }

    void onSwipeBegin(View viewSwiped) {
        if (!(viewSwiped instanceof ExpandableNotificationRow)) {
            return;
+43 −0
Original line number Diff line number Diff line
@@ -572,6 +572,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                 */
                @Override
                public void onChildDismissed(View view) {
                    logOnChildDismissed(view);
                    if (!(view instanceof ActivatableNotificationView row)) {
                        return;
                    }
@@ -595,6 +596,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                public void handleChildViewDismissed(View view) {
                    // The View needs to clean up the Swipe states, e.g. roundness.
                    mMagneticNotificationRowManager.resetRoundness();
                    logHandleChildViewDismissed(view);
                    mView.onSwipeEnd();
                    if (mView.getClearAllInProgress()) {
                        return;
@@ -692,6 +694,34 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    mView.onSwipeBegin(v);
                }

                @Override
                public void onSwipeOutAnimStart(View v) {
                    logOnSwipeOutAnimationStart(v);
                }

                private void logOnSwipeOutAnimationStart(View v) {
                    if (mLogger != null && v instanceof ExpandableNotificationRow row) {
                        mLogger.logOnSwipeBegin(row.getLoggingKey(),
                                /* reason = */"onSwipeOutAnimStart",
                                mView.getClearAllInProgress());
                    }
                }

                @Override
                public void onChildNotDismissed(View v, boolean animationCancelled,
                        boolean viewWasRemoved) {
                    logOnChildNotDismissed(v, animationCancelled, viewWasRemoved);
                }

                private void logOnChildNotDismissed(View v, boolean animationCancelled,
                        boolean viewWasRemoved) {
                    if (mLogger != null && v instanceof ExpandableNotificationRow row) {
                        mLogger.logOnChildNotDismissed(row.getLoggingKey(),
                                animationCancelled, viewWasRemoved);
                    }
                }


                @Override
                public void setMagneticAndRoundableTargets(View v) {
                    if (v instanceof ExpandableNotificationRow row) {
@@ -767,6 +797,19 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                }
            };

    private void logHandleChildViewDismissed(View view) {
        if (mLogger != null && view instanceof ExpandableNotificationRow row) {
            mLogger.logOnSwipeEnd(row.getLoggingKey(),
                    /* reason = */"handleChildViewDismissed", mView.getClearAllInProgress());
        }
    }

    private void logOnChildDismissed(View view) {
        if (mLogger != null && view instanceof  ExpandableNotificationRow enr) {
            mLogger.logOnChildDismissed(enr.getLoggingKey(), mView.getClearAllInProgress());
        }
    }

    private final OnHeadsUpChangedListener mOnHeadsUpChangedListener =
            new OnHeadsUpChangedListener() {
                @Override
+70 −0
Original line number Diff line number Diff line
@@ -233,6 +233,76 @@ constructor(
            { "setMaxDisplayedNotifications: $int1" },
        )
    }

    fun logAddSwipedOutView(loggingKey: String, clearAllInProgress: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = loggingKey
                bool1 = clearAllInProgress
            },
            { "addSwipedOutView from NSSL: childKey = $str1 -- clearAllInProgress:$bool1" },
        )
    }

    fun logOnChildDismissed(loggingKey: String, clearAllInProgress: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = loggingKey
                bool1 = clearAllInProgress
            },
            { "onChildDismissed from NSSL: childKey = $str1 -- clearAllInProgress:$bool1" },
        )
    }

    fun logOnSwipeBegin(loggingKey: String, reason: String, clearAllInProgress: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = loggingKey
                str2 = reason
                bool1 = clearAllInProgress
            },
            { "onSwipeBegin from $str2: childKey = $str1 -- clearAllInProgress:$bool1" },
        )
    }

    fun logOnSwipeEnd(loggingKey: String, reason: String, clearAllInProgress: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = loggingKey
                str2 = reason
                bool1 = clearAllInProgress
            },
            { "onSwipeEnd from $str2: childKey = $str1 -- clearAllInProgress:$bool1" },
        )
    }

    fun logOnChildNotDismissed(
        loggingKey: String,
        animationCancelled: Boolean,
        viewWasRemoved: Boolean,
    ) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = loggingKey
                bool1 = animationCancelled
                bool2 = viewWasRemoved
            },
            {
                "onChildNotDismissed (ERROR) childKey = $str1 " +
                    "-- animationCancelled:$bool1 -- viewWasRemoved:$bool2"
            },
        )
    }
}

private const val TAG = "NotificationStackScroll"