diff options
| author | 2018-07-20 16:35:39 -0700 | |
|---|---|---|
| committer | 2018-07-20 17:20:11 -0700 | |
| commit | a8c34e148cbd926eff8ba8c3b51d4419e2e0fa24 (patch) | |
| tree | 2f5be93605393f9c60e9cfb4eeb6a753b86bc85b | |
| parent | 3261b948e5b8898420852349bba03c6bfc8c8fda (diff) | |
Check for Wifi's power stats capabilities before asking for it.
Bug: 79893981
Test: On devices where Wifi's power stats are not available, `adb shell
'time dumpsys batterystats --checkin |wc -l'` returns much faster now.
Change-Id: Id5a9dbe6496c3033afafcff6cae86d91c13f8c90
| -rw-r--r-- | services/core/java/com/android/server/am/BatteryExternalStatsWorker.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java index d9a8818c3988..2541352b6daa 100644 --- a/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java +++ b/services/core/java/com/android/server/am/BatteryExternalStatsWorker.java @@ -15,6 +15,8 @@ */ package com.android.server.am; +import static android.net.wifi.WifiManager.WIFI_FEATURE_LINK_LAYER_STATS; + import android.annotation.Nullable; import android.bluetooth.BluetoothActivityEnergyInfo; import android.bluetooth.BluetoothAdapter; @@ -410,8 +412,11 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { if (mWifiManager != null) { try { - wifiReceiver = new SynchronousResultReceiver("wifi"); - mWifiManager.requestActivityInfo(wifiReceiver); + // Only fetch WiFi power data if it is supported. + if ((mWifiManager.getSupportedFeatures() & WIFI_FEATURE_LINK_LAYER_STATS) != 0) { + wifiReceiver = new SynchronousResultReceiver("wifi"); + mWifiManager.requestActivityInfo(wifiReceiver); + } } catch (RemoteException e) { // Oh well. } |