services: MountService: Refactor MountService for vold2
Squash of the following: services: MountService: Rework the way volume states are handled MountService: Add new API for directly getting volume state via a mount point Environment: Switch from using system property for external storage state. MountService: Add support for UMS MountService: Fix a few bugs services: MountService: Add support for mount-on-insertion services: MountService: Add some debugging around UMS services: MountService: Fix some UMS bugs and clean-up startup mount code Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
@@ -18,6 +18,8 @@ package android.os;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.os.IMountService;
|
||||
|
||||
/**
|
||||
* Provides access to environment variables.
|
||||
*/
|
||||
@@ -28,6 +30,8 @@ public class Environment {
|
||||
|
||||
private static final String SYSTEM_PROPERTY_EFS_ENABLED = "persist.security.efs.enabled";
|
||||
|
||||
private static IMountService mMntSvc = null;
|
||||
|
||||
/**
|
||||
* Gets the Android root directory.
|
||||
*/
|
||||
@@ -167,9 +171,19 @@ public class Environment {
|
||||
|
||||
/**
|
||||
* Gets the current state of the external storage device.
|
||||
* Note: This call should be deprecated as it doesn't support
|
||||
* multiple volumes.
|
||||
*/
|
||||
public static String getExternalStorageState() {
|
||||
return SystemProperties.get("EXTERNAL_STORAGE_STATE", MEDIA_REMOVED);
|
||||
try {
|
||||
if (mMntSvc == null) {
|
||||
mMntSvc = IMountService.Stub.asInterface(ServiceManager
|
||||
.getService("mount"));
|
||||
}
|
||||
return mMntSvc.getVolumeState(getExternalStorageDirectory().toString());
|
||||
} catch (android.os.RemoteException rex) {
|
||||
return Environment.MEDIA_REMOVED;
|
||||
}
|
||||
}
|
||||
|
||||
static File getDirectory(String variableName, String defaultPath) {
|
||||
|
||||
@@ -75,4 +75,9 @@ interface IMountService
|
||||
* when a UMS host is detected.
|
||||
*/
|
||||
void setAutoStartUms(boolean value);
|
||||
|
||||
/**
|
||||
* Gets the state of an volume via it's mountpoint.
|
||||
*/
|
||||
String getVolumeState(String mountPoint);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user