Revert "Update tests to use Doze DeviceConfig flags."
This change went into internal after R branched, and did not go to AOSP. Revert it in mainline-prod in order to ensure that CtsHostsideNetworkTests builds. These tests are developed in internal, not AOSP, so do not need to automerge to mainline-prod. Bug: 167645754 Test: treehugger Ignore-AOSP-First: needed to sync mainline-prod with AOSP Merged-In: Ib0ac49609e444a53a6fee4575f5078e15f364eef Change-Id: I2b7d9855b81be5ef968a3de72bf9f7e7225075e1
This commit is contained in:
@@ -101,7 +101,7 @@ abstract class AbstractDozeModeTestCase extends AbstractRestrictBackgroundNetwor
|
||||
@Test
|
||||
public void testBackgroundNetworkAccess_enabledButWhitelistedOnNotificationAction()
|
||||
throws Exception {
|
||||
setPendingIntentAllowlistDuration(NETWORK_TIMEOUT_MS);
|
||||
setPendingIntentWhitelistDuration(NETWORK_TIMEOUT_MS);
|
||||
try {
|
||||
registerNotificationListenerService();
|
||||
setDozeMode(true);
|
||||
|
||||
@@ -25,6 +25,7 @@ import static com.android.cts.net.hostside.NetworkPolicyTestUtils.executeShellCo
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.getConnectivityManager;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.getContext;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.getInstrumentation;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.getWifiManager;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.isDozeModeSupported;
|
||||
import static com.android.cts.net.hostside.NetworkPolicyTestUtils.restrictBackgroundValueToString;
|
||||
|
||||
@@ -45,17 +46,15 @@ import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
import android.net.NetworkInfo.State;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.compatibility.common.util.SystemUtil;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -131,6 +130,7 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
||||
protected int mUid;
|
||||
private int mMyUid;
|
||||
private MyServiceClient mServiceClient;
|
||||
private String mDeviceIdleConstantsSetting;
|
||||
|
||||
@Rule
|
||||
public final RuleChain mRuleChain = RuleChain.outerRule(new RequiredPropertiesRule())
|
||||
@@ -147,6 +147,7 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
||||
mMyUid = getUid(mContext.getPackageName());
|
||||
mServiceClient = new MyServiceClient(mContext);
|
||||
mServiceClient.bind();
|
||||
mDeviceIdleConstantsSetting = "device_idle_constants";
|
||||
executeShellCommand("cmd netpolicy start-watching " + mUid);
|
||||
setAppIdle(false);
|
||||
|
||||
@@ -724,18 +725,15 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
||||
nm.isNotificationListenerAccessGranted(listenerComponent));
|
||||
}
|
||||
|
||||
protected void setPendingIntentAllowlistDuration(long durationMs) {
|
||||
SystemUtil.runWithShellPermissionIdentity(() -> {
|
||||
DeviceConfig.setProperty(
|
||||
DeviceConfig.NAMESPACE_DEVICE_IDLE, "notification_allowlist_duration_ms",
|
||||
String.valueOf(durationMs), /* makeDefault */ false);
|
||||
});
|
||||
protected void setPendingIntentWhitelistDuration(int durationMs) throws Exception {
|
||||
executeSilentShellCommand(String.format(
|
||||
"settings put global %s %s=%d", mDeviceIdleConstantsSetting,
|
||||
"notification_whitelist_duration", durationMs));
|
||||
}
|
||||
|
||||
protected void resetDeviceIdleSettings() {
|
||||
SystemUtil.runWithShellPermissionIdentity(() ->
|
||||
DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
|
||||
DeviceConfig.NAMESPACE_DEVICE_IDLE));
|
||||
protected void resetDeviceIdleSettings() throws Exception {
|
||||
executeShellCommand(String.format("settings delete global %s",
|
||||
mDeviceIdleConstantsSetting));
|
||||
}
|
||||
|
||||
protected void launchComponentAndAssertNetworkAccess(int type) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user