am db32c8c5: Merge "Restrict access to protected networks." into honeycomb-LTE

* commit 'db32c8c540fa478e5f89d57f437d2f7e5366e4c3':
  Restrict access to protected networks.
This commit is contained in:
Robert Greenwalt
2011-06-23 08:19:48 -07:00
committed by Android Git Automerger

View File

@@ -250,6 +250,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
RadioAttributes[] mRadioAttributes; RadioAttributes[] mRadioAttributes;
// the set of network types that can only be enabled by system/sig apps
List mProtectedNetworks;
public static synchronized ConnectivityService getInstance(Context context) { public static synchronized ConnectivityService getInstance(Context context) {
if (sServiceInstance == null) { if (sServiceInstance == null) {
sServiceInstance = new ConnectivityService(context); sServiceInstance = new ConnectivityService(context);
@@ -349,6 +352,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
} }
mProtectedNetworks = new ArrayList<Integer>();
int[] protectedNetworks = context.getResources().getIntArray(
com.android.internal.R.array.config_protectedNetworks);
for (int p : protectedNetworks) {
if ((mNetConfigs[p] != null) && (mProtectedNetworks.contains(p) == false)) {
mProtectedNetworks.add(p);
} else {
if (DBG) loge("Ignoring protectedNetwork " + p);
}
}
// high priority first // high priority first
mPriorityList = new int[mNetworksDefined]; mPriorityList = new int[mNetworksDefined];
{ {
@@ -678,6 +692,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
usedNetworkType = networkType; usedNetworkType = networkType;
} }
} }
if (mProtectedNetworks.contains(usedNetworkType)) {
enforceConnectivityInternalPermission();
}
NetworkStateTracker network = mNetTrackers[usedNetworkType]; NetworkStateTracker network = mNetTrackers[usedNetworkType];
if (network != null) { if (network != null) {
Integer currentPid = new Integer(getCallingPid()); Integer currentPid = new Integer(getCallingPid());
@@ -888,6 +907,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
*/ */
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) { public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) {
enforceChangePermission(); enforceChangePermission();
if (mProtectedNetworks.contains(networkType)) {
enforceConnectivityInternalPermission();
}
if (!ConnectivityManager.isNetworkTypeValid(networkType)) { if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
return false; return false;
} }
@@ -1005,7 +1028,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
public void setDataDependency(int networkType, boolean met) { public void setDataDependency(int networkType, boolean met) {
enforceChangePermission(); enforceConnectivityInternalPermission();
if (DBG) { if (DBG) {
log("setDataDependency(" + networkType + ", " + met + ")"); log("setDataDependency(" + networkType + ", " + met + ")");
} }