diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2018-08-13 17:42:54 -0600 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2018-08-14 10:56:43 -0600 |
| commit | 5790af08f8b299e7a8d88390abd38ada52f2d4f4 (patch) | |
| tree | d0a9fd74e6cdd213c45e10a8007eba31ed1e7ddb /core/java | |
| parent | 4aacd8b6685f5879f1fc9137961edbff46d29471 (diff) | |
Methods to translate sandbox paths.
System components (like MediaProvider) will live in a mount namespace
that has a view of the "real" shared storage device, and normal apps
will have "sandboxed" views of the shared storage device. (Parallel
changes are implementing these namespaces in vold and installd.)
The system components mentioned above will need to translate between
the two namespaces, so this change introduces methods that perform
that translation, along with a nice batch of tests to verify.
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/StorageManagerServiceTest.java
Bug: 111893193, 111892833, 111268862
Change-Id: Iae91a44ce09eb33d6cd9b90f6c7b4f88c8cd12f0
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/pm/PackageManagerInternal.java | 17 | ||||
| -rw-r--r-- | core/java/android/os/storage/IStorageManager.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/os/storage/StorageManager.java | 30 |
3 files changed, 49 insertions, 0 deletions
diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java index a2a483280123..823d9951862c 100644 --- a/core/java/android/content/pm/PackageManagerInternal.java +++ b/core/java/android/content/pm/PackageManagerInternal.java @@ -31,6 +31,7 @@ import android.util.SparseArray; import com.android.internal.util.function.TriFunction; +import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; @@ -680,4 +681,20 @@ public abstract class PackageManagerInternal { * @return a SparseArray mapping from appId to it's sharedUserId. */ public abstract SparseArray<String> getAppsWithSharedUserIds(); + + /** + * Return if device is currently in a "core" boot environment, typically + * used to support full-disk encryption. Only apps marked with + * {@code coreApp} attribute are available. + */ + public abstract boolean isOnlyCoreApps(); + + /** + * Make a best-effort attempt to provide the requested free disk space by + * deleting cached files. + * + * @throws IOException if the request was unable to be fulfilled. + */ + public abstract void freeStorage(String volumeUuid, long bytes, int storageFlags) + throws IOException; } diff --git a/core/java/android/os/storage/IStorageManager.aidl b/core/java/android/os/storage/IStorageManager.aidl index 55a202fd3a66..5c2d41e1aebc 100644 --- a/core/java/android/os/storage/IStorageManager.aidl +++ b/core/java/android/os/storage/IStorageManager.aidl @@ -187,4 +187,6 @@ interface IStorageManager { void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78; void runIdleMaintenance() = 79; void abortIdleMaintenance() = 80; + String translateAppToSystem(String path, String packageName, int userId) = 81; + String translateSystemToApp(String path, String packageName, int userId) = 82; } diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index b24dda002caa..5a1ea68b65da 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -1486,6 +1486,36 @@ public class StorageManager { return path; } + /** + * Translate given shared storage path from a path in an app sandbox + * namespace to a path in the system namespace. + * + * @hide + */ + public File translateAppToSystem(File file, String packageName) { + try { + return new File(mStorageManager.translateAppToSystem(file.getAbsolutePath(), + packageName, mContext.getUserId())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Translate given shared storage path from a path in the system namespace + * to a path in an app sandbox namespace. + * + * @hide + */ + public File translateSystemToApp(File file, String packageName) { + try { + return new File(mStorageManager.translateSystemToApp(file.getAbsolutePath(), + packageName, mContext.getUserId())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** {@hide} */ @VisibleForTesting public @NonNull ParcelFileDescriptor openProxyFileDescriptor( |
