Merge changes from topic "cherrypicker-L53700000954454916:N44100001263878999" into tm-dev

* changes:
  Check carrier privilege for CBS network requests synchronously
  Allow 3p apps to request restricted networks
This commit is contained in:
Paul Hu
2022-05-12 02:48:34 +00:00
committed by Android (Google) Code Review
4 changed files with 93 additions and 79 deletions

View File

@@ -5880,7 +5880,7 @@ public class ConnectivityServiceTest {
}
/**
* Validate the callback flow CBS request without carrier privilege.
* Validate the service throws if request with CBS but without carrier privilege.
*/
@Test
public void testCBSRequestWithoutCarrierPrivilege() throws Exception {
@@ -5889,10 +5889,8 @@ public class ConnectivityServiceTest {
final TestNetworkCallback networkCallback = new TestNetworkCallback();
mServiceContext.setPermission(CONNECTIVITY_USE_RESTRICTED_NETWORKS, PERMISSION_DENIED);
// Now file the test request and expect it.
mCm.requestNetwork(nr, networkCallback);
networkCallback.expectCallback(CallbackEntry.UNAVAILABLE, (Network) null);
mCm.unregisterNetworkCallback(networkCallback);
// Now file the test request and expect the service throws.
assertThrows(SecurityException.class, () -> mCm.requestNetwork(nr, networkCallback));
}
private static class TestKeepaliveCallback extends PacketKeepaliveCallback {