Merge "Ensure all calls to getCallingUid use the version in mDeps."

This commit is contained in:
Lorenzo Colitti
2021-03-19 07:36:52 +00:00
committed by Gerrit Code Review

View File

@@ -1785,7 +1785,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
// No need to check mLockdownEnabled. If it's true, getVpnUnderlyingNetworks returns null. // No need to check mLockdownEnabled. If it's true, getVpnUnderlyingNetworks returns null.
final Network[] networks = getVpnUnderlyingNetworks(Binder.getCallingUid()); final Network[] networks = getVpnUnderlyingNetworks(mDeps.getCallingUid());
if (null != networks) { if (null != networks) {
for (final Network network : networks) { for (final Network network : networks) {
final NetworkCapabilities nc = getNetworkCapabilitiesInternal(network); final NetworkCapabilities nc = getNetworkCapabilitiesInternal(network);
@@ -3691,7 +3691,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
log("Replacing " + existingRequest.mRequests.get(0) + " with " log("Replacing " + existingRequest.mRequests.get(0) + " with "
+ nri.mRequests.get(0) + " because their intents matched."); + nri.mRequests.get(0) + " because their intents matched.");
} }
handleReleaseNetworkRequest(existingRequest.mRequests.get(0), getCallingUid(), handleReleaseNetworkRequest(existingRequest.mRequests.get(0), mDeps.getCallingUid(),
/* callOnUnavailable */ false); /* callOnUnavailable */ false);
} }
handleRegisterNetworkRequest(nri); handleRegisterNetworkRequest(nri);
@@ -5777,14 +5777,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void releasePendingNetworkRequestWithDelay(PendingIntent operation) { private void releasePendingNetworkRequestWithDelay(PendingIntent operation) {
mHandler.sendMessageDelayed( mHandler.sendMessageDelayed(
mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT, mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT,
getCallingUid(), 0, operation), mReleasePendingIntentDelayMs); mDeps.getCallingUid(), 0, operation), mReleasePendingIntentDelayMs);
} }
@Override @Override
public void releasePendingNetworkRequest(PendingIntent operation) { public void releasePendingNetworkRequest(PendingIntent operation) {
Objects.requireNonNull(operation, "PendingIntent cannot be null."); Objects.requireNonNull(operation, "PendingIntent cannot be null.");
mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT, mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT,
getCallingUid(), 0, operation)); mDeps.getCallingUid(), 0, operation));
} }
// In order to implement the compatibility measure for pre-M apps that call // In order to implement the compatibility measure for pre-M apps that call
@@ -5881,7 +5881,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
public void releaseNetworkRequest(NetworkRequest networkRequest) { public void releaseNetworkRequest(NetworkRequest networkRequest) {
ensureNetworkRequestHasType(networkRequest); ensureNetworkRequestHasType(networkRequest);
mHandler.sendMessage(mHandler.obtainMessage( mHandler.sendMessage(mHandler.obtainMessage(
EVENT_RELEASE_NETWORK_REQUEST, getCallingUid(), 0, networkRequest)); EVENT_RELEASE_NETWORK_REQUEST, mDeps.getCallingUid(), 0, networkRequest));
} }
private void handleRegisterNetworkProvider(NetworkProviderInfo npi) { private void handleRegisterNetworkProvider(NetworkProviderInfo npi) {
@@ -8359,7 +8359,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
final NetworkAgentInfo vpn = getVpnForUid(uid); final NetworkAgentInfo vpn = getVpnForUid(uid);
if (vpn == null || getVpnType(vpn) != VpnManager.TYPE_VPN_SERVICE if (vpn == null || getVpnType(vpn) != VpnManager.TYPE_VPN_SERVICE
|| vpn.networkCapabilities.getOwnerUid() != Binder.getCallingUid()) { || vpn.networkCapabilities.getOwnerUid() != mDeps.getCallingUid()) {
return INVALID_UID; return INVALID_UID;
} }