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

Commit 62c7da84 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:...

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

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

Change-Id: I17bb27f3551d2b182b65b3ac0bf795fd12c8788a
parents 0fd40e09 592053f9
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -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
+13 −11
Original line number Original line Diff line number Diff line
@@ -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
                }
                }
                if (DEBUG) {
                    Log.d(TAG, "Set Smartspace media to be inactive for the data update")
                    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,14 +731,13 @@ 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.")
                if (DEBUG) Log.d(TAG, "Forwarding Smartspace media update.")
                smartspaceMediaData = toSmartspaceMediaData(newMediaTarget, isActive = true)
                smartspaceMediaData = toSmartspaceMediaData(newMediaTarget, isActive = true)
                notifySmartspaceMediaDataLoaded(
                notifySmartspaceMediaDataLoaded(
                    smartspaceMediaData.targetId, smartspaceMediaData)
                    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
                // indicates a bad state or an error. Reset the status accordingly.
                // indicates a bad state or an error. Reset the status accordingly.
@@ -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
    }
    }