Merge "Add test case for issue 170357245"
diff --git a/tests/res/raw/large_xmp.mp4 b/tests/res/raw/large_xmp.mp4
new file mode 100644
index 0000000..3dd4b2c
--- /dev/null
+++ b/tests/res/raw/large_xmp.mp4
Binary files differ
diff --git a/tests/src/com/android/providers/media/scan/ModernMediaScannerTest.java b/tests/src/com/android/providers/media/scan/ModernMediaScannerTest.java
index dd1b41c..9b7f0d2 100644
--- a/tests/src/com/android/providers/media/scan/ModernMediaScannerTest.java
+++ b/tests/src/com/android/providers/media/scan/ModernMediaScannerTest.java
@@ -1030,4 +1030,21 @@
             assertEquals(0, cursor.getCount());
         }
     }
+
+    @Test
+    public void testScan_largeXmpData() throws Exception {
+        final File image = new File(mDir, "large_xmp.mp4");
+        stage(R.raw.large_xmp, image);
+        assertTrue(image.exists());
+
+        mModern.scanDirectory(mDir, REASON_UNKNOWN);
+
+        try (Cursor cursor = mIsolatedResolver
+                .query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
+                 new String[] { MediaColumns.XMP }, null, null, null)) {
+             assertEquals(1, cursor.getCount());
+             cursor.moveToFirst();
+             assertEquals(0, cursor.getBlob(0).length);
+        }
+    }
 }