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

Commit c8f18d19 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "[DO NOT MERGE] Revert "Allow user to block individual apps from resuming"" into rvc-qpr-dev

parents 8b9d4058 f7159102
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -8928,14 +8928,6 @@ public final class Settings {
         */
        public static final String MEDIA_CONTROLS_RESUME = "qs_media_resumption";
        /**
         * Controls which packages are blocked from persisting in media controls when resumption is
         * enabled. The list of packages is set by the user in the Settings app.
         * @see Settings.Secure#MEDIA_CONTROLS_RESUME
         * @hide
         */
        public static final String MEDIA_CONTROLS_RESUME_BLOCKED = "qs_media_resumption_blocked";
        /**
         * Controls if window magnification is enabled.
         * @hide
+0 −1
Original line number Diff line number Diff line
@@ -165,7 +165,6 @@ public class SecureSettings {
        Settings.Secure.AWARE_TAP_PAUSE_TOUCH_COUNT,
        Settings.Secure.PEOPLE_STRIP,
        Settings.Secure.MEDIA_CONTROLS_RESUME,
        Settings.Secure.MEDIA_CONTROLS_RESUME_BLOCKED,
        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE,
        Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS,
        Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED
+0 −2
Original line number Diff line number Diff line
@@ -244,8 +244,6 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.TAP_GESTURE, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.PEOPLE_STRIP, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.MEDIA_CONTROLS_RESUME, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.MEDIA_CONTROLS_RESUME_BLOCKED,
                COLON_SEPARATED_PACKAGE_LIST_VALIDATOR);
        VALIDATORS.put(Secure.ACCESSIBILITY_MAGNIFICATION_MODE,
                new InclusiveIntegerRangeValidator(
                        Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN,
+1 −23
Original line number Diff line number Diff line
@@ -56,8 +56,6 @@ import java.io.PrintWriter
import java.util.concurrent.Executor
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.collections.ArrayList
import kotlin.collections.LinkedHashMap

// URI fields to try loading album art from
private val ART_URIS = arrayOf(
@@ -106,17 +104,6 @@ class MediaDataManager(

    private val listeners: MutableSet<Listener> = mutableSetOf()
    private val mediaEntries: LinkedHashMap<String, MediaData> = LinkedHashMap()
    internal var appsBlockedFromResume: MutableSet<String> = Utils.getBlockedMediaApps(context)
        set(value) {
            // Update list
            appsBlockedFromResume.clear()
            appsBlockedFromResume.addAll(value)

            // Remove any existing resume players that are now blocked
            appsBlockedFromResume.forEach {
                removeAllForPackage(it)
            }
        }

    @Inject
    constructor(
@@ -548,8 +535,7 @@ class MediaDataManager(
    fun onNotificationRemoved(key: String) {
        Assert.isMainThread()
        val removed = mediaEntries.remove(key)
        if (useMediaResumption && removed?.resumeAction != null &&
                !isBlockedFromResume(removed?.packageName)) {
        if (useMediaResumption && removed?.resumeAction != null) {
            if (DEBUG) Log.d(TAG, "Not removing $key because resumable")
            // Move to resume key (aka package name) if that key doesn't already exist.
            val resumeAction = getResumeMediaAction(removed.resumeAction!!)
@@ -586,13 +572,6 @@ class MediaDataManager(
        }
    }

    private fun isBlockedFromResume(packageName: String?): Boolean {
        if (packageName == null) {
            return true
        }
        return appsBlockedFromResume.contains(packageName)
    }

    fun setMediaResumptionEnabled(isEnabled: Boolean) {
        if (useMediaResumption == isEnabled) {
            return
@@ -635,7 +614,6 @@ class MediaDataManager(
            println("listeners: $listeners")
            println("mediaEntries: $mediaEntries")
            println("useMediaResumption: $useMediaResumption")
            println("appsBlockedFromResume: $appsBlockedFromResume")
        }
    }
}
+3 −15
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ class MediaResumeListener @Inject constructor(

    private var useMediaResumption: Boolean = Utils.useMediaResumption(context)
    private val resumeComponents: ConcurrentLinkedQueue<ComponentName> = ConcurrentLinkedQueue()
    private var blockedApps: MutableSet<String> = Utils.getBlockedMediaApps(context)

    private lateinit var mediaDataManager: MediaDataManager

@@ -115,14 +114,6 @@ class MediaResumeListener @Inject constructor(
                mediaDataManager.setMediaResumptionEnabled(useMediaResumption)
            }
        }, Settings.Secure.MEDIA_CONTROLS_RESUME)

        // Listen to changes in which apps are allowed to persist
        tunerService.addTunable(object : TunerService.Tunable {
            override fun onTuningChanged(key: String?, newValue: String?) {
                blockedApps = Utils.getBlockedMediaApps(context)
                mediaDataManager.appsBlockedFromResume = blockedApps
            }
        }, Settings.Secure.MEDIA_CONTROLS_RESUME_BLOCKED)
    }

    fun isResumptionEnabled() = useMediaResumption
@@ -153,20 +144,17 @@ class MediaResumeListener @Inject constructor(
        }

        resumeComponents.forEach {
            if (!blockedApps.contains(it.packageName)) {
            val browser = ResumeMediaBrowser(context, mediaBrowserCallback, it)
            browser.findRecentMedia()
        }
    }
    }

    override fun onMediaDataLoaded(key: String, oldKey: String?, data: MediaData) {
        if (useMediaResumption) {
            // If this had been started from a resume state, disconnect now that it's live
            mediaBrowser?.disconnect()
            // If we don't have a resume action, check if we haven't already
            if (data.resumeAction == null && !data.hasCheckedForResume &&
                    !blockedApps.contains(data.packageName)) {
            if (data.resumeAction == null && !data.hasCheckedForResume) {
                // TODO also check for a media button receiver intended for restarting (b/154127084)
                Log.d(TAG, "Checking for service component for " + data.packageName)
                val pm = context.packageManager
Loading