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

Commit 5887049c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix expansion change is not reported if the notification is updated"

parents d6a69968 96b3f1bd
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.systemui.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -220,6 +219,11 @@ public class NotificationLogger implements StateListener {
                mExpansionStateLogger.onEntryRemoved(entry.key);
            }

            @Override
            public void onEntryReinflated(NotificationEntry entry) {
                mExpansionStateLogger.onEntryReinflated(entry.key);
            }

            @Override
            public void onInflationError(
                    StatusBarNotification notification,
@@ -468,6 +472,13 @@ public class NotificationLogger implements StateListener {
            mLoggedExpansionState.remove(key);
        }

        @VisibleForTesting
        void onEntryReinflated(String key) {
            // When the notification is updated, we should consider the notification as not
            // yet logged.
            mLoggedExpansionState.remove(key);
        }

        private State getState(String key) {
            State state = mExpansionStates.get(key);
            if (state == null) {
+23 −1
Original line number Diff line number Diff line
@@ -15,10 +15,10 @@
 */
package com.android.systemui.statusbar.notification.logging;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.os.RemoteException;
@@ -31,6 +31,7 @@ import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dependency;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;

import org.junit.Before;
import org.junit.Test;
@@ -155,6 +156,27 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
                NotificationVisibility.NotificationLocation.LOCATION_UNKNOWN.toMetricsEventEnum());
    }

    @Test
    public void testOnEntryReinflated() throws RemoteException {
        mLogger.onExpansionChanged(NOTIFICATION_KEY, true, true,
                NotificationVisibility.NotificationLocation.LOCATION_UNKNOWN);
        mLogger.onVisibilityChanged(
                Collections.singletonList(createNotificationVisibility(NOTIFICATION_KEY, true)),
                Collections.emptyList());
        waitForUiOffloadThread();
        verify(mBarService).onNotificationExpansionChanged(
                NOTIFICATION_KEY, true, true, ExpandableViewState.LOCATION_UNKNOWN);

        mLogger.onEntryReinflated(NOTIFICATION_KEY);
        mLogger.onVisibilityChanged(
                Collections.singletonList(createNotificationVisibility(NOTIFICATION_KEY, true)),
                Collections.emptyList());
        waitForUiOffloadThread();
        // onNotificationExpansionChanged is called the second time.
        verify(mBarService, times(2)).onNotificationExpansionChanged(
                NOTIFICATION_KEY, true, true, ExpandableViewState.LOCATION_UNKNOWN);
    }

    private NotificationVisibility createNotificationVisibility(String key, boolean visibility) {
        return createNotificationVisibility(key, visibility,
                NotificationVisibility.NotificationLocation.LOCATION_UNKNOWN);