From 0a8b73a22306e8644d4ca3afdb42f9d94a9efc8d Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Tue, 24 Apr 2018 10:27:30 -0700 Subject: ScanRequestProxy: Bypass scan throttling for setup wizard Use the newly added |NETWORK_SETUP_WIZARD| permission to bypass scan throttling for setup wizard. Bug: 77924407 Test: Unit tests Test: Verified setup wizard scan requests are not throttled. Change-Id: Id39824b3543bbdb5b9df6923f6c0775993c377fd --- service/java/com/android/server/wifi/ScanRequestProxy.java | 9 ++++++--- .../java/com/android/server/wifi/util/WifiPermissionsUtil.java | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/ScanRequestProxy.java b/service/java/com/android/server/wifi/ScanRequestProxy.java index b9e48ea56..646fa5858 100644 --- a/service/java/com/android/server/wifi/ScanRequestProxy.java +++ b/service/java/com/android/server/wifi/ScanRequestProxy.java @@ -349,9 +349,12 @@ public class ScanRequestProxy { sendScanResultFailureBroadcastToPackage(packageName); return false; } - boolean fromSettings = mWifiPermissionsUtil.checkNetworkSettingsPermission(callingUid); + boolean fromSettingsOrSetupWizard = + mWifiPermissionsUtil.checkNetworkSettingsPermission(callingUid) + || mWifiPermissionsUtil.checkNetworkSetupWizardPermission(callingUid); // Check and throttle scan request from apps without NETWORK_SETTINGS permission. - if (!fromSettings && shouldScanRequestBeThrottledForApp(callingUid, packageName)) { + if (!fromSettingsOrSetupWizard + && shouldScanRequestBeThrottledForApp(callingUid, packageName)) { Log.i(TAG, "Scan request from " + packageName + " throttled"); sendScanResultFailureBroadcastToPackage(packageName); return false; @@ -362,7 +365,7 @@ public class ScanRequestProxy { // Create the scan settings. WifiScanner.ScanSettings settings = new WifiScanner.ScanSettings(); // Scan requests from apps with network settings will be of high accuracy type. - if (fromSettings) { + if (fromSettingsOrSetupWizard) { settings.type = WifiScanner.TYPE_HIGH_ACCURACY; } // always do full scans diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java index 3d838645d..cf43eb36f 100644 --- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java +++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java @@ -287,4 +287,13 @@ public class WifiPermissionsUtil { android.Manifest.permission.NETWORK_SETTINGS, uid) == PackageManager.PERMISSION_GRANTED; } + + /** + * Returns true if the |uid| holds NETWORK_SETUP_WIZARD permission. + */ + public boolean checkNetworkSetupWizardPermission(int uid) { + return mWifiPermissionsWrapper.getUidPermission( + android.Manifest.permission.NETWORK_SETUP_WIZARD, uid) + == PackageManager.PERMISSION_GRANTED; + } } -- cgit v1.2.3