summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java27
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/Pluggable.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilder.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewManager.kt19
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/TraceUtils.kt32
8 files changed, 84 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
index dfdc548ea35e..b36b7c903d88 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
@@ -48,6 +48,7 @@ import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.Notification;
import android.os.RemoteException;
+import android.os.Trace;
import android.os.UserHandle;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.Ranking;
@@ -512,6 +513,7 @@ public class NotifCollection implements Dumpable {
}
private void dispatchEventsAndRebuildList() {
+ Trace.beginSection("NotifCollection.dispatchEventsAndRebuildList");
mAmDispatchingToOtherCode = true;
while (!mEventQueue.isEmpty()) {
mEventQueue.remove().dispatchTo(mNotifCollectionListeners);
@@ -521,6 +523,7 @@ public class NotifCollection implements Dumpable {
if (mBuildListener != null) {
mBuildListener.onBuildList(mReadOnlyNotificationSet);
}
+ Trace.endSection();
}
private void onEndLifetimeExtension(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java
index 9faec7bac40f..6d38389713a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java
@@ -30,6 +30,7 @@ import static com.android.systemui.statusbar.notification.collection.listbuilder
import android.annotation.MainThread;
import android.annotation.Nullable;
+import android.os.Trace;
import android.util.ArrayMap;
import androidx.annotation.NonNull;
@@ -332,6 +333,7 @@ public class ShadeListBuilder implements Dumpable {
* if we detect that behavior, we should crash instantly.
*/
private void buildList() {
+ Trace.beginSection("ShadeListBuilder.buildList");
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
mPipelineState.setState(STATE_BUILD_STARTED);
@@ -385,9 +387,11 @@ public class ShadeListBuilder implements Dumpable {
// Step 8: Dispatch the new list, first to any listeners and then to the view layer
dispatchOnBeforeRenderList(mReadOnlyNotifList);
+ Trace.beginSection("ShadeListBuilder.onRenderList");
if (mOnRenderListListener != null) {
mOnRenderListListener.onRenderList(mReadOnlyNotifList);
}
+ Trace.endSection();
// Step 9: We're done!
mLogger.logEndBuildList(
@@ -399,9 +403,11 @@ public class ShadeListBuilder implements Dumpable {
}
mPipelineState.setState(STATE_IDLE);
mIterationCount++;
+ Trace.endSection();
}
private void notifySectionEntriesUpdated() {
+ Trace.beginSection("ShadeListBuilder.notifySectionEntriesUpdated");
NotifSection currentSection = null;
mTempSectionMembers.clear();
for (int i = 0; i < mNotifList.size(); i++) {
@@ -415,6 +421,7 @@ public class ShadeListBuilder implements Dumpable {
}
mTempSectionMembers.add(currentEntry);
}
+ Trace.endSection();
}
/**
@@ -456,6 +463,7 @@ public class ShadeListBuilder implements Dumpable {
Collection<? extends ListEntry> entries,
List<ListEntry> out,
List<NotifFilter> filters) {
+ Trace.beginSection("ShadeListBuilder.filterNotifs");
final long now = mSystemClock.uptimeMillis();
for (ListEntry entry : entries) {
if (entry instanceof GroupEntry) {
@@ -487,9 +495,11 @@ public class ShadeListBuilder implements Dumpable {
}
}
}
+ Trace.endSection();
}
private void groupNotifs(List<ListEntry> entries, List<ListEntry> out) {
+ Trace.beginSection("ShadeListBuilder.groupNotifs");
for (ListEntry listEntry : entries) {
// since grouping hasn't happened yet, all notifs are NotificationEntries
NotificationEntry entry = (NotificationEntry) listEntry;
@@ -545,12 +555,14 @@ public class ShadeListBuilder implements Dumpable {
}
}
}
+ Trace.endSection();
}
private void stabilizeGroupingNotifs(List<ListEntry> topLevelList) {
if (mNotifStabilityManager == null) {
return;
}
+ Trace.beginSection("ShadeListBuilder.stabilizeGroupingNotifs");
for (int i = 0; i < topLevelList.size(); i++) {
final ListEntry tle = topLevelList.get(i);
@@ -576,6 +588,7 @@ public class ShadeListBuilder implements Dumpable {
}
}
}
+ Trace.endSection();
}
/**
@@ -608,6 +621,7 @@ public class ShadeListBuilder implements Dumpable {
}
private void promoteNotifs(List<ListEntry> list) {
+ Trace.beginSection("ShadeListBuilder.promoteNotifs");
for (int i = 0; i < list.size(); i++) {
final ListEntry tle = list.get(i);
@@ -626,9 +640,11 @@ public class ShadeListBuilder implements Dumpable {
});
}
}
+ Trace.endSection();
}
private void pruneIncompleteGroups(List<ListEntry> shadeList) {
+ Trace.beginSection("ShadeListBuilder.pruneIncompleteGroups");
for (int i = 0; i < shadeList.size(); i++) {
final ListEntry tle = shadeList.get(i);
@@ -683,6 +699,7 @@ public class ShadeListBuilder implements Dumpable {
}
}
}
+ Trace.endSection();
}
/**
@@ -749,6 +766,7 @@ public class ShadeListBuilder implements Dumpable {
}
private void sortListAndNotifySections() {
+ Trace.beginSection("ShadeListBuilder.sortListAndNotifySections");
// Assign sections to top-level elements and sort their children
for (ListEntry entry : mNotifList) {
NotifSection section = applySections(entry);
@@ -766,6 +784,7 @@ public class ShadeListBuilder implements Dumpable {
// notify sections since the list is sorted now
notifySectionEntriesUpdated();
+ Trace.endSection();
}
private void freeEmptyGroups() {
@@ -1016,27 +1035,35 @@ public class ShadeListBuilder implements Dumpable {
}
private void dispatchOnBeforeTransformGroups(List<ListEntry> entries) {
+ Trace.beginSection("ShadeListBuilder.dispatchOnBeforeTransformGroups");
for (int i = 0; i < mOnBeforeTransformGroupsListeners.size(); i++) {
mOnBeforeTransformGroupsListeners.get(i).onBeforeTransformGroups(entries);
}
+ Trace.endSection();
}
private void dispatchOnBeforeSort(List<ListEntry> entries) {
+ Trace.beginSection("ShadeListBuilder.dispatchOnBeforeSort");
for (int i = 0; i < mOnBeforeSortListeners.size(); i++) {
mOnBeforeSortListeners.get(i).onBeforeSort(entries);
}
+ Trace.endSection();
}
private void dispatchOnBeforeFinalizeFilter(List<ListEntry> entries) {
+ Trace.beginSection("ShadeListBuilder.dispatchOnBeforeFinalizeFilter");
for (int i = 0; i < mOnBeforeFinalizeFilterListeners.size(); i++) {
mOnBeforeFinalizeFilterListeners.get(i).onBeforeFinalizeFilter(entries);
}
+ Trace.endSection();
}
private void dispatchOnBeforeRenderList(List<ListEntry> entries) {
+ Trace.beginSection("ShadeListBuilder.dispatchOnBeforeRenderList");
for (int i = 0; i < mOnBeforeRenderListListeners.size(); i++) {
mOnBeforeRenderListListeners.get(i).onBeforeRenderList(entries);
}
+ Trace.endSection();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/Pluggable.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/Pluggable.java
index 8e4fb7523767..b981a9621526 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/Pluggable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/pluggable/Pluggable.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.collection.listbuilder.pluggable;
import android.annotation.Nullable;
+import android.os.Trace;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -50,7 +51,9 @@ public abstract class Pluggable<This> {
*/
public final void invalidateList() {
if (mListener != null) {
+ Trace.beginSection("Pluggable<" + mName + ">.invalidateList");
mListener.onPluggableInvalidated((This) this);
+ Trace.endSection();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilder.kt
index 9b8ac722d5c9..010b6f80121c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilder.kt
@@ -20,6 +20,7 @@ import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
+import com.android.systemui.util.traceSection
/**
* Converts a notif list (the output of the ShadeListBuilder) into a NodeSpec, an abstract
@@ -36,7 +37,7 @@ class NodeSpecBuilder(
fun buildNodeSpec(
rootController: NodeController,
notifList: List<ListEntry>
- ): NodeSpec {
+ ): NodeSpec = traceSection("NodeSpecBuilder.buildNodeSpec") {
val root = NodeSpecImpl(null, rootController)
var currentSection: NotifSection? = null
val prevSections = mutableSetOf<NotifSection?>()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt
index 7babbb40b6c1..6d4ae4b1a869 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewDiffer.kt
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.collection.render
import android.annotation.MainThread
import android.view.View
import com.android.systemui.util.kotlin.transform
+import com.android.systemui.util.traceSection
/**
* Given a "spec" that describes a "tree" of views, adds and removes views from the
@@ -47,7 +48,7 @@ class ShadeViewDiffer(
* provided [spec]. The root node of the spec must match the root controller passed to the
* differ's constructor.
*/
- fun applySpec(spec: NodeSpec) {
+ fun applySpec(spec: NodeSpec) = traceSection("ShadeViewDiffer.applySpec") {
val specMap = treeToMap(spec)
if (spec.controller != rootNode.controller) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewManager.kt
index 1db737d5d29e..b582a24f5a3e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/ShadeViewManager.kt
@@ -24,6 +24,7 @@ import com.android.systemui.statusbar.notification.collection.ShadeListBuilder
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.stack.NotificationListContainer
import com.android.systemui.statusbar.phone.NotificationIconAreaController
+import com.android.systemui.util.traceSection
import javax.inject.Inject
/**
@@ -47,16 +48,20 @@ class ShadeViewManager constructor(
listBuilder.setOnRenderListListener(::onNewNotifTree)
private fun onNewNotifTree(notifList: List<ListEntry>) {
- viewDiffer.applySpec(specBuilder.buildNodeSpec(rootController, notifList))
- updateGroupCounts(notifList)
- notificationIconAreaController.updateNotificationIcons(notifList)
+ traceSection("ShadeViewManager.onNewNotifTree") {
+ viewDiffer.applySpec(specBuilder.buildNodeSpec(rootController, notifList))
+ updateGroupCounts(notifList)
+ notificationIconAreaController.updateNotificationIcons(notifList)
+ }
}
private fun updateGroupCounts(notifList: List<ListEntry>) {
- notifList.asSequence().filterIsInstance<GroupEntry>().forEach { groupEntry ->
- val controller = viewBarn.requireView(checkNotNull(groupEntry.summary))
- val row = controller.view as ExpandableNotificationRow
- row.setUntruncatedChildCount(groupEntry.untruncatedChildCount)
+ traceSection("ShadeViewManager.updateGroupCounts") {
+ notifList.asSequence().filterIsInstance<GroupEntry>().forEach { groupEntry ->
+ val controller = viewBarn.requireView(checkNotNull(groupEntry.summary))
+ val row = controller.view as ExpandableNotificationRow
+ row.setUntruncatedChildCount(groupEntry.untruncatedChildCount)
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index 6516abd143ed..fbe59a2743b3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -6,6 +6,7 @@ import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
+import android.os.Trace;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
@@ -336,12 +337,14 @@ public class NotificationIconAreaController implements
}
private void updateNotificationIcons() {
+ Trace.beginSection("NotificationIconAreaController.updateNotificationIcons");
updateStatusBarIcons();
updateShelfIcons();
updateCenterIcon();
updateAodNotificationIcons();
applyNotificationIconsTint();
+ Trace.endSection();
}
private void updateShelfIcons() {
diff --git a/packages/SystemUI/src/com/android/systemui/util/TraceUtils.kt b/packages/SystemUI/src/com/android/systemui/util/TraceUtils.kt
new file mode 100644
index 000000000000..5b16ae999aa3
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/util/TraceUtils.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 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.util
+
+import android.os.Trace
+
+/**
+ * Run a block within a [Trace] section.
+ * Calls [Trace.beginSection] before and [Trace.endSection] after the passed block.
+ */
+inline fun <T> traceSection(tag: String, block: () -> T): T {
+ Trace.beginSection(tag)
+ try {
+ return block()
+ } finally {
+ Trace.endSection()
+ }
+} \ No newline at end of file