Bug 1091544 - Set volume as STATE_MOUNT_FAIL while mounting the volume failed, r=dhylands.

This commit is contained in:
Eden Chuang 2015-01-12 12:01:07 +08:00
parent 1ebfec775a
commit 2d9177ec18
4 changed files with 17 additions and 5 deletions

View File

@ -1059,15 +1059,16 @@ AutoMounter::UpdateState()
vol->StartUnmount(mResponseCallback);
return; // UpdateState will be called again when the Unmount command completes
}
case nsIVolume::STATE_IDLE: {
LOG("UpdateState: Volume %s is nsIVolume::STATE_IDLE", vol->NameStr());
case nsIVolume::STATE_IDLE:
case nsIVolume::STATE_MOUNT_FAIL: {
LOG("UpdateState: Volume %s is %s", vol->NameStr(), vol->StateStr());
if (vol->IsFormatting() && !vol->IsFormatRequested()) {
vol->SetFormatRequested(false);
LOG("UpdateState: Mounting %s", vol->NameStr());
vol->StartMount(mResponseCallback);
break;
}
if (tryToShare && vol->IsSharingEnabled()) {
if (tryToShare && vol->IsSharingEnabled() && volState == nsIVolume::STATE_IDLE) {
// Volume is unmounted. We can go ahead and share.
LOG("UpdateState: Sharing %s", vol->NameStr());
vol->StartShare(mResponseCallback);

View File

@ -337,11 +337,13 @@ Volume::SetState(Volume::STATE aNewState)
break;
case nsIVolume::STATE_MOUNTED:
case nsIVolume::STATE_MOUNT_FAIL:
mMountRequested = false;
mIsFormatting = false;
mIsSharing = false;
mIsUnmounting = false;
break;
case nsIVolume::STATE_FORMATTING:
mFormatRequested = false;
mIsFormatting = true;
@ -541,7 +543,12 @@ Volume::HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer& aTokenizer
// then the AutoMounter will set the volume as STATE_MOUNTED.
SetState(nsIVolume::STATE_CHECKMNT);
} else {
SetState(newState);
if (State() == nsIVolume::STATE_CHECKING && newState == nsIVolume::STATE_IDLE) {
LOG("Mount of volume '%s' failed", NameStr());
SetState(nsIVolume::STATE_MOUNT_FAIL);
} else {
SetState(newState);
}
}
break;
}

View File

@ -5,10 +5,12 @@
#include "nsISupports.idl"
#include "nsIVolumeStat.idl"
[scriptable, uuid(946B5334-6EC9-11E4-8689-F3061E5D46B0)]
[scriptable, uuid(EE752CB8-8FD7-11E4-A602-70221D5D46B0)]
interface nsIVolume : nsISupports
{
// These MUST match the states from android's system/vold/Volume.h header
// Note: Changes made to the STATE_xxx names should also be reflected in the
// NS_VolumeStateStr function found in Volume.cpp
const long STATE_INIT = -1;
const long STATE_NOMEDIA = 0;
const long STATE_IDLE = 1;
@ -20,6 +22,7 @@ interface nsIVolume : nsISupports
const long STATE_SHARED = 7;
const long STATE_SHAREDMNT = 8;
const long STATE_CHECKMNT = 100;
const long STATE_MOUNT_FAIL = 101;
// The name of the volume. Often there is only one volume, called sdcard.
// But some phones support multiple volumes.

View File

@ -38,6 +38,7 @@ NS_VolumeStateStr(int32_t aState)
case nsIVolume::STATE_SHARED: return "Shared";
case nsIVolume::STATE_SHAREDMNT: return "Shared-Mounted";
case nsIVolume::STATE_CHECKMNT: return "Check-Mounted";
case nsIVolume::STATE_MOUNT_FAIL: return "Mount-Fail";
}
return "???";
}