Merge "Use unified Tethering Permission Check" into lmp-dev

This commit is contained in:
Robert Greenwalt 2014-09-18 00:02:15 +00:00 • committed by Android (Google) Code Review
commit ab9254efd3

View file

@ -1402,6 +1402,20 @@ public class ConnectivityManager {
return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}
/** {@hide */
public static final void enforceTetherChangePermission(Context context) {
if (context.getResources().getStringArray(
com.android.internal.R.array.config_mobile_hotspot_provision_app).length == 2) {
// Have a provisioning app - must only let system apps (which check this app)
// turn on tethering
context.enforceCallingOrSelfPermission(
android.Manifest.permission.CONNECTIVITY_INTERNAL, "ConnectivityService");
} else {
context.enforceCallingOrSelfPermission(
android.Manifest.permission.CHANGE_NETWORK_STATE, "ConnectivityService");
}
}
/**
* Get the set of tetherable, available interfaces. This list is limited by
* device configuration and current interface existence.