Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf0cb26a authored by Kenny Root's avatar Kenny Root Committed by Android Git Automerger
Browse files

am f5ee5358: am ac9717ab: Merge "Move OBB file reading to DefaultContainerService" into gingerbread

Merge commit 'f5ee5358'

* commit 'f5ee5358':
  Move OBB file reading to DefaultContainerService
parents 6b63dce8 f5ee5358
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ LOCAL_SRC_FILES += \
	core/java/android/os/storage/IMountService.aidl \
	core/java/android/os/storage/IMountServiceListener.aidl \
	core/java/android/os/storage/IMountShutdownObserver.aidl \
	core/java/android/os/storage/IObbActionListener.aidl \
	core/java/android/os/INetworkManagementService.aidl \
	core/java/android/os/INetStatService.aidl \
	core/java/android/os/IPermissionController.aidl \
+4 −0
Original line number Diff line number Diff line
@@ -136185,6 +136185,8 @@
>
<parameter name="filename" type="java.lang.String">
</parameter>
<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
</exception>
</method>
<method name="isUsbMassStorageConnected"
 return="boolean"
@@ -136250,6 +136252,8 @@
</parameter>
<parameter name="force" type="boolean">
</parameter>
<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
</exception>
</method>
<method name="unregisterListener"
 return="void"
+9 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.os.storage;

import android.os.storage.IMountServiceListener;
import android.os.storage.IMountShutdownObserver;
import android.os.storage.IObbActionListener;

/** WARNING! Update IMountService.h and IMountService.cpp if you change this file.
 * In particular, the ordering of the methods below must match the 
@@ -156,14 +157,20 @@ interface IMountService
    /**
     * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and only
     * allows the calling process's UID access to the contents.
     *
     * MountService will call back to the supplied IObbActionListener to inform
     * it of the terminal state of the call.
     */
    int mountObb(String filename, String key);
    void mountObb(String filename, String key, IObbActionListener token);

    /**
     * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified, any
     * program using it will be forcibly killed to unmount the image.
     *
     * MountService will call back to the supplied IObbActionListener to inform
     * it of the terminal state of the call.
     */
    int unmountObb(String filename, boolean force);
    void unmountObb(String filename, boolean force, IObbActionListener token);

    /**
     * Checks whether the specified Opaque Binary Blob (OBB) is mounted somewhere.
+34 −0
Original line number Diff line number Diff line
/*
 * 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.os.storage;

/**
 * Callback class for receiving events from MountService about
 * Opaque Binary Blobs (OBBs).
 *
 * @hide - Applications should use android.os.storage.StorageManager
 * to interact with OBBs.
 */
interface IObbActionListener {
    /**
     * Return from an OBB action result.
     *
     * @param filename the path to the OBB the operation was performed on
     * @param returnCode status of the operation
     */
    void onObbResult(String filename, String status);
}
+59 −25
Original line number Diff line number Diff line
@@ -16,28 +16,14 @@

package android.os.storage;

import android.content.Context;
import android.os.Binder;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcelable;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.storage.IMountService;
import android.os.storage.IMountServiceListener;
import android.util.Log;
import android.util.SparseArray;

import java.io.FileDescriptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

/**
 * StorageManager is the interface to the systems storage service.
@@ -87,6 +73,17 @@ public class StorageManager
        }
    }

    /**
     * Binder listener for OBB action results.
     */
    private final ObbActionBinderListener mObbActionListener = new ObbActionBinderListener();
    private class ObbActionBinderListener extends IObbActionListener.Stub {
        @Override
        public void onObbResult(String filename, String status) throws RemoteException {
            Log.i(TAG, "filename = " + filename + ", result = " + status);
        }
    }

    /**
     * Private base class for messages sent between the callback thread
     * and the target looper handler.
@@ -290,12 +287,23 @@ public class StorageManager
    }

    /**
     * Mount an OBB file.
     * Mount an Opaque Binary Blob (OBB) file. If a <code>key</code> is
     * specified, it is supplied to the mounting process to be used in any
     * encryption used in the OBB.
     * <p>
     * <em>Note:</em> you can only mount OBB files for which the OBB tag on the
     * file matches a package ID that is owned by the calling program's UID.
     * That is, shared UID applications can obtain access to any other
     * application's OBB that shares its UID.
     * 
     * @param filename the path to the OBB file
     * @param key decryption key
     * @return whether the mount call was successfully queued or not
     */
    public boolean mountObb(String filename, String key) {
        try {
            return mMountService.mountObb(filename, key)
                    == StorageResultCode.OperationSucceeded;
            mMountService.mountObb(filename, key, mObbActionListener);
            return true;
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to mount OBB", e);
        }
@@ -304,12 +312,24 @@ public class StorageManager
    }

    /**
     * Mount an OBB file.
     * Unmount an Opaque Binary Blob (OBB) file. If the <code>force</code> flag
     * is true, it will kill any application needed to unmount the given OBB.
     * <p>
     * <em>Note:</em> you can only mount OBB files for which the OBB tag on the
     * file matches a package ID that is owned by the calling program's UID.
     * That is, shared UID applications can obtain access to any other
     * application's OBB that shares its UID.
     * 
     * @param filename path to the OBB file
     * @param force whether to kill any programs using this in order to unmount
     *            it
     * @return whether the unmount call was successfully queued or not
     * @throws IllegalArgumentException when OBB is not already mounted
     */
    public boolean unmountObb(String filename, boolean force) {
    public boolean unmountObb(String filename, boolean force) throws IllegalArgumentException {
        try {
            return mMountService.unmountObb(filename, force)
                    == StorageResultCode.OperationSucceeded;
            mMountService.unmountObb(filename, force, mObbActionListener);
            return true;
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to mount OBB", e);
        }
@@ -317,7 +337,13 @@ public class StorageManager
        return false;
    }

    public boolean isObbMounted(String filename) {
    /**
     * Check whether an Opaque Binary Blob (OBB) is mounted or not.
     * 
     * @param filename path to OBB image
     * @return true if OBB is mounted; false if not mounted or on error
     */
    public boolean isObbMounted(String filename) throws IllegalArgumentException {
        try {
            return mMountService.isObbMounted(filename);
        } catch (RemoteException e) {
@@ -328,13 +354,21 @@ public class StorageManager
    }

    /**
     * Check the mounted path of an OBB file.
     * Check the mounted path of an Opaque Binary Blob (OBB) file. This will
     * give you the path to where you can obtain access to the internals of the
     * OBB.
     * 
     * @param filename path to OBB image
     * @return absolute path to mounted OBB image data or <code>null</code> if
     *         not mounted or exception encountered trying to read status
     */
    public String getMountedObbPath(String filename) {
        try {
            return mMountService.getMountedObbPath(filename);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to find mounted path for OBB", e);
        } catch (IllegalArgumentException e) {
            Log.d(TAG, "Couldn't read OBB file", e);
        }

        return null;
Loading