Review Changes for CTS tests related to Media CP Redirection
This CL is in continuation to ag/16659018 and takes care of few review
comments which were pending from the CTS tests related to media content
provider redirection.
Bug: 205817813
Test: atest CtsAppCloningHostTest
Change-Id: Iebcf53cfd2c3221411af5b15ef7ac95ef6d41e0c
diff --git a/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningBaseHostTest.java b/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningBaseHostTest.java
index 8857d51..8c82a54 100644
--- a/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningBaseHostTest.java
+++ b/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningBaseHostTest.java
@@ -35,6 +35,7 @@
protected static final String APP_A_PACKAGE = "com.android.cts.appcloningtestapp";
+ private static final String APP_A = "CtsAppCloningTestApp.apk";
private static final String TEST_CLASS_A = APP_A_PACKAGE + ".AppCloningDeviceTest";
private static final long DEFAULT_INSTRUMENTATION_TIMEOUT_MS = 600_000; // 10min
@@ -57,6 +58,20 @@
CommandResult out = executeShellV2Command("am start-user -w %s", mCloneUserId);
assertThat(isSuccessful(out)).isTrue();
+
+ // Install the app in both the user spaces
+ installAppAsUser(APP_A, getCurrentUserId());
+ installAppAsUser(APP_A, Integer.valueOf(mCloneUserId));
+ }
+
+ public void baseHostTeardown() throws Exception {
+ if (isHeadlessSystemUserMode() || !isAtLeastS() || usesSdcardFs()) return;
+
+ // Uninstall the app
+ uninstallPackage(APP_A_PACKAGE);
+
+ // remove the clone user
+ executeShellCommand("pm remove-user %s", mCloneUserId);
}
protected void installAppAsUser(String packageFile, int userId)
diff --git a/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningHostTest.java b/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningHostTest.java
index e951aa9..7dea833 100644
--- a/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningHostTest.java
+++ b/hostsidetests/appcloning/hostside/src/com/android/cts/appcloning/AppCloningHostTest.java
@@ -41,7 +41,6 @@
private static final int CLONE_PROFILE_DIRECTORY_CREATION_TIMEOUT_MS = 20000;
- private static final String APP_A = "CtsAppCloningTestApp.apk";
private static final String IMAGE_NAME_TO_BE_CREATED_KEY = "imageNameToBeCreated";
private static final String IMAGE_NAME_TO_BE_DISPLAYED_KEY = "imageNameToBeDisplayed";
private static final String IMAGE_NAME_TO_BE_VERIFIED_IN_OWNER_PROFILE_KEY =
@@ -58,25 +57,15 @@
mContentProviderHandler = new ContentProviderHandler(getDevice());
mContentProviderHandler.setUp();
-
- // Install the app in both the user spaces
- installAppAsUser(APP_A, getCurrentUserId());
- installAppAsUser(APP_A, Integer.valueOf(mCloneUserId));
}
@After
public void tearDown() throws Exception {
- if (isHeadlessSystemUserMode() || !isAtLeastS() || usesSdcardFs()) return;
+ super.baseHostTeardown();
if (mContentProviderHandler != null) {
mContentProviderHandler.tearDown();
}
-
- // Uninstall the app
- uninstallPackage(APP_A_PACKAGE);
-
- // remove the clone user
- executeShellCommand("pm remove-user %s", mCloneUserId);
}
@Test
diff --git a/hostsidetests/appcloning/test-apps/AppCloningTestApp/src/com/android/cts/appcloningtestapp/MediaStoreReadOperation.java b/hostsidetests/appcloning/test-apps/AppCloningTestApp/src/com/android/cts/appcloningtestapp/MediaStoreReadOperation.java
index 80939a1..af6270e 100644
--- a/hostsidetests/appcloning/test-apps/AppCloningTestApp/src/com/android/cts/appcloningtestapp/MediaStoreReadOperation.java
+++ b/hostsidetests/appcloning/test-apps/AppCloningTestApp/src/com/android/cts/appcloningtestapp/MediaStoreReadOperation.java
@@ -19,7 +19,6 @@
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Build;
import android.provider.MediaStore;
import java.util.ArrayList;
@@ -34,10 +33,7 @@
public static List<Image> getImageFilesFromMediaStore(Context context) {
List<Image> imageList = new ArrayList<>();
- // Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q is always true
- Uri collection = Build.VERSION.SDK_INT >= ANDROID_Q
- ? MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL) :
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ Uri collection = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL);
String[] projection = new String[] {
MediaStore.Images.Media.DATA,