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

Commit a4f24f08 authored by Eric Biggers's avatar Eric Biggers Committed by Gerrit Code Review
Browse files

Merge "Remove broken code for mounting encrypted OBB files"

parents ad309731 8bc9340b
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -54,13 +54,13 @@ interface IStorageManager {
     */
    void shutdown(IStorageShutdownObserver observer) = 19;
    /**
     * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
     * only allows the calling process's UID access to the contents.
     * StorageManagerService will call back to the supplied IObbActionListener to inform
     * it of the terminal state of the call.
     * Mounts an Opaque Binary Blob (OBB). Only allows the calling process's UID
     * access to the contents. StorageManagerService will call back to the
     * supplied IObbActionListener to inform it of the terminal state of the
     * call.
     */
    void mountObb(in String rawPath, in String canonicalPath, in String key,
            IObbActionListener token, int nonce, in ObbInfo obbInfo) = 21;
    void mountObb(in String rawPath, in String canonicalPath, IObbActionListener token,
            int nonce, in ObbInfo obbInfo) = 21;
    /**
     * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
     * any program using it will be forcibly killed to unmount the image.
+7 −6
Original line number Diff line number Diff line
@@ -665,9 +665,7 @@ public class StorageManager {
    }

    /**
     * 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.
     * Mount an Opaque Binary Blob (OBB) file.
     * <p>
     * The OBB will remain mounted for as long as the StorageManager reference
     * is held by the application. As soon as this reference is lost, the OBBs
@@ -680,19 +678,22 @@ public class StorageManager {
     * application's OBB that shares its UID.
     *
     * @param rawPath the path to the OBB file
     * @param key secret used to encrypt the OBB; may be <code>null</code> if no
     *            encryption was used on the OBB.
     * @param key must be <code>null</code>. Previously, some Android device
     *            implementations accepted a non-<code>null</code> key to mount
     *            an encrypted OBB file. However, this never worked reliably and
     *            is no longer supported.
     * @param listener will receive the success or failure of the operation
     * @return whether the mount call was successfully queued or not
     */
    public boolean mountObb(String rawPath, String key, OnObbStateChangeListener listener) {
        Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
        Preconditions.checkArgument(key == null, "mounting encrypted OBBs is no longer supported");
        Preconditions.checkNotNull(listener, "listener cannot be null");

        try {
            final String canonicalPath = new File(rawPath).getCanonicalPath();
            final int nonce = mObbActionListener.addListener(listener);
            mStorageManager.mountObb(rawPath, canonicalPath, key, mObbActionListener, nonce,
            mStorageManager.mountObb(rawPath, canonicalPath, mObbActionListener, nonce,
                    getObbInfo(canonicalPath));
            return true;
        } catch (IOException e) {
−269 KiB

File deleted.

−292 KiB

File deleted.

+10 −16
Original line number Diff line number Diff line
@@ -46,11 +46,7 @@ public class StorageManagerBaseTest extends InstrumentationTestCase {
    protected static String OBB_FILE_1_CONTENTS_1 = "OneToOneThousandInts.bin";
    protected static String OBB_FILE_2 = "obb_file2.obb";
    protected static String OBB_FILE_3 = "obb_file3.obb";
    protected static String OBB_FILE_1_PASSWORD = "password1";
    protected static String OBB_FILE_1_ENCRYPTED = "obb_enc_file100_orig1.obb";
    protected static String OBB_FILE_2_UNSIGNED = "obb_file2_nosign.obb";
    protected static String OBB_FILE_3_PASSWORD = "password3";
    protected static String OBB_FILE_3_ENCRYPTED = "obb_enc_file100_orig3.obb";
    protected static String OBB_FILE_3_BAD_PACKAGENAME = "obb_file3_bad_packagename.obb";

    protected static boolean FORCE = true;
@@ -180,22 +176,21 @@ public class StorageManagerBaseTest extends InstrumentationTestCase {
     * Mounts an OBB file
     *
     * @param obbFilePath The full path to the OBB file to mount
     * @param key (optional) The key to use to unencrypt the OBB; pass null for no encryption
     * @param expectedState The expected state resulting from trying to mount the OBB
     * @return A {@link String} representing the normalized path to OBB file that was mounted
     */
    protected String mountObb(String obbFilePath, String key, int expectedState) {
        return doMountObb(obbFilePath, key, expectedState);
    protected String mountObb(String obbFilePath, int expectedState) {
        return doMountObb(obbFilePath, expectedState);
    }

    /**
     * Mounts an OBB file with default options (no encryption, mounting succeeds)
     * Mounts an OBB file with default options.
     *
     * @param obbFilePath The full path to the OBB file to mount
     * @return A {@link String} representing the normalized path to OBB file that was mounted
     */
    protected String mountObb(String obbFilePath) {
        return doMountObb(obbFilePath, null, OnObbStateChangeListener.MOUNTED);
        return doMountObb(obbFilePath, OnObbStateChangeListener.MOUNTED);
    }

    /**
@@ -232,13 +227,13 @@ public class StorageManagerBaseTest extends InstrumentationTestCase {
     * @return true if the listener was signaled of a state change by the system; else a fail()
     *      is triggered if we timed out
     */
    protected String doMountObb_noThrow(String obbFilePath, String key, int expectedState) {
        Log.i(LOG_TAG, "doMountObb() on " + obbFilePath + " using key: " + key);
    protected String doMountObb_noThrow(String obbFilePath, int expectedState) {
        Log.i(LOG_TAG, "doMountObb() on " + obbFilePath);
        assertTrue ("Null path was passed in for OBB file!", obbFilePath != null);
        assertTrue ("Null path was passed in for OBB file!", obbFilePath != null);

        ObbListener obbListener = new ObbListener();
        boolean success = mSm.mountObb(obbFilePath, key, obbListener);
        boolean success = mSm.mountObb(obbFilePath, null, obbListener);
        success &= obbFilePath.equals(doWaitForObbStateChange(obbListener));
        success &= (expectedState == obbListener.state());

@@ -260,17 +255,16 @@ public class StorageManagerBaseTest extends InstrumentationTestCase {
     * Mounts an OBB file without throwing and synchronously waits for it to finish mounting
     *
     * @param obbFilePath The full path to the OBB file to mount
     * @param key (optional) The key to use to unencrypt the OBB; pass null for no encryption
     * @param expectedState The expected state resulting from trying to mount the OBB
     * @return A {@link String} representing the actual normalized path to OBB file that was
     *      mounted, or null if the mounting failed
     */
    protected String doMountObb(String obbFilePath, String key, int expectedState) {
        Log.i(LOG_TAG, "doMountObb() on " + obbFilePath + " using key: " + key);
    protected String doMountObb(String obbFilePath, int expectedState) {
        Log.i(LOG_TAG, "doMountObb() on " + obbFilePath);
        assertTrue ("Null path was passed in for OBB file!", obbFilePath != null);

        ObbListener obbListener = new ObbListener();
        assertTrue("mountObb call failed", mSm.mountObb(obbFilePath, key, obbListener));
        assertTrue("mountObb call failed", mSm.mountObb(obbFilePath, null, obbListener));
        assertTrue("Failed to get OBB mount status change for file: " + obbFilePath,
                doWaitForObbStateChange(obbListener));
        assertEquals("OBB mount state not what was expected!", expectedState,
Loading