Merge "Change MTS CTS tests to desired config" into sc-dev
diff --git a/apex/framework/java/android/provider/MediaStore.java b/apex/framework/java/android/provider/MediaStore.java
index 103e09e..2a17e34 100644
--- a/apex/framework/java/android/provider/MediaStore.java
+++ b/apex/framework/java/android/provider/MediaStore.java
@@ -928,13 +928,19 @@
@NonNull ParcelFileDescriptor fileDescriptor) throws IOException {
Bundle input = new Bundle();
input.putParcelable(EXTRA_FILE_DESCRIPTOR, fileDescriptor);
+ ParcelFileDescriptor pfd;
try {
Bundle output = context.getContentResolver().call(AUTHORITY,
GET_ORIGINAL_MEDIA_FORMAT_FILE_DESCRIPTOR_CALL, null, input);
- return output.getParcelable(EXTRA_FILE_DESCRIPTOR);
+ pfd = output.getParcelable(EXTRA_FILE_DESCRIPTOR);
} catch (Exception e) {
throw new IOException(e);
}
+
+ if (pfd == null) {
+ throw new IOException("Input file descriptor already original");
+ }
+ return pfd;
}
/**
diff --git a/res/values-ne/strings.xml b/res/values-ne/strings.xml
index e93dd86..ea47c97 100644
--- a/res/values-ne/strings.xml
+++ b/res/values-ne/strings.xml
@@ -171,8 +171,7 @@
<item quantity="other"><xliff:g id="COUNT">^1</xliff:g> वटा वस्तु मेटाइँदै छन्…</item>
<item quantity="one">वस्तु मेटाइँदै छ…</item>
</plurals>
- <!-- no translation found for transcode_denied (6760546817138288976) -->
- <skip />
+ <string name="transcode_denied" msgid="6760546817138288976">"<xliff:g id="APP_NAME">%s</xliff:g> ले मिडिया फाइलहरू प्रयोग गर्न सक्दैन"</string>
<string name="transcode_processing_cancelled" msgid="5340383917746945590">"मिडिया प्रोसेस गर्ने कार्य रद्द गरियो"</string>
<string name="transcode_processing_error" msgid="8921643164508407874">"मिडिया प्रोसेस गर्ने क्रममा त्रुटि भयो"</string>
<string name="transcode_processing_success" msgid="447288876429730122">"मिडिया प्रोसेस गरियो"</string>
diff --git a/src/com/android/providers/media/LocalCallingIdentity.java b/src/com/android/providers/media/LocalCallingIdentity.java
index 868f34d..d19627c 100644
--- a/src/com/android/providers/media/LocalCallingIdentity.java
+++ b/src/com/android/providers/media/LocalCallingIdentity.java
@@ -420,9 +420,12 @@
ai = context.getPackageManager()
.getApplicationInfo(getPackageName(), 0);
if (ai != null) {
- Boolean shouldBypass = ai.hasRequestRawExternalStorageAccess();
- if (shouldBypass != null) {
- return shouldBypass;
+ final int requestRawExternalStorageValue
+ = ai.getRequestRawExternalStorageAccess();
+ if (requestRawExternalStorageValue
+ != ApplicationInfo.RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT) {
+ return requestRawExternalStorageValue
+ == ApplicationInfo.RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED;
}
// Manifest flag is not set, hence return default value based on the category of the
// app and targetSDK.
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index a16f6eb..2a8cb3b 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -5697,10 +5697,12 @@
extras.getParcelable(MediaStore.EXTRA_FILE_DESCRIPTOR);
try {
File file = getFileFromFileDescriptor(inputPfd);
- boolean supportsTranscode = mTranscodeHelper.supportsTranscode(file.getPath());
- if (!supportsTranscode) {
- throw new IllegalArgumentException(
- "Input file descriptor is already original");
+ boolean isModernFormat = mTranscodeHelper.isModernFormat(file.getPath());
+ if (!isModernFormat) {
+ // Return an empty bundle instead of throwing an exception in the special
+ // case where the file is not a modern format. This avoids a misleading
+ // warning in android.database.DatabaseUtils#writeExceptionToParcel
+ return new Bundle();
}
FuseDaemon fuseDaemon = getFuseDaemonForFile(file);
diff --git a/src/com/android/providers/media/TranscodeHelper.java b/src/com/android/providers/media/TranscodeHelper.java
index 596db57..e1ffbca 100644
--- a/src/com/android/providers/media/TranscodeHelper.java
+++ b/src/com/android/providers/media/TranscodeHelper.java
@@ -792,7 +792,19 @@
return isHevc(mimeType) || isHdr10Plus(colorStandard, colorTransfer);
}
- public boolean supportsTranscode(String path) {
+ public boolean isModernFormat(String filePath) {
+ if (supportsTranscode(filePath)) {
+ Pair<Integer, Long> result = getFileFlagsAndDurationMs(filePath);
+ int fileFlags = result.first;
+ if (fileFlags != 0) {
+ // File is HEVC or HDR
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean supportsTranscode(String path) {
File file = new File(path);
String name = file.getName();
final String cameraRelativePath =
diff --git a/src/com/android/providers/media/scan/ModernMediaScanner.java b/src/com/android/providers/media/scan/ModernMediaScanner.java
index 4915de9..9a38945 100644
--- a/src/com/android/providers/media/scan/ModernMediaScanner.java
+++ b/src/com/android/providers/media/scan/ModernMediaScanner.java
@@ -367,7 +367,11 @@
mRoot = root;
mReason = reason;
- mVolume = MediaVolume.fromStorageVolume(FileUtils.getStorageVolume(mContext, root));
+ if (FileUtils.contains(Environment.getStorageDirectory(), root)) {
+ mVolume = MediaVolume.fromStorageVolume(FileUtils.getStorageVolume(mContext, root));
+ } else {
+ mVolume = MediaVolume.fromInternal();
+ }
mVolumeName = mVolume.getName();
mFilesUri = MediaStore.Files.getContentUri(mVolumeName);
mSignal = new CancellationSignal();