am 1011960c: am decfd707: Merge "Add the calling package name to requestRouteToHost" into klp-dev

* commit '1011960c44a4f84d53d05199fe1ca09be9473822':
  Add the calling package name to requestRouteToHost
This commit is contained in:
Chad Brubaker
2014-03-12 23:21:02 +00:00
committed by Android Git Automerger
3 changed files with 12 additions and 8 deletions

View File

@@ -395,6 +395,8 @@ public class ConnectivityManager {
private final IConnectivityManager mService; private final IConnectivityManager mService;
private final String mPackageName;
/** /**
* Tests if a given integer represents a valid network type. * Tests if a given integer represents a valid network type.
* @param networkType the type to be tested * @param networkType the type to be tested
@@ -802,7 +804,7 @@ public class ConnectivityManager {
public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
byte[] address = hostAddress.getAddress(); byte[] address = hostAddress.getAddress();
try { try {
return mService.requestRouteToHostAddress(networkType, address); return mService.requestRouteToHostAddress(networkType, address, mPackageName);
} catch (RemoteException e) { } catch (RemoteException e) {
return false; return false;
} }
@@ -898,8 +900,9 @@ public class ConnectivityManager {
/** /**
* {@hide} * {@hide}
*/ */
public ConnectivityManager(IConnectivityManager service) { public ConnectivityManager(IConnectivityManager service, String packageName) {
mService = checkNotNull(service, "missing IConnectivityManager"); mService = checkNotNull(service, "missing IConnectivityManager");
mPackageName = checkNotNull(packageName, "missing package name");
} }
/** {@hide} */ /** {@hide} */

View File

@@ -71,9 +71,9 @@ interface IConnectivityManager
int stopUsingNetworkFeature(int networkType, in String feature); int stopUsingNetworkFeature(int networkType, in String feature);
boolean requestRouteToHost(int networkType, int hostAddress); boolean requestRouteToHost(int networkType, int hostAddress, String packageName);
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress); boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName);
boolean getMobileDataEnabled(); boolean getMobileDataEnabled();
void setMobileDataEnabled(boolean enabled); void setMobileDataEnabled(boolean enabled);

View File

@@ -1537,14 +1537,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* desired * desired
* @return {@code true} on success, {@code false} on failure * @return {@code true} on success, {@code false} on failure
*/ */
public boolean requestRouteToHost(int networkType, int hostAddress) { public boolean requestRouteToHost(int networkType, int hostAddress, String packageName) {
InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
if (inetAddress == null) { if (inetAddress == null) {
return false; return false;
} }
return requestRouteToHostAddress(networkType, inetAddress.getAddress()); return requestRouteToHostAddress(networkType, inetAddress.getAddress(), packageName);
} }
/** /**
@@ -1556,7 +1556,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* desired * desired
* @return {@code true} on success, {@code false} on failure * @return {@code true} on success, {@code false} on failure
*/ */
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) { public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress,
String packageName) {
enforceChangePermission(); enforceChangePermission();
if (mProtectedNetworks.contains(networkType)) { if (mProtectedNetworks.contains(networkType)) {
enforceConnectivityInternalPermission(); enforceConnectivityInternalPermission();
@@ -4354,7 +4355,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// Make a route to host so we check the specific interface. // Make a route to host so we check the specific interface.
if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI, if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI,
hostAddr.getAddress())) { hostAddr.getAddress(), null)) {
// Wait a short time to be sure the route is established ?? // Wait a short time to be sure the route is established ??
log("isMobileOk:" log("isMobileOk:"
+ " wait to establish route to hostAddr=" + hostAddr); + " wait to establish route to hostAddr=" + hostAddr);