Merge "Improve wallpaper CTS reliability"
diff --git a/hostsidetests/backup/AndroidTest.xml b/hostsidetests/backup/AndroidTest.xml
index f9e1d36..f81279c 100644
--- a/hostsidetests/backup/AndroidTest.xml
+++ b/hostsidetests/backup/AndroidTest.xml
@@ -17,6 +17,7 @@
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsBackupDeviceApp.apk" />
+        <option name="test-file-name" value="CtsBackupDeviceApp2.apk" />
     </target_preparer>
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsBackupHostTestCases.jar" />
diff --git a/hostsidetests/backup/app/Android.mk b/hostsidetests/backup/app/Android.mk
index 2573bd9..7e40c5a 100644
--- a/hostsidetests/backup/app/Android.mk
+++ b/hostsidetests/backup/app/Android.mk
@@ -25,8 +25,6 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 # tag this module as a cts test artifact
diff --git a/hostsidetests/backup/app/AndroidManifest.xml b/hostsidetests/backup/app/AndroidManifest.xml
index e5dd962..e67404c 100644
--- a/hostsidetests/backup/app/AndroidManifest.xml
+++ b/hostsidetests/backup/app/AndroidManifest.xml
@@ -19,7 +19,6 @@
     package="android.backup.cts.app">
 
     <application>
-        <uses-library android:name="android.test.runner" />
 
         <service
                 android:name="android.backup.cts.app.DummyLiveWallpaper"
@@ -36,8 +35,4 @@
 
     </application>
 
-    <instrumentation
-        android:name="android.support.test.runner.AndroidJUnitRunner"
-        android:targetPackage="android.backup.cts.app" />
-
 </manifest>
diff --git a/hostsidetests/backup/app2/Android.mk b/hostsidetests/backup/app2/Android.mk
new file mode 100644
index 0000000..c88be6d
--- /dev/null
+++ b/hostsidetests/backup/app2/Android.mk
@@ -0,0 +1,39 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_PACKAGE_NAME := CtsBackupDeviceApp2
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/app2/AndroidManifest.xml b/hostsidetests/backup/app2/AndroidManifest.xml
new file mode 100644
index 0000000..518f26f
--- /dev/null
+++ b/hostsidetests/backup/app2/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="android.backup.cts.app2">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+
+    </application>
+
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:targetPackage="android.backup.cts.app2" />
+
+</manifest>
diff --git a/hostsidetests/backup/app/src/android/backup/cts/app/WallpaperRestoreTest.java b/hostsidetests/backup/app2/src/android/backup/cts/app2/WallpaperRestoreTest.java
similarity index 98%
rename from hostsidetests/backup/app/src/android/backup/cts/app/WallpaperRestoreTest.java
rename to hostsidetests/backup/app2/src/android/backup/cts/app2/WallpaperRestoreTest.java
index 68b4c1c..3bb294f 100644
--- a/hostsidetests/backup/app/src/android/backup/cts/app/WallpaperRestoreTest.java
+++ b/hostsidetests/backup/app2/src/android/backup/cts/app2/WallpaperRestoreTest.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.backup.cts.app;
+package android.backup.cts.app2;
 
 import static android.app.WallpaperManager.FLAG_LOCK;
 import static android.app.WallpaperManager.FLAG_SYSTEM;
diff --git a/hostsidetests/backup/src/android/backup/cts/WallpaperRestoreHostSideTest.java b/hostsidetests/backup/src/android/backup/cts/WallpaperRestoreHostSideTest.java
index 46d9262..cc2dbbc 100644
--- a/hostsidetests/backup/src/android/backup/cts/WallpaperRestoreHostSideTest.java
+++ b/hostsidetests/backup/src/android/backup/cts/WallpaperRestoreHostSideTest.java
@@ -96,8 +96,8 @@
     private void checkDeviceTest(String testName) throws DeviceNotAvailableException {
         boolean result =
                 runDeviceTests(
-                        "android.backup.cts.app",
-                        "android.backup.cts.app.WallpaperRestoreTest",
+                        "android.backup.cts.app2",
+                        "android.backup.cts.app2.WallpaperRestoreTest",
                         testName);
         assertTrue("Device test failed: " + testName, result);
     }