Merge "Remove logspam from Smartspace media update pipeline." into sc-dev am: a9b80b098c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14822980

Change-Id: Ie1978e298269bd85f084b2d6df42f4c3c32978ff
This commit is contained in:
Cecilia Hong
2021-06-22 15:35:20 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 14 deletions

View File

@@ -32,6 +32,7 @@ import javax.inject.Provider
private const val TAG = "MediaCarouselController" private const val TAG = "MediaCarouselController"
private val settingsIntent = Intent().setAction(ACTION_MEDIA_CONTROLS_SETTINGS) private val settingsIntent = Intent().setAction(ACTION_MEDIA_CONTROLS_SETTINGS)
private const val DEBUG = false
/** /**
* Class that is responsible for keeping the view carousel up to date. * Class that is responsible for keeping the view carousel up to date.
@@ -237,7 +238,7 @@ class MediaCarouselController @Inject constructor(
data: SmartspaceMediaData, data: SmartspaceMediaData,
shouldPrioritize: Boolean shouldPrioritize: Boolean
) { ) {
Log.d(TAG, "My Smartspace media update is here") if (DEBUG) Log.d(TAG, "Loading Smartspace media update")
if (data.isActive) { if (data.isActive) {
addSmartspaceMediaRecommendations(key, data, shouldPrioritize) addSmartspaceMediaRecommendations(key, data, shouldPrioritize)
MediaPlayerData.getMediaPlayer(key, null)?.let { MediaPlayerData.getMediaPlayer(key, null)?.let {
@@ -266,7 +267,7 @@ class MediaCarouselController @Inject constructor(
} }
override fun onSmartspaceMediaDataRemoved(key: String, immediately: Boolean) { override fun onSmartspaceMediaDataRemoved(key: String, immediately: Boolean) {
Log.d(TAG, "My Smartspace media removal request is received") if (DEBUG) Log.d(TAG, "My Smartspace media removal request is received")
if (immediately || visualStabilityManager.isReorderingAllowed) { if (immediately || visualStabilityManager.isReorderingAllowed) {
onMediaDataRemoved(key) onMediaDataRemoved(key)
} else { } else {
@@ -384,7 +385,7 @@ class MediaCarouselController @Inject constructor(
data: SmartspaceMediaData, data: SmartspaceMediaData,
shouldPrioritize: Boolean shouldPrioritize: Boolean
) { ) {
Log.d(TAG, "Updating smartspace target in carousel") if (DEBUG) Log.d(TAG, "Updating smartspace target in carousel")
if (MediaPlayerData.getMediaPlayer(key, null) != null) { if (MediaPlayerData.getMediaPlayer(key, null) != null) {
Log.w(TAG, "Skip adding smartspace target in carousel") Log.w(TAG, "Skip adding smartspace target in carousel")
return return

View File

@@ -453,7 +453,8 @@ class MediaDataManager(
if (smartspaceMediaData.targetId != key) { if (smartspaceMediaData.targetId != key) {
return return
} }
Log.d(TAG, "Dismissing Smartspace media target")
if (DEBUG) Log.d(TAG, "Dismissing Smartspace media target")
if (smartspaceMediaData.isActive) { if (smartspaceMediaData.isActive) {
smartspaceMediaData = EMPTY_SMARTSPACE_MEDIA_DATA.copy( smartspaceMediaData = EMPTY_SMARTSPACE_MEDIA_DATA.copy(
targetId = smartspaceMediaData.targetId) targetId = smartspaceMediaData.targetId)
@@ -709,17 +710,19 @@ class MediaDataManager(
override fun onSmartspaceTargetsUpdated(targets: List<Parcelable>) { override fun onSmartspaceTargetsUpdated(targets: List<Parcelable>) {
if (!allowMediaRecommendations) { if (!allowMediaRecommendations) {
if (DEBUG) Log.d(TAG, "Smartspace recommendation is disabled in Settings.")
return return
} }
val mediaTargets = targets.filterIsInstance<SmartspaceTarget>() val mediaTargets = targets.filterIsInstance<SmartspaceTarget>()
when (mediaTargets.size) { when (mediaTargets.size) {
0 -> { 0 -> {
Log.d(TAG, "Empty Smartspace media target")
if (!smartspaceMediaData.isActive) { if (!smartspaceMediaData.isActive) {
return return
} }
Log.d(TAG, "Set Smartspace media to be inactive for the data update") if (DEBUG) {
Log.d(TAG, "Set Smartspace media to be inactive for the data update")
}
smartspaceMediaData = EMPTY_SMARTSPACE_MEDIA_DATA.copy( smartspaceMediaData = EMPTY_SMARTSPACE_MEDIA_DATA.copy(
targetId = smartspaceMediaData.targetId) targetId = smartspaceMediaData.targetId)
notifySmartspaceMediaDataRemoved(smartspaceMediaData.targetId, immediately = false) notifySmartspaceMediaDataRemoved(smartspaceMediaData.targetId, immediately = false)
@@ -728,13 +731,12 @@ class MediaDataManager(
val newMediaTarget = mediaTargets.get(0) val newMediaTarget = mediaTargets.get(0)
if (smartspaceMediaData.targetId == newMediaTarget.smartspaceTargetId) { if (smartspaceMediaData.targetId == newMediaTarget.smartspaceTargetId) {
// The same Smartspace updates can be received. Skip the duplicate updates. // The same Smartspace updates can be received. Skip the duplicate updates.
Log.d(TAG, "Same Smartspace media update exists. Skip loading data.") return
} else {
Log.d(TAG, "Forwarding Smartspace media update.")
smartspaceMediaData = toSmartspaceMediaData(newMediaTarget, isActive = true)
notifySmartspaceMediaDataLoaded(
smartspaceMediaData.targetId, smartspaceMediaData)
} }
if (DEBUG) Log.d(TAG, "Forwarding Smartspace media update.")
smartspaceMediaData = toSmartspaceMediaData(newMediaTarget, isActive = true)
notifySmartspaceMediaDataLoaded(
smartspaceMediaData.targetId, smartspaceMediaData)
} }
else -> { else -> {
// There should NOT be more than 1 Smartspace media update. When it happens, it // There should NOT be more than 1 Smartspace media update. When it happens, it
@@ -883,7 +885,7 @@ class MediaDataManager(
private fun packageName(target: SmartspaceTarget): String? { private fun packageName(target: SmartspaceTarget): String? {
val recommendationList = target.iconGrid val recommendationList = target.iconGrid
if (recommendationList == null || recommendationList.isEmpty()) { if (recommendationList == null || recommendationList.isEmpty()) {
Log.d(TAG, "Empty or media recommendation list.") Log.w(TAG, "Empty or null media recommendation list.")
return null return null
} }
for (recommendation in recommendationList) { for (recommendation in recommendationList) {
@@ -893,7 +895,7 @@ class MediaDataManager(
packageName -> return packageName } packageName -> return packageName }
} }
} }
Log.d(TAG, "No valid package name is provided.") Log.w(TAG, "No valid package name is provided.")
return null return null
} }