summaryrefslogtreecommitdiffstats
path: root/wifi/java/android
diff options
context:
space:
mode:
authorShashank Mittal <mittals@codeaurora.org>2014-09-05 16:03:20 -0700
committerRoman Birg <roman@cyngn.com>2015-10-29 11:01:55 -0700
commit93a5bde8b9d03c5285bf504c1180946abd83de64 (patch)
treeac994b443f145764201155efc3778c359f25ab5c /wifi/java/android
parent43eded91cdd545b1a41933aa85f8b910b43244dd (diff)
downloadframeworks_base-93a5bde8b9d03c5285bf504c1180946abd83de64.zip
frameworks_base-93a5bde8b9d03c5285bf504c1180946abd83de64.tar.gz
frameworks_base-93a5bde8b9d03c5285bf504c1180946abd83de64.tar.bz2
wifi: Confirm user permission before toggling wifi
Check user permissions before enabling/disabling wifi. Change-Id: I1ddae6e47f42b6d3fc831c2c135ece75cf9e935d
Diffstat (limited to 'wifi/java/android')
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 6b6be54e..46ae8d3 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -1,4 +1,7 @@
/*
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,6 +22,7 @@ package android.net.wifi;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.app.AppOpsManager;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
@@ -623,6 +627,7 @@ public class WifiManager {
private static final Object sThreadRefLock = new Object();
private static int sThreadRefCount;
private static HandlerThread sHandlerThread;
+ private final AppOpsManager mAppOps;
@GuardedBy("sCM")
// TODO: Introduce refcounting and make this a per-process static callback, instead of a
@@ -644,6 +649,7 @@ public class WifiManager {
mService = service;
mTargetSdkVersion = context.getApplicationInfo().targetSdkVersion;
init();
+ mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
}
/**
@@ -1454,6 +1460,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) {