diff options
author | David Su <dysu@google.com> | 2019-09-26 17:43:03 -0700 |
---|---|---|
committer | David Su <dysu@google.com> | 2019-09-27 00:59:01 +0000 |
commit | 221019ff231c5a8bd9148e7aed062bbac26a1453 (patch) | |
tree | 8f27ab9abe3bb5d02bbe8578c4a481b017c8f2a0 /service | |
parent | af908ff619accf068bcdca827687d1fe2d863395 (diff) |
Make Wifi more resilient to services starting late
Fix crash caused by WifiScanningService starting late
by checking mScanningEnabled flag before calling
WifiScanner APIs.
Fix NPE in RTT service isAvailable() caused by RTT
service starting late. Now if mRttNative is null we
return unavailable
Bug: 140938772
Bug: 141624112
Test: atest FrameworksWifiTests
Test: reboot device and check logs for errors
Change-Id: I197bedf492d0b73018e5bb386bf1efa6dd494f60
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/ScanRequestProxy.java | 2 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/rtt/RttServiceImpl.java | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/ScanRequestProxy.java b/service/java/com/android/server/wifi/ScanRequestProxy.java index 1b74191d5..cd5f1280e 100644 --- a/service/java/com/android/server/wifi/ScanRequestProxy.java +++ b/service/java/com/android/server/wifi/ScanRequestProxy.java @@ -453,7 +453,7 @@ public class ScanRequestProxy { * @return true if the scan request was placed or a scan is already ongoing, false otherwise. */ public boolean startScan(int callingUid, String packageName) { - if (!retrieveWifiScannerIfNecessary()) { + if (!mScanningEnabled || !retrieveWifiScannerIfNecessary()) { Log.e(TAG, "Failed to retrieve wifiscanner"); sendScanResultFailureBroadcastToPackage(packageName); return false; diff --git a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java index d69ce8f00..ce64d2e4a 100644 --- a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java +++ b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java @@ -399,7 +399,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub { public boolean isAvailable() { long ident = Binder.clearCallingIdentity(); try { - return mRttNative.isReady() && !mPowerManager.isDeviceIdleMode() + return mRttNative != null && mRttNative.isReady() && !mPowerManager.isDeviceIdleMode() && mWifiPermissionsUtil.isLocationModeEnabled(); } finally { Binder.restoreCallingIdentity(ident); |