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

Commit 4270e1ea authored by San Mehat's avatar San Mehat
Browse files

MountService: Massive bloat reduction and rewrite



- Most API calls now return an int as a result code (see MountServiceResultCode.java)
- All notification code has been removed
- All settings code has been removed
- Removed UMS centric API calls in favor of more generic 'shares'
- Mount error reporting is no longer done via an event, but is done as part of the
  actual mount process
- Rework vold IPC commands to be more sane

Updated:
    MountService: Rename MountServiceObserver -> MountServiceListener
    MountService: Add support for Async callbacks

Updated:
    MountService: Add BinderDeath handling

Updated:
    MountService: Remove notifys since we dont listen anyways

Updated:
    MountService: Fix bad cast

Signed-off-by: default avatarSan Mehat <san@google.com>
parent 78071b73
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ LOCAL_SRC_FILES += \
	core/java/android/os/ICheckinService.aidl \
	core/java/android/os/IMessenger.aidl \
	core/java/android/os/IMountService.aidl \
	core/java/android/os/IMountServiceObserver.aidl \
	core/java/android/os/IMountServiceListener.aidl \
	core/java/android/os/INetworkManagementService.aidl \
	core/java/android/os/INetStatService.aidl \
	core/java/android/os/IParentalControlCallback.aidl \
+47 −25
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@

package android.os;

import android.os.IMountServiceListener;

/** WARNING! Update IMountService.h and IMountService.cpp if you change this file.
 * In particular, the ordering of the methods below must match the 
 * _TRANSACTION enum in IMountService.cpp
@@ -25,44 +27,60 @@ package android.os;
interface IMountService
{
    /**
     * Is mass storage support enabled?
     * Registers an IMountServiceListener for receiving async
     * notifications.
     */
    boolean getMassStorageEnabled();
    void registerListener(IMountServiceListener listener);

    /**
     * Enable or disable mass storage support.
     * Unregisters an IMountServiceListener
     */
    void setMassStorageEnabled(boolean enabled);
    void unregisterListener(IMountServiceListener listener);

    /**
     * Is mass storage connected?
     * Gets an Array of supported share methods
     */
    boolean getMassStorageConnected();
    String[] getShareMethodList();

    /**
     * Mount external storage at given mount point.
     * Returns true if the share method is available
     */
    void mountVolume(String mountPoint);
    boolean getShareMethodAvailable(String method);

    /**
     * Safely unmount external storage at given mount point.
     * Shares a volume via the specified method
     * Returns an int consistent with MountServiceResultCode
     */
    void unmountVolume(String mountPoint);
    int shareVolume(String path, String method);

    /**
     * Format external storage given a mount point.
     * Unshares a volume via the specified method
     * Returns an int consistent with MountServiceResultCode
     */
    void formatVolume(String mountPoint);
    int unshareVolume(String path, String method);

    /**
     * Returns true if media notification sounds are enabled.
     * Returns true if the volume is shared via the specified method.
     */
    boolean getPlayNotificationSounds();
    boolean getVolumeShared(String path, String method);

    /**
     * Sets whether or not media notification sounds are played.
     * Mount external storage at given mount point.
     * Returns an int consistent with MountServiceResultCode
     */
    int mountVolume(String mountPoint);

    /**
     * Safely unmount external storage at given mount point.
     * Returns an int consistent with MountServiceResultCode
     */
    int unmountVolume(String mountPoint);

    /**
     * Format external storage given a mount point.
     * Returns an int consistent with MountServiceResultCode
     */
    void setPlayNotificationSounds(boolean value);
    int formatVolume(String mountPoint);

    /**
     * Gets the state of an volume via it's mountpoint.
@@ -71,37 +89,41 @@ interface IMountService

    /*
     * Creates a secure container with the specified parameters.
     * On success, the filesystem container-path is returned.
     * Returns an int consistent with MountServiceResultCode
     */
    String createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid);
    int createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid);

    /*
     * Finalize a container which has just been created and populated.
     * After finalization, the container is immutable.
     * Returns an int consistent with MountServiceResultCode
     */
    void finalizeSecureContainer(String id);
    int finalizeSecureContainer(String id);

    /*
     * Destroy a secure container, and free up all resources associated with it.
     * NOTE: Ensure all references are released prior to deleting.
     * Returns an int consistent with MountServiceResultCode
     */
    void destroySecureContainer(String id);
     int destroySecureContainer(String id);

    /*
     * Mount a secure container with the specified key and owner UID.
     * On success, the filesystem container-path is returned.
     * Returns an int consistent with MountServiceResultCode
     */
    String mountSecureContainer(String id, String key, int ownerUid);
    int mountSecureContainer(String id, String key, int ownerUid);

    /*
     * Unount a secure container.
     * Returns an int consistent with MountServiceResultCode
     */
    void unmountSecureContainer(String id);
    int unmountSecureContainer(String id);

    /*
     * Rename an unmounted secure container.
     * Returns an int consistent with MountServiceResultCode
     */
    void renameSecureContainer(String oldId, String newId);
    int renameSecureContainer(String oldId, String newId);

    /*
     * Returns the filesystem path of a mounted secure container.
+5 −5
Original line number Diff line number Diff line
@@ -21,14 +21,14 @@ package android.os;
 *
 * @hide
 */
interface IMountServiceObserver {
interface IMountServiceListener {
    /**
     * A sharing method has changed availability state.
     *
     * @param method The share method which has changed.
     * @param available The share availability state.
     */
    void shareAvailabilityChange(String method, boolean available);
    void onShareAvailabilityChanged(String method, boolean available);

    /**
     * Media has been inserted
@@ -38,7 +38,7 @@ interface IMountServiceObserver {
     * @param major The backing device major number.
     * @param minor The backing device minor number.
     */
    void mediaInserted(String label, String path, int major, int minor);
    void onMediaInserted(String label, String path, int major, int minor);

    /**
     * Media has been removed
@@ -49,7 +49,7 @@ interface IMountServiceObserver {
     * @param minor The backing device minor number.
     * @param clean Indicates if the removal was clean (unmounted first).
     */
    void mediaRemoved(String label, String path, int major, int minor, boolean clean);
    void onMediaRemoved(String label, String path, int major, int minor, boolean clean);

    /**
     *  Volume state has changed.
@@ -61,6 +61,6 @@ interface IMountServiceObserver {
     *
     * Note: State is one of the values returned by Environment.getExternalStorageState()
     */
    void volumeStateChange(String label, String path, String oldState, String newState);
    void onVolumeStateChanged(String label, String path, String oldState, String newState);

}
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ package android.os;
 * methods will all be called on your application's main thread.
 * @hide
 */
public abstract class MountServiceObserver {
public abstract class MountServiceListener {
    /**
     * A sharing method has changed availability state.
     *
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 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;

import java.io.IOException;

/**
 * Class that provides access to constants returned from MountService APIs
 *
 * {@hide}
 */
public class MountServiceResultCode
{
    public static final int OperationSucceeded               =  0;
    public static final int OperationFailedInternalError     = -1;
    public static final int OperationFailedNoMedia           = -2;
    public static final int OperationFailedMediaBlank        = -3;
    public static final int OperationFailedMediaCorrupt      = -4;
    public static final int OperationFailedVolumeNotMounted  = -5;
}
Loading