Bug 792506 - AutoMounter should not allow UMS to be disabled while USB cable is plugged in. r=qDot

This commit is contained in:
Dave Hylands 2012-09-20 00:02:19 -07:00
parent be1841aacd
commit 61960aa498

View File

@ -253,6 +253,21 @@ public:
// AUTOMOUNTER_DISABLE_WHEN_UNPLUGGED implies "enabled until unplugged"
aMode = AUTOMOUNTER_DISABLE;
}
if ((aMode == AUTOMOUNTER_DISABLE) &&
(mMode == AUTOMOUNTER_ENABLE) && IsUsbCablePluggedIn()) {
// On many devices (esp non-Samsung), we can't force the disable, so we
// need to defer until the USB cable is actually unplugged.
// See bug 777043.
//
// Otherwise our attempt to disable it will fail, and we'll wind up in a bad
// state where the AutoMounter thinks that Sharing has been turned off, but
// the files are actually still being Shared because the attempt to unshare
// failed.
LOG("Attempting to disable UMS. Deferring until USB cable is unplugged.");
aMode = AUTOMOUNTER_DISABLE_WHEN_UNPLUGGED;
}
if (aMode != mMode) {
LOG("Changing mode from '%s' to '%s'", ModeStr(mMode), ModeStr(aMode));
mMode = aMode;