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

Commit 55140738 authored by Yining Liu's avatar Yining Liu Committed by Android (Google) Code Review
Browse files

Merge changes I95fd75ac,I56977a66 into main

* changes:
  Re-format files
  Log reasons of HeadsUpManager#removeNotification
parents 26db4709 a26b0bae
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase {
        alm.showNotification(entry);

        final boolean removedImmediately = alm.removeNotification(
                entry.getKey(), /* releaseImmediately = */ false);
                entry.getKey(), /* releaseImmediately = */ false, "removeDeferred");
        assertFalse(removedImmediately);
        assertTrue(alm.isHeadsUpEntry(entry.getKey()));
    }
@@ -254,7 +254,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase {
        alm.showNotification(entry);

        final boolean removedImmediately = alm.removeNotification(
                entry.getKey(), /* releaseImmediately = */ true);
                entry.getKey(), /* releaseImmediately = */ true, "forceRemove");
        assertTrue(removedImmediately);
        assertFalse(alm.isHeadsUpEntry(entry.getKey()));
    }
@@ -430,7 +430,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase {
        hum.showNotification(entry);

        final boolean removedImmediately = hum.removeNotification(
                entry.getKey(), /* releaseImmediately = */ false);
                entry.getKey(), /* releaseImmediately = */ false, "beforeMinimumDisplayTime");
        assertFalse(removedImmediately);
        assertTrue(hum.isHeadsUpEntry(entry.getKey()));

@@ -452,7 +452,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase {
        assertTrue(hum.isHeadsUpEntry(entry.getKey()));

        final boolean removedImmediately = hum.removeNotification(
                entry.getKey(), /* releaseImmediately = */ false);
                entry.getKey(), /* releaseImmediately = */ false, "afterMinimumDisplayTime");
        assertTrue(removedImmediately);
        assertFalse(hum.isHeadsUpEntry(entry.getKey()));
    }
@@ -466,7 +466,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase {
        hum.showNotification(entry);

        final boolean removedImmediately = hum.removeNotification(
                entry.getKey(), /* releaseImmediately = */ true);
                entry.getKey(), /* releaseImmediately = */ true, "afterMinimumDisplayTime");
        assertTrue(removedImmediately);
        assertFalse(hum.isHeadsUpEntry(entry.getKey()));
    }
+8 −3
Original line number Diff line number Diff line
@@ -179,8 +179,8 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager
        mContext
            .getOrCreateTestableResources()
            .addOverride(R.integer.ambient_notification_extension_time, 500)
        mAvalancheController = AvalancheController(dumpManager, mUiEventLogger,
                mHeadsUpManagerLogger, mBgHandler)
        mAvalancheController =
            AvalancheController(dumpManager, mUiEventLogger, mHeadsUpManagerLogger, mBgHandler)
    }

    @Test
@@ -200,7 +200,12 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager
        hmp.addSwipedOutNotification(entry.key)

        // Remove should succeed because the notification is swiped out
        val removedImmediately = hmp.removeNotification(entry.key, /* releaseImmediately= */ false)
        val removedImmediately =
            hmp.removeNotification(
                entry.key,
                /* releaseImmediately= */ false,
                /* reason= */ "swipe out"
            )
        Assert.assertTrue(removedImmediately)
        Assert.assertFalse(hmp.isHeadsUpEntry(entry.key))
    }
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ class TestableHeadsUpManager extends BaseHeadsUpManager {

    @Override
    public boolean removeNotification(@NonNull String key, boolean releaseImmediately,
            boolean animate) {
            boolean animate, @NonNull String reason) {
        throw new UnsupportedOperationException();
    }

+12 −6
Original line number Diff line number Diff line
@@ -142,14 +142,15 @@ class NotificationTransitionAnimatorController(
    }

    override fun onIntentStarted(willAnimate: Boolean) {
        val reason = "onIntentStarted(willAnimate=$willAnimate)"
        if (ActivityTransitionAnimator.DEBUG_TRANSITION_ANIMATION) {
            Log.d(TAG, "onIntentStarted(willAnimate=$willAnimate)")
            Log.d(TAG, reason)
        }
        notificationLaunchAnimationInteractor.setIsLaunchAnimationRunning(willAnimate)
        notificationEntry.isExpandAnimationRunning = willAnimate

        if (!willAnimate) {
            removeHun(animate = true)
            removeHun(animate = true, reason)
            onFinishAnimationCallback?.run()
        }
    }
@@ -166,13 +167,18 @@ class NotificationTransitionAnimatorController(
            }
        }

    private fun removeHun(animate: Boolean) {
    private fun removeHun(animate: Boolean, reason: String) {
        val row = headsUpNotificationRow ?: return

        // TODO: b/297247841 - Call on the row we're removing, which may differ from notification.
        HeadsUpUtil.setNeedsHeadsUpDisappearAnimationAfterClick(notification, animate)

        headsUpManager.removeNotification(row.entry.key, true /* releaseImmediately */, animate)
        headsUpManager.removeNotification(
            row.entry.key,
            true /* releaseImmediately */,
            animate,
            reason
        )
    }

    override fun onTransitionAnimationCancelled(newKeyguardOccludedState: Boolean?) {
@@ -184,7 +190,7 @@ class NotificationTransitionAnimatorController(
        // here?
        notificationLaunchAnimationInteractor.setIsLaunchAnimationRunning(false)
        notificationEntry.isExpandAnimationRunning = false
        removeHun(animate = true)
        removeHun(animate = true, "onLaunchAnimationCancelled()")
        onFinishAnimationCallback?.run()
    }

@@ -206,7 +212,7 @@ class NotificationTransitionAnimatorController(
        notificationEntry.isExpandAnimationRunning = false
        notificationListContainer.setExpandingNotification(null)
        applyParams(null)
        removeHun(animate = false)
        removeHun(animate = false, "onLaunchAnimationEnd()")
        onFinishAnimationCallback?.run()
    }

+17 −5
Original line number Diff line number Diff line
@@ -496,7 +496,11 @@ constructor(
                if (posted?.shouldHeadsUpEver == false) {
                    if (posted.isHeadsUpEntry) {
                        // We don't want this to be interrupting anymore, let's remove it
                        mHeadsUpManager.removeNotification(posted.key, false /*removeImmediately*/)
                        mHeadsUpManager.removeNotification(
                            posted.key,
                            /* removeImmediately= */ false,
                            "onEntryUpdated"
                        )
                    } else if (posted.isBinding) {
                        // Don't let the bind finish
                        cancelHeadsUpBind(posted.entry)
@@ -520,7 +524,11 @@ constructor(
                    val removeImmediatelyForRemoteInput =
                        (mRemoteInputManager.isSpinning(entryKey) &&
                            !NotificationRemoteInputManager.FORCE_REMOTE_INPUT_HISTORY)
                    mHeadsUpManager.removeNotification(entry.key, removeImmediatelyForRemoteInput)
                    mHeadsUpManager.removeNotification(
                        entry.key,
                        removeImmediatelyForRemoteInput,
                        "onEntryRemoved, reason: $reason"
                    )
                }
            }

@@ -721,7 +729,9 @@ constructor(
                            {
                                mHeadsUpManager.removeNotification(
                                    entry.key, /* releaseImmediately */
                                    true
                                    true,
                                    "cancel lifetime extension - extended for reason: " +
                                        "$reason, isSticky: true"
                                )
                            },
                            removeAfterMillis
@@ -730,7 +740,9 @@ constructor(
                    mExecutor.execute {
                        mHeadsUpManager.removeNotification(
                            entry.key, /* releaseImmediately */
                            false
                            false,
                            "lifetime extension - extended for reason: $reason" +
                                ", isSticky: false"
                        )
                    }
                    mNotifsExtendingLifetime[entry] = null
@@ -902,7 +914,7 @@ private class HunMutatorImpl(private val headsUpManager: HeadsUpManager) : HunMu

    fun commitModifications() {
        deferred.forEach { (key, releaseImmediately) ->
            headsUpManager.removeNotification(key, releaseImmediately)
            headsUpManager.removeNotification(key, releaseImmediately, "commitModifications")
        }
        deferred.clear()
    }
Loading