Loading services/core/java/com/android/server/ConnectivityService.java +22 −14 Original line number Diff line number Diff line Loading @@ -1712,16 +1712,17 @@ public class ConnectivityService extends IConnectivityManager.Stub return newNc; } Binder.withCleanCallingIdentity( () -> { final long token = Binder.clearCallingIdentity(); try { if (!mLocationPermissionChecker.checkLocationPermission( callerPkgName, null /* featureId */, callerUid, null /* message */)) { // Caller does not have the requisite location permissions. Reset the // owner's UID in the NetworkCapabilities. newNc.setOwnerUid(INVALID_UID); } } finally { Binder.restoreCallingIdentity(token); } ); return newNc; } Loading Loading @@ -3906,8 +3907,12 @@ public class ConnectivityService extends IConnectivityManager.Stub new CaptivePortal(new CaptivePortalImpl(network).asBinder())); appIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); Binder.withCleanCallingIdentity(() -> mContext.startActivityAsUser(appIntent, UserHandle.CURRENT)); final long token = Binder.clearCallingIdentity(); try { mContext.startActivityAsUser(appIntent, UserHandle.CURRENT); } finally { Binder.restoreCallingIdentity(token); } } private class CaptivePortalImpl extends ICaptivePortal.Stub { Loading Loading @@ -7800,10 +7805,13 @@ public class ConnectivityService extends IConnectivityManager.Stub final int userId = UserHandle.getCallingUserId(); Binder.withCleanCallingIdentity(() -> { final long token = Binder.clearCallingIdentity(); try { final IpMemoryStore ipMemoryStore = IpMemoryStore.getMemoryStore(mContext); ipMemoryStore.factoryReset(); }); } finally { Binder.restoreCallingIdentity(token); } // Turn airplane mode off setAirplaneMode(false); Loading services/core/java/com/android/server/TestNetworkService.java +23 −18 Original line number Diff line number Diff line Loading @@ -107,8 +107,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { String ifacePrefix = isTun ? TEST_TUN_PREFIX : TEST_TAP_PREFIX; String iface = ifacePrefix + sTestTunIndex.getAndIncrement(); return Binder.withCleanCallingIdentity( () -> { final long token = Binder.clearCallingIdentity(); try { ParcelFileDescriptor tunIntf = ParcelFileDescriptor.adoptFd(jniCreateTunTap(isTun, iface)); Loading @@ -122,8 +121,9 @@ class TestNetworkService extends ITestNetworkManager.Stub { return new TestNetworkInterface(tunIntf, iface); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } finally { Binder.restoreCallingIdentity(token); } }); } /** Loading Loading @@ -317,7 +317,12 @@ class TestNetworkService extends ITestNetworkManager.Stub { try { // This requires NETWORK_STACK privileges. Binder.withCleanCallingIdentity(() -> mNMS.setInterfaceUp(iface)); final long token = Binder.clearCallingIdentity(); try { mNMS.setInterfaceUp(iface); } finally { Binder.restoreCallingIdentity(token); } // Synchronize all accesses to mTestNetworkTracker to prevent the case where: // 1. TestNetworkAgent successfully binds to death of binder Loading Loading
services/core/java/com/android/server/ConnectivityService.java +22 −14 Original line number Diff line number Diff line Loading @@ -1712,16 +1712,17 @@ public class ConnectivityService extends IConnectivityManager.Stub return newNc; } Binder.withCleanCallingIdentity( () -> { final long token = Binder.clearCallingIdentity(); try { if (!mLocationPermissionChecker.checkLocationPermission( callerPkgName, null /* featureId */, callerUid, null /* message */)) { // Caller does not have the requisite location permissions. Reset the // owner's UID in the NetworkCapabilities. newNc.setOwnerUid(INVALID_UID); } } finally { Binder.restoreCallingIdentity(token); } ); return newNc; } Loading Loading @@ -3906,8 +3907,12 @@ public class ConnectivityService extends IConnectivityManager.Stub new CaptivePortal(new CaptivePortalImpl(network).asBinder())); appIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); Binder.withCleanCallingIdentity(() -> mContext.startActivityAsUser(appIntent, UserHandle.CURRENT)); final long token = Binder.clearCallingIdentity(); try { mContext.startActivityAsUser(appIntent, UserHandle.CURRENT); } finally { Binder.restoreCallingIdentity(token); } } private class CaptivePortalImpl extends ICaptivePortal.Stub { Loading Loading @@ -7800,10 +7805,13 @@ public class ConnectivityService extends IConnectivityManager.Stub final int userId = UserHandle.getCallingUserId(); Binder.withCleanCallingIdentity(() -> { final long token = Binder.clearCallingIdentity(); try { final IpMemoryStore ipMemoryStore = IpMemoryStore.getMemoryStore(mContext); ipMemoryStore.factoryReset(); }); } finally { Binder.restoreCallingIdentity(token); } // Turn airplane mode off setAirplaneMode(false); Loading
services/core/java/com/android/server/TestNetworkService.java +23 −18 Original line number Diff line number Diff line Loading @@ -107,8 +107,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { String ifacePrefix = isTun ? TEST_TUN_PREFIX : TEST_TAP_PREFIX; String iface = ifacePrefix + sTestTunIndex.getAndIncrement(); return Binder.withCleanCallingIdentity( () -> { final long token = Binder.clearCallingIdentity(); try { ParcelFileDescriptor tunIntf = ParcelFileDescriptor.adoptFd(jniCreateTunTap(isTun, iface)); Loading @@ -122,8 +121,9 @@ class TestNetworkService extends ITestNetworkManager.Stub { return new TestNetworkInterface(tunIntf, iface); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } finally { Binder.restoreCallingIdentity(token); } }); } /** Loading Loading @@ -317,7 +317,12 @@ class TestNetworkService extends ITestNetworkManager.Stub { try { // This requires NETWORK_STACK privileges. Binder.withCleanCallingIdentity(() -> mNMS.setInterfaceUp(iface)); final long token = Binder.clearCallingIdentity(); try { mNMS.setInterfaceUp(iface); } finally { Binder.restoreCallingIdentity(token); } // Synchronize all accesses to mTestNetworkTracker to prevent the case where: // 1. TestNetworkAgent successfully binds to death of binder Loading