Merge "Add debug logging to sections manager" into rvc-dev

This commit is contained in:
Steve Elliott
2020-05-12 17:27:36 +00:00
committed by Android (Google) Code Review
12 changed files with 206 additions and 23 deletions

View File

@@ -61,6 +61,18 @@ public class LogModule {
return buffer;
}
/** Provides a logging buffer for all logs related to managing notification sections. */
@Provides
@Singleton
@NotificationSectionLog
public static LogBuffer provideNotificationSectionLogBuffer(
LogcatEchoTracker bufferFilter,
DumpManager dumpManager) {
LogBuffer buffer = new LogBuffer("NotifSectionLog", 500, 10, bufferFilter);
buffer.attach(dumpManager);
return buffer;
}
/** Provides a logging buffer for all logs related to the data layer of notifications. */
@Provides
@Singleton

View File

@@ -0,0 +1,33 @@
/*
* 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.log.dagger;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.android.systemui.log.LogBuffer;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import javax.inject.Qualifier;
/** A {@link LogBuffer} for notification sections-related messages. */
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface NotificationSectionLog {
}

View File

@@ -52,7 +52,7 @@ public interface NotificationPresenter extends ExpandableNotificationRow.OnExpan
/**
* Updates the visual representation of the notifications.
*/
void updateNotificationViews();
void updateNotificationViews(String reason);
/**
* Returns the maximum number of notifications to show while locked.

View File

@@ -674,7 +674,7 @@ public class NotificationEntryManager implements
public void updateNotifications(String reason) {
reapplyFilterAndSort(reason);
if (mPresenter != null && !mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
mPresenter.updateNotificationViews();
mPresenter.updateNotificationViews(reason);
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.stack
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel
import com.android.systemui.log.dagger.NotificationSectionLog
import javax.inject.Inject
import javax.inject.Singleton
private const val TAG = "NotifSections"
@Singleton
class NotificationSectionsLogger @Inject constructor(
@NotificationSectionLog private val logBuffer: LogBuffer
) {
fun logStartSectionUpdate(reason: String) = logBuffer.log(
TAG,
LogLevel.DEBUG,
{ str1 = reason },
{ "Updating section boundaries: $reason" }
)
fun logStr(str: String) = logBuffer.log(
TAG,
LogLevel.DEBUG,
{ str1 = str },
{ str1 ?: "" }
)
fun logPosition(position: Int, label: String) = logBuffer.log(
TAG,
LogLevel.DEBUG,
{
int1 = position
str1 = label
},
{ "$int1: $str1" }
)
}

View File

@@ -79,14 +79,14 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
private final NotificationSectionsFeatureManager mSectionsFeatureManager;
private final KeyguardMediaController mKeyguardMediaController;
private final int mNumberOfSections;
private final NotificationSectionsLogger mLogger;
private final PeopleHubViewBoundary mPeopleHubViewBoundary = new PeopleHubViewBoundary() {
@Override
public void setVisible(boolean isVisible) {
if (mPeopleHubVisible != isVisible) {
mPeopleHubVisible = isVisible;
if (mInitialized) {
updateSectionBoundaries();
updateSectionBoundaries("PeopleHub visibility changed");
}
}
}
@@ -126,7 +126,9 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
ConfigurationController configurationController,
PeopleHubViewAdapter peopleHubViewAdapter,
KeyguardMediaController keyguardMediaController,
NotificationSectionsFeatureManager sectionsFeatureManager) {
NotificationSectionsFeatureManager sectionsFeatureManager,
NotificationSectionsLogger logger) {
mActivityStarter = activityStarter;
mStatusBarStateController = statusBarStateController;
mConfigurationController = configurationController;
@@ -134,6 +136,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
mSectionsFeatureManager = sectionsFeatureManager;
mNumberOfSections = mSectionsFeatureManager.getNumberOfBuckets();
mKeyguardMediaController = keyguardMediaController;
mLogger = logger;
}
NotificationSection[] createSectionsForBuckets() {
@@ -249,15 +252,70 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
return null;
}
private void logShadeContents() {
final int childCount = mParent.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mParent.getChildAt(i);
if (child == mIncomingHeader) {
mLogger.logPosition(i, "INCOMING HEADER");
continue;
}
if (child == mMediaControlsView) {
mLogger.logPosition(i, "MEDIA CONTROLS");
continue;
}
if (child == mPeopleHubView) {
mLogger.logPosition(i, "CONVERSATIONS HEADER");
continue;
}
if (child == mAlertingHeader) {
mLogger.logPosition(i, "ALERTING HEADER");
continue;
}
if (child == mGentleHeader) {
mLogger.logPosition(i, "SILENT HEADER");
continue;
}
if (!(child instanceof ExpandableNotificationRow)) {
mLogger.logPosition(i, "other:" + child.getClass().getName());
continue;
}
ExpandableNotificationRow row = (ExpandableNotificationRow) child;
// Once we enter a new section, calculate the target position for the header.
switch (row.getEntry().getBucket()) {
case BUCKET_HEADS_UP:
mLogger.logPosition(i, "Heads Up");
break;
case BUCKET_PEOPLE:
mLogger.logPosition(i, "Conversation");
break;
case BUCKET_ALERTING:
mLogger.logPosition(i, "Alerting");
break;
case BUCKET_SILENT:
mLogger.logPosition(i, "Silent");
break;
}
}
}
@VisibleForTesting
void updateSectionBoundaries() {
updateSectionBoundaries("test");
}
/**
* Should be called whenever notifs are added, removed, or updated. Updates section boundary
* bookkeeping and adds/moves/removes section headers if appropriate.
*/
void updateSectionBoundaries() {
void updateSectionBoundaries(String reason) {
if (!isUsingMultipleSections()) {
return;
}
mLogger.logStartSectionUpdate(reason);
// The overall strategy here is to iterate over the current children of mParent, looking
// for where the sections headers are currently positioned, and where each section begins.
// Then, once we find the start of a new section, we track that position as the "target" for
@@ -291,27 +349,33 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
// Track the existing positions of the headers
if (child == mIncomingHeader) {
mLogger.logPosition(i, "INCOMING HEADER");
currentIncomingHeaderIdx = i;
continue;
}
if (child == mMediaControlsView) {
mLogger.logPosition(i, "MEDIA CONTROLS");
currentMediaControlsIdx = i;
continue;
}
if (child == mPeopleHubView) {
mLogger.logPosition(i, "CONVERSATIONS HEADER");
currentPeopleHeaderIdx = i;
continue;
}
if (child == mAlertingHeader) {
mLogger.logPosition(i, "ALERTING HEADER");
currentAlertingHeaderIdx = i;
continue;
}
if (child == mGentleHeader) {
mLogger.logPosition(i, "SILENT HEADER");
currentGentleHeaderIdx = i;
continue;
}
if (!(child instanceof ExpandableNotificationRow)) {
mLogger.logPosition(i, "other");
continue;
}
lastNotifIndex = i;
@@ -319,6 +383,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
// Once we enter a new section, calculate the target position for the header.
switch (row.getEntry().getBucket()) {
case BUCKET_HEADS_UP:
mLogger.logPosition(i, "Heads Up");
if (showHeaders && incomingHeaderTarget == -1) {
incomingHeaderTarget = i;
// Offset the target if there are other headers before this that will be
@@ -344,6 +409,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
}
break;
case BUCKET_PEOPLE:
mLogger.logPosition(i, "Conversation");
peopleNotifsPresent = true;
if (showHeaders && peopleHeaderTarget == -1) {
peopleHeaderTarget = i;
@@ -361,6 +427,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
}
break;
case BUCKET_ALERTING:
mLogger.logPosition(i, "Alerting");
if (showHeaders && usingPeopleFiltering && alertingHeaderTarget == -1) {
alertingHeaderTarget = i;
// Offset the target if there are other headers before this that will be
@@ -374,6 +441,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
}
break;
case BUCKET_SILENT:
mLogger.logPosition(i, "Silent");
if (showHeaders && gentleHeaderTarget == -1) {
gentleHeaderTarget = i;
// Offset the target if there are other headers before this that will be
@@ -404,6 +472,14 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
}
}
mLogger.logStr("New header target positions:");
mLogger.logPosition(incomingHeaderTarget, "INCOMING HEADER");
mLogger.logPosition(mediaControlsTarget, "MEDIA CONTROLS");
mLogger.logPosition(peopleHeaderTarget, "CONVERSATIONS HEADER");
mLogger.logPosition(alertingHeaderTarget, "ALERTING HEADER");
mLogger.logPosition(gentleHeaderTarget, "SILENT HEADER");
// Add headers in reverse order to preserve indices
adjustHeaderVisibilityAndPosition(
gentleHeaderTarget, mGentleHeader, currentGentleHeaderIdx);
@@ -414,6 +490,13 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
adjustViewPosition(mediaControlsTarget, mMediaControlsView, currentMediaControlsIdx);
adjustViewPosition(incomingHeaderTarget, mIncomingHeader, currentIncomingHeaderIdx);
mLogger.logStr("Final order:");
logShadeContents();
mLogger.logStr("Section boundary update complete");
// Update headers to reflect state of section contents
mGentleHeader.setAreThereDismissableGentleNotifs(
mParent.hasActiveClearableNotifications(ROWS_GENTLE));
@@ -586,7 +669,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
void hidePeopleRow() {
mPeopleHubVisible = false;
updateSectionBoundaries();
updateSectionBoundaries("PeopleHub dismissed");
}
void setHeaderForegroundColor(@ColorInt int color) {

View File

@@ -29,7 +29,6 @@ import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEX
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.app.TaskStackBuilder;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeAnimator;
@@ -51,7 +50,6 @@ import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -5845,7 +5843,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
// Let's update the footer once the notifications have been updated (in the next frame)
post(() -> {
updateFooter();
updateSectionBoundaries();
updateSectionBoundaries("dynamic privacy changed");
});
}
@@ -5926,8 +5924,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
/** Updates the indices of the boundaries between sections. */
@ShadeViewRefactor(RefactorComponent.INPUT)
public void updateSectionBoundaries() {
mSectionsManager.updateSectionBoundaries();
public void updateSectionBoundaries(String reason) {
mSectionsManager.updateSectionBoundaries(reason);
}
private void updateContinuousBackgroundDrawing() {

View File

@@ -2884,8 +2884,8 @@ public class NotificationPanelViewController extends PanelViewController {
return mNotificationStackScroller.createDelegate();
}
public void updateNotificationViews() {
mNotificationStackScroller.updateSectionBoundaries();
void updateNotificationViews(String reason) {
mNotificationStackScroller.updateSectionBoundaries(reason);
mNotificationStackScroller.updateSpeedBumpIndex();
mNotificationStackScroller.updateFooter();
updateShowEmptyShadeView();

View File

@@ -296,20 +296,20 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
}
@Override
public void updateNotificationViews() {
public void updateNotificationViews(final String reason) {
// The function updateRowStates depends on both of these being non-null, so check them here.
// We may be called before they are set from DeviceProvisionedController's callback.
if (mScrimController == null) return;
// Do not modify the notifications during collapse.
if (isCollapsing()) {
mShadeController.addPostCollapseAction(this::updateNotificationViews);
mShadeController.addPostCollapseAction(() -> updateNotificationViews(reason));
return;
}
mViewHierarchyManager.updateNotificationViews();
mNotificationPanel.updateNotificationViews();
mNotificationPanel.updateNotificationViews(reason);
}
public void onNotificationRemoved(String key, StatusBarNotification old) {
@@ -347,7 +347,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
updateNotificationOnUiModeChanged();
mDispatchUiModeChangeOnUserSwitched = false;
}
updateNotificationViews();
updateNotificationViews("user switched");
mMediaManager.clearCurrentMediaNotification();
mStatusBar.setLockscreenUser(newUserId);
updateMediaMetaData(true, false);

View File

@@ -243,7 +243,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
// Ensure that update callbacks happen in correct order
InOrder order = inOrder(mEntryListener, mPresenter, mEntryListener);
order.verify(mEntryListener).onPreEntryUpdated(mEntry);
order.verify(mPresenter).updateNotificationViews();
order.verify(mPresenter).updateNotificationViews(any());
order.verify(mEntryListener).onPostEntryUpdated(mEntry);
}
@@ -254,7 +254,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
mEntryManager.removeNotification(mSbn.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON);
verify(mPresenter).updateNotificationViews();
verify(mPresenter).updateNotificationViews(any());
verify(mEntryListener).onEntryRemoved(
eq(mEntry), any(), eq(false) /* removedByUser */, eq(UNDEFINED_DISMISS_REASON));
verify(mRow).setRemoved();

View File

@@ -335,7 +335,7 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
assertNotNull(mEntryManager.getActiveNotificationUnfiltered(mSbn.getKey()));
// THEN we update the presenter
verify(mPresenter).updateNotificationViews();
verify(mPresenter).updateNotificationViews(any());
}
@Test
@@ -364,7 +364,7 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
verify(mEntryListener).onEntryReinflated(entry);
// THEN we update the presenter
verify(mPresenter).updateNotificationViews();
verify(mPresenter).updateNotificationViews(any());
}
@Test

View File

@@ -78,6 +78,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
@Mock private NotificationSectionsFeatureManager mSectionsFeatureManager;
@Mock private NotificationRowComponent mNotificationRowComponent;
@Mock private ActivatableNotificationViewController mActivatableNotificationViewController;
@Mock private NotificationSectionsLogger mLogger;
private NotificationSectionsManager mSectionsManager;
@@ -94,7 +95,8 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
mConfigurationController,
mPeopleHubAdapter,
mKeyguardMediaController,
mSectionsFeatureManager
mSectionsFeatureManager,
mLogger
);
// Required in order for the header inflation to work properly
when(mNssl.generateLayoutParams(any(AttributeSet.class)))