diff options
author | San Mehat <san@google.com> | 2010-02-09 19:30:34 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-02-09 19:30:34 -0800 |
commit | 739e1f8cdaee7ad448086f61412d118cb18152c5 (patch) | |
tree | 0fa259858bc835d739550151e8f77ced37598563 | |
parent | 46d350233328b703455ae10bf3ef724fa6733662 (diff) | |
parent | 6cdd9c08565a6871ad72cd388adfdfca23532e5e (diff) | |
download | frameworks_base-739e1f8cdaee7ad448086f61412d118cb18152c5.zip frameworks_base-739e1f8cdaee7ad448086f61412d118cb18152c5.tar.gz frameworks_base-739e1f8cdaee7ad448086f61412d118cb18152c5.tar.bz2 |
Merge "MountService: Add isSecureContainerMounted() API call"
-rw-r--r-- | core/java/android/os/storage/IMountService.aidl | 5 | ||||
-rw-r--r-- | services/java/com/android/server/MountService.java | 34 |
2 files changed, 39 insertions, 0 deletions
diff --git a/core/java/android/os/storage/IMountService.aidl b/core/java/android/os/storage/IMountService.aidl index 84e3f58..3d1ef25 100644 --- a/core/java/android/os/storage/IMountService.aidl +++ b/core/java/android/os/storage/IMountService.aidl @@ -109,6 +109,11 @@ interface IMountService int unmountSecureContainer(String id); /* + * Returns true if the specified container is mounted + */ + boolean isSecureContainerMounted(String id); + + /* * Rename an unmounted secure container. * Returns an int consistent with MountServiceResultCode */ diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 8d45033..456244a 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -37,6 +37,7 @@ import android.os.Handler; import android.text.TextUtils; import android.util.Log; import java.util.ArrayList; +import java.util.HashSet; import java.io.File; import java.io.FileReader; @@ -116,6 +117,11 @@ class MountService extends IMountService.Stub private boolean mBooted; private boolean mReady; + /** + * Private hash of currently mounted secure containers. + */ + private HashSet<String> mAsecMountSet = new HashSet<String>(); + private void waitForReady() { while (mReady == false) { for (int retries = 5; retries > 0; retries--) { @@ -862,6 +868,12 @@ class MountService extends IMountService.Stub } catch (NativeDaemonConnectorException e) { rc = StorageResultCode.OperationFailedInternalError; } + + if (rc == StorageResultCode.OperationSucceeded) { + synchronized (mAsecMountSet) { + mAsecMountSet.add(id); + } + } return rc; } @@ -870,6 +882,12 @@ class MountService extends IMountService.Stub waitForReady(); warnOnNotMounted(); + synchronized (mAsecMountSet) { + if (!mAsecMountSet.contains(id)) { + return StorageResultCode.OperationFailedVolumeNotMounted; + } + } + int rc = StorageResultCode.OperationSucceeded; String cmd = String.format("asec unmount %s", id); try { @@ -877,9 +895,25 @@ class MountService extends IMountService.Stub } catch (NativeDaemonConnectorException e) { rc = StorageResultCode.OperationFailedInternalError; } + + if (rc == StorageResultCode.OperationSucceeded) { + synchronized (mAsecMountSet) { + mAsecMountSet.remove(id); + } + } return rc; } + public boolean isSecureContainerMounted(String id) { + validatePermission(android.Manifest.permission.ASEC_ACCESS); + waitForReady(); + warnOnNotMounted(); + + synchronized (mAsecMountSet) { + return mAsecMountSet.contains(id); + } + } + public int renameSecureContainer(String oldId, String newId) { validatePermission(android.Manifest.permission.ASEC_RENAME); waitForReady(); |