Loading core/java/android/app/AppOpsManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,9 @@ public class AppOpsManager { /** @hide Continually monitoring location data with a relatively high power request. */ public static final int OP_MONITOR_HIGH_POWER_LOCATION = 42; /** @hide */ public static final int _NUM_OP = 43; public static final int OP_WIFI_CHANGE = 43; /** @hide */ public static final int _NUM_OP = 44; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = Loading Loading @@ -262,6 +264,7 @@ public class AppOpsManager { OP_WAKE_LOCK, OP_COARSE_LOCATION, OP_COARSE_LOCATION, OP_WIFI_CHANGE, }; /** Loading Loading @@ -312,6 +315,7 @@ public class AppOpsManager { null, OPSTR_MONITOR_LOCATION, OPSTR_MONITOR_HIGH_POWER_LOCATION, null, }; /** Loading Loading @@ -362,6 +366,7 @@ public class AppOpsManager { "WAKE_LOCK", "MONITOR_LOCATION", "MONITOR_HIGH_POWER_LOCATION", "WIFI_CHANGE", }; /** Loading Loading @@ -412,6 +417,7 @@ public class AppOpsManager { android.Manifest.permission.WAKE_LOCK, null, // no permission for generic location monitoring null, // no permission for high power location monitoring android.Manifest.permission.CHANGE_WIFI_STATE, }; /** Loading Loading @@ -461,6 +467,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_WAKE_LOCK AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ALLOWED, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ALLOWED, // OP_WIFI_CHANGE }; /** Loading Loading @@ -510,6 +517,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_WAKE_LOCK AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ASK, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ASK, // OP_WIFI_CHANGE }; Loading Loading @@ -564,6 +572,7 @@ public class AppOpsManager { false, false, false, false, }; private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); Loading core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1356,5 +1356,6 @@ <item>Trying to Keep device awake</item> <item>Trying to access location</item> <item>Trying to access location</item> <item>Trying to turn on/off Wifi</item> </string-array> </resources> wifi/java/android/net/wifi/WifiManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net.wifi; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.AppOpsManager; import android.content.Context; import android.net.DhcpInfo; import android.os.Binder; Loading Loading @@ -546,6 +547,7 @@ public class WifiManager { private static final Object sThreadRefLock = new Object(); private static int sThreadRefCount; private static HandlerThread sHandlerThread; private final AppOpsManager mAppOps; /** * Create a new WifiManager instance. Loading @@ -561,6 +563,7 @@ public class WifiManager { mContext = context; mService = service; init(); mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE); } /** Loading Loading @@ -1004,6 +1007,9 @@ public class WifiManager { * is the same as the requested state). */ public boolean setWifiEnabled(boolean enabled) { if (mAppOps.noteOp(AppOpsManager.OP_WIFI_CHANGE) != AppOpsManager.MODE_ALLOWED) return false; try { return mService.setWifiEnabled(enabled); } catch (RemoteException e) { Loading Loading
core/java/android/app/AppOpsManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,9 @@ public class AppOpsManager { /** @hide Continually monitoring location data with a relatively high power request. */ public static final int OP_MONITOR_HIGH_POWER_LOCATION = 42; /** @hide */ public static final int _NUM_OP = 43; public static final int OP_WIFI_CHANGE = 43; /** @hide */ public static final int _NUM_OP = 44; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = Loading Loading @@ -262,6 +264,7 @@ public class AppOpsManager { OP_WAKE_LOCK, OP_COARSE_LOCATION, OP_COARSE_LOCATION, OP_WIFI_CHANGE, }; /** Loading Loading @@ -312,6 +315,7 @@ public class AppOpsManager { null, OPSTR_MONITOR_LOCATION, OPSTR_MONITOR_HIGH_POWER_LOCATION, null, }; /** Loading Loading @@ -362,6 +366,7 @@ public class AppOpsManager { "WAKE_LOCK", "MONITOR_LOCATION", "MONITOR_HIGH_POWER_LOCATION", "WIFI_CHANGE", }; /** Loading Loading @@ -412,6 +417,7 @@ public class AppOpsManager { android.Manifest.permission.WAKE_LOCK, null, // no permission for generic location monitoring null, // no permission for high power location monitoring android.Manifest.permission.CHANGE_WIFI_STATE, }; /** Loading Loading @@ -461,6 +467,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_WAKE_LOCK AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ALLOWED, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ALLOWED, // OP_WIFI_CHANGE }; /** Loading Loading @@ -510,6 +517,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_WAKE_LOCK AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ASK, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ASK, // OP_WIFI_CHANGE }; Loading Loading @@ -564,6 +572,7 @@ public class AppOpsManager { false, false, false, false, }; private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); Loading
core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1356,5 +1356,6 @@ <item>Trying to Keep device awake</item> <item>Trying to access location</item> <item>Trying to access location</item> <item>Trying to turn on/off Wifi</item> </string-array> </resources>
wifi/java/android/net/wifi/WifiManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net.wifi; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.AppOpsManager; import android.content.Context; import android.net.DhcpInfo; import android.os.Binder; Loading Loading @@ -546,6 +547,7 @@ public class WifiManager { private static final Object sThreadRefLock = new Object(); private static int sThreadRefCount; private static HandlerThread sHandlerThread; private final AppOpsManager mAppOps; /** * Create a new WifiManager instance. Loading @@ -561,6 +563,7 @@ public class WifiManager { mContext = context; mService = service; init(); mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE); } /** Loading Loading @@ -1004,6 +1007,9 @@ public class WifiManager { * is the same as the requested state). */ public boolean setWifiEnabled(boolean enabled) { if (mAppOps.noteOp(AppOpsManager.OP_WIFI_CHANGE) != AppOpsManager.MODE_ALLOWED) return false; try { return mService.setWifiEnabled(enabled); } catch (RemoteException e) { Loading