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

Commit f19865ce authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9adecb7a,I4d2a4dca,I5051ae43,I313f1f1b into main

* changes:
  Fix lockscreen notification shelf jump animation
  Add logs to monitor NSSL height-related changes
  Format NotificationStackScrollLogger
  Check minimalism flag before monitoring settings value
parents b18e8dac 03f19e4a
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map

/**
@@ -132,9 +131,6 @@ constructor(
    }

    private fun minimalismFeatureSettingEnabled(): Flow<Boolean> {
        if (!NotificationMinimalism.isEnabled) {
            return flowOf(false)
        }
        return seenNotificationsInteractor.isLockScreenNotificationMinimalismEnabled()
    }

+28 −20
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
@@ -131,9 +132,15 @@ constructor(
            .conflate()

    fun isLockScreenNotificationMinimalismEnabled(): Flow<Boolean> =
        if (!NotificationMinimalism.isEnabled) {
            flowOf(false)
        } else {
            secureSettings
                // emit whenever the setting has changed
            .observerFlow(UserHandle.USER_ALL, Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM)
                .observerFlow(
                    UserHandle.USER_ALL,
                    Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM,
                )
                // perform a query immediately
                .onStart { emit(Unit) }
                // for each change, lookup the new value
@@ -148,7 +155,8 @@ constructor(
                .distinctUntilChanged()
                // perform lookups on the bg thread pool
                .flowOn(bgDispatcher)
            // only track the most recent emission, if events are happening faster than they can be
            // consumed
                // only track the most recent emission, if events are happening faster than they can
                // be consumed
                .conflate()
        }
}
+20 −2
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;
import com.android.systemui.statusbar.notification.shared.NotificationContentAlphaOptimization;
import com.android.systemui.statusbar.notification.shared.NotificationHeadsUpCycling;
import com.android.systemui.statusbar.notification.shared.NotificationMinimalism;
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun;
import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor;
import com.android.systemui.statusbar.notification.stack.shared.model.AccessibilityScrollEvent;
@@ -272,6 +273,7 @@ public class NotificationStackScrollLayout
    private OnOverscrollTopChangedListener mOverscrollTopChangedListener;
    private ExpandableView.OnHeightChangedListener mOnHeightChangedListener;
    private Runnable mOnHeightChangedRunnable;
    private Runnable mOnKeyguardTopLevelNotificationRemovedRunnable;
    private OnEmptySpaceClickListener mOnEmptySpaceClickListener;
    private boolean mNeedsAnimation;
    private boolean mTopPaddingNeedsAnimation;
@@ -2583,7 +2585,8 @@ public class NotificationStackScrollLayout
        final int notificationsHeight = (int) mNotificationStackSizeCalculator.computeHeight(
                /* notificationStackScrollLayout= */ this,
                mMaxDisplayedNotifications,
                shelfIntrinsicHeight
                shelfIntrinsicHeight,
                "updateIntrinsicStackHeight"
        );
        if (mScrollViewFields.getIntrinsicStackHeight() != notificationsHeight) {
            mScrollViewFields.setIntrinsicStackHeight(notificationsHeight);
@@ -2603,7 +2606,7 @@ public class NotificationStackScrollLayout
        final float height =
                (int) scrimTopPadding + (int) mNotificationStackSizeCalculator.computeHeight(
                        /* notificationStackScrollLayout= */ this, mMaxDisplayedNotifications,
                        shelfIntrinsicHeight);
                        shelfIntrinsicHeight, "updateContentHeight");
        setIntrinsicContentHeight(height);

        // The topPadding can be bigger than the regular padding when qs is expanded, in that
@@ -2880,6 +2883,11 @@ public class NotificationStackScrollLayout
        // notification which becomes a child notification
        ExpandableView expandableView = (ExpandableView) child;
        if (!mChildTransferInProgress) {
            if (NotificationMinimalism.isEnabled()
                    && mAmbientState.isOnKeyguard()
                    && this.mOnKeyguardTopLevelNotificationRemovedRunnable != null) {
                mOnKeyguardTopLevelNotificationRemovedRunnable.run();
            }
            onViewRemovedInternal(expandableView, this);
        }
        mShelf.requestRoundnessResetFor(expandableView);
@@ -4485,6 +4493,9 @@ public class NotificationStackScrollLayout
        ExpandableView firstVisibleChild =
                firstSection == null ? null : firstSection.getFirstVisibleChild();
        if (row != null) {
            if (mLogger != null) {
                mLogger.childHeightUpdated(row, needsAnimation);
            }
            if (row == firstVisibleChild
                    || row.getNotificationParent() == firstVisibleChild) {
                updateAlgorithmLayoutMinHeight();
@@ -4546,6 +4557,10 @@ public class NotificationStackScrollLayout
        this.mOnHeightChangedRunnable = r;
    }

    void setOnKeyguardTopLevelNotificationRemovedRunnable(Runnable r) {
        this.mOnKeyguardTopLevelNotificationRemovedRunnable = r;
    }

    void onChildAnimationFinished() {
        setAnimationRunning(false);
        if (SceneContainerFlag.isEnabled()) {
@@ -5292,6 +5307,9 @@ public class NotificationStackScrollLayout

    public void setMaxDisplayedNotifications(int maxDisplayedNotifications) {
        if (mMaxDisplayedNotifications != maxDisplayedNotifications) {
            if (mLogger != null) {
                mLogger.setMaxDisplayedNotifications(maxDisplayedNotifications);
            }
            mMaxDisplayedNotifications = maxDisplayedNotifications;
            if (SceneContainerFlag.isEnabled()) {
                updateIntrinsicStackHeight();
+8 −0
Original line number Diff line number Diff line
@@ -1091,6 +1091,14 @@ public class NotificationStackScrollLayoutController implements Dumpable {
        mView.setOnHeightChangedRunnable(r);
    }

    /**
     * Invoked when a top-level notification(one with NSSL as parent, not group-child) is removed
     * from the lockscreen NSSL.
     */
    public void setOnKeyguardTopLevelNotificationRemovedRunnable(Runnable r) {
        mView.setOnKeyguardTopLevelNotificationRemovedRunnable(r);
    }

    public void setOverscrollTopChangedListener(
            OnOverscrollTopChangedListener listener) {
        SceneContainerFlag.assertInLegacyMode();
+141 −102
Original line number Diff line number Diff line
@@ -3,13 +3,12 @@ package com.android.systemui.statusbar.notification.stack
import android.view.ViewGroup
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.log.core.LogLevel.INFO
import com.android.systemui.log.core.LogLevel.ERROR
import com.android.systemui.log.core.LogLevel.INFO
import com.android.systemui.log.dagger.NotificationHeadsUpLog
import com.android.systemui.log.dagger.NotificationRenderLog
import com.android.systemui.log.dagger.ShadeLog
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_ADD
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR
@@ -18,22 +17,29 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject

class NotificationStackScrollLogger @Inject constructor(
class NotificationStackScrollLogger
@Inject
constructor(
    @NotificationHeadsUpLog private val buffer: LogBuffer,
    @NotificationRenderLog private val notificationRenderBuffer: LogBuffer,
    @ShadeLog private val shadeLogBuffer: LogBuffer,
) {
    fun hunAnimationSkipped(entry: String, reason: String) {
        buffer.log(TAG, INFO, {
        buffer.log(
            TAG,
            INFO,
            {
                str1 = entry
                str2 = reason
        }, {
            "heads up animation skipped: key: $str1 reason: $str2"
        })
            },
            { "heads up animation skipped: key: $str1 reason: $str2" },
        )
    }

    fun hunAnimationEventAdded(entry: String, type: Int) {
        val reason: String
        reason = if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR) {
        reason =
            if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR) {
                "HEADS_UP_DISAPPEAR"
            } else if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
                "HEADS_UP_DISAPPEAR_CLICK"
@@ -46,23 +52,31 @@ class NotificationStackScrollLogger @Inject constructor(
            } else {
                type.toString()
            }
        buffer.log(TAG, INFO, {
        buffer.log(
            TAG,
            INFO,
            {
                str1 = entry
                str2 = reason
        }, {
            "heads up animation added: $str1 with type $str2"
        })
            },
            { "heads up animation added: $str1 with type $str2" },
        )
    }

    fun hunSkippedForUnexpectedState(entry: String, expected: Boolean, actual: Boolean) {
        buffer.log(TAG, INFO, {
        buffer.log(
            TAG,
            INFO,
            {
                str1 = entry
                bool1 = expected
                bool2 = actual
        }, {
            },
            {
                "HUN animation skipped for unexpected hun state: " +
                    "key: $str1 expected: $bool1 actual: $bool2"
        })
            },
        )
    }

    fun logShadeDebugEvent(@CompileTimeConstant msg: String) = shadeLogBuffer.log(TAG, DEBUG, msg)
@@ -71,68 +85,76 @@ class NotificationStackScrollLogger @Inject constructor(
        isBelowLastNotification: Boolean,
        statusBarState: Int,
        touchIsClick: Boolean,
        motionEventDesc: String
        motionEventDesc: String,
    ) {
        shadeLogBuffer.log(TAG, DEBUG, {
        shadeLogBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = statusBarState
                bool1 = touchIsClick
                bool2 = isBelowLastNotification
                str1 = motionEventDesc
        }, {
            },
            {
                "handleEmptySpaceClick: statusBarState: $int1 isTouchAClick: $bool1 " +
                    "isTouchBelowNotification: $bool2 motionEvent: $str1"
        })
            },
        )
    }

    fun transientNotificationRowTraversalCleaned(entry: String, reason: String) {
        notificationRenderBuffer.log(TAG, INFO, {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = entry
                str2 = reason
        }, {
            "transientNotificationRowTraversalCleaned: key: $str1 reason: $str2"
        })
            },
            { "transientNotificationRowTraversalCleaned: key: $str1 reason: $str2" },
        )
    }

    fun addTransientChildNotificationToChildContainer(
            childEntry: String,
            containerEntry: String,
    ) {
        notificationRenderBuffer.log(TAG, INFO, {
    fun addTransientChildNotificationToChildContainer(childEntry: String, containerEntry: String) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = childEntry
                str2 = containerEntry
        }, {
            },
            {
                "addTransientChildToContainer from onViewRemovedInternal: childKey: $str1 " +
                    "-- containerKey: $str2"
        })
            },
        )
    }

    fun addTransientChildNotificationToNssl(
            childEntry: String,
    ) {
        notificationRenderBuffer.log(TAG, INFO, {
            str1 = childEntry
        }, {
            "addTransientRowToNssl from onViewRemovedInternal: childKey: $str1"
        })
    fun addTransientChildNotificationToNssl(childEntry: String) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            { str1 = childEntry },
            { "addTransientRowToNssl from onViewRemovedInternal: childKey: $str1" },
        )
    }

    fun addTransientChildNotificationToViewGroup(
            childEntry: String,
            container: ViewGroup
    ) {
        notificationRenderBuffer.log(TAG, ERROR, {
    fun addTransientChildNotificationToViewGroup(childEntry: String, container: ViewGroup) {
        notificationRenderBuffer.log(
            TAG,
            ERROR,
            {
                str1 = childEntry
                str2 = container.toString()
        }, {
            },
            {
                "addTransientRowTo unhandled ViewGroup from onViewRemovedInternal: childKey: $str1 " +
                    "-- ViewGroup: $str2"
        })
            },
        )
    }

    fun addTransientRow(
            childEntry: String,
            index: Int
    ) {
    fun addTransientRow(childEntry: String, index: Int) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
@@ -140,20 +162,16 @@ class NotificationStackScrollLogger @Inject constructor(
                str1 = childEntry
                int1 = index
            },
                { "addTransientRow to NSSL: childKey: $str1 -- index: $int1" }
            { "addTransientRow to NSSL: childKey: $str1 -- index: $int1" },
        )
    }

    fun removeTransientRow(
            childEntry: String,
    ) {
    fun removeTransientRow(childEntry: String) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
                {
                    str1 = childEntry
                },
                { "removeTransientRow from NSSL: childKey: $str1" }
            { str1 = childEntry },
            { "removeTransientRow from NSSL: childKey: $str1" },
        )
    }

@@ -194,6 +212,27 @@ class NotificationStackScrollLogger @Inject constructor(
            },
        )
    }

    fun childHeightUpdated(row: ExpandableNotificationRow, needsAnimation: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            {
                str1 = row.key
                bool1 = needsAnimation
            },
            { "childHeightUpdated: childKey: $str1 -- needsAnimation: $bool1" },
        )
    }

    fun setMaxDisplayedNotifications(maxDisplayedNotifications: Int) {
        notificationRenderBuffer.log(
            TAG,
            INFO,
            { int1 = maxDisplayedNotifications },
            { "setMaxDisplayedNotifications: $int1" },
        )
    }
}

private const val TAG = "NotificationStackScroll"
Loading