diff options
author | Fyodor Kupolov <fkupolov@google.com> | 2015-09-08 14:41:41 -0700 |
---|---|---|
committer | Fyodor Kupolov <fkupolov@google.com> | 2015-10-14 17:37:01 -0700 |
commit | 12167e21e1371720b49055ce69a178727d0ae37c (patch) | |
tree | 54ff83899ca99f563fa570d90ddad44960e3eacc /service/java | |
parent | a7d7d91ebbeb326d9d41e05768aa5f5667e68106 (diff) | |
download | android_frameworks_opt_net_wifi-12167e21e1371720b49055ce69a178727d0ae37c.tar.gz android_frameworks_opt_net_wifi-12167e21e1371720b49055ce69a178727d0ae37c.tar.bz2 android_frameworks_opt_net_wifi-12167e21e1371720b49055ce69a178727d0ae37c.zip |
Do not throw an exception if appop's result is MODE_IGNORED
Previously, an exception was thrown when a result of checking for an app op
was MODE_IGNORED. We should return zero results instead.
Bug: 23675817
Bug: 23563867
Change-Id: Iba6b6eca8a0d21acd77b8d388b8bfe3119cac8f9
Diffstat (limited to 'service/java')
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 2b83b6884..b02556614 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -2064,29 +2064,24 @@ public final class WifiServiceImpl extends IWifiManager.Stub { private boolean checkCallerCanAccessScanResults(String callingPackage, int uid) { if (ActivityManager.checkUidPermission(Manifest.permission.ACCESS_FINE_LOCATION, uid) == PackageManager.PERMISSION_GRANTED - && isAppOppAllowed(AppOpsManager.OP_FINE_LOCATION, callingPackage, uid)) { + && checkAppOppAllowed(AppOpsManager.OP_FINE_LOCATION, callingPackage, uid)) { return true; } if (ActivityManager.checkUidPermission(Manifest.permission.ACCESS_COARSE_LOCATION, uid) == PackageManager.PERMISSION_GRANTED - && isAppOppAllowed(AppOpsManager.OP_COARSE_LOCATION, callingPackage, uid)) { + && checkAppOppAllowed(AppOpsManager.OP_COARSE_LOCATION, callingPackage, uid)) { return true; } - // Enforce location permission for apps targeting M and later versions - boolean enforceLocationPermission = true; + boolean apiLevel23App = true; try { - enforceLocationPermission = mContext.getPackageManager().getApplicationInfo( + apiLevel23App = mContext.getPackageManager().getApplicationInfo( callingPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M; } catch (PackageManager.NameNotFoundException e) { - // In case of exception, enforce permission anyway - } - if (enforceLocationPermission) { - throw new SecurityException("Need ACCESS_COARSE_LOCATION or " - + "ACCESS_FINE_LOCATION permission to get scan results"); + // In case of exception, assume app's API level is 23+ } // Pre-M apps running in the foreground should continue getting scan results - if (isForegroundApp(callingPackage)) { + if (!apiLevel23App && isForegroundApp(callingPackage)) { return true; } Log.e(TAG, "Permission denial: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION " @@ -2094,7 +2089,7 @@ public final class WifiServiceImpl extends IWifiManager.Stub { return false; } - private boolean isAppOppAllowed(int op, String callingPackage, int uid) { + private boolean checkAppOppAllowed(int op, String callingPackage, int uid) { return mAppOps.noteOp(op, uid, callingPackage) == AppOpsManager.MODE_ALLOWED; } |