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

This commit is contained in:
Cecilia Hong
2021-06-22 15:30:37 +00:00
committed by Android (Google) Code Review
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 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.
@@ -237,7 +238,7 @@ class MediaCarouselController @Inject constructor(
data: SmartspaceMediaData,
shouldPrioritize: Boolean
) {
Log.d(TAG, "My Smartspace media update is here")
if (DEBUG) Log.d(TAG, "Loading Smartspace media update")
if (data.isActive) {
addSmartspaceMediaRecommendations(key, data, shouldPrioritize)
MediaPlayerData.getMediaPlayer(key, null)?.let {
@@ -266,7 +267,7 @@ class MediaCarouselController @Inject constructor(
}
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) {
onMediaDataRemoved(key)
} else {
@@ -384,7 +385,7 @@ class MediaCarouselController @Inject constructor(
data: SmartspaceMediaData,
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) {
Log.w(TAG, "Skip adding smartspace target in carousel")
return

View File

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