Merge changes I60fb07e4,Ie16987a8 into tm-qpr-dev

* changes:
  Only log NOTIF INFLATION ABORTED if we may have actually aborted something.
  Add the invalidation reason to existing log statements
This commit is contained in:
Jeff DeCew
2022-07-10 10:23:01 +00:00
committed by Android (Google) Code Review
25 changed files with 186 additions and 216 deletions

View File

@@ -75,8 +75,8 @@ public class NotifInflaterImpl implements NotifInflater {
} }
@Override @Override
public void abortInflation(NotificationEntry entry) { public boolean abortInflation(NotificationEntry entry) {
entry.abortTask(); return entry.abortTask();
} }
@Override @Override

View File

@@ -476,11 +476,13 @@ public final class NotificationEntry extends ListEntry {
/** /**
* Abort all existing inflation tasks * Abort all existing inflation tasks
*/ */
public void abortTask() { public boolean abortTask() {
if (mRunningTask != null) { if (mRunningTask != null) {
mRunningTask.abort(); mRunningTask.abort();
mRunningTask = null; mRunningTask = null;
return true;
} }
return false;
} }
public void setInflationTask(InflationTask abortableTask) { public void setInflationTask(InflationTask abortableTask) {

View File

@@ -314,60 +314,62 @@ public class ShadeListBuilder implements Dumpable {
} }
}; };
private void onPreRenderInvalidated(Invalidator invalidator) { private void onPreRenderInvalidated(Invalidator invalidator, @Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logPreRenderInvalidated(invalidator.getName(), mPipelineState.getState()); mLogger.logPreRenderInvalidated(invalidator, mPipelineState.getState(), reason);
rebuildListIfBefore(STATE_FINALIZING); rebuildListIfBefore(STATE_FINALIZING);
} }
private void onPreGroupFilterInvalidated(NotifFilter filter) { private void onPreGroupFilterInvalidated(NotifFilter filter, @Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logPreGroupFilterInvalidated(filter.getName(), mPipelineState.getState()); mLogger.logPreGroupFilterInvalidated(filter, mPipelineState.getState(), reason);
rebuildListIfBefore(STATE_PRE_GROUP_FILTERING); rebuildListIfBefore(STATE_PRE_GROUP_FILTERING);
} }
private void onReorderingAllowedInvalidated(NotifStabilityManager stabilityManager) { private void onReorderingAllowedInvalidated(NotifStabilityManager stabilityManager,
@Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logReorderingAllowedInvalidated( mLogger.logReorderingAllowedInvalidated(
stabilityManager.getName(), stabilityManager,
mPipelineState.getState()); mPipelineState.getState(),
reason);
rebuildListIfBefore(STATE_GROUPING); rebuildListIfBefore(STATE_GROUPING);
} }
private void onPromoterInvalidated(NotifPromoter promoter) { private void onPromoterInvalidated(NotifPromoter promoter, @Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logPromoterInvalidated(promoter.getName(), mPipelineState.getState()); mLogger.logPromoterInvalidated(promoter, mPipelineState.getState(), reason);
rebuildListIfBefore(STATE_TRANSFORMING); rebuildListIfBefore(STATE_TRANSFORMING);
} }
private void onNotifSectionInvalidated(NotifSectioner section) { private void onNotifSectionInvalidated(NotifSectioner section, @Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logNotifSectionInvalidated(section.getName(), mPipelineState.getState()); mLogger.logNotifSectionInvalidated(section, mPipelineState.getState(), reason);
rebuildListIfBefore(STATE_SORTING); rebuildListIfBefore(STATE_SORTING);
} }
private void onFinalizeFilterInvalidated(NotifFilter filter) { private void onFinalizeFilterInvalidated(NotifFilter filter, @Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logFinalizeFilterInvalidated(filter.getName(), mPipelineState.getState()); mLogger.logFinalizeFilterInvalidated(filter, mPipelineState.getState(), reason);
rebuildListIfBefore(STATE_FINALIZE_FILTERING); rebuildListIfBefore(STATE_FINALIZE_FILTERING);
} }
private void onNotifComparatorInvalidated(NotifComparator comparator) { private void onNotifComparatorInvalidated(NotifComparator comparator, @Nullable String reason) {
Assert.isMainThread(); Assert.isMainThread();
mLogger.logNotifComparatorInvalidated(comparator.getName(), mPipelineState.getState()); mLogger.logNotifComparatorInvalidated(comparator, mPipelineState.getState(), reason);
rebuildListIfBefore(STATE_SORTING); rebuildListIfBefore(STATE_SORTING);
} }

View File

@@ -142,7 +142,7 @@ public class BubbleCoordinator implements Coordinator {
@Override @Override
public void invalidateNotifications(String reason) { public void invalidateNotifications(String reason) {
mNotifFilter.invalidateList(); mNotifFilter.invalidateList(reason);
} }
@Override @Override

View File

@@ -30,11 +30,11 @@ class DebugModeCoordinator @Inject constructor(
) : Coordinator { ) : Coordinator {
override fun attach(pipeline: NotifPipeline) { override fun attach(pipeline: NotifPipeline) {
pipeline.addPreGroupFilter(preGroupFilter) pipeline.addPreGroupFilter(filter)
debugModeFilterProvider.registerInvalidationListener(preGroupFilter::invalidateList) debugModeFilterProvider.registerInvalidationListener { filter.invalidateList(null) }
} }
private val preGroupFilter = object : NotifFilter("DebugModeCoordinator") { private val filter = object : NotifFilter("DebugModeFilter") {
override fun shouldFilterOut(entry: NotificationEntry, now: Long) = override fun shouldFilterOut(entry: NotificationEntry, now: Long) =
debugModeFilterProvider.shouldFilterOut(entry) debugModeFilterProvider.shouldFilterOut(entry)
} }

View File

@@ -90,7 +90,7 @@ public class DeviceProvisionedCoordinator implements Coordinator {
new DeviceProvisionedController.DeviceProvisionedListener() { new DeviceProvisionedController.DeviceProvisionedListener() {
@Override @Override
public void onDeviceProvisionedChanged() { public void onDeviceProvisionedChanged() {
mNotifFilter.invalidateList(); mNotifFilter.invalidateList("onDeviceProvisionedChanged");
} }
}; };
} }

View File

@@ -35,6 +35,7 @@ import com.android.systemui.statusbar.notification.collection.render.NodeControl
import com.android.systemui.statusbar.notification.dagger.IncomingHeader import com.android.systemui.statusbar.notification.dagger.IncomingHeader
import com.android.systemui.statusbar.notification.interruption.HeadsUpViewBinder import com.android.systemui.statusbar.notification.interruption.HeadsUpViewBinder
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider
import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.statusbar.notification.stack.BUCKET_HEADS_UP import com.android.systemui.statusbar.notification.stack.BUCKET_HEADS_UP
import com.android.systemui.statusbar.policy.HeadsUpManager import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener
@@ -278,8 +279,8 @@ class HeadsUpCoordinator @Inject constructor(
.firstOrNull() .firstOrNull()
?.let { posted -> ?.let { posted ->
posted.entry.takeIf { entry -> posted.entry.takeIf { entry ->
locationLookupByKey(entry.key) == GroupLocation.Isolated locationLookupByKey(entry.key) == GroupLocation.Isolated &&
&& entry.sbn.notification.groupAlertBehavior == GROUP_ALERT_SUMMARY entry.sbn.notification.groupAlertBehavior == GROUP_ALERT_SUMMARY
} }
} }
@@ -512,7 +513,7 @@ class HeadsUpCoordinator @Inject constructor(
private val mOnHeadsUpChangedListener = object : OnHeadsUpChangedListener { private val mOnHeadsUpChangedListener = object : OnHeadsUpChangedListener {
override fun onHeadsUpStateChanged(entry: NotificationEntry, isHeadsUp: Boolean) { override fun onHeadsUpStateChanged(entry: NotificationEntry, isHeadsUp: Boolean) {
if (!isHeadsUp) { if (!isHeadsUp) {
mNotifPromoter.invalidateList() mNotifPromoter.invalidateList("headsUpEnded: ${entry.logKey}")
mHeadsUpViewBinder.unbindHeadsUpView(entry) mHeadsUpViewBinder.unbindHeadsUpView(entry)
endNotifLifetimeExtensionIfExtended(entry) endNotifLifetimeExtensionIfExtended(entry)
} }

View File

@@ -41,14 +41,11 @@ import javax.inject.Inject;
@CoordinatorScope @CoordinatorScope
public class HideNotifsForOtherUsersCoordinator implements Coordinator { public class HideNotifsForOtherUsersCoordinator implements Coordinator {
private final NotificationLockscreenUserManager mLockscreenUserManager; private final NotificationLockscreenUserManager mLockscreenUserManager;
private final SharedCoordinatorLogger mLogger;
@Inject @Inject
public HideNotifsForOtherUsersCoordinator( public HideNotifsForOtherUsersCoordinator(
NotificationLockscreenUserManager lockscreenUserManager, NotificationLockscreenUserManager lockscreenUserManager) {
SharedCoordinatorLogger logger) {
mLockscreenUserManager = lockscreenUserManager; mLockscreenUserManager = lockscreenUserManager;
mLogger = logger;
} }
@Override @Override
@@ -70,23 +67,19 @@ public class HideNotifsForOtherUsersCoordinator implements Coordinator {
// changes // changes
@Override @Override
public void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) { public void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) {
mLogger.logUserOrProfileChanged( StringBuilder sb = new StringBuilder("onCurrentProfilesChanged:");
mLockscreenUserManager.getCurrentUserId(), sb.append(" user=").append(mLockscreenUserManager.getCurrentUserId());
profileIdsToStr(currentProfiles)); sb.append(" profiles=");
mFilter.invalidateList(); sb.append("{");
for (int i = 0; i < currentProfiles.size(); i++) {
if (i != 0) {
sb.append(",");
}
sb.append(currentProfiles.keyAt(i));
}
sb.append("}");
mFilter.invalidateList(sb.toString());
} }
}; };
private String profileIdsToStr(SparseArray<UserInfo> currentProfiles) {
StringBuilder sb = new StringBuilder();
sb.append("{");
for (int i = 0; i < currentProfiles.size(); i++) {
sb.append(currentProfiles.keyAt(i));
if (i < currentProfiles.size() - 1) {
sb.append(",");
}
}
sb.append("}");
return sb.toString();
}
} }

View File

@@ -38,18 +38,15 @@ public class KeyguardCoordinator implements Coordinator {
private static final String TAG = "KeyguardCoordinator"; private static final String TAG = "KeyguardCoordinator";
private final KeyguardNotificationVisibilityProvider mKeyguardNotificationVisibilityProvider; private final KeyguardNotificationVisibilityProvider mKeyguardNotificationVisibilityProvider;
private final SectionHeaderVisibilityProvider mSectionHeaderVisibilityProvider; private final SectionHeaderVisibilityProvider mSectionHeaderVisibilityProvider;
private final SharedCoordinatorLogger mLogger;
private final StatusBarStateController mStatusBarStateController; private final StatusBarStateController mStatusBarStateController;
@Inject @Inject
public KeyguardCoordinator( public KeyguardCoordinator(
KeyguardNotificationVisibilityProvider keyguardNotificationVisibilityProvider, KeyguardNotificationVisibilityProvider keyguardNotificationVisibilityProvider,
SectionHeaderVisibilityProvider sectionHeaderVisibilityProvider, SectionHeaderVisibilityProvider sectionHeaderVisibilityProvider,
SharedCoordinatorLogger logger,
StatusBarStateController statusBarStateController) { StatusBarStateController statusBarStateController) {
mKeyguardNotificationVisibilityProvider = keyguardNotificationVisibilityProvider; mKeyguardNotificationVisibilityProvider = keyguardNotificationVisibilityProvider;
mSectionHeaderVisibilityProvider = sectionHeaderVisibilityProvider; mSectionHeaderVisibilityProvider = sectionHeaderVisibilityProvider;
mLogger = logger;
mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController;
} }
@@ -78,9 +75,8 @@ public class KeyguardCoordinator implements Coordinator {
} }
private void invalidateListFromFilter(String reason) { private void invalidateListFromFilter(String reason) {
mLogger.logKeyguardCoordinatorInvalidated(reason);
updateSectionHeadersVisibility(); updateSectionHeadersVisibility();
mNotifFilter.invalidateList(); mNotifFilter.invalidateList(reason);
} }
private void updateSectionHeadersVisibility() { private void updateSectionHeadersVisibility() {

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.notification.collection.coordinator; package com.android.systemui.statusbar.notification.collection.coordinator;
import static com.android.systemui.statusbar.notification.NotificationUtils.logKey;
import static com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED; import static com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
@@ -147,7 +148,8 @@ public class PreparationCoordinator implements Coordinator {
@Override @Override
public void attach(NotifPipeline pipeline) { public void attach(NotifPipeline pipeline) {
mNotifErrorManager.addInflationErrorListener(mInflationErrorListener); mNotifErrorManager.addInflationErrorListener(mInflationErrorListener);
mAdjustmentProvider.addDirtyListener(mNotifInflatingFilter::invalidateList); mAdjustmentProvider.addDirtyListener(
() -> mNotifInflatingFilter.invalidateList("adjustmentProviderChanged"));
pipeline.addCollectionListener(mNotifCollectionListener); pipeline.addCollectionListener(mNotifCollectionListener);
// Inflate after grouping/sorting since that affects what views to inflate. // Inflate after grouping/sorting since that affects what views to inflate.
@@ -245,12 +247,13 @@ public class PreparationCoordinator implements Coordinator {
} catch (RemoteException ex) { } catch (RemoteException ex) {
// System server is dead, nothing to do about that // System server is dead, nothing to do about that
} }
mNotifInflationErrorFilter.invalidateList(); mNotifInflationErrorFilter.invalidateList("onNotifInflationError for " + logKey(entry));
} }
@Override @Override
public void onNotifInflationErrorCleared(NotificationEntry entry) { public void onNotifInflationErrorCleared(NotificationEntry entry) {
mNotifInflationErrorFilter.invalidateList(); mNotifInflationErrorFilter.invalidateList(
"onNotifInflationErrorCleared for " + logKey(entry));
} }
}; };
@@ -360,9 +363,11 @@ public class PreparationCoordinator implements Coordinator {
} }
private void abortInflation(NotificationEntry entry, String reason) { private void abortInflation(NotificationEntry entry, String reason) {
final boolean taskAborted = mNotifInflater.abortInflation(entry);
final boolean wasInflating = mInflatingNotifs.remove(entry);
if (taskAborted || wasInflating) {
mLogger.logInflationAborted(entry, reason); mLogger.logInflationAborted(entry, reason);
mNotifInflater.abortInflation(entry); }
mInflatingNotifs.remove(entry);
} }
private void onInflationFinished(NotificationEntry entry, NotifViewController controller) { private void onInflationFinished(NotificationEntry entry, NotifViewController controller) {
@@ -371,7 +376,7 @@ public class PreparationCoordinator implements Coordinator {
mViewBarn.registerViewForEntry(entry, controller); mViewBarn.registerViewForEntry(entry, controller);
mInflationStates.put(entry, STATE_INFLATED); mInflationStates.put(entry, STATE_INFLATED);
mBindEventManager.notifyViewBound(entry); mBindEventManager.notifyViewBound(entry);
mNotifInflatingFilter.invalidateList(); mNotifInflatingFilter.invalidateList("onInflationFinished for " + logKey(entry));
} }
private void freeNotifViews(NotificationEntry entry) { private void freeNotifViews(NotificationEntry entry) {

View File

@@ -199,7 +199,7 @@ public class RankingCoordinator implements Coordinator {
new StatusBarStateController.StateListener() { new StatusBarStateController.StateListener() {
@Override @Override
public void onDozingChanged(boolean isDozing) { public void onDozingChanged(boolean isDozing) {
mDndVisualEffectsFilter.invalidateList(); mDndVisualEffectsFilter.invalidateList("onDozingChanged to " + isDozing);
} }
}; };
} }

View File

@@ -64,7 +64,7 @@ private class SensitiveContentCoordinatorImpl @Inject constructor(
pipeline.addPreRenderInvalidator(this) pipeline.addPreRenderInvalidator(this)
} }
override fun onDynamicPrivacyChanged(): Unit = invalidateList() override fun onDynamicPrivacyChanged(): Unit = invalidateList("onDynamicPrivacyChanged")
override fun onBeforeRenderList(entries: List<ListEntry>) { override fun onBeforeRenderList(entries: List<ListEntry>) {
if (keyguardStateController.isKeyguardGoingAway() || if (keyguardStateController.isKeyguardGoingAway() ||

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.notification.collection.coordinator
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel
import com.android.systemui.log.dagger.NotificationLog
import javax.inject.Inject
/**
* Shared logging class for coordinators that don't log enough to merit their own logger.
*/
class SharedCoordinatorLogger @Inject constructor(
@NotificationLog private val buffer: LogBuffer
) {
fun logUserOrProfileChanged(userId: Int, profiles: String) {
buffer.log("NotCurrentUserFilter", LogLevel.INFO, {
int1 = userId
str1 = profiles
}, {
"Current user or profiles changed. Current user is $int1; profiles are $str1"
})
}
fun logKeyguardCoordinatorInvalidated(reason: String) {
buffer.log("KeyguardCoordinator", LogLevel.DEBUG, {
str1 = reason
}, {
"KeyguardCoordinator invalidated: $str1"
})
}
}

View File

@@ -30,6 +30,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.time.SystemClock import com.android.systemui.util.time.SystemClock
import java.util.concurrent.TimeUnit.SECONDS import java.util.concurrent.TimeUnit.SECONDS
@@ -130,7 +131,7 @@ class SmartspaceDedupingCoordinator @Inject constructor(
} }
if (changed) { if (changed) {
filter.invalidateList() filter.invalidateList("onNewSmartspaceTargets")
notificationEntryManager.updateNotifications("Smartspace targets changed") notificationEntryManager.updateNotifications("Smartspace targets changed")
} }
@@ -167,7 +168,7 @@ class SmartspaceDedupingCoordinator @Inject constructor(
target.cancelTimeoutRunnable = executor.executeDelayed({ target.cancelTimeoutRunnable = executor.executeDelayed({
target.cancelTimeoutRunnable = null target.cancelTimeoutRunnable = null
target.shouldFilter = true target.shouldFilter = true
filter.invalidateList() filter.invalidateList("updateAlertException: ${entry.logKey}")
notificationEntryManager.updateNotifications("deduping timeout expired") notificationEntryManager.updateNotifications("deduping timeout expired")
}, alertExceptionExpires - now) }, alertExceptionExpires - now)
} }
@@ -184,7 +185,7 @@ class SmartspaceDedupingCoordinator @Inject constructor(
isOnLockscreen = newState == StatusBarState.KEYGUARD isOnLockscreen = newState == StatusBarState.KEYGUARD
if (isOnLockscreen != wasOnLockscreen) { if (isOnLockscreen != wasOnLockscreen) {
filter.invalidateList() filter.invalidateList("recordStatusBarState: " + StatusBarState.toString(newState))
// No need to call notificationEntryManager.updateNotifications; something else already // No need to call notificationEntryManager.updateNotifications; something else already
// does it for us when the keyguard state changes // does it for us when the keyguard state changes
} }

View File

@@ -192,11 +192,16 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable,
+ " reorderingAllowed " + wasReorderingAllowed + "->" + mReorderingAllowed + " reorderingAllowed " + wasReorderingAllowed + "->" + mReorderingAllowed
+ " when setting " + field + "=" + value); + " when setting " + field + "=" + value);
} }
if ((mPipelineRunAllowed && mIsSuppressingPipelineRun) if (mPipelineRunAllowed && mIsSuppressingPipelineRun) {
|| (mReorderingAllowed && (mIsSuppressingGroupChange mNotifStabilityManager.invalidateList("pipeline run suppression ended");
} else if (mReorderingAllowed && (mIsSuppressingGroupChange
|| isSuppressingSectionChange() || isSuppressingSectionChange()
|| mIsSuppressingEntryReorder))) { || mIsSuppressingEntryReorder)) {
mNotifStabilityManager.invalidateList(); String reason = "reorder suppression ended for"
+ " group=" + mIsSuppressingGroupChange
+ " section=" + isSuppressingSectionChange()
+ " sort=" + mIsSuppressingEntryReorder;
mNotifStabilityManager.invalidateList(reason);
} }
mVisualStabilityProvider.setReorderingAllowed(mReorderingAllowed); mVisualStabilityProvider.setReorderingAllowed(mReorderingAllowed);
} }
@@ -241,7 +246,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable,
now + ALLOW_SECTION_CHANGE_TIMEOUT)); now + ALLOW_SECTION_CHANGE_TIMEOUT));
if (!wasSectionChangeAllowed) { if (!wasSectionChangeAllowed) {
mNotifStabilityManager.invalidateList(); mNotifStabilityManager.invalidateList("temporarilyAllowSectionChanges");
} }
} }

View File

@@ -42,9 +42,9 @@ interface NotifInflater {
/** /**
* Request to stop the inflation of an entry. For example, called when a notification is * Request to stop the inflation of an entry. For example, called when a notification is
* removed and no longer needs to be inflated. * removed and no longer needs to be inflated. Returns whether anything may have been aborted.
*/ */
fun abortInflation(entry: NotificationEntry) fun abortInflation(entry: NotificationEntry): Boolean
/** /**
* Called to let the system remove the content views from the notification row. * Called to let the system remove the content views from the notification row.

View File

@@ -25,8 +25,15 @@ import com.android.systemui.statusbar.notification.NotifPipelineFlags
import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.ListEntry import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.StateName
import com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.getStateName
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Invalidator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable
import com.android.systemui.statusbar.notification.logKey import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.util.Compile import com.android.systemui.util.Compile
import javax.inject.Inject import javax.inject.Inject
@@ -60,68 +67,63 @@ class ShadeListBuilderLogger @Inject constructor(
}) })
} }
fun logPreRenderInvalidated(filterName: String, pipelineState: Int) { private fun logPluggableInvalidated(
type: String,
pluggable: Pluggable<*>,
@StateName pipelineState: Int,
reason: String?
) {
buffer.log(TAG, DEBUG, { buffer.log(TAG, DEBUG, {
str1 = filterName str1 = type
str2 = pluggable.name
int1 = pipelineState int1 = pipelineState
str3 = reason
}, { }, {
"""Pre-render Invalidator "$str1" invalidated; pipeline state is $int1""" """Invalidated while ${getStateName(int1)} by $str1 "$str2" because $str3"""
}) })
} }
fun logPreGroupFilterInvalidated(filterName: String, pipelineState: Int) { fun logPreRenderInvalidated(
buffer.log(TAG, DEBUG, { invalidator: Invalidator,
str1 = filterName @StateName pipelineState: Int,
int1 = pipelineState reason: String?
}, { ) = logPluggableInvalidated("Pre-render Invalidator", invalidator, pipelineState, reason)
"""Pre-group NotifFilter "$str1" invalidated; pipeline state is $int1"""
})
}
fun logReorderingAllowedInvalidated(name: String, pipelineState: Int) { fun logPreGroupFilterInvalidated(
buffer.log(TAG, DEBUG, { filter: NotifFilter,
str1 = name @StateName pipelineState: Int,
int1 = pipelineState reason: String?
}, { ) = logPluggableInvalidated("Pre-group NotifFilter", filter, pipelineState, reason)
"""ReorderingNowAllowed "$str1" invalidated; pipeline state is $int1"""
})
}
fun logPromoterInvalidated(name: String, pipelineState: Int) { fun logReorderingAllowedInvalidated(
buffer.log(TAG, DEBUG, { stabilityManager: NotifStabilityManager,
str1 = name @StateName pipelineState: Int,
int1 = pipelineState reason: String?
}, { ) = logPluggableInvalidated("ReorderingNowAllowed", stabilityManager, pipelineState, reason)
"""NotifPromoter "$str1" invalidated; pipeline state is $int1"""
})
}
fun logNotifSectionInvalidated(name: String, pipelineState: Int) { fun logPromoterInvalidated(
buffer.log(TAG, DEBUG, { promoter: NotifPromoter,
str1 = name @StateName pipelineState: Int,
int1 = pipelineState reason: String?
}, { ) = logPluggableInvalidated("NotifPromoter", promoter, pipelineState, reason)
"""NotifSection "$str1" invalidated; pipeline state is $int1"""
})
}
fun logNotifComparatorInvalidated(name: String, pipelineState: Int) { fun logNotifSectionInvalidated(
buffer.log(TAG, DEBUG, { sectioner: NotifSectioner,
str1 = name @StateName pipelineState: Int,
int1 = pipelineState reason: String?
}, { ) = logPluggableInvalidated("NotifSection", sectioner, pipelineState, reason)
"""NotifComparator "$str1" invalidated; pipeline state is $int1"""
})
}
fun logFinalizeFilterInvalidated(name: String, pipelineState: Int) { fun logNotifComparatorInvalidated(
buffer.log(TAG, DEBUG, { comparator: NotifComparator,
str1 = name @StateName pipelineState: Int,
int1 = pipelineState reason: String?
}, { ) = logPluggableInvalidated("NotifComparator", comparator, pipelineState, reason)
"""Finalize NotifFilter "$str1" invalidated; pipeline state is $int1"""
}) fun logFinalizeFilterInvalidated(
} filter: NotifFilter,
@StateName pipelineState: Int,
reason: String?
) = logPluggableInvalidated("Finalize NotifFilter", filter, pipelineState, reason)
fun logDuplicateSummary( fun logDuplicateSummary(
buildId: Int, buildId: Int,

View File

@@ -49,10 +49,10 @@ public abstract class Pluggable<This> {
* Call this method when something has caused this pluggable's behavior to change. The pipeline * Call this method when something has caused this pluggable's behavior to change. The pipeline
* will be re-run. * will be re-run.
*/ */
public final void invalidateList() { public final void invalidateList(@Nullable String reason) {
if (mListener != null) { if (mListener != null) {
Trace.beginSection("Pluggable<" + mName + ">.invalidateList"); Trace.beginSection("Pluggable<" + mName + ">.invalidateList");
mListener.onPluggableInvalidated((This) this); mListener.onPluggableInvalidated((This) this, reason);
Trace.endSection(); Trace.endSection();
} }
} }
@@ -74,7 +74,7 @@ public abstract class Pluggable<This> {
* @param <T> The type of pluggable that is being listened to. * @param <T> The type of pluggable that is being listened to.
*/ */
public interface PluggableListener<T> { public interface PluggableListener<T> {
/** Called whenever {@link #invalidateList()} is called on this pluggable. */ /** Called whenever {@link #invalidateList(String)} is called on this pluggable. */
void onPluggableInvalidated(T pluggable); void onPluggableInvalidated(T pluggable, @Nullable String reason);
} }
} }

View File

@@ -1028,37 +1028,37 @@ public class ShadeListBuilderTest extends SysuiTestCase {
// WHEN each pluggable is invalidated THEN the list is re-rendered // WHEN each pluggable is invalidated THEN the list is re-rendered
clearInvocations(mOnRenderListListener); clearInvocations(mOnRenderListListener);
packageFilter.invalidateList(); packageFilter.invalidateList(null);
assertTrue(mPipelineChoreographer.isScheduled()); assertTrue(mPipelineChoreographer.isScheduled());
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
verify(mOnRenderListListener).onRenderList(anyList()); verify(mOnRenderListListener).onRenderList(anyList());
clearInvocations(mOnRenderListListener); clearInvocations(mOnRenderListListener);
idPromoter.invalidateList(); idPromoter.invalidateList(null);
assertTrue(mPipelineChoreographer.isScheduled()); assertTrue(mPipelineChoreographer.isScheduled());
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
verify(mOnRenderListListener).onRenderList(anyList()); verify(mOnRenderListListener).onRenderList(anyList());
clearInvocations(mOnRenderListListener); clearInvocations(mOnRenderListListener);
section.invalidateList(); section.invalidateList(null);
assertTrue(mPipelineChoreographer.isScheduled()); assertTrue(mPipelineChoreographer.isScheduled());
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
verify(mOnRenderListListener).onRenderList(anyList()); verify(mOnRenderListListener).onRenderList(anyList());
clearInvocations(mOnRenderListListener); clearInvocations(mOnRenderListListener);
hypeComparator.invalidateList(); hypeComparator.invalidateList(null);
assertTrue(mPipelineChoreographer.isScheduled()); assertTrue(mPipelineChoreographer.isScheduled());
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
verify(mOnRenderListListener).onRenderList(anyList()); verify(mOnRenderListListener).onRenderList(anyList());
clearInvocations(mOnRenderListListener); clearInvocations(mOnRenderListListener);
sectionComparator.invalidateList(); sectionComparator.invalidateList(null);
assertTrue(mPipelineChoreographer.isScheduled()); assertTrue(mPipelineChoreographer.isScheduled());
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
verify(mOnRenderListListener).onRenderList(anyList()); verify(mOnRenderListListener).onRenderList(anyList());
clearInvocations(mOnRenderListListener); clearInvocations(mOnRenderListListener);
preRenderInvalidator.invalidateList(); preRenderInvalidator.invalidateList(null);
assertTrue(mPipelineChoreographer.isScheduled()); assertTrue(mPipelineChoreographer.isScheduled());
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
verify(mOnRenderListListener).onRenderList(anyList()); verify(mOnRenderListListener).onRenderList(anyList());
@@ -1584,7 +1584,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
// WHEN visual stability manager allows group changes again // WHEN visual stability manager allows group changes again
mStabilityManager.setAllowGroupChanges(true); mStabilityManager.setAllowGroupChanges(true);
mStabilityManager.invalidateList(); mStabilityManager.invalidateList(null);
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
// THEN entries are grouped // THEN entries are grouped
@@ -1623,7 +1623,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
// WHEN section changes are allowed again // WHEN section changes are allowed again
mStabilityManager.setAllowSectionChanges(true); mStabilityManager.setAllowSectionChanges(true);
mStabilityManager.invalidateList(); mStabilityManager.invalidateList(null);
mPipelineChoreographer.runIfScheduled(); mPipelineChoreographer.runIfScheduled();
// THEN the section updates // THEN the section updates
@@ -1719,7 +1719,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
public void testOutOfOrderPreGroupFilterInvalidationThrows() { public void testOutOfOrderPreGroupFilterInvalidationThrows() {
// GIVEN a PreGroupNotifFilter that gets invalidated during the grouping stage // GIVEN a PreGroupNotifFilter that gets invalidated during the grouping stage
NotifFilter filter = new PackageFilter(PACKAGE_5); NotifFilter filter = new PackageFilter(PACKAGE_5);
OnBeforeTransformGroupsListener listener = (list) -> filter.invalidateList(); OnBeforeTransformGroupsListener listener = (list) -> filter.invalidateList(null);
mListBuilder.addPreGroupFilter(filter); mListBuilder.addPreGroupFilter(filter);
mListBuilder.addOnBeforeTransformGroupsListener(listener); mListBuilder.addOnBeforeTransformGroupsListener(listener);
@@ -1735,7 +1735,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
// GIVEN a NotifPromoter that gets invalidated during the sorting stage // GIVEN a NotifPromoter that gets invalidated during the sorting stage
NotifPromoter promoter = new IdPromoter(47); NotifPromoter promoter = new IdPromoter(47);
OnBeforeSortListener listener = OnBeforeSortListener listener =
(list) -> promoter.invalidateList(); (list) -> promoter.invalidateList(null);
mListBuilder.addPromoter(promoter); mListBuilder.addPromoter(promoter);
mListBuilder.addOnBeforeSortListener(listener); mListBuilder.addOnBeforeSortListener(listener);
@@ -1751,7 +1751,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
// GIVEN a NotifComparator that gets invalidated during the finalizing stage // GIVEN a NotifComparator that gets invalidated during the finalizing stage
NotifComparator comparator = new HypeComparator(PACKAGE_5); NotifComparator comparator = new HypeComparator(PACKAGE_5);
OnBeforeRenderListListener listener = OnBeforeRenderListListener listener =
(list) -> comparator.invalidateList(); (list) -> comparator.invalidateList(null);
mListBuilder.setComparators(singletonList(comparator)); mListBuilder.setComparators(singletonList(comparator));
mListBuilder.addOnBeforeRenderListListener(listener); mListBuilder.addOnBeforeRenderListListener(listener);
@@ -1766,7 +1766,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
public void testOutOfOrderPreRenderFilterInvalidationThrows() { public void testOutOfOrderPreRenderFilterInvalidationThrows() {
// GIVEN a PreRenderNotifFilter that gets invalidated during the finalizing stage // GIVEN a PreRenderNotifFilter that gets invalidated during the finalizing stage
NotifFilter filter = new PackageFilter(PACKAGE_5); NotifFilter filter = new PackageFilter(PACKAGE_5);
OnBeforeRenderListListener listener = (list) -> filter.invalidateList(); OnBeforeRenderListListener listener = (list) -> filter.invalidateList(null);
mListBuilder.addFinalizeFilter(filter); mListBuilder.addFinalizeFilter(filter);
mListBuilder.addOnBeforeRenderListListener(listener); mListBuilder.addOnBeforeRenderListListener(listener);
@@ -1903,7 +1903,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
public void testInOrderPreRenderFilter() { public void testInOrderPreRenderFilter() {
// GIVEN a PreRenderFilter that gets invalidated during the grouping stage // GIVEN a PreRenderFilter that gets invalidated during the grouping stage
NotifFilter filter = new PackageFilter(PACKAGE_5); NotifFilter filter = new PackageFilter(PACKAGE_5);
OnBeforeTransformGroupsListener listener = (list) -> filter.invalidateList(); OnBeforeTransformGroupsListener listener = (list) -> filter.invalidateList(null);
mListBuilder.addFinalizeFilter(filter); mListBuilder.addFinalizeFilter(filter);
mListBuilder.addOnBeforeTransformGroupsListener(listener); mListBuilder.addOnBeforeTransformGroupsListener(listener);
@@ -1936,8 +1936,8 @@ public class ShadeListBuilderTest extends SysuiTestCase {
mListBuilder.addFinalizeFilter(filter2); mListBuilder.addFinalizeFilter(filter2);
// WHEN both filters invalidate // WHEN both filters invalidate
filter1.invalidateList(); filter1.invalidateList(null);
filter2.invalidateList(); filter2.invalidateList(null);
// THEN the pipeline choreographer is scheduled to evaluate, AND the pipeline hasn't // THEN the pipeline choreographer is scheduled to evaluate, AND the pipeline hasn't
// actually run. // actually run.

View File

@@ -18,7 +18,9 @@ package com.android.systemui.statusbar.notification.collection.coordinator;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -51,7 +53,6 @@ public class HideNotifsForOtherUsersCoordinatorTest extends SysuiTestCase {
@Mock private NotificationLockscreenUserManager mLockscreenUserManager; @Mock private NotificationLockscreenUserManager mLockscreenUserManager;
@Mock private NotifPipeline mNotifPipeline; @Mock private NotifPipeline mNotifPipeline;
@Mock private PluggableListener<NotifFilter> mInvalidationListener; @Mock private PluggableListener<NotifFilter> mInvalidationListener;
@Mock private SharedCoordinatorLogger mLogger;
@Captor private ArgumentCaptor<UserChangedListener> mUserChangedListenerCaptor; @Captor private ArgumentCaptor<UserChangedListener> mUserChangedListenerCaptor;
@Captor private ArgumentCaptor<NotifFilter> mNotifFilterCaptor; @Captor private ArgumentCaptor<NotifFilter> mNotifFilterCaptor;
@@ -66,7 +67,7 @@ public class HideNotifsForOtherUsersCoordinatorTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
HideNotifsForOtherUsersCoordinator coordinator = HideNotifsForOtherUsersCoordinator coordinator =
new HideNotifsForOtherUsersCoordinator(mLockscreenUserManager, mLogger); new HideNotifsForOtherUsersCoordinator(mLockscreenUserManager);
coordinator.attach(mNotifPipeline); coordinator.attach(mNotifPipeline);
verify(mLockscreenUserManager).addUserChangedListener(mUserChangedListenerCaptor.capture()); verify(mLockscreenUserManager).addUserChangedListener(mUserChangedListenerCaptor.capture());
@@ -102,6 +103,6 @@ public class HideNotifsForOtherUsersCoordinatorTest extends SysuiTestCase {
mCapturedUserChangeListener.onCurrentProfilesChanged(new SparseArray<>()); mCapturedUserChangeListener.onCurrentProfilesChanged(new SparseArray<>());
// THEN the filter is invalidated // THEN the filter is invalidated
verify(mInvalidationListener).onPluggableInvalidated(mCapturedNotifFilter); verify(mInvalidationListener).onPluggableInvalidated(eq(mCapturedNotifFilter), any());
} }
} }

View File

@@ -41,7 +41,6 @@ class KeyguardCoordinatorTest : SysuiTestCase() {
private val notifPipeline: NotifPipeline = mock() private val notifPipeline: NotifPipeline = mock()
private val keyguardNotifVisibilityProvider: KeyguardNotificationVisibilityProvider = mock() private val keyguardNotifVisibilityProvider: KeyguardNotificationVisibilityProvider = mock()
private val sectionHeaderVisibilityProvider: SectionHeaderVisibilityProvider = mock() private val sectionHeaderVisibilityProvider: SectionHeaderVisibilityProvider = mock()
private val sharedCoordinatorLogger: SharedCoordinatorLogger = mock()
private val statusBarStateController: StatusBarStateController = mock() private val statusBarStateController: StatusBarStateController = mock()
private lateinit var onStateChangeListener: Consumer<String> private lateinit var onStateChangeListener: Consumer<String>
@@ -52,7 +51,6 @@ class KeyguardCoordinatorTest : SysuiTestCase() {
val keyguardCoordinator = KeyguardCoordinator( val keyguardCoordinator = KeyguardCoordinator(
keyguardNotifVisibilityProvider, keyguardNotifVisibilityProvider,
sectionHeaderVisibilityProvider, sectionHeaderVisibilityProvider,
sharedCoordinatorLogger,
statusBarStateController statusBarStateController
) )
keyguardCoordinator.attach(notifPipeline) keyguardCoordinator.attach(notifPipeline)

View File

@@ -463,7 +463,8 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
} }
@Override @Override
public void abortInflation(@NonNull NotificationEntry entry) { public boolean abortInflation(@NonNull NotificationEntry entry) {
return false;
} }
public InflationCallback getInflateCallback(NotificationEntry entry) { public InflationCallback getInflateCallback(NotificationEntry entry) {

View File

@@ -34,6 +34,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable
import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.withArgCaptor import com.android.systemui.util.mockito.withArgCaptor
import dagger.BindsInstance import dagger.BindsInstance
@@ -79,7 +80,7 @@ class SensitiveContentCoordinatorTest : SysuiTestCase() {
dynamicPrivacyListener.onDynamicPrivacyChanged() dynamicPrivacyListener.onDynamicPrivacyChanged()
verify(invalidationListener).onPluggableInvalidated(invalidator) verify(invalidationListener).onPluggableInvalidated(eq(invalidator), any())
} }
@Test @Test

View File

@@ -35,21 +35,23 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.withArgCaptor import com.android.systemui.util.mockito.withArgCaptor
import com.android.systemui.util.time.FakeSystemClock import com.android.systemui.util.time.FakeSystemClock
import java.util.concurrent.TimeUnit
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.anyString import org.mockito.Mockito.anyString
import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.never import org.mockito.Mockito.never
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
import java.util.concurrent.TimeUnit
@SmallTest @SmallTest
class SmartspaceDedupingCoordinatorTest : SysuiTestCase() { class SmartspaceDedupingCoordinatorTest : SysuiTestCase() {
@@ -349,7 +351,7 @@ class SmartspaceDedupingCoordinatorTest : SysuiTestCase() {
// THEN the new pipeline is invalidated (but the old one isn't because it's not // THEN the new pipeline is invalidated (but the old one isn't because it's not
// necessary) because the notif should no longer be filtered out // necessary) because the notif should no longer be filtered out
verify(pluggableListener).onPluggableInvalidated(filter) verify(pluggableListener).onPluggableInvalidated(eq(filter), any())
verify(notificationEntryManager, never()).updateNotifications(anyString()) verify(notificationEntryManager, never()).updateNotifications(anyString())
assertFalse(filter.shouldFilterOut(entry2HasNotRecentlyAlerted, now)) assertFalse(filter.shouldFilterOut(entry2HasNotRecentlyAlerted, now))
} }
@@ -387,7 +389,7 @@ class SmartspaceDedupingCoordinatorTest : SysuiTestCase() {
} }
private fun verifyPipelinesInvalidated() { private fun verifyPipelinesInvalidated() {
verify(pluggableListener).onPluggableInvalidated(filter) verify(pluggableListener).onPluggableInvalidated(eq(filter), any())
verify(notificationEntryManager).updateNotifications(anyString()) verify(notificationEntryManager).updateNotifications(anyString())
} }
@@ -396,7 +398,7 @@ class SmartspaceDedupingCoordinatorTest : SysuiTestCase() {
} }
private fun verifyPipelinesNotInvalidated() { private fun verifyPipelinesNotInvalidated() {
verify(pluggableListener, never()).onPluggableInvalidated(filter) verify(pluggableListener, never()).onPluggableInvalidated(eq(filter), any())
verify(notificationEntryManager, never()).updateNotifications(anyString()) verify(notificationEntryManager, never()).updateNotifications(anyString())
} }

View File

@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator;
import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
@@ -55,6 +56,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.mockito.verification.VerificationMode;
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
@@ -130,7 +132,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
doAnswer(i -> { doAnswer(i -> {
mNotifStabilityManager.onBeginRun(); mNotifStabilityManager.onBeginRun();
return null; return null;
}).when(mInvalidateListener).onPluggableInvalidated(eq(mNotifStabilityManager)); }).when(mInvalidateListener).onPluggableInvalidated(eq(mNotifStabilityManager), any());
} }
@Test @Test
@@ -280,7 +282,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
mCoordinator.temporarilyAllowSectionChanges(mEntry, mFakeSystemClock.uptimeMillis()); mCoordinator.temporarilyAllowSectionChanges(mEntry, mFakeSystemClock.uptimeMillis());
// THEN the notification list is invalidated // THEN the notification list is invalidated
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
} }
@Test @Test
@@ -295,7 +297,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
mCoordinator.temporarilyAllowSectionChanges(mEntry, mFakeSystemClock.currentTimeMillis()); mCoordinator.temporarilyAllowSectionChanges(mEntry, mFakeSystemClock.currentTimeMillis());
// THEN invalidate is not called because this entry was never suppressed from reordering // THEN invalidate is not called because this entry was never suppressed from reordering
verify(mInvalidateListener, never()).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(never());
} }
@Test @Test
@@ -312,7 +314,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
// THEN invalidate is not called because this entry was never suppressed from reordering; // THEN invalidate is not called because this entry was never suppressed from reordering;
// THEN section changes are allowed for this notification // THEN section changes are allowed for this notification
verify(mInvalidateListener, never()).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(never());
assertTrue(mNotifStabilityManager.isSectionChangeAllowed(mEntry)); assertTrue(mNotifStabilityManager.isSectionChangeAllowed(mEntry));
// WHEN we're pulsing (now disallowing reordering) // WHEN we're pulsing (now disallowing reordering)
@@ -341,13 +343,13 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
// WHEN we temporarily allow section changes for this notification entry // WHEN we temporarily allow section changes for this notification entry
mCoordinator.temporarilyAllowSectionChanges(mEntry, mFakeSystemClock.currentTimeMillis()); mCoordinator.temporarilyAllowSectionChanges(mEntry, mFakeSystemClock.currentTimeMillis());
// can now reorder, so invalidates // can now reorder, so invalidates
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
// WHEN reordering is now allowed because device isn't pulsing anymore // WHEN reordering is now allowed because device isn't pulsing anymore
setPulsing(false); setPulsing(false);
// THEN invalidate isn't called a second time since reordering was already allowed // THEN invalidate isn't called a second time since reordering was already allowed
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
} }
@Test @Test
@@ -368,7 +370,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
// THEN we never see any calls to invalidate since there weren't any notifications that // THEN we never see any calls to invalidate since there weren't any notifications that
// were being suppressed from grouping or section changes // were being suppressed from grouping or section changes
verify(mInvalidateListener, never()).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(never());
} }
@Test @Test
@@ -386,7 +388,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setPanelExpanded(false); setPanelExpanded(false);
// invalidate is called because we were previously suppressing a group change // invalidate is called because we were previously suppressing a group change
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
} }
@Test @Test
@@ -400,7 +402,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setActivityLaunching(false); setActivityLaunching(false);
// invalidate is called, b/c we were previously suppressing the pipeline from running // invalidate is called, b/c we were previously suppressing the pipeline from running
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
} }
@Test @Test
@@ -414,7 +416,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setPanelCollapsing(false); setPanelCollapsing(false);
// invalidate is called, b/c we were previously suppressing the pipeline from running // invalidate is called, b/c we were previously suppressing the pipeline from running
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
} }
@Test @Test
@@ -426,7 +428,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setPanelCollapsing(false); setPanelCollapsing(false);
// THEN invalidate is not called, b/c nothing has been suppressed // THEN invalidate is not called, b/c nothing has been suppressed
verify(mInvalidateListener, never()).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(never());
} }
@Test @Test
@@ -438,7 +440,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setActivityLaunching(false); setActivityLaunching(false);
// THEN invalidate is not called, b/c nothing has been suppressed // THEN invalidate is not called, b/c nothing has been suppressed
verify(mInvalidateListener, never()).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(never());
} }
@Test @Test
@@ -457,7 +459,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setPanelExpanded(false); setPanelExpanded(false);
// invalidate is called because we were previously suppressing an entry reorder // invalidate is called because we were previously suppressing an entry reorder
verify(mInvalidateListener, times(1)).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(times(1));
} }
@Test @Test
@@ -474,7 +476,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
setPanelExpanded(false); setPanelExpanded(false);
// invalidate is not called because we were not told that an entry reorder was suppressed // invalidate is not called because we were not told that an entry reorder was suppressed
verify(mInvalidateListener, never()).onPluggableInvalidated(mNotifStabilityManager); verifyStabilityManagerWasInvalidated(never());
} }
@Test @Test
@@ -499,6 +501,10 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
assertFalse(mNotifStabilityManager.isGroupPruneAllowed(mGroupEntry)); assertFalse(mNotifStabilityManager.isGroupPruneAllowed(mGroupEntry));
} }
private void verifyStabilityManagerWasInvalidated(VerificationMode mode) {
verify(mInvalidateListener, mode).onPluggableInvalidated(eq(mNotifStabilityManager), any());
}
private void setActivityLaunching(boolean activityLaunching) { private void setActivityLaunching(boolean activityLaunching) {
mNotifPanelEventsCallback.onLaunchingActivityChanged(activityLaunching); mNotifPanelEventsCallback.onLaunchingActivityChanged(activityLaunching);
} }