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.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
import android.util.Log;
|
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.Rule;
|
||||||
import org.junit.rules.RuleChain;
|
import org.junit.rules.RuleChain;
|
||||||
@@ -130,20 +131,18 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
protected int mUid;
|
protected int mUid;
|
||||||
private int mMyUid;
|
private int mMyUid;
|
||||||
private MyServiceClient mServiceClient;
|
private MyServiceClient mServiceClient;
|
||||||
private DeviceConfigStateHelper mDeviceIdleDeviceConfigStateHelper;
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final RuleChain mRuleChain = RuleChain.outerRule(new RequiredPropertiesRule())
|
public final RuleChain mRuleChain = RuleChain.outerRule(new RequiredPropertiesRule())
|
||||||
.around(new MeterednessConfigurationRule());
|
.around(new MeterednessConfigurationRule());
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
|
||||||
PROCESS_STATE_FOREGROUND_SERVICE = (Integer) ActivityManager.class
|
PROCESS_STATE_FOREGROUND_SERVICE = (Integer) ActivityManager.class
|
||||||
.getDeclaredField("PROCESS_STATE_FOREGROUND_SERVICE").get(null);
|
.getDeclaredField("PROCESS_STATE_FOREGROUND_SERVICE").get(null);
|
||||||
mInstrumentation = getInstrumentation();
|
mInstrumentation = getInstrumentation();
|
||||||
mContext = getContext();
|
mContext = getContext();
|
||||||
mCm = getConnectivityManager();
|
mCm = getConnectivityManager();
|
||||||
mDeviceIdleDeviceConfigStateHelper =
|
|
||||||
new DeviceConfigStateHelper(DeviceConfig.NAMESPACE_DEVICE_IDLE);
|
|
||||||
mUid = getUid(TEST_APP2_PKG);
|
mUid = getUid(TEST_APP2_PKG);
|
||||||
mMyUid = getUid(mContext.getPackageName());
|
mMyUid = getUid(mContext.getPackageName());
|
||||||
mServiceClient = new MyServiceClient(mContext);
|
mServiceClient = new MyServiceClient(mContext);
|
||||||
@@ -726,12 +725,17 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setPendingIntentAllowlistDuration(long durationMs) {
|
protected void setPendingIntentAllowlistDuration(long durationMs) {
|
||||||
mDeviceIdleDeviceConfigStateHelper.set("notification_allowlist_duration_ms",
|
SystemUtil.runWithShellPermissionIdentity(() -> {
|
||||||
String.valueOf(durationMs));
|
DeviceConfig.setProperty(
|
||||||
|
DeviceConfig.NAMESPACE_DEVICE_IDLE, "notification_allowlist_duration_ms",
|
||||||
|
String.valueOf(durationMs), /* makeDefault */ false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetDeviceIdleSettings() {
|
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 {
|
protected void launchComponentAndAssertNetworkAccess(int type) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user