Merge "No longer using specific watch device idle settings" into oc-dev am: 8bde47ae82
am: eb2c021f93
Change-Id: Iff4af17accb81c3111c0a7517dfcb295858ad48f
diff --git a/tests/cts/hostside/Android.mk b/tests/cts/hostside/Android.mk
index 88fbe0c..7270580 100644
--- a/tests/cts/hostside/Android.mk
+++ b/tests/cts/hostside/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.net.hostsidenetwork
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/tests/cts/hostside/AndroidTest.xml b/tests/cts/hostside/AndroidTest.xml
index ad7f81b..4a2e2e3 100644
--- a/tests/cts/hostside/AndroidTest.xml
+++ b/tests/cts/hostside/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS net host test cases">
<option name="config-descriptor:metadata" key="component" value="networking" />
+ <target_preparer class="com.android.cts.net.NetPolicyTestsPreparer" />
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsHostsideNetworkTests.jar" />
<option name="runtime-hint" value="3m56s" />
diff --git a/tests/cts/hostside/app/Android.mk b/tests/cts/hostside/app/Android.mk
index 5e8c2b6..f094f3f 100644
--- a/tests/cts/hostside/app/Android.mk
+++ b/tests/cts/hostside/app/Android.mk
@@ -31,6 +31,6 @@
LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/cts/hostside/app2/Android.mk b/tests/cts/hostside/app2/Android.mk
index 02071bf..9a4a30f 100644
--- a/tests/cts/hostside/app2/Android.mk
+++ b/tests/cts/hostside/app2/Android.mk
@@ -30,6 +30,6 @@
LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java b/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java
new file mode 100644
index 0000000..9b19554
--- /dev/null
+++ b/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.net;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil;
+import com.android.tradefed.targetprep.ITargetCleaner;
+import com.android.tradefed.targetprep.ITargetPreparer;
+
+public class NetPolicyTestsPreparer implements ITargetPreparer, ITargetCleaner {
+ private final static String KEY_PAROLE_DURATION = "parole_duration";
+ private final static String DESIRED_PAROLE_DURATION = "0";
+
+ private boolean mAppIdleConstsUpdated;
+ private String mOriginalAppIdleConsts;
+
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo) throws DeviceNotAvailableException {
+ updateParoleDuration(device);
+ LogUtil.CLog.d("Original app_idle_constants: " + mOriginalAppIdleConsts);
+ }
+
+ @Override
+ public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable throwable)
+ throws DeviceNotAvailableException {
+ if (mAppIdleConstsUpdated) {
+ executeCmd(device, "settings put global app_idle_constants " + mOriginalAppIdleConsts);
+ }
+ }
+
+ /**
+ * Updates parole_duration with the desired value.
+ */
+ private void updateParoleDuration(ITestDevice device) throws DeviceNotAvailableException {
+ mOriginalAppIdleConsts = executeCmd(device, "settings get global app_idle_constants");
+ String newAppIdleConstants;
+ final String newConstant = KEY_PAROLE_DURATION + "=" + DESIRED_PAROLE_DURATION;
+ if (mOriginalAppIdleConsts == null || "null".equals(mOriginalAppIdleConsts)) {
+ // app_idle_constants is initially empty, so just assign the desired value.
+ newAppIdleConstants = newConstant;
+ } else if (mOriginalAppIdleConsts.contains(KEY_PAROLE_DURATION)) {
+ // app_idle_constants contains parole_duration, so replace it with the desired value.
+ newAppIdleConstants = mOriginalAppIdleConsts.replaceAll(
+ KEY_PAROLE_DURATION + "=\\d+", newConstant);
+ } else {
+ // app_idle_constants didn't have parole_duration, so append the desired value.
+ newAppIdleConstants = mOriginalAppIdleConsts + "," + newConstant;
+ }
+ executeCmd(device, "settings put global app_idle_constants " + newAppIdleConstants);
+ mAppIdleConstsUpdated = true;
+ }
+
+ private String executeCmd(ITestDevice device, String cmd)
+ throws DeviceNotAvailableException {
+ final String output = device.executeShellCommand(cmd).trim();
+ LogUtil.CLog.d("Output for '%s': %s", cmd, output);
+ return output;
+ }
+}
diff --git a/tests/cts/net/Android.mk b/tests/cts/net/Android.mk
index 3493ccb..4aeab38 100644
--- a/tests/cts/net/Android.mk
+++ b/tests/cts/net/Android.mk
@@ -47,7 +47,7 @@
#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/cts/net/appForApi23/Android.mk b/tests/cts/net/appForApi23/Android.mk
index ea99684..54b60a0 100644
--- a/tests/cts/net/appForApi23/Android.mk
+++ b/tests/cts/net/appForApi23/Android.mk
@@ -31,7 +31,7 @@
LOCAL_SDK_VERSION := 23
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/cts/net/jni/Android.mk b/tests/cts/net/jni/Android.mk
index 0ec8d28..887e95e 100644
--- a/tests/cts/net/jni/Android.mk
+++ b/tests/cts/net/jni/Android.mk
@@ -27,6 +27,9 @@
LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
LOCAL_CXX_STL := libc++_static
+
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
diff --git a/tests/cts/net/native/qtaguid/Android.mk b/tests/cts/net/native/qtaguid/Android.mk
index b3eb28b..6c92b5c 100644
--- a/tests/cts/net/native/qtaguid/Android.mk
+++ b/tests/cts/net/native/qtaguid/Android.mk
@@ -36,7 +36,7 @@
LOCAL_CTS_TEST_PACKAGE := android.net.native
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CFLAGS := -Werror -Wall