Revert "Fix DeviceConfig resetting."
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 Change-Id: Ieb1f0ce2a69180bbe89f810ddb3b48188ae3530e Merged-In: Ib0ac49609e444a53a6fee4575f5078e15f364eef
This commit is contained in:
@@ -50,10 +50,11 @@ 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.DeviceConfigStateHelper;
|
||||
import com.android.compatibility.common.util.SystemUtil;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.RuleChain;
|
||||
@@ -130,20 +131,18 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
||||
protected int mUid;
|
||||
private int mMyUid;
|
||||
private MyServiceClient mServiceClient;
|
||||
private DeviceConfigStateHelper mDeviceIdleDeviceConfigStateHelper;
|
||||
|
||||
@Rule
|
||||
public final RuleChain mRuleChain = RuleChain.outerRule(new RequiredPropertiesRule())
|
||||
.around(new MeterednessConfigurationRule());
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
PROCESS_STATE_FOREGROUND_SERVICE = (Integer) ActivityManager.class
|
||||
.getDeclaredField("PROCESS_STATE_FOREGROUND_SERVICE").get(null);
|
||||
mInstrumentation = getInstrumentation();
|
||||
mContext = getContext();
|
||||
mCm = getConnectivityManager();
|
||||
mDeviceIdleDeviceConfigStateHelper =
|
||||
new DeviceConfigStateHelper(DeviceConfig.NAMESPACE_DEVICE_IDLE);
|
||||
mUid = getUid(TEST_APP2_PKG);
|
||||
mMyUid = getUid(mContext.getPackageName());
|
||||
mServiceClient = new MyServiceClient(mContext);
|
||||
@@ -726,12 +725,17 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
||||
}
|
||||
|
||||
protected void setPendingIntentAllowlistDuration(long durationMs) {
|
||||
mDeviceIdleDeviceConfigStateHelper.set("notification_allowlist_duration_ms",
|
||||
String.valueOf(durationMs));
|
||||
SystemUtil.runWithShellPermissionIdentity(() -> {
|
||||
DeviceConfig.setProperty(
|
||||
DeviceConfig.NAMESPACE_DEVICE_IDLE, "notification_allowlist_duration_ms",
|
||||
String.valueOf(durationMs), /* makeDefault */ false);
|
||||
});
|
||||
}
|
||||
|
||||
protected void resetDeviceIdleSettings() {
|
||||
mDeviceIdleDeviceConfigStateHelper.restoreOriginalValues();
|
||||
SystemUtil.runWithShellPermissionIdentity(() ->
|
||||
DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
|
||||
DeviceConfig.NAMESPACE_DEVICE_IDLE));
|
||||
}
|
||||
|
||||
protected void launchComponentAndAssertNetworkAccess(int type) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user