Create new isNetworkSupported API am: 0114f6e8e9

Original change: undetermined

Change-Id: I4515e99688ec38ecfa5663829a8f02e909ec9083
This commit is contained in:
Robert Greenwalt
2021-05-31 05:02:37 +00:00
committed by Automerger Merge Worker
3 changed files with 26 additions and 0 deletions

View File

@@ -814,4 +814,22 @@ public class ConnectivityManager {
} catch (RemoteException e) {
}
}
/**
* Returns true if the hardware supports the given network type
* else it returns false. This doesn't indicate we have coverage
* or are authorized onto a network, just whether or not the
* hardware supports it. For example a gsm phone without a sim
* should still return true for mobile data, but a wifi only tablet
* would return false.
* @param networkType The nework type we'd like to check
* @return true if supported, else false
* @hide
*/
public boolean isNetworkSupported(int networkType) {
try {
return mService.isNetworkSupported(networkType);
} catch (RemoteException e) {}
return false;
}
}

View File

@@ -43,6 +43,8 @@ interface IConnectivityManager
NetworkInfo getNetworkInfo(int networkType);
NetworkInfo[] getAllNetworkInfo();
boolean isNetworkSupported(int networkType);
LinkProperties getActiveLinkProperties();
LinkProperties getLinkProperties(int networkType);

View File

@@ -703,6 +703,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return result.toArray(new NetworkInfo[result.size()]);
}
@Override
public boolean isNetworkSupported(int networkType) {
enforceAccessPermission();
return (isNetworkTypeValid(networkType) && (mNetTrackers[networkType] != null));
}
/**
* Return LinkProperties for the active (i.e., connected) default
* network interface. It is assumed that at most one default network