Skip to content
Snippets Groups Projects
Commit 5f3923b0 authored by Fabián Kozynski's avatar Fabián Kozynski Committed by Android Build Coastguard Worker
Browse files

Unbind TileService onNullBinding

Test: atest TileLifecycleManagerTest
Test: manual: adb shell dumpsys activity service
Test: sts test
Bug: 300903792
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:7cf363d1fe7c474120ae1c4a96c6adc4c8946d9f)
Merged-In: Ia8126ac65432b124683960e3ebf47301ba6172a1
Change-Id: Ia8126ac65432b124683960e3ebf47301ba6172a1
parent 988b22c4
No related branches found
No related tags found
No related merge requests found
......@@ -280,6 +280,11 @@ public class TileLifecycleManager extends BroadcastReceiver implements
handlePendingMessages();
}
@Override
public void onNullBinding(ComponentName name) {
executeSetBindService(false);
}
@Override
public void onServiceDisconnected(ComponentName name) {
if (DEBUG) Log.d(TAG, "onServiceDisconnected " + name);
......
......@@ -373,6 +373,30 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
verify(falseContext).bindServiceAsUser(any(), any(), eq(flags), any());
}
@Test
public void testNullBindingCallsUnbind() {
Context mockContext = mock(Context.class);
// Binding has to succeed
when(mockContext.bindServiceAsUser(any(), any(), anyInt(), any())).thenReturn(true);
TileLifecycleManager manager = new TileLifecycleManager(mHandler, mockContext,
mock(IQSService.class),
mMockPackageManagerAdapter,
mMockBroadcastDispatcher,
mTileServiceIntent,
mUser,
mExecutor);
manager.executeSetBindService(true);
mExecutor.runAllReady();
ArgumentCaptor<ServiceConnection> captor = ArgumentCaptor.forClass(ServiceConnection.class);
verify(mockContext).bindServiceAsUser(any(), captor.capture(), anyInt(), any());
captor.getValue().onNullBinding(mTileServiceComponentName);
mExecutor.runAllReady();
verify(mockContext).unbindService(captor.getValue());
}
private void mockChangeEnabled(long changeId, boolean enabled) {
doReturn(enabled).when(() -> CompatChanges.isChangeEnabled(eq(changeId), anyString(),
any(UserHandle.class)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment