Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +12 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading Loading @@ -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) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/ExpansionStateLoggerTest.java +23 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +12 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading Loading @@ -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) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/ExpansionStateLoggerTest.java +23 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); Loading