Bug 1113518 - [automounter] Add a case for fuse and add some useful logs. r=dhylands

This commit is contained in:
Alphan Chen 2015-01-27 13:54:31 +08:00
parent b9fc329ce5
commit a68bf1c038
2 changed files with 19 additions and 4 deletions

View File

@ -106,6 +106,7 @@ namespace system {
#define USB_FUNC_NONE "none"
#define USB_FUNC_RNDIS "rndis"
#define USB_FUNC_UMS "mass_storage"
#define USB_FUNC_DEFAULT "default"
class AutoMounter;
@ -552,6 +553,9 @@ SetUsbFunction(const char* aUsbFunc)
// We're enabling UMS. For this we make the assumption that the persisted
// property has mass_storage enabled.
property_get(PERSIST_SYS_USB_CONFIG, newSysUsbConfig, "");
} else if (strcmp(aUsbFunc, USB_FUNC_DEFAULT) == 0) {
// Set the property as PERSIST_SYS_USB_CONFIG
property_get(PERSIST_SYS_USB_CONFIG, newSysUsbConfig, "");
} else {
printf_stderr("AutoMounter::SetUsbFunction Unrecognized aUsbFunc '%s'\n", aUsbFunc);
MOZ_ASSERT(0);
@ -626,6 +630,7 @@ AutoMounter::StartMtpServer()
sMozMtpServer = new MozMtpServer();
if (!sMozMtpServer->Init()) {
sMozMtpServer = nullptr;
return false;
}
@ -786,9 +791,15 @@ AutoMounter::UpdateState()
if (StartMtpServer()) {
SetState(STATE_MTP_STARTED);
} else {
// Unable to start MTP. Go back to UMS.
SetUsbFunction(USB_FUNC_UMS);
SetState(STATE_UMS_CONFIGURING);
if (umsAvail) {
// Unable to start MTP. Go back to UMS.
LOG("UpdateState: StartMtpServer failed, switch to UMS");
SetUsbFunction(USB_FUNC_UMS);
SetState(STATE_UMS_CONFIGURING);
} else {
LOG("UpdateState: StartMtpServer failed, keep idle state");
SetUsbFunction(USB_FUNC_DEFAULT);
}
}
} else {
// We need to configure USB to use mtp. Wait for it to be configured
@ -849,6 +860,10 @@ AutoMounter::UpdateState()
SetState(STATE_UMS_CONFIGURING);
break;
}
// if ums/rndis is not available and mtp is disable,
// restore the usb function as PERSIST_SYS_USB_CONFIG.
SetUsbFunction(USB_FUNC_DEFAULT);
SetState(STATE_IDLE);
break;

View File

@ -232,7 +232,7 @@ MozMtpServer::Init()
const char *mtpUsbFilename = "/dev/mtp_usb";
mMtpUsbFd = open(mtpUsbFilename, O_RDWR);
if (mMtpUsbFd.get() < 0) {
MTP_ERR("open of '%s' failed", mtpUsbFilename);
MTP_ERR("open of '%s' failed((%s))", mtpUsbFilename, strerror(errno));
return false;
}
MTP_LOG("Opened '%s' fd %d", mtpUsbFilename, mMtpUsbFd.get());