data saver test exception for wear

WearOs should not be treated  as supporting Data Saver mode. Users
can not enable or disable the mode.

Data Saver is used on WearOs for battery improvements with LTE enabled
devices but should not block WiFi or Bluetooth PROXY networks.

Bug: 222086830
Test: run cts CtsHostsideNetworkTests
Change-Id: I8e76f7f9574c1ef2c1bd04ff0be652a74cd241f9
(cherry picked from commit cf709bbae312ad7cd0ffdf64af0a8ce23d8b1610)
This commit is contained in:
Andriy Naborskyy
2022-03-25 05:22:01 +00:00
parent 59e6e2b730
commit 1b35da1ccb

View File

@@ -38,6 +38,7 @@ import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.UiAutomation;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
@@ -99,6 +100,10 @@ public class NetworkPolicyTestUtils {
return mBatterySaverSupported;
}
private static boolean isWear() {
return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
}
/**
* As per CDD requirements, if the device doesn't support data saver mode then
* ConnectivityManager.getRestrictBackgroundStatus() will always return
@@ -107,6 +112,9 @@ public class NetworkPolicyTestUtils {
* RESTRICT_BACKGROUND_STATUS_DISABLED or not.
*/
public static boolean isDataSaverSupported() {
if (isWear()) {
return false;
}
if (mDataSaverSupported == null) {
assertMyRestrictBackgroundStatus(RESTRICT_BACKGROUND_STATUS_DISABLED);
try {