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

Commit 71e9754e authored by Michael Mikhail's avatar Michael Mikhail
Browse files

[Flexiglass] avoid blocking media conversion from resume to active

Flag: com.android.systemui.media_load_metadata_via_media_data_loader
Flag: com.android.systemui.scene_container
Bug: 368472246
Test: atest MediaDataLoaderTest
Change-Id: If81a01fc10dbbb7134a49e21210c1f69b6b62b10
parent 68b39435
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -330,6 +330,7 @@ class MediaDataProcessor(
    fun onNotificationAdded(key: String, sbn: StatusBarNotification) {
        if (useQsMediaPlayer && isMediaNotification(sbn)) {
            var isNewlyActiveEntry = false
            var isConvertingToActive = false
            Assert.isMainThread()
            val oldKey = findExistingEntry(key, sbn.packageName)
            if (oldKey == null) {
@@ -347,9 +348,10 @@ class MediaDataProcessor(
                // Resume -> active conversion; move to new key
                val oldData = mediaDataRepository.removeMediaEntry(oldKey)!!
                isNewlyActiveEntry = true
                isConvertingToActive = true
                mediaDataRepository.addMediaEntry(key, oldData)
            }
            loadMediaData(key, sbn, oldKey, isNewlyActiveEntry)
            loadMediaData(key, sbn, oldKey, isNewlyActiveEntry, isConvertingToActive)
        } else {
            onNotificationRemoved(key)
        }
@@ -488,10 +490,11 @@ class MediaDataProcessor(
        sbn: StatusBarNotification,
        oldKey: String?,
        isNewlyActiveEntry: Boolean = false,
        isConvertingToActive: Boolean = false,
    ) {
        if (Flags.mediaLoadMetadataViaMediaDataLoader()) {
            applicationScope.launch {
                loadMediaDataWithLoader(key, sbn, oldKey, isNewlyActiveEntry)
                loadMediaDataWithLoader(key, sbn, oldKey, isNewlyActiveEntry, isConvertingToActive)
            }
        } else {
            backgroundExecutor.execute { loadMediaDataInBg(key, sbn, oldKey, isNewlyActiveEntry) }
@@ -835,10 +838,11 @@ class MediaDataProcessor(
        sbn: StatusBarNotification,
        oldKey: String?,
        isNewlyActiveEntry: Boolean = false,
        isConvertingToActive: Boolean = false,
    ) =
        withContext(backgroundDispatcher) {
            val lastActive = systemClock.elapsedRealtime()
            val result = mediaDataLoader.get().loadMediaData(key, sbn)
            val result = mediaDataLoader.get().loadMediaData(key, sbn, isConvertingToActive)
            if (result == null) {
                Log.d(TAG, "No result from loadMediaData")
                return@withContext