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

Commit cdf6067f authored by Anton Potapov's avatar Anton Potapov
Browse files

Synchronously call callback when load is cancelled

This prevents the case when controller unbinds and nulls the provider
used by the callback with a slight delay. Callback is ignored when there
is no provider and ControlsController gets stuck in seeding state.

Test: manual with the steps from the comment#18
Test: atest ControlsBindingControllerImplTest
Fixes: 283888863
Change-Id: I5683170b71ad47702c924fbb2df293118937cb37
parent b9777bc4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -312,6 +312,7 @@ open class ControlsBindingControllerImpl @Inject constructor(
                Log.d(TAG, "Canceling loadSubscribtion")
                Log.d(TAG, "Canceling loadSubscribtion")
                it.invoke()
                it.invoke()
            }
            }
            callback.error("Load cancelled")
        }
        }


        override fun onSubscribe(token: IBinder, subs: IControlsSubscription) {
        override fun onSubscribe(token: IBinder, subs: IControlsSubscription) {
+2 −5
Original line number Original line Diff line number Diff line
@@ -116,11 +116,7 @@ class ControlsBindingControllerImplTest : SysuiTestCase() {


    @Test
    @Test
    fun testBindAndLoad_cancel() {
    fun testBindAndLoad_cancel() {
        val callback = object : ControlsBindingController.LoadCallback {
        val callback = mock(ControlsBindingController.LoadCallback::class.java)
            override fun error(message: String) {}

            override fun accept(t: List<Control>) {}
        }
        val subscription = mock(IControlsSubscription::class.java)
        val subscription = mock(IControlsSubscription::class.java)


        val canceller = controller.bindAndLoad(TEST_COMPONENT_NAME_1, callback)
        val canceller = controller.bindAndLoad(TEST_COMPONENT_NAME_1, callback)
@@ -130,6 +126,7 @@ class ControlsBindingControllerImplTest : SysuiTestCase() {


        canceller.run()
        canceller.run()
        verify(providers[0]).cancelSubscription(subscription)
        verify(providers[0]).cancelSubscription(subscription)
        verify(callback).error(any())
    }
    }


    @Test
    @Test