summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nandana Dutt <nandana@google.com> 2020-01-03 16:43:46 +0000
committer Nandana Dutt <nandana@google.com> 2020-01-06 10:07:16 +0000
commitdc15bb4e3d69e1f42f4e9ca6a66fe026cdc13338 (patch)
tree2feb274eba13bdc400ccb921703ac34bc40a4959
parent3522d98589b2021b7ddc06e41e15ed4039aea4ba (diff)
Allow R targeting apps a legacy view
Allow R targeting apps to have a legacy view when accessing sdcard via raw file paths temporarily. This will let us bring back a986bc6420665453a898db61329f32cdc7f19cbb This will also let apps that target R and keep the legacy flag to use raw paths continue to work until we enable FUSE BUG: 137755945 BUG: 131432978 Test: atest CtsDeqpTestCases Test: atest RestrictedPermissionsTest Test: atest RestrictedStoragePermissionSharedUidTest Change-Id: I0d49eca9d4e1769dcd3c0e2338db5b5e5a473032
-rw-r--r--services/core/java/com/android/server/StorageManagerService.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 22fa8ff4a0fa..b027ed6a728e 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -61,6 +61,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.PackageManager;
@@ -3898,8 +3899,22 @@ class StorageManagerService extends IStorageManager.Stub
// Otherwise we're willing to give out sandboxed or non-sandboxed if
// they hold the runtime permission
- final boolean hasLegacy = mIAppOpsService.checkOperation(OP_LEGACY_STORAGE,
+ boolean hasLegacy = mIAppOpsService.checkOperation(OP_LEGACY_STORAGE,
uid, packageName) == MODE_ALLOWED;
+
+ // Hack(b/147137425): we have to honor hasRequestedLegacyExternalStorage for a short
+ // while to enable 2 cases.
+ // 1) Apps that want to be in scoped storage in R, but want to opt out in Q devices,
+ // because they want to use raw file paths, would fail until fuse is enabled by default.
+ // 2) Test apps that target current sdk will fail. They would fail even after fuse is
+ // enabled, but we are fixing it with b/142395442. We are not planning to enable
+ // fuse by default until b/142395442 is fixed.
+ if (!hasLegacy && !mIsFuseEnabled) {
+ ApplicationInfo ai = mIPackageManager.getApplicationInfo(packageName,
+ 0, UserHandle.getUserId(uid));
+ hasLegacy = ai.hasRequestedLegacyExternalStorage();
+ }
+
if (hasLegacy && hasWrite) {
return Zygote.MOUNT_EXTERNAL_WRITE;
} else if (hasLegacy && hasRead) {