Closed Bug 1142450 Opened 5 years ago Closed 4 years ago

[Flame][MTP]The device will automatically switch to UMS from MTP.

Categories

(Firefox OS Graveyard :: Gaia::Settings, defect, major)

ARM
Gonk (Firefox OS)
defect
Not set
major

Tracking

(blocking-b2g:2.5+, b2g-v2.1 unaffected, b2g-v2.2 affected, b2g-master affected)

RESOLVED DUPLICATE of bug 1194045
FxOS-S7 (18Sep)
blocking-b2g 2.5+
Tracking Status
b2g-v2.1 --- unaffected
b2g-v2.2 --- affected
b2g-master --- affected

People

(Reporter: fan.luo, Assigned: edenchuang)

References

Details

(Keywords: regression, Whiteboard: [2.2-nexus-5-l])

Attachments

(4 files)

Attached video Video.mp4
[1.Description]:
[Flame][v2.2][MTP]The device will automatically switch to UMS from MTP. And MTP is still checked in device.
Attached: Video.mp4 and logcat.txt
Found at: 1:43am.

[2.Testing Steps]: 
1. Launch Settings
2. Tap USB Storage
3. Check MTP
4. Enable USB Storage
5. Do some other operations or let device stay idle.

[3.Expected Result]: 
5. Device works normally and storage is still in MTP.

[4.Actual Result]: 
5. Device will switch to UMS automatically.

[5.Reproduction build]: 
Woodduck 2.0M(Unaffect):
Build ID               20150312050313
Gaia Revision          0e0a84a03f7253d1544e6e8ecbadac9d0f325a64
Gaia Date              2015-03-11 05:43:46
Gecko Revision         4dd211ecc070564dea1af8fc5125cfc748f24a23
Gecko Version          32.0
Device Name            jrdhz72_w_ff
Firmware(Release)      4.4.2
Firmware(Incremental)  1426107908
Firmware Date          Thu Mar 12 05:05:26 CST 2015

------------------
Flame 2.0(Unaffect):
Build ID               20150311000206
Gaia Revision          896803174633fc6acd3fd105f81c349b8e9b9633
Gaia Date              2015-03-10 06:32:26
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g32_v2_0/rev/78df3174fb10
Gecko Version          32.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150311.034723
Firmware Date          Wed Mar 11 03:47:34 EDT 2015
Bootloader             L1TC000118D0
------------------
Flame 2.1(Unaffect):
Build ID               20150311001232
Gaia Revision          04623ffbdc1e9c53de5a9a522bc9d8d93020a56d
Gaia Date              2015-03-10 18:12:15
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/421ee858039c
Gecko Version          34.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150311.040426
Firmware Date          Wed Mar 11 04:04:37 EDT 2015
Bootloader             L1TC000118D0
------------------
Flame 2.1s_256mb(Unaffect):
Build ID               20150311001238
Gaia Revision          a66813e488374b8ba9d8aa187b00f84ad5bd1bb9
Gaia Date              2015-03-10 06:56:29
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g34_v2_1s/rev/ee8a2d1b86a5
Gecko Version          34.0
Device Name            scx15_sp7715ga
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150311.040335
Firmware Date          Wed Mar 11 04:03:48 EDT 2015
------------------
Flame 2.2(Affect):
Build ID               20150311002522
Gaia Revision          3f032238a52f08e4c2f68a47ad065a96eb22d470
Gaia Date              2015-03-11 00:28:07
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g37_v2_2/rev/004fa1cb1dd4
Gecko Version          37.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150311.040546
Firmware Date          Wed Mar 11 04:05:57 EDT 2015
Bootloader             L1TC000118D0
----------------
N5_2.2(Unaffect):
Build ID               20150311002522
Gaia Revision          3f032238a52f08e4c2f68a47ad065a96eb22d470
Gaia Date              2015-03-11 00:28:07
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g37_v2_2/rev/004fa1cb1dd4
Gecko Version          37.0
Device Name            hammerhead
Firmware(Release)      5.0
Firmware(Incremental)  eng.cltbld.20150311.040337
Firmware Date          Wed Mar 11 04:03:52 EDT 2015
Bootloader             HHZ12d
----------------
Flame 3.0(Unaffect):
Build ID               20150311010231
Gaia Revision          943c8b4039f59b08ba100390e164a076a20c892e
Gaia Date              2015-03-10 20:35:07
Gecko Revision         https://hg.mozilla.org/mozilla-central/rev/fd8e079d6335
Gecko Version      

[6.Reproduction Frequency]: 
Seldom Recurrence,2/10

[7.TCID]: 
14299
Attached file logcat.txt
Hi Alison, Could you take a look at this, thank you.
Flags: needinfo?(ashiue)
Unfortunately, I could not reproduce this problem.
Could you please keep monitor if this issue still occur at recently build?
Flags: needinfo?(ashiue)
Attached video VIDEO0602.3gp
Hi Alison,

Sorry for so late reply.
Now I can 100% repro this bug with below STR. 
1. Launch Settings
2. Enable USB Storage
3. Tap USB storage and check MTP
4. Lock screen
5. Unlock screen.

Actual result: the MTP mode in PC will change to UMS automatically.

See attachment: VIDEO0602.3gp, logcat_2011.txt
Found at: 20:11
Rate: 100%

I also check the flame v2.1, found it is a regression bug since the flame v2.1 is unaffected.

Flame v2.1(Unaffected)
Build ID               20150628001204
Gaia Revision          f8b848c82d1ed589f7a1eb5cc099830c867ff1d4
Gaia Date              2015-06-08 09:48:23
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/d3e432c4546a
Gecko Version          34.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150628.033856
Firmware Date          Sun Jun 28 03:39:07 EDT 2015
Bootloader             L1TC000118D0

Flame v2.2(Affected):
Build ID               20150628002505
Gaia Revision          0179935627012dfde3ca036c9a71035be463b7ad
Gaia Date              2015-06-26 21:13:44
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g37_v2_2/rev/35e09270da3a
Gecko Version          37.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150628.035537
Firmware Date          Sun Jun 28 03:55:48 EDT 2015
Bootloader             L1TC000118D0

Flame v3.0(Affected):
Build ID               20150629134017
Gaia Revision          27fe0f4261e3685187769411f2f74cff19287b19
Gaia Date              2015-06-29 14:29:00
Gecko Revision         https://hg.mozilla.org/mozilla-central/rev/c26dbd63604d
Gecko Version          42.0a1
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150629.170951
Firmware Date          Mon Jun 29 17:10:03 EDT 2015
Bootloader             L1TC000118D0

N5 v2.2(Affected):
Build ID               20150626162505
Gaia Revision          0179935627012dfde3ca036c9a71035be463b7ad
Gaia Date              2015-06-26 21:13:44
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g37_v2_2/rev/330f52ef6a2d
Gecko Version          37.0
Device Name            hammerhead
Firmware(Release)      5.1
Firmware(Incremental)  eng.cltbld.20150626.195122
Firmware Date          Fri Jun 26 19:51:42 EDT 2015
Bootloader             HHZ12f

N5 v3.0(Affected):
Build ID               20150628160206
Gaia Revision          8a1e4ae522c121c5cacd39b20a5386ec9055db82
Gaia Date              2015-06-25 21:58:25
Gecko Revision         https://hg.mozilla.org/mozilla-central/rev/eaf4f9b45117
Gecko Version          41.0a1
Device Name            hammerhead
Firmware(Release)      5.1
Firmware(Incremental)  eng.cltbld.20150628.192615
Firmware Date          Sun Jun 28 19:26:32 EDT 2015
Bootloader             HHZ12f
Attached file logcat_2011.txt
Flags: needinfo?(ashiue)
NI Hermes to let him know this bug.
Severity: normal → major
Flags: needinfo?(hcheng)
Keywords: regression
Whiteboard: [2.2-nexus-5-l]
Make a supplementary for comment 4: in Nexus 5 v2.2 and Nexus 5 v3.0, the actual result is MTP mode in PC will disappear, and UMS disk will not appear.
Update the 100% reproduce steps:
1. Toggle USB storage in Settings (ex, default is UMS)
2. Go inside USB storage to select another protocol (ex, MTP)
3. Lock screen and unlock screen
4. The protocol would change to another one(ex, UMS)
Flags: needinfo?(ashiue)
Nominate to block 2.2 since this is a serious function issue.
blocking-b2g: --- → 2.2?
QA Whiteboard: [COM=MTP/UMS]
Component: Gaia::Settings → MTP/UMS
I find that both the oldest flame v2.1&flame v2.2 build can also repro this bug, while the bug can't be repro on flame v2.1 latest build. So I do the regression window on v2.1 nightly build to find out which patch fixed the bug on v2.1

Nightly Regression Window: 

Last Broken
Device: Flame v2.1
Gaia-Rev        234ec27050481f4787f1f4750ec26f62ce5cc2c0
Gecko-Rev       https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/103ca3fdec47
Build-ID        20150124001230
Version         34.0
Device-Name     flame
FW-Release      4.4.2
FW-Incremental  eng.cltbld.20150124.194942
FW-Date         Sat Jan 24 19:49:53 EST 2015
Bootloader      L1TC000118D0

First Working
Device: Flame v2.1
Gaia-Rev        54d92cc0755e5102223276ab23063b5eee74b514
Gecko-Rev       https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/522d6c980917
Build-ID        20150124161204
Version         34.0
Device-Name     flame
FW-Release      4.4.2
FW-Incremental  eng.cltbld.20150124.194942
FW-Date         Sat Jan 24 19:49:53 EST 2015
Bootloader      L1TC000118D0

Last Broken gaia+First Working gecko: Issue DOES reproduce
Gaia:234ec27050481f4787f1f4750ec26f62ce5cc2c0
Gecko:522d6c980917

Last Broken gecko+First Working gaia: Issue DOES NOT reproduce
Gaia:54d92cc0755e5102223276ab23063b5eee74b514
Gecko:103ca3fdec47

Gaia pushlog: https://github.com/mozilla-b2g/gaia/compare/234ec27050481f4787f1f4750ec26f62ce5cc2c0...54d92cc0755e5102223276ab23063b5eee74b514

It seems that bug 1111725 fixed this bug on flame v2.1
QA Whiteboard: [COM=MTP/UMS] → [COM=MTP/UMS][MGSEI-Triage+]
I found that before executing unlock screen, the protocol keeps the original protocol and can work normally on PC side(through MTP or UMS).

Following is the related log according to the steps of comment 8

After toggle USB storage in Settings

 1798 07-03 05:56:47.250  2812  2835 I AutoMounter: Changing mode from 'Disable' to 'Enable-UMS'

After switch protocol to MTP

 4657 07-03 05:56:57.980  2812  2835 I AutoMounter: Changing mode from 'Enable-UMS' to 'Enable-MTP'
 ...
 5426 07-03 05:56:58.290  2812  2835 I MozMtp  : Init: Opened '/dev/mtp_usb' fd 116
 5427 07-03 05:56:58.290  2812  2835 I MozMtp  : MozMtpStorage: Storage constructed for Volume sdcard mStorageID 0x00010001
 5428 07-03 05:56:58.290  2812  2835 I MozMtp  : Notify: Volume sdcard mStorageID 0x00010001 state changed to Mounted SharingEn      abled: 1
 5429 07-03 05:56:58.290  2812  2835 I MozMtp  : StorageAvailable: Adding Volume sdcard mStorageID 0x00010001 mountPoint /stora      ge/sdcard to MozMtpDatabase
 5430 07-03 05:56:58.300  2812  2835 I MozMtp  : AddStorage: added 8 items from tree '/storage/sdcard'
 5431 07-03 05:56:58.300  2812  2835 I MozMtp  : StorageAvailable: Adding Volume sdcard mStorageID 0x00010001 mountPoint /stora      ge/sdcard to MtpServer
 5432 07-03 05:56:58.300  2812  2835 I MozMtp  : Notify: Volume sdcard mStorageID 0x00010001 state changed to Mounted SharingEn      abled: 1
 5433 07-03 05:56:58.300  2812  2835 I MozMtp  : MozMtpStorage: Storage constructed for Volume sdcard1 mStorageID 0x00020001
 5434 07-03 05:56:58.300  2812  2835 I MozMtp  : Notify: Volume sdcard1 mStorageID 0x00020001 state changed to NoMedia SharingE      nabled: 1
 5435 07-03 05:56:58.300  2812  2835 I MozMtp  : Notify: Volume sdcard1 mStorageID 0x00020001 state changed to NoMedia SharingE      nabled: 1

After lock screen

 6512 07-03 05:57:07.630  2812  2835 I AutoMounter: Changing mode from 'Enable-MTP' to 'DisableWhenUnplugged'

After unlock screen

 9203 07-03 05:57:13.980  2812  2835 I AutoMounter: Changing mode from 'DisableWhenUnplugged' to 'Enable-UMS'
 9204 07-03 05:57:13.980  2812  2835 I AutoMounter: Stopping MtpServer
 9205 07-03 05:57:13.980  2812  2835 I MozMtp  : ~MozMtpStorage: Storage destructed for Volume sdcard mStorageID 0x00010001
 9206 07-03 05:57:13.980  2812  2835 I MozMtp  : StorageUnavailable: Removing mStorageID 0x00010001 from MtpServer
 9207 07-03 05:57:13.980  2812  2835 I MozMtp  : StorageUnavailable: Removing mStorageID 0x00010001 from MozMtpDatabse
 9208 07-03 05:57:13.980  2812  2835 I MozMtp  : ~MozMtpStorage: Storage destructed for Volume sdcard1 mStorageID 0x00020001
 9209 07-03 05:57:13.980  2812  2835 I AutoMounter: SetUsbFunction(mass_storage) sys.usb.config from 'mtp,adb' to 'diag,serial_      smd,serial_tty,rmnet_bam,mass_storage,adb'
 9210 07-03 05:57:13.980  2812  5046 I MozMtp  : sessionEnded:
 9211 07-03 05:57:13.980  2812  5046 I MozMtp  : Run: MozMtpServer finished

According to the line 9203, AutoMounter receives the change mode request from Settings change observer, then read Settings key and get the value "Enable-UMS", so the protocol is changed to UMS. However, the key value should not be "Enalble-UMS". I will trace related code to check what's going on.


BTW, opposite situation also has the same problem.

1. Go inside USB storage to select another protocol (ex, MTP) 
2. Toggle USB storage in Settings
3. Go inside USB storage to select another protocol (ex. UMS)
4. Lock screen and unlock screen
5. The protocol would change to another one(ex, MTP)
Hello Fred

It seems that restoring wrong usb mode value from settings app while unlocking the screen.
Could you help me to check the usb mode value saved in settings app during the whole progress?
Thanks.
Flags: needinfo?(gasolin)
dave could you help check it?
Flags: needinfo?(gasolin) → needinfo?(dhylands)
according to usb_storage.js source code, when lock/unlock screen, _updateMode() will be called and the _protocol value will be used to restore the USB storage protocol. However, the _protocol value is only saved while usb storage switch is changed.

1. Toggle USB storage in Settings (ex, default is UMS)
   In this step, the _protocol is saved as UMS.

2. Go inside USB storage to select another protocol (ex, MTP)
   The _protocol value should be changed to MTP, but it doesn't.

3. Lock screen and unlock screen
   When unlock screen, usb storage protocol is restored with the _protocol value (here is UMS)

4. The protocol would change to another one(ex, UMS)

That's the reason why the usb storage mode changed back to UMS while unlock screen.
I think the _protocol value should be saved while the protocol changed, not when the usb storage switch changed.
Flags: needinfo?(dhylands)
The AutoMounter does switch to UMS mode (for technical reasons) but that should only happen when the USB cable is unplugged.

When in UMS mode, what's important is whether a volume is shared with the PC or not.

When MTP is enabled, then the AutoMounter mode should be changing like the following:

1 - Phone is unplugged - AutoMounter should be in UMS mode
2 - Phone is plugged in but has never been unlocked - AutoMounter should be in UMS mode
3 - Phone is plugged in and has been unlocked at least once - AutoMounter should be in MTP mode
4 - When the phone is unplugged or USB Sharing is disabled, then the AutoMounter will switch back to UMS mode.

For both UMS and MTP, nothing should be shared with the PC until the phone is unlocked for the first time. Once something is shared with the PC, then it should stay shared with the PC even if the phone is locked, until USB sharing is explicitly disabled, or the phone is unplugged from the PC.

So there are really 3 modes that the AutoMounter has:

1 - In UMS mode and no volumes are being shared with the PC
2 - In UMS mode and volumes are being shared with the PC
3 - In MTP mode and volumes are being shared with the PC

MTP doesn't have a notion of being in MTP mode and not sharing volumes (well, I suppose we could have the MTP server running awith no volumes). When I wrote it I decided to instead switch to UMS mode and have no volumes shared - this allows us to reclaim all of the memory used by the MTP server.

If the phone was in MTP mode with no volumes being shared, then it would still show up as a device to the PC, and it would look like there were no volumes, which I thought would be confusing to the user.

I just thought I'd write this out so that you have some context when trying to read the logs.
Something else I noticed that may be relevant.

With some phones, once you've shared volumes with the PC, you need to physically unplug the cable before UMS mode is well and truly off.

If used to be that when you disabled USB Sharing, you would see a message in the settings app about needing to unplug the phone before USB Sharing was truly disabled. I seem to recall that that I don't see that message anymore.

I also think that switching from UMS to MTP mode should be grayed out while USB Sharing is enabled. i.e. to switch between UMS and MTP you should first disable USB Sharing, and then once its been fully disabled (including the cable unplug for disabling UMS) then the controls would become ungrayed.

Otherwise, I think that the state machine to track this becomes very complicated and the user would be unable to discern what mode the phone is actually in.
So the crux of my previous comments is that I don't think that the SW deals with changing modes between UMS and MTP while USB Sharing is enabled.
Hello Harly

According to comment 16, could you give some comment about this behavior change?
Or could you help to transfer this to the correct person to comment it?
Thanks.
Flags: needinfo?(hhsu)
add comment 15 to https://wiki.mozilla.org/Gaia/System/FileManagement so we could have some central reference there. Thanks dave.
I think this is covered in bug 922927, if you take a look at page 11 in the spec "[2.1 Settings] MTP_SD card v1.3.pdf". A dialog will show up to tell the user "Under UMS mode, to complete the action, please unplug USB cable". So I think this is a bug.
Hello Harly
 
Maybe I does not describe clearly in previous comment. The changed behavior I said in comment 16 is

"I also think that switching from UMS to MTP mode should be grayed out while USB Sharing is enabled. i.e. to switch between UMS and MTP you should first disable USB Sharing, and then once its been fully disabled (including the cable unplug for disabling UMS) then the controls would become ungrayed."

The above description is different with the spec in bug 922927 (see the page7). That's the reason why I need your comment that if this spec change is reasonable for UX.

This spec change will make user can only change the USB sharing protocol while the USB sharing is disabled.
Flags: needinfo?(hhsu)
Need information on comment 21.
Flags: needinfo?(hhsu)
Hi Eden, just want to make sure with you that there is really no way to switch between UMS and MTP without unplugging the USB?
Flags: needinfo?(hhsu) → needinfo?(echuang)
You can switch from MTP to UMS without nplugging, but not from UMS to MTP.

At least this was the case with some phones.

I felt that having the software behave the same across all phones was more important than optimizing things for particular phones.

If we want to make it different for each phone, then it would be possible to add an attribute for the phone so that the software knows whether an unplug is needed or not.
Hello Harly

Just like Dave mentioned in comment 24, some phones might switch protocols without unplugging, but some phones cannot.

I also agree that we should make the software behave the same cross all phones. Only allowing protocol switching when phone is unplugged in default. And an attribute to support protocol switching without unplugging.
Flags: needinfo?(echuang) → needinfo?(hhsu)
Hi Eden,
I agree with what Dave suggested in comment 24, and to have an attribute for phone that support protocol for switching without unplugging. Thanks!
Flags: needinfo?(hhsu)
Flags: needinfo?(hcheng)
[Blocking Requested - why for this release]:
Continue fixing on next release
blocking-b2g: 2.2? → 2.5?
marked as 2.5+

Eden/Fred, please help working on this, thanks!
blocking-b2g: 2.5? → 2.5+
Assign owner to Eden.

Eden, please help open another bug for gaia change and cowork with Fred. Thanks.
Assignee: nobody → echuang
Target Milestone: --- → FxOS-S5 (21Aug)
Depends on: 1194045
Target Milestone: FxOS-S5 (21Aug) → FxOS-S7 (18Sep)
Blocks: 1194045
No longer depends on: 1194045
After discuss with Fred, we will add a new key in mozSettings to control whether can switch the transferring protocol while usb storage is enabled.
Partner should set the settings key according to their phone environment, and there is no need Gecko support an API to control.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1194045
QA Whiteboard: [COM=MTP/UMS][MGSEI-Triage+] → [MGSEI-Triage+]
Correct component to Gaia::Settings as bug 1194045.
Component: MTP/UMS → Gaia::Settings
You need to log in before you can comment on or make changes to this bug.