Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68ed635f authored by Cecilia Hong's avatar Cecilia Hong Committed by Automerger Merge Worker
Browse files

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

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

Change-Id: I6bb4f7c1af1c5f98a6ccc418749f87ce7a34a64a
parents cf5b268a a9b80b09
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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
+13 −11
Original line number Diff line number Diff line
@@ -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
                }
                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,14 +731,13 @@ 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.")
                    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
                // indicates a bad state or an error. Reset the status accordingly.
@@ -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
    }