Skip wifi stats test if link layer stats is not supported

Wifi link layer is an optional feature so this test will be
failed on wifi stats check if a device does not support it.
Add a check to know if the  device supports wifi link layer
stats and skip it if it is not supported.

Ignore-AOSP-First: Needs cherry-picks
Bug: 195518957
Test: CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I592dd5f1d6e13b020beadb11b9d913857a82e524
This commit is contained in:
Aaron Huang
2021-08-06 17:53:14 +08:00
parent e8b35336f4
commit 58b493abf6

View File

@@ -31,6 +31,7 @@ import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.cts.util.CtsNetUtils;
import android.net.wifi.WifiManager;
import android.os.BatteryStatsManager;
import android.os.Build;
import android.os.connectivity.CellularBatteryStats;
@@ -70,6 +71,7 @@ public class BatteryStatsManagerTest{
private Context mContext;
private BatteryStatsManager mBsm;
private ConnectivityManager mCm;
private WifiManager mWm;
private CtsNetUtils mCtsNetUtils;
@Before
@@ -77,6 +79,7 @@ public class BatteryStatsManagerTest{
mContext = getContext();
mBsm = mContext.getSystemService(BatteryStatsManager.class);
mCm = mContext.getSystemService(ConnectivityManager.class);
mWm = mContext.getSystemService(WifiManager.class);
mCtsNetUtils = new CtsNetUtils(mContext);
}
@@ -128,6 +131,11 @@ public class BatteryStatsManagerTest{
cellularStatsAfter -> cellularBatteryStatsIncreased(
cellularStatsBefore, cellularStatsAfter)));
if (!mWm.isEnhancedPowerReportingSupported()) {
Log.d(TAG, "Skip wifi stats test because wifi does not support link layer stats.");
return;
}
WifiBatteryStats wifiStatsBefore = runAsShell(UPDATE_DEVICE_STATS,
mBsm::getWifiBatteryStats);