summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2015-10-16 22:33:54 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-10-16 22:33:54 +0000
commit9af179986539ea927978f61262a33223f39a5f19 (patch)
treee6e956236af1360aacaa404af5b087e4f956c44c
parenta8249332821bd9be23df911aa9e0fbe5eac4f22a (diff)
parentbe964f00e71597f880c051772e8acd1a44b08e17 (diff)
downloadandroid_frameworks_opt_net_wifi-9af179986539ea927978f61262a33223f39a5f19.tar.gz
android_frameworks_opt_net_wifi-9af179986539ea927978f61262a33223f39a5f19.tar.bz2
android_frameworks_opt_net_wifi-9af179986539ea927978f61262a33223f39a5f19.zip
am be964f00: am 35f3b9ce: Merge "Fix foreground scans for pre-M apps when location is disabled" into mnc-dr-dev
* commit 'be964f00e71597f880c051772e8acd1a44b08e17': Fix foreground scans for pre-M apps when location is disabled
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 1a790ef36..33ce852e2 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -988,7 +988,7 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
long ident = Binder.clearCallingIdentity();
try {
if (!canReadPeerMacAddresses && !isActiveNetworkScorer
- && !isLocationEnabled()) {
+ && !isLocationEnabled(callingPackage)) {
return new ArrayList<ScanResult>();
}
if (!canReadPeerMacAddresses && !isActiveNetworkScorer
@@ -1008,9 +1008,12 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
}
}
- private boolean isLocationEnabled() {
- return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE,
- Settings.Secure.LOCATION_MODE_OFF) != Settings.Secure.LOCATION_MODE_OFF;
+ private boolean isLocationEnabled(String callingPackage) {
+ boolean legacyForegroundApp = !isMApp(mContext, callingPackage)
+ && isForegroundApp(callingPackage);
+ return legacyForegroundApp || Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF)
+ != Settings.Secure.LOCATION_MODE_OFF;
}
/**
@@ -2073,13 +2076,7 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
&& checkAppOppAllowed(AppOpsManager.OP_COARSE_LOCATION, callingPackage, uid)) {
return true;
}
- boolean apiLevel23App = true;
- try {
- apiLevel23App = mContext.getPackageManager().getApplicationInfo(
- callingPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M;
- } catch (PackageManager.NameNotFoundException e) {
- // In case of exception, assume app's API level is 23+
- }
+ boolean apiLevel23App = isMApp(mContext, callingPackage);
// Pre-M apps running in the foreground should continue getting scan results
if (!apiLevel23App && isForegroundApp(callingPackage)) {
return true;
@@ -2093,6 +2090,16 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
return mAppOps.noteOp(op, uid, callingPackage) == AppOpsManager.MODE_ALLOWED;
}
+ private static boolean isMApp(Context context, String pkgName) {
+ try {
+ return context.getPackageManager().getApplicationInfo(pkgName, 0)
+ .targetSdkVersion >= Build.VERSION_CODES.M;
+ } catch (PackageManager.NameNotFoundException e) {
+ // In case of exception, assume M app (more strict checking)
+ }
+ return true;
+ }
+
/**
* Return true if the specified package name is a foreground app.
*