Guard MediaDeviceManager.Entry against successive stop calls am: ae173fef18

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

Change-Id: Ie343026b0e079607b19cf55614e1c838ddbb7feb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Santiago Seifert
2022-09-23 22:34:16 +00:00
committed by Automerger Merge Worker

View File

@@ -188,24 +188,28 @@ class MediaDeviceManager @Inject constructor(
@AnyThread @AnyThread
fun start() = bgExecutor.execute { fun start() = bgExecutor.execute {
localMediaManager.registerCallback(this) if (!started) {
localMediaManager.startScan() localMediaManager.registerCallback(this)
muteAwaitConnectionManager?.startListening() localMediaManager.startScan()
playbackType = controller?.playbackInfo?.playbackType ?: PLAYBACK_TYPE_UNKNOWN muteAwaitConnectionManager?.startListening()
controller?.registerCallback(this) playbackType = controller?.playbackInfo?.playbackType ?: PLAYBACK_TYPE_UNKNOWN
updateCurrent() controller?.registerCallback(this)
started = true updateCurrent()
configurationController.addCallback(configListener) started = true
configurationController.addCallback(configListener)
}
} }
@AnyThread @AnyThread
fun stop() = bgExecutor.execute { fun stop() = bgExecutor.execute {
started = false if (started) {
controller?.unregisterCallback(this) started = false
localMediaManager.stopScan() controller?.unregisterCallback(this)
localMediaManager.unregisterCallback(this) localMediaManager.stopScan()
muteAwaitConnectionManager?.stopListening() localMediaManager.unregisterCallback(this)
configurationController.removeCallback(configListener) muteAwaitConnectionManager?.stopListening()
configurationController.removeCallback(configListener)
}
} }
fun dump(pw: PrintWriter) { fun dump(pw: PrintWriter) {