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

Commit ae173fef authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Guard MediaDeviceManager.Entry against successive stop calls

This is a cherrypick of commit 543dd362.

It's non obvious from the code that an entry will be stopped
only once. The start() protection is added for simmetry.

Bug: 232812007
Test: Manual behavioral test.
Test: atest MediaDeviceManagerTest MediaDataCombineLatestTest
Change-Id: Icb4573d30790b4055b67eff57c495ceb6c3ae61b
Merged-In: Icb4573d30790b4055b67eff57c495ceb6c3ae61b
parent 9958359c
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ class MediaDeviceManager @Inject constructor(

        @AnyThread
        fun start() = bgExecutor.execute {
            if (!started) {
                localMediaManager.registerCallback(this)
                localMediaManager.startScan()
                muteAwaitConnectionManager?.startListening()
@@ -197,9 +198,11 @@ class MediaDeviceManager @Inject constructor(
                started = true
                configurationController.addCallback(configListener)
            }
        }

        @AnyThread
        fun stop() = bgExecutor.execute {
            if (started) {
                started = false
                controller?.unregisterCallback(this)
                localMediaManager.stopScan()
@@ -207,6 +210,7 @@ class MediaDeviceManager @Inject constructor(
                muteAwaitConnectionManager?.stopListening()
                configurationController.removeCallback(configListener)
            }
        }

        fun dump(pw: PrintWriter) {
            val routingSession = controller?.let {