Merge "Reinstate CHANGE_NETWORK_STATE as a normal permission." into mnc-dr-dev am: 809dcade99 am: bdc458048a am: bb8f652372
am: 550cc7cfd2
* commit '550cc7cfd2e8f93c8cb6e59078ce9c16d93c912a':
Reinstate CHANGE_NETWORK_STATE as a normal permission.
This commit is contained in:
@@ -901,8 +901,12 @@ public class ConnectivityManager {
|
||||
* Tells the underlying networking system that the caller wants to
|
||||
* begin using the named feature. The interpretation of {@code feature}
|
||||
* is completely up to each networking implementation.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param networkType specifies which network the request pertains to
|
||||
* @param feature the name of the feature to be used
|
||||
* @return an integer value representing the outcome of the request.
|
||||
@@ -952,8 +956,12 @@ public class ConnectivityManager {
|
||||
* Tells the underlying networking system that the caller is finished
|
||||
* using the named feature. The interpretation of {@code feature}
|
||||
* is completely up to each networking implementation.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param networkType specifies which network the request pertains to
|
||||
* @param feature the name of the feature that is no longer needed
|
||||
* @return an integer value representing the outcome of the request.
|
||||
@@ -1339,8 +1347,12 @@ public class ConnectivityManager {
|
||||
* Ensure that a network route exists to deliver traffic to the specified
|
||||
* host via the specified network interface. An attempt to add a route that
|
||||
* already exists is ignored, but treated as successful.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param networkType the type of the network over which traffic to the specified
|
||||
* host is to be routed
|
||||
* @param hostAddress the IP address of the host to which the route is desired
|
||||
@@ -1360,8 +1372,12 @@ public class ConnectivityManager {
|
||||
* Ensure that a network route exists to deliver traffic to the specified
|
||||
* host via the specified network interface. An attempt to add a route that
|
||||
* already exists is ignored, but treated as successful.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param networkType the type of the network over which traffic to the specified
|
||||
* host is to be routed
|
||||
* @param hostAddress the IP address of the host to which the route is desired
|
||||
@@ -1561,6 +1577,13 @@ public class ConnectivityManager {
|
||||
return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public static final void enforceChangePermission(Context context) {
|
||||
int uid = Binder.getCallingUid();
|
||||
Settings.checkAndNoteChangeNetworkStateOperation(context, uid, Settings
|
||||
.getPackageNameForUid(context, uid), true /* throwException */);
|
||||
}
|
||||
|
||||
/** {@hide */
|
||||
public static final void enforceTetherChangePermission(Context context) {
|
||||
if (context.getResources().getStringArray(
|
||||
@@ -1571,8 +1594,8 @@ public class ConnectivityManager {
|
||||
android.Manifest.permission.CONNECTIVITY_INTERNAL, "ConnectivityService");
|
||||
} else {
|
||||
int uid = Binder.getCallingUid();
|
||||
Settings.checkAndNoteChangeNetworkStateOperation(context, uid, Settings
|
||||
.getPackageNameForUid(context, uid), true);
|
||||
Settings.checkAndNoteWriteSettingsOperation(context, uid, Settings
|
||||
.getPackageNameForUid(context, uid), true /* throwException */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1677,8 +1700,11 @@ public class ConnectivityManager {
|
||||
* allowed between the tethered devices and this device, though upstream net
|
||||
* access will of course fail until an upstream network interface becomes
|
||||
* active.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param iface the interface name to tether.
|
||||
* @return error a {@code TETHER_ERROR} value indicating success or failure type
|
||||
@@ -1695,8 +1721,11 @@ public class ConnectivityManager {
|
||||
|
||||
/**
|
||||
* Stop tethering the named interface.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param iface the interface name to untether.
|
||||
* @return error a {@code TETHER_ERROR} value indicating success or failure type
|
||||
@@ -1796,8 +1825,11 @@ public class ConnectivityManager {
|
||||
* attempt to switch to Rndis and subsequently tether the resulting
|
||||
* interface on {@code true} or turn off tethering and switch off
|
||||
* Rndis on {@code false}.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param enable a boolean - {@code true} to enable tethering
|
||||
* @return error a {@code TETHER_ERROR} value indicating success or failure type
|
||||
@@ -2467,8 +2499,11 @@ public class ConnectivityManager {
|
||||
* network may never attain, and whether a network will attain these states
|
||||
* is unknown prior to bringing up the network so the framework does not
|
||||
* know how to go about satisfing a request with these capabilities.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The {@link NetworkCallback} to be utilized for this
|
||||
@@ -2490,8 +2525,12 @@ public class ConnectivityManager {
|
||||
* network is not found within the given time (in milliseconds) the
|
||||
* {@link NetworkCallback#unavailable} callback is called. The request must
|
||||
* still be released normally by calling {@link releaseNetworkRequest}.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param networkCallback The callbacks to be utilized for this request. Note
|
||||
* the callbacks must not be shared - they uniquely specify
|
||||
@@ -2564,8 +2603,12 @@ public class ConnectivityManager {
|
||||
* network may never attain, and whether a network will attain these states
|
||||
* is unknown prior to bringing up the network so the framework does not
|
||||
* know how to go about satisfing a request with these capabilities.
|
||||
* <p>This method requires the caller to hold the permission
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
|
||||
*
|
||||
* <p>This method requires the caller to hold either the
|
||||
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
|
||||
* or the ability to modify system settings as determined by
|
||||
* {@link android.provider.Settings.System#canWrite}.</p>
|
||||
*
|
||||
* @param request {@link NetworkRequest} describing this request.
|
||||
* @param operation Action to perform when the network is available (corresponds
|
||||
* to the {@link NetworkCallback#onAvailable} call. Typically
|
||||
|
||||
@@ -1450,10 +1450,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
private void enforceChangePermission() {
|
||||
int uid = Binder.getCallingUid();
|
||||
Settings.checkAndNoteChangeNetworkStateOperation(mContext, uid, Settings
|
||||
.getPackageNameForUid(mContext, uid), true);
|
||||
|
||||
ConnectivityManager.enforceChangePermission(mContext);
|
||||
}
|
||||
|
||||
private void enforceTetherAccessPermission() {
|
||||
|
||||
Reference in New Issue
Block a user