summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorc_jyuan <yuanjiao@codeaurora.org>2016-06-14 15:53:44 +0800
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:07:54 -0600
commit42750c90ef88f4e707f75be27fcb071896852e8c (patch)
tree59d1aeebd3f5d57f120eb4167249f17c797fcffb
parent9006e6755799ec95c74596be08998b1ba55a4e00 (diff)
downloadandroid_frameworks_opt_net_wifi-42750c90ef88f4e707f75be27fcb071896852e8c.tar.gz
android_frameworks_opt_net_wifi-42750c90ef88f4e707f75be27fcb071896852e8c.tar.bz2
android_frameworks_opt_net_wifi-42750c90ef88f4e707f75be27fcb071896852e8c.zip
framework/opt/net/wifi: Add noteOp when enable wifi
Add noteOp when enable wifi for CTA test Change-Id: Iaf8cbe48571acb969ca8ba2cfe302b7b3df33408
-rwxr-xr-x[-rw-r--r--]service/java/com/android/server/wifi/WifiServiceImpl.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 7193580de..f0eb1704b 100644..100755
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -30,6 +30,7 @@ import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED;
import android.Manifest;
import android.app.ActivityManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.app.AppOpsManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
@@ -112,6 +113,8 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import android.app.AppOpsManager;
+import android.os.SystemProperties;
/**
* WifiService handles remote WiFi operation requests by implementing
@@ -543,6 +546,10 @@ public class WifiServiceImpl extends IWifiManager.Stub {
"ConnectivityService");
}
+ private boolean isStrictOpEnable() {
+ return SystemProperties.getBoolean("persist.sys.strict_op_enable", false);
+ }
+
/**
* see {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)}
* @param enable {@code true} to enable, {@code false} to disable.
@@ -553,7 +560,16 @@ public class WifiServiceImpl extends IWifiManager.Stub {
enforceChangePermission();
Slog.d(TAG, "setWifiEnabled: " + enable + " pid=" + Binder.getCallingPid()
+ ", uid=" + Binder.getCallingUid());
-
+ if(isStrictOpEnable()){
+ String packageName = mContext.getPackageManager().getNameForUid(Binder.getCallingUid());
+ if((Binder.getCallingUid() > 10000) && (packageName.indexOf("android.uid.systemui") !=0) && (packageName.indexOf("android.uid.system") != 0)) {
+ AppOpsManager mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
+ int result = mAppOpsManager.noteOp(AppOpsManager.OP_CHANGE_WIFI_STATE,Binder.getCallingUid(),packageName);
+ if(result == AppOpsManager.MODE_IGNORED){
+ return false;
+ }
+ }
+ }
/*
* Caller might not have WRITE_SECURE_SETTINGS,
* only CHANGE_WIFI_STATE is enforced