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
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index e2dc1a1..b5e763d 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -50,10 +50,11 @@
 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 @@
     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 @@
     }
 
     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 {