From 59443a673a736978361dc341f41ce4e9dae053a0 Mon Sep 17 00:00:00 2001 From: San Mehat Date: Tue, 9 Feb 2010 13:28:45 -0800 Subject: MountService: Check for failure to unmount when enabling UMS and fix reversed logic Signed-off-by: San Mehat --- services/java/com/android/server/MountService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 6de2effe388e..8d450337a13a 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -177,8 +177,12 @@ class MountService extends IMountService.Stub String vs = getVolumeState(path); if (enable && vs.equals(Environment.MEDIA_MOUNTED)) { mUmsEnabling = enable; // Override for isUsbMassStorageEnabled() - doUnmountVolume(path); + int rc = doUnmountVolume(path); mUmsEnabling = false; // Clear override + if (rc != StorageResultCode.OperationSucceeded) { + Log.e(TAG, String.format("Failed to unmount before enabling UMS (%d)", rc)); + return rc; + } } try { @@ -517,7 +521,7 @@ class MountService extends IMountService.Stub } private int doUnmountVolume(String path) { - if (getVolumeState(path).equals(Environment.MEDIA_MOUNTED)) { + if (!getVolumeState(path).equals(Environment.MEDIA_MOUNTED)) { return VoldResponseCode.OpFailedVolNotMounted; } -- cgit v1.2.3-59-g8ed1b