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

Commit ce582062 authored by Justin Weir's avatar Justin Weir Committed by Automerger Merge Worker
Browse files

Merge "Add a unique ID to MediaDeviceData" into tm-dev am: a275233f am:...

Merge "Add a unique ID to MediaDeviceData" into tm-dev am: a275233f am: 2850b848 am: b2d0ad8c am: 43bdec14

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



Change-Id: I953829bcb8a0e4874843a8bf1c8dfd3c65e62829
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents aeae22a2 43bdec14
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -212,5 +212,8 @@ data class MediaDeviceData
    val name: CharSequence?,
    val name: CharSequence?,


    /** Optional intent to override the default output switcher for this control */
    /** Optional intent to override the default output switcher for this control */
    val intent: PendingIntent? = null
    val intent: PendingIntent? = null,

    /** Unique id for this device */
    val id: String? = null
)
)
+3 −2
Original line number Original line Diff line number Diff line
@@ -155,7 +155,8 @@ class MediaDeviceManager @Inject constructor(
        private var playbackType = PLAYBACK_TYPE_UNKNOWN
        private var playbackType = PLAYBACK_TYPE_UNKNOWN
        private var current: MediaDeviceData? = null
        private var current: MediaDeviceData? = null
            set(value) {
            set(value) {
                if (!started || value != field) {
                val hasSameId = value?.id != null && value.id == field?.id
                if (!started || (!hasSameId && value != field)) {
                    field = value
                    field = value
                    fgExecutor.execute {
                    fgExecutor.execute {
                        processDevice(key, oldKey, value)
                        processDevice(key, oldKey, value)
@@ -263,7 +264,7 @@ class MediaDeviceManager @Inject constructor(
            // If we have a controller but get a null route, then don't trust the device
            // If we have a controller but get a null route, then don't trust the device
            val enabled = device != null && (controller == null || route != null)
            val enabled = device != null && (controller == null || route != null)
            val name = route?.name?.toString() ?: device?.name
            val name = route?.name?.toString() ?: device?.name
            current = MediaDeviceData(enabled, device?.iconWithoutBackground, name)
            current = MediaDeviceData(enabled, device?.iconWithoutBackground, name, id = device?.id)
        }
        }
    }
    }
}
}