Truly ignore insert errors when bypassing scoped storage restrctions
Make sure we don't leak any unexpected Exceptions from
MediaProvider#insertFileForFuse back to the native level when we bypass
FUSE restrictions.
Test: atest CtsScopedStorageHostTest
Fix: 157641906
Change-Id: Ida4bfb3d487621447470921b6de7ecb0dfa6b77e
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index fe5fe87..becb497 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -6356,8 +6356,10 @@
if (shouldBypassFuseRestrictions(/*forWrite*/ true, path)) {
// Ignore insert errors for apps that bypass scoped storage restriction.
- insertFileForFuse(path, FileUtils.getContentUriForPath(path), mimeType,
- /*useData*/ isCallingPackageRequestingLegacy());
+ try {
+ insertFileForFuse(path, FileUtils.getContentUriForPath(path), mimeType,
+ /*useData*/ isCallingPackageRequestingLegacy());
+ } catch (Exception ignored) {}
return 0;
}