diff options
| author | 2023-06-06 18:02:11 +0100 | |
|---|---|---|
| committer | 2023-06-06 18:02:11 +0100 | |
| commit | cdf6067fbc432970d048e808b3a69ed4fc3065da (patch) | |
| tree | 947aeaa93806784043239e6d3de2da401a16395c | |
| parent | b9777bc49b2c4e49dcc69c410b3b9b371fee364b (diff) | |
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
2 files changed, 3 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt index 18bd46756660..ccbde011334d 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt @@ -312,6 +312,7 @@ open class ControlsBindingControllerImpl @Inject constructor( Log.d(TAG, "Canceling loadSubscribtion") it.invoke() } + callback.error("Load cancelled") } override fun onSubscribe(token: IBinder, subs: IControlsSubscription) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt index 26cbd7703075..724c9d1dfc42 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/controls/controller/ControlsBindingControllerImplTest.kt @@ -116,11 +116,7 @@ class ControlsBindingControllerImplTest : SysuiTestCase() { @Test fun testBindAndLoad_cancel() { - val callback = object : ControlsBindingController.LoadCallback { - override fun error(message: String) {} - - override fun accept(t: List<Control>) {} - } + val callback = mock(ControlsBindingController.LoadCallback::class.java) val subscription = mock(IControlsSubscription::class.java) val canceller = controller.bindAndLoad(TEST_COMPONENT_NAME_1, callback) @@ -130,6 +126,7 @@ class ControlsBindingControllerImplTest : SysuiTestCase() { canceller.run() verify(providers[0]).cancelSubscription(subscription) + verify(callback).error(any()) } @Test |