Loading packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt +20 −4 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ class MediaCarouselController @Inject constructor( * It will be called when the container is out of view. */ lateinit var updateUserVisibility: () -> Unit lateinit var updateHostVisibility: () -> Unit private val isReorderingAllowed: Boolean get() = visualStabilityProvider.isReorderingAllowed Loading @@ -225,7 +226,13 @@ class MediaCarouselController @Inject constructor( reorderAllPlayers(previousVisiblePlayerKey = null) } keysNeedRemoval.forEach { removePlayer(it) } keysNeedRemoval.forEach { removePlayer(it) } if (keysNeedRemoval.size > 0) { // Carousel visibility may need to be updated after late removals updateHostVisibility() } keysNeedRemoval.clear() // Update user visibility so that no extra impression will be logged when Loading @@ -247,6 +254,7 @@ class MediaCarouselController @Inject constructor( receivedSmartspaceCardLatency: Int, isSsReactivated: Boolean ) { debugLogger.logMediaLoaded(key) if (addOrUpdatePlayer(key, oldKey, data, isSsReactivated)) { // Log card received if a new resumable media card is added MediaPlayerData.getMediaPlayer(key)?.let { Loading Loading @@ -315,7 +323,7 @@ class MediaCarouselController @Inject constructor( data: SmartspaceMediaData, shouldPrioritize: Boolean ) { if (DEBUG) Log.d(TAG, "Loading Smartspace media update") debugLogger.logRecommendationLoaded(key) // Log the case where the hidden media carousel with the existed inactive resume // media is shown by the Smartspace signal. if (data.isActive) { Loading Loading @@ -370,13 +378,21 @@ class MediaCarouselController @Inject constructor( } override fun onMediaDataRemoved(key: String) { debugLogger.logMediaRemoved(key) removePlayer(key) } override fun onSmartspaceMediaDataRemoved(key: String, immediately: Boolean) { if (DEBUG) Log.d(TAG, "My Smartspace media removal request is received") debugLogger.logRecommendationRemoved(key, immediately) if (immediately || isReorderingAllowed) { onMediaDataRemoved(key) removePlayer(key) if (!immediately) { // Although it wasn't requested, we were able to process the removal // immediately since reordering is allowed. So, notify hosts to update if (this@MediaCarouselController::updateHostVisibility.isInitialized) { updateHostVisibility() } } } else { keysNeedRemoval.add(key) } Loading packages/SystemUI/src/com/android/systemui/media/MediaCarouselControllerLogger.kt +31 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,37 @@ class MediaCarouselControllerLogger @Inject constructor( "Removing control panel for $str1 from map without calling #onDestroy" } ) fun logMediaLoaded(key: String) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key }, { "add player $str1" } ) fun logMediaRemoved(key: String) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key }, { "removing player $str1" } ) fun logRecommendationLoaded(key: String) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key }, { "add recommendation $str1" } ) fun logRecommendationRemoved(key: String, immediately: Boolean) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key bool1 = immediately }, { "removing recommendation $str1, immediate=$bool1" } ) } private const val TAG = "MediaCarouselCtlrLog" packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt +1 −0 Original line number Diff line number Diff line Loading @@ -1322,6 +1322,7 @@ class MediaDataManager( println("externalListeners: ${mediaDataFilter.listeners}") println("mediaEntries: $mediaEntries") println("useMediaResumption: $useMediaResumption") println("allowMediaRecommendations: $allowMediaRecommendations") } } } packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -546,6 +546,11 @@ class MediaHierarchyManager @Inject constructor( mediaCarouselController.updateUserVisibility = { mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = isVisibleToUser() } mediaCarouselController.updateHostVisibility = { mediaHosts.forEach { it?.updateViewVisibility() } } panelEventsEvents.registerListener(object : NotifPanelEvents.Listener { override fun onExpandImmediateChanged(isExpandImmediateEnabled: Boolean) { Loading packages/SystemUI/src/com/android/systemui/media/MediaHost.kt +5 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,11 @@ class MediaHost constructor( } } private fun updateViewVisibility() { /** * Updates this host's state based on the current media data's status, and invokes listeners if * the visibility has changed */ fun updateViewVisibility() { state.visible = if (showsOnlyActiveMedia) { mediaDataManager.hasActiveMediaOrRecommendation() } else { Loading Loading
packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt +20 −4 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ class MediaCarouselController @Inject constructor( * It will be called when the container is out of view. */ lateinit var updateUserVisibility: () -> Unit lateinit var updateHostVisibility: () -> Unit private val isReorderingAllowed: Boolean get() = visualStabilityProvider.isReorderingAllowed Loading @@ -225,7 +226,13 @@ class MediaCarouselController @Inject constructor( reorderAllPlayers(previousVisiblePlayerKey = null) } keysNeedRemoval.forEach { removePlayer(it) } keysNeedRemoval.forEach { removePlayer(it) } if (keysNeedRemoval.size > 0) { // Carousel visibility may need to be updated after late removals updateHostVisibility() } keysNeedRemoval.clear() // Update user visibility so that no extra impression will be logged when Loading @@ -247,6 +254,7 @@ class MediaCarouselController @Inject constructor( receivedSmartspaceCardLatency: Int, isSsReactivated: Boolean ) { debugLogger.logMediaLoaded(key) if (addOrUpdatePlayer(key, oldKey, data, isSsReactivated)) { // Log card received if a new resumable media card is added MediaPlayerData.getMediaPlayer(key)?.let { Loading Loading @@ -315,7 +323,7 @@ class MediaCarouselController @Inject constructor( data: SmartspaceMediaData, shouldPrioritize: Boolean ) { if (DEBUG) Log.d(TAG, "Loading Smartspace media update") debugLogger.logRecommendationLoaded(key) // Log the case where the hidden media carousel with the existed inactive resume // media is shown by the Smartspace signal. if (data.isActive) { Loading Loading @@ -370,13 +378,21 @@ class MediaCarouselController @Inject constructor( } override fun onMediaDataRemoved(key: String) { debugLogger.logMediaRemoved(key) removePlayer(key) } override fun onSmartspaceMediaDataRemoved(key: String, immediately: Boolean) { if (DEBUG) Log.d(TAG, "My Smartspace media removal request is received") debugLogger.logRecommendationRemoved(key, immediately) if (immediately || isReorderingAllowed) { onMediaDataRemoved(key) removePlayer(key) if (!immediately) { // Although it wasn't requested, we were able to process the removal // immediately since reordering is allowed. So, notify hosts to update if (this@MediaCarouselController::updateHostVisibility.isInitialized) { updateHostVisibility() } } } else { keysNeedRemoval.add(key) } Loading
packages/SystemUI/src/com/android/systemui/media/MediaCarouselControllerLogger.kt +31 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,37 @@ class MediaCarouselControllerLogger @Inject constructor( "Removing control panel for $str1 from map without calling #onDestroy" } ) fun logMediaLoaded(key: String) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key }, { "add player $str1" } ) fun logMediaRemoved(key: String) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key }, { "removing player $str1" } ) fun logRecommendationLoaded(key: String) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key }, { "add recommendation $str1" } ) fun logRecommendationRemoved(key: String, immediately: Boolean) = buffer.log( TAG, LogLevel.DEBUG, { str1 = key bool1 = immediately }, { "removing recommendation $str1, immediate=$bool1" } ) } private const val TAG = "MediaCarouselCtlrLog"
packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt +1 −0 Original line number Diff line number Diff line Loading @@ -1322,6 +1322,7 @@ class MediaDataManager( println("externalListeners: ${mediaDataFilter.listeners}") println("mediaEntries: $mediaEntries") println("useMediaResumption: $useMediaResumption") println("allowMediaRecommendations: $allowMediaRecommendations") } } }
packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -546,6 +546,11 @@ class MediaHierarchyManager @Inject constructor( mediaCarouselController.updateUserVisibility = { mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = isVisibleToUser() } mediaCarouselController.updateHostVisibility = { mediaHosts.forEach { it?.updateViewVisibility() } } panelEventsEvents.registerListener(object : NotifPanelEvents.Listener { override fun onExpandImmediateChanged(isExpandImmediateEnabled: Boolean) { Loading
packages/SystemUI/src/com/android/systemui/media/MediaHost.kt +5 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,11 @@ class MediaHost constructor( } } private fun updateViewVisibility() { /** * Updates this host's state based on the current media data's status, and invokes listeners if * the visibility has changed */ fun updateViewVisibility() { state.visible = if (showsOnlyActiveMedia) { mediaDataManager.hasActiveMediaOrRecommendation() } else { Loading