Internal API for system apps to determine default network for other apps

Callers with CONNECTIVITY_INTERNAL permission can read off the netId
that an application is assigned to by default.

Necessary for making connections as the default network for a client
app eg. when downloading stuff on its behalf.

Bug: 27074270
Change-Id: I8d35e8e99126875f55f3c545090326f3e9be43fb
This commit is contained in:
Robin Lee 2016-03-24 12:07:00 +00:00
commit da4d2e2b67

View file

@ -1006,7 +1006,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
@Override
public Network getActiveNetwork() {
enforceAccessPermission();
final int uid = Binder.getCallingUid();
return getActiveNetworkForUidInternal(Binder.getCallingUid());
}
@Override
public Network getActiveNetworkForUid(int uid) {
enforceConnectivityInternalPermission();
return getActiveNetworkForUidInternal(uid);
}
private Network getActiveNetworkForUidInternal(final int uid) {
final int user = UserHandle.getUserId(uid);
int vpnNetId = NETID_UNSET;
synchronized (mVpns) {