summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-05-16 23:08:38 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-05-16 23:08:38 +0000
commitee1b4d021f7dc3f0d427e45c0e0815ad2475b51a (patch)
tree59f0d6ba0f64ef2e6d8ecbf68f6b9abc17c2c97b
parent8c88d0304106e8c3724aa3735456d0f77b7f1735 (diff)
parent8a7aa67dac6c75c058a509e9afb116b2a8e902ab (diff)
Merge "[Media] Add some tracing to media classes." into tm-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java24
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt14
6 files changed, 56 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt
index 8a104c42068e..0f8687183e94 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt
@@ -32,6 +32,7 @@ import com.android.systemui.util.animation.UniqueObjectHostView
import com.android.systemui.util.animation.requiresRemeasuring
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.time.SystemClock
+import com.android.systemui.util.traceSection
import java.io.PrintWriter
import java.util.TreeMap
import javax.inject.Inject
@@ -425,7 +426,7 @@ class MediaCarouselController @Inject constructor(
oldKey: String?,
data: MediaData,
isSsReactivated: Boolean
- ): Boolean {
+ ): Boolean = traceSection("MediaCarouselController#addOrUpdatePlayer") {
MediaPlayerData.moveIfExists(oldKey, key)
val existingPlayer = MediaPlayerData.getMediaPlayer(key)
val curVisibleMediaKey = MediaPlayerData.playerKeys()
@@ -471,7 +472,7 @@ class MediaCarouselController @Inject constructor(
key: String,
data: SmartspaceMediaData,
shouldPrioritize: Boolean
- ) {
+ ) = traceSection("MediaCarouselController#addSmartspaceMediaRecommendations") {
if (DEBUG) Log.d(TAG, "Updating smartspace target in carousel")
if (MediaPlayerData.getMediaPlayer(key) != null) {
Log.w(TAG, "Skip adding smartspace target in carousel")
@@ -698,7 +699,7 @@ class MediaCarouselController @Inject constructor(
animate: Boolean,
duration: Long = 200,
startDelay: Long = 0
- ) {
+ ) = traceSection("MediaCarouselController#onDesiredLocationChanged") {
desiredHostState?.let {
if (this.desiredLocation != desiredLocation) {
// Only log an event when location changes
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index 6ef25046d328..972e93b886b8 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -28,7 +28,6 @@ import android.app.WallpaperColors;
import android.app.smartspace.SmartspaceAction;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
@@ -45,6 +44,7 @@ import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.PlaybackState;
import android.os.Process;
+import android.os.Trace;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -397,6 +397,7 @@ public class MediaControlPanel {
if (mMediaViewHolder == null) {
return;
}
+ Trace.beginSection("MediaControlPanel#bindPlayer<" + key + ">");
mKey = key;
mMediaData = data;
MediaSession.Token token = data.getToken();
@@ -455,7 +456,7 @@ public class MediaControlPanel {
bindActionButtons(data);
boolean isSongUpdated = bindSongMetadata(data);
- bindArtworkAndColors(data, isSongUpdated);
+ bindArtworkAndColors(data, key, isSongUpdated);
// TODO: We don't need to refresh this state constantly, only if the state actually changed
// to something which might impact the measurement
@@ -463,6 +464,7 @@ public class MediaControlPanel {
if (!mMetadataAnimationHandler.isRunning()) {
mMediaViewController.refreshState();
}
+ Trace.endSection();
}
private void bindOutputSwitcherChip(MediaData data) {
@@ -607,7 +609,11 @@ public class MediaControlPanel {
mRecommendationViewHolder.getRecommendations().setContentDescription(contentDescription);
}
- private void bindArtworkAndColors(MediaData data, boolean updateBackground) {
+ private void bindArtworkAndColors(MediaData data, String key, boolean updateBackground) {
+ final int traceCookie = data.hashCode();
+ final String traceName = "MediaControlPanel#bindArtworkAndColors<" + key + ">";
+ Trace.beginAsyncSection(traceName, traceCookie);
+
final int reqId = mArtworkNextBindRequestId++;
if (updateBackground) {
mIsArtworkBound = false;
@@ -648,7 +654,10 @@ public class MediaControlPanel {
final ColorScheme colorScheme = mutableColorScheme;
mMainExecutor.execute(() -> {
// Cancel the request if a later one arrived first
- if (reqId < mArtworkBoundId) return;
+ if (reqId < mArtworkBoundId) {
+ Trace.endAsyncSection(traceName, traceCookie);
+ return;
+ }
mArtworkBoundId = reqId;
// Bind the album view to the artwork or a transition drawable
@@ -698,6 +707,7 @@ public class MediaControlPanel {
appIconView.setImageResource(R.drawable.ic_music_note);
}
}
+ Trace.endAsyncSection(traceName, traceCookie);
});
});
}
@@ -990,6 +1000,9 @@ public class MediaControlPanel {
return;
}
+ Trace.beginSection(
+ "MediaControlPanel#bindRecommendation<" + data.getPackageName() + ">");
+
mRecommendationData = data;
mSmartspaceId = SmallHash.hash(data.getTargetId());
mPackageName = data.getPackageName();
@@ -1003,12 +1016,14 @@ public class MediaControlPanel {
mUid = applicationInfo.uid;
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Fail to get media recommendation's app info", e);
+ Trace.endSection();
return;
}
CharSequence appName = data.getAppName(mContext);
if (appName == null) {
Log.w(TAG, "Fail to get media recommendation's app name");
+ Trace.endSection();
return;
}
@@ -1123,6 +1138,7 @@ public class MediaControlPanel {
if (mMetadataAnimationHandler == null || !mMetadataAnimationHandler.isRunning()) {
mMediaViewController.refreshState();
}
+ Trace.endSection();
}
private void fetchAndUpdateRecommendationColors(Drawable appIcon) {
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
index 0a4455658b6b..8bf2c6e92105 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
@@ -65,6 +65,7 @@ import com.android.systemui.util.Assert
import com.android.systemui.util.Utils
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.time.SystemClock
+import com.android.systemui.util.traceSection
import java.io.IOException
import java.io.PrintWriter
import java.util.concurrent.Executor
@@ -1031,7 +1032,11 @@ class MediaDataManager(
)
}
- fun onMediaDataLoaded(key: String, oldKey: String?, data: MediaData) {
+ fun onMediaDataLoaded(
+ key: String,
+ oldKey: String?,
+ data: MediaData
+ ) = traceSection("MediaDataManager#onMediaDataLoaded") {
Assert.isMainThread()
if (mediaEntries.containsKey(key)) {
// Otherwise this was removed already
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
index 30771c728e86..ed5c1933af25 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
@@ -45,6 +45,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.LargeScreenUtils
import com.android.systemui.util.animation.UniqueObjectHostView
+import com.android.systemui.util.traceSection
import javax.inject.Inject
/**
@@ -582,7 +583,7 @@ class MediaHierarchyManager @Inject constructor(
private fun updateDesiredLocation(
forceNoAnimation: Boolean = false,
forceStateUpdate: Boolean = false
- ) {
+ ) = traceSection("MediaHierarchyManager#updateDesiredLocation") {
val desiredLocation = calculateLocation()
if (desiredLocation != this.desiredLocation || forceStateUpdate) {
if (this.desiredLocation >= 0 && desiredLocation != this.desiredLocation) {
@@ -616,7 +617,10 @@ class MediaHierarchyManager @Inject constructor(
}
}
- private fun performTransitionToNewLocation(isNewView: Boolean, animate: Boolean) {
+ private fun performTransitionToNewLocation(
+ isNewView: Boolean,
+ animate: Boolean
+ ) = traceSection("MediaHierarchyManager#performTransitionToNewLocation") {
if (previousLocation < 0 || isNewView) {
cancelAnimationAndApplyDesiredState()
return
@@ -899,7 +903,7 @@ class MediaHierarchyManager @Inject constructor(
alpha: Float,
immediately: Boolean = false,
clipBounds: Rect = EMPTY_RECT
- ) {
+ ) = traceSection("MediaHierarchyManager#applyState") {
currentBounds.set(bounds)
currentClipping = clipBounds
carouselAlpha = if (isCurrentlyFading()) alpha else 1.0f
@@ -922,7 +926,9 @@ class MediaHierarchyManager @Inject constructor(
}
}
- private fun updateHostAttachment() {
+ private fun updateHostAttachment() = traceSection(
+ "MediaHierarchyManager#updateHostAttachment"
+ ) {
var newLocation = resolveLocationForFading()
var canUseOverlay = !isCurrentlyFading()
if (isCrossFadeAnimatorRunning) {
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt
index ba7c1679b174..aea2934c46fe 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt
@@ -18,6 +18,7 @@ package com.android.systemui.media
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.util.animation.MeasurementOutput
+import com.android.systemui.util.traceSection
import javax.inject.Inject
/**
@@ -46,7 +47,10 @@ class MediaHostStatesManager @Inject constructor() {
* Notify that a media state for a given location has changed. Should only be called from
* Media hosts themselves.
*/
- fun updateHostState(@MediaLocation location: Int, hostState: MediaHostState) {
+ fun updateHostState(
+ @MediaLocation location: Int,
+ hostState: MediaHostState
+ ) = traceSection("MediaHostStatesManager#updateHostState") {
val currentState = mediaHostStates.get(location)
if (!hostState.equals(currentState)) {
val newState = hostState.copy()
@@ -71,7 +75,7 @@ class MediaHostStatesManager @Inject constructor() {
fun updateCarouselDimensions(
@MediaLocation location: Int,
hostState: MediaHostState
- ): MeasurementOutput {
+ ): MeasurementOutput = traceSection("MediaHostStatesManager#updateCarouselDimensions") {
val result = MeasurementOutput(0, 0)
for (controller in controllers) {
val measurement = controller.getMeasurementsForState(hostState)
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt b/packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt
index 7eccb3b91bb5..ae62355e6768 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt
@@ -26,6 +26,7 @@ import com.android.systemui.util.animation.MeasurementOutput
import com.android.systemui.util.animation.TransitionLayout
import com.android.systemui.util.animation.TransitionLayoutController
import com.android.systemui.util.animation.TransitionViewState
+import com.android.systemui.util.traceSection
import javax.inject.Inject
/**
@@ -371,7 +372,10 @@ class MediaViewController @Inject constructor(
* Attach a view to this controller. This may perform measurements if it's not available yet
* and should therefore be done carefully.
*/
- fun attach(transitionLayout: TransitionLayout, type: TYPE) {
+ fun attach(
+ transitionLayout: TransitionLayout,
+ type: TYPE
+ ) = traceSection("MediaViewController#attach") {
updateMediaViewControllerType(type)
logger.logMediaLocation("attach", currentStartLocation, currentEndLocation)
this.transitionLayout = transitionLayout
@@ -392,7 +396,9 @@ class MediaViewController @Inject constructor(
* and all widgets know their location. Calling this method may create a measurement if we
* don't have a cached value available already.
*/
- fun getMeasurementsForState(hostState: MediaHostState): MeasurementOutput? {
+ fun getMeasurementsForState(
+ hostState: MediaHostState
+ ): MeasurementOutput? = traceSection("MediaViewController#getMeasurementsForState") {
val viewState = obtainViewState(hostState) ?: return null
measurement.measuredWidth = viewState.width
measurement.measuredHeight = viewState.height
@@ -408,7 +414,7 @@ class MediaViewController @Inject constructor(
@MediaLocation endLocation: Int,
transitionProgress: Float,
applyImmediately: Boolean
- ) {
+ ) = traceSection("MediaViewController#setCurrentState") {
currentEndLocation = endLocation
currentStartLocation = startLocation
currentTransitionProgress = transitionProgress
@@ -540,7 +546,7 @@ class MediaViewController @Inject constructor(
/**
* Clear all existing measurements and refresh the state to match the view.
*/
- fun refreshState() {
+ fun refreshState() = traceSection("MediaViewController#refreshState") {
// Let's clear all of our measurements and recreate them!
viewStates.clear()
if (firstRefresh) {