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:
parent
bd0c0af47f
commit
5b52bef8d8
2 changed files with 36 additions and 1 deletions
|
|
@ -766,6 +766,28 @@ public class ConnectivityManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Network} object corresponding to the currently active
|
||||
* default data network for a specific UID. In the event that the default data
|
||||
* network disconnects, the returned {@code Network} object will no longer
|
||||
* be usable. This will return {@code null} when there is no default
|
||||
* network for the UID.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
|
||||
*
|
||||
* @return a {@link Network} object for the current default network for the
|
||||
* given UID or {@code null} if no default network is currently active
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public Network getActiveNetworkForUid(int uid) {
|
||||
try {
|
||||
return mService.getActiveNetworkForUid(uid);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an always-on VPN connection through a specific application.
|
||||
* This connection is automatically granted and persisted after a reboot.
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import com.android.internal.net.VpnProfile;
|
|||
interface IConnectivityManager
|
||||
{
|
||||
Network getActiveNetwork();
|
||||
Network getActiveNetworkForUid(int uid);
|
||||
NetworkInfo getActiveNetworkInfo();
|
||||
NetworkInfo getActiveNetworkInfoForUid(int uid);
|
||||
NetworkInfo getNetworkInfo(int networkType);
|
||||
|
|
|
|||
Loading…
Reference in a new issue