summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDipankar Bhardwaj <dipankarb@google.com>2023-12-06 13:51:23 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-12-06 13:51:23 +0000
commit03a478c9d0e23f78930e547bef5b4f3cac23195e (patch)
tree1c46b8e68775d57f1386ca27ca1f194906812ff5
parentb63e95bd872f67d7f8854d009cca9237e013c084 (diff)
parente04c62d319c8bc70e9a7fb494897834bb461e803 (diff)
downloadMediaProvider-03a478c9d0e23f78930e547bef5b4f3cac23195e.tar.gz
Merge "Ignore public volume test" into udc-mainline-prod am: e04c62d319
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/25559602 Change-Id: Ia24dbde0e51378a6e9190bb0f0ed7553f2602ecb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--tests/src/com/android/providers/media/stableuris/job/StableUriIdleMaintenanceServiceTest.java106
1 files changed, 56 insertions, 50 deletions
diff --git a/tests/src/com/android/providers/media/stableuris/job/StableUriIdleMaintenanceServiceTest.java b/tests/src/com/android/providers/media/stableuris/job/StableUriIdleMaintenanceServiceTest.java
index 76580f464..735230911 100644
--- a/tests/src/com/android/providers/media/stableuris/job/StableUriIdleMaintenanceServiceTest.java
+++ b/tests/src/com/android/providers/media/stableuris/job/StableUriIdleMaintenanceServiceTest.java
@@ -49,6 +49,7 @@ import com.android.providers.media.stableuris.dao.BackupIdRow;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -105,13 +106,10 @@ public class StableUriIdleMaintenanceServiceTest {
DeviceConfig.setProperty(ConfigStore.NAMESPACE_MEDIAPROVIDER,
ConfigStore.ConfigStoreImpl.KEY_STABILIZE_VOLUME_PUBLIC, Boolean.TRUE.toString(),
false);
-
- createNewPublicVolume();
}
@AfterClass
public static void tearDownClass() throws Exception {
- deletePublicVolumes();
// Restore previous value of the flag
DeviceConfig.setProperty(ConfigStore.NAMESPACE_MEDIAPROVIDER,
@@ -214,59 +212,67 @@ public class StableUriIdleMaintenanceServiceTest {
}
@Test
+ @Ignore
public void testDataMigrationForPublicVolume() throws Exception {
- final Context context = InstrumentationRegistry.getTargetContext();
- final ContentResolver resolver = context.getContentResolver();
- final Set<String> volNames = MediaStore.getExternalVolumeNames(context);
-
- for (String volName : volNames) {
- if (!MediaStore.VOLUME_EXTERNAL_PRIMARY.equalsIgnoreCase(volName)
- && !MediaStore.VOLUME_INTERNAL.equalsIgnoreCase(volName)) {
- // public volume
- Set<String> newFilePaths = new HashSet<String>();
- Map<String, Long> pathToIdMap = new HashMap<>();
- MediaStore.waitForIdle(resolver);
-
- try {
- for (int i = 0; i < 10; i++) {
- File volPath = getVolumePath(context, volName);
- final File dir = new File(volPath.getAbsoluteFile() + "/Download");
- final File file = new File(dir, System.nanoTime() + ".png");
-
- // Write 1 byte because 0 byte files are not valid in the db
- try (FileOutputStream fos = new FileOutputStream(file)) {
- fos.write(1);
- }
+ createNewPublicVolume();
+ try {
+ final Context context = InstrumentationRegistry.getTargetContext();
+ final ContentResolver resolver = context.getContentResolver();
+ final Set<String> volNames = MediaStore.getExternalVolumeNames(context);
+
+ for (String volName : volNames) {
+ if (!MediaStore.VOLUME_EXTERNAL_PRIMARY.equalsIgnoreCase(volName)
+ && !MediaStore.VOLUME_INTERNAL.equalsIgnoreCase(volName)) {
+ // public volume
+ Set<String> newFilePaths = new HashSet<String>();
+ Map<String, Long> pathToIdMap = new HashMap<>();
+ MediaStore.waitForIdle(resolver);
- Uri uri = MediaStore.scanFile(resolver, file);
- long id = ContentUris.parseId(uri);
- newFilePaths.add(file.getAbsolutePath());
- pathToIdMap.put(file.getAbsolutePath(), id);
- }
+ try {
+ for (int i = 0; i < 10; i++) {
+ File volPath = getVolumePath(context, volName);
+ final File dir = new File(volPath.getAbsoluteFile() + "/Download");
+ final File file = new File(dir, System.nanoTime() + ".png");
+
+ // Write 1 byte because 0 byte files are not valid in the db
+ try (FileOutputStream fos = new FileOutputStream(file)) {
+ fos.write(1);
+ }
+
+ Uri uri = MediaStore.scanFile(resolver, file);
+ long id = ContentUris.parseId(uri);
+ newFilePaths.add(file.getAbsolutePath());
+ pathToIdMap.put(file.getAbsolutePath(), id);
+ }
- assertFalse(newFilePaths.isEmpty());
- MediaStore.waitForIdle(resolver);
- // Creates backup
- MediaStore.runIdleMaintenanceForStableUris(resolver);
-
- verifyLevelDbPresence(resolver, PUBLIC_VOLUME_BACKUP_NAME + volName);
- verifyLevelDbPresence(resolver, OWNERSHIP_BACKUP_NAME);
- // Verify that all internal files are backed up
- for (String filePath : newFilePaths) {
- BackupIdRow backupIdRow = BackupIdRow.deserialize(
- MediaStore.readBackup(resolver, volName, filePath));
- assertNotNull(backupIdRow);
- assertEquals(pathToIdMap.get(filePath).longValue(), backupIdRow.getId());
- assertEquals(UserHandle.myUserId(), backupIdRow.getUserId());
- assertEquals(context.getPackageName(),
- MediaStore.getOwnerPackageName(resolver, backupIdRow.getOwnerPackageId()));
- }
- } finally {
- for (String path : newFilePaths) {
- new File(path).delete();
+ assertFalse(newFilePaths.isEmpty());
+ MediaStore.waitForIdle(resolver);
+ // Creates backup
+ MediaStore.runIdleMaintenanceForStableUris(resolver);
+
+ verifyLevelDbPresence(resolver, PUBLIC_VOLUME_BACKUP_NAME + volName);
+ verifyLevelDbPresence(resolver, OWNERSHIP_BACKUP_NAME);
+ // Verify that all internal files are backed up
+ for (String filePath : newFilePaths) {
+ BackupIdRow backupIdRow = BackupIdRow.deserialize(
+ MediaStore.readBackup(resolver, volName, filePath));
+ assertNotNull(backupIdRow);
+ assertEquals(pathToIdMap.get(filePath).longValue(),
+ backupIdRow.getId());
+ assertEquals(UserHandle.myUserId(), backupIdRow.getUserId());
+ assertEquals(context.getPackageName(),
+ MediaStore.getOwnerPackageName(resolver,
+ backupIdRow.getOwnerPackageId()));
+ }
+ } finally {
+ for (String path : newFilePaths) {
+ new File(path).delete();
+ }
}
}
}
+ } finally {
+ deletePublicVolumes();
}
}