Merge "Disable data saver mode in AbstractRestrictBackgroundNetworkTestCase setup" into main
This commit is contained in:
@@ -29,6 +29,7 @@ import static com.android.cts.net.hostside.NetworkPolicyTestUtils.isAppStandbySu
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.isBatterySaverSupported;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.isDozeModeSupported;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.restrictBackgroundValueToString;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.setRestrictBackgroundInternal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -52,9 +53,9 @@ import android.net.NetworkRequest;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.RemoteCallback;
|
||||
import android.os.SystemClock;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.util.Log;
|
||||
@@ -180,6 +181,12 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
||||
mServiceClient.bind();
|
||||
mPowerManager = mContext.getSystemService(PowerManager.class);
|
||||
executeShellCommand("cmd netpolicy start-watching " + mUid);
|
||||
// Some of the test cases assume that Data saver mode is initially disabled, which might not
|
||||
// always be the case. Therefore, explicitly disable it before running the tests.
|
||||
// Invoke setRestrictBackgroundInternal() directly instead of going through
|
||||
// setRestrictBackground(), as some devices do not fully support the Data saver mode but
|
||||
// still have certain parts of it enabled by default.
|
||||
setRestrictBackgroundInternal(false);
|
||||
setAppIdle(false);
|
||||
mLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ public class NetworkPolicyTestUtils {
|
||||
setRestrictBackgroundInternal(enabled);
|
||||
}
|
||||
|
||||
private static void setRestrictBackgroundInternal(boolean enabled) {
|
||||
static void setRestrictBackgroundInternal(boolean enabled) {
|
||||
executeShellCommand("cmd netpolicy set restrict-background " + enabled);
|
||||
final String output = executeShellCommand("cmd netpolicy get restrict-background");
|
||||
final String expectedSuffix = enabled ? "enabled" : "disabled";
|
||||
|
||||
Reference in New Issue
Block a user