Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8c34e14 authored by Ben Lin's avatar Ben Lin
Browse files

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
parent 3261b948
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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 {
                    // 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.
                }