Merge "Handle onNullBinding" into sc-qpr1-dev am: b785d6d94e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15854017 Change-Id: I12a796310313629f321e055ee40cc8903a05bc0a
This commit is contained in:
@@ -1536,7 +1536,7 @@ abstract public class ManagedServices {
|
|||||||
@Override
|
@Override
|
||||||
public void onNullBinding(ComponentName name) {
|
public void onNullBinding(ComponentName name) {
|
||||||
Slog.v(TAG, "onNullBinding() called with: name = [" + name + "]");
|
Slog.v(TAG, "onNullBinding() called with: name = [" + name + "]");
|
||||||
mServicesBound.remove(servicesBindingTag);
|
mContext.unbindService(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!mContext.bindServiceAsUser(intent,
|
if (!mContext.bindServiceAsUser(intent,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import com.google.android.collect.Lists;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
@@ -1320,16 +1321,15 @@ public class ManagedServicesTest extends UiServiceTestCase {
|
|||||||
APPROVAL_BY_COMPONENT);
|
APPROVAL_BY_COMPONENT);
|
||||||
ComponentName cn = ComponentName.unflattenFromString("a/a");
|
ComponentName cn = ComponentName.unflattenFromString("a/a");
|
||||||
|
|
||||||
service.registerSystemService(cn, 0);
|
ArgumentCaptor<ServiceConnection> captor = ArgumentCaptor.forClass(ServiceConnection.class);
|
||||||
when(context.bindServiceAsUser(any(), any(), anyInt(), any())).thenAnswer(invocation -> {
|
when(context.bindServiceAsUser(any(), captor.capture(), anyInt(), any()))
|
||||||
Object[] args = invocation.getArguments();
|
.thenAnswer(invocation -> {
|
||||||
ServiceConnection sc = (ServiceConnection) args[1];
|
captor.getValue().onNullBinding(cn);
|
||||||
sc.onNullBinding(cn);
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
service.registerSystemService(cn, 0);
|
service.registerSystemService(cn, 0);
|
||||||
assertFalse(service.isBound(cn, 0));
|
verify(context).unbindService(captor.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user