diff options
author | Kenny Root <kroot@google.com> | 2010-07-15 21:35:53 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-07-15 21:35:53 -0700 |
commit | 181bb0ab461b1c8a6bf608f19c136fc0bbee7a3d (patch) | |
tree | 4f3d702e1c2290b99fd3a55289c91fbc9cf243aa /core/java/android | |
parent | aca672ba2eea19420df16906851d56077a3fd3b2 (diff) | |
parent | 02c8730c1bf19daf48bec8c6995df676a00a73b1 (diff) | |
download | frameworks_base-181bb0ab461b1c8a6bf608f19c136fc0bbee7a3d.zip frameworks_base-181bb0ab461b1c8a6bf608f19c136fc0bbee7a3d.tar.gz frameworks_base-181bb0ab461b1c8a6bf608f19c136fc0bbee7a3d.tar.bz2 |
am 02c8730c: Add API to call to vold for mounting OBBs
Merge commit '02c8730c1bf19daf48bec8c6995df676a00a73b1' into gingerbread-plus-aosp
* commit '02c8730c1bf19daf48bec8c6995df676a00a73b1':
Add API to call to vold for mounting OBBs
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/content/Context.java | 3 | ||||
-rwxr-xr-x | core/java/android/content/res/ObbInfo.aidl | 19 | ||||
-rw-r--r-- | core/java/android/content/res/ObbInfo.java | 71 | ||||
-rw-r--r-- | core/java/android/content/res/ObbScanner.java | 40 | ||||
-rw-r--r-- | core/java/android/os/storage/IMountService.aidl | 22 | ||||
-rw-r--r-- | core/java/android/os/storage/StorageManager.java | 64 |
6 files changed, 214 insertions, 5 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index a14bd8f..e3b7731 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1372,9 +1372,8 @@ public abstract class Context { public static final String SENSOR_SERVICE = "sensor"; /** - * @hide * Use with {@link #getSystemService} to retrieve a {@link - * android.os.storage.StorageManager} for accesssing system storage + * android.os.storage.StorageManager} for accessing system storage * functions. * * @see #getSystemService diff --git a/core/java/android/content/res/ObbInfo.aidl b/core/java/android/content/res/ObbInfo.aidl new file mode 100755 index 0000000..636ad6a --- /dev/null +++ b/core/java/android/content/res/ObbInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.content.res; + +parcelable ObbInfo; diff --git a/core/java/android/content/res/ObbInfo.java b/core/java/android/content/res/ObbInfo.java new file mode 100644 index 0000000..b18d784 --- /dev/null +++ b/core/java/android/content/res/ObbInfo.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.content.res; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Basic information about a Opaque Binary Blob (OBB) that reflects + * the info from the footer on the OBB file. + * @hide + */ +public class ObbInfo implements Parcelable { + /** + * The name of the package to which the OBB file belongs. + */ + public String packageName; + + /** + * The version of the package to which the OBB file belongs. + */ + public int version; + + public ObbInfo() { + } + + public String toString() { + return "ObbInfo{" + + Integer.toHexString(System.identityHashCode(this)) + + " packageName=" + packageName + ",version=" + version + "}"; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int parcelableFlags) { + dest.writeString(packageName); + dest.writeInt(version); + } + + public static final Parcelable.Creator<ObbInfo> CREATOR + = new Parcelable.Creator<ObbInfo>() { + public ObbInfo createFromParcel(Parcel source) { + return new ObbInfo(source); + } + + public ObbInfo[] newArray(int size) { + return new ObbInfo[size]; + } + }; + + private ObbInfo(Parcel source) { + packageName = source.readString(); + version = source.readInt(); + } +} diff --git a/core/java/android/content/res/ObbScanner.java b/core/java/android/content/res/ObbScanner.java new file mode 100644 index 0000000..eb383c3 --- /dev/null +++ b/core/java/android/content/res/ObbScanner.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.content.res; + +/** + * Class to scan Opaque Binary Blob (OBB) files. + * @hide + */ +public class ObbScanner { + // Don't allow others to instantiate this class + private ObbScanner() {} + + public static ObbInfo getObbInfo(String filePath) { + if (filePath == null) { + return null; + } + + ObbInfo obbInfo = new ObbInfo(); + if (!getObbInfo_native(filePath, obbInfo)) { + throw new IllegalArgumentException("Could not read OBB file: " + filePath); + } + return obbInfo; + } + + private native static boolean getObbInfo_native(String filePath, ObbInfo obbInfo); +} diff --git a/core/java/android/os/storage/IMountService.aidl b/core/java/android/os/storage/IMountService.aidl index 4862f80..ca7efe7 100644 --- a/core/java/android/os/storage/IMountService.aidl +++ b/core/java/android/os/storage/IMountService.aidl @@ -152,4 +152,26 @@ interface IMountService * processing the media status update request. */ void finishMediaUpdate(); + + /** + * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and only + * allows the calling process's UID access to the contents. + */ + int mountObb(String filename, String key); + + /** + * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified, any + * program using it will be forcibly killed to unmount the image. + */ + int unmountObb(String filename, boolean force); + + /** + * Checks whether the specified Opaque Binary Blob (OBB) is mounted somewhere. + */ + boolean isObbMounted(String filename); + + /** + * Gets the path to the mounted Opaque Binary Blob (OBB). + */ + String getMountedObbPath(String filename); } diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index a12603c..96bf2d5 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -44,9 +44,6 @@ import java.util.List; * Get an instance of this class by calling * {@link android.content.Context#getSystemService(java.lang.String)} with an argument * of {@link android.content.Context#STORAGE_SERVICE}. - * - * @hide - * */ public class StorageManager @@ -209,6 +206,7 @@ public class StorageManager * * @param listener A {@link android.os.storage.StorageEventListener StorageEventListener} object. * + * @hide */ public void registerListener(StorageEventListener listener) { if (listener == null) { @@ -225,6 +223,7 @@ public class StorageManager * * @param listener A {@link android.os.storage.StorageEventListener StorageEventListener} object. * + * @hide */ public void unregisterListener(StorageEventListener listener) { if (listener == null) { @@ -245,6 +244,8 @@ public class StorageManager /** * Enables USB Mass Storage (UMS) on the device. + * + * @hide */ public void enableUsbMassStorage() { try { @@ -256,6 +257,8 @@ public class StorageManager /** * Disables USB Mass Storage (UMS) on the device. + * + * @hide */ public void disableUsbMassStorage() { try { @@ -268,6 +271,8 @@ public class StorageManager /** * Query if a USB Mass Storage (UMS) host is connected. * @return true if UMS host is connected. + * + * @hide */ public boolean isUsbMassStorageConnected() { try { @@ -281,6 +286,8 @@ public class StorageManager /** * Query if a USB Mass Storage (UMS) is enabled on the device. * @return true if UMS host is enabled. + * + * @hide */ public boolean isUsbMassStorageEnabled() { try { @@ -290,4 +297,55 @@ public class StorageManager } return false; } + + /** + * Mount an OBB file. + */ + public boolean mountObb(String filename, String key) { + try { + return mMountService.mountObb(filename, key) + == StorageResultCode.OperationSucceeded; + } catch (RemoteException e) { + Log.e(TAG, "Failed to mount OBB", e); + } + + return false; + } + + /** + * Mount an OBB file. + */ + public boolean unmountObb(String filename, boolean force) { + try { + return mMountService.unmountObb(filename, force) + == StorageResultCode.OperationSucceeded; + } catch (RemoteException e) { + Log.e(TAG, "Failed to mount OBB", e); + } + + return false; + } + + public boolean isObbMounted(String filename) { + try { + return mMountService.isObbMounted(filename); + } catch (RemoteException e) { + Log.e(TAG, "Failed to check if OBB is mounted", e); + } + + return false; + } + + /** + * Check the mounted path of an OBB file. + */ + public String getMountedObbPath(String filename) { + try { + return mMountService.getMountedObbPath(filename); + } catch (RemoteException e) { + Log.e(TAG, "Failed to find mounted path for OBB", e); + } + + return null; + } } |