Closed Bug 1059086 Opened 10 years ago Closed 10 years ago

[MTP] Need to keep the functionality after unpluging and re-pluging USB cable

Categories

(Firefox OS Graveyard :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
2.1 S3 (29aug)

People

(Reporter: alchen, Assigned: dhylands)

References

Details

Attachments

(1 file, 1 obsolete file)

Symptom:
In current status, MTP won't work after unpluging and re-pluging USB cable.
We need to disable MTP first and enable MTP again to have the MTP function work.

How to reproduce?
1. enable MTP first
2. unplug USB cable from PC
3. Plug USB cable into PC again



(LOG)
----> unplug USB cable from PC
08-22 15:22:36.120   292   981 V MtpServer: request read returned -1, errno: 5
08-22 15:22:36.120   292   981 I MozMtp  : sessionEnded:
08-22 15:22:36.120   292   981 I MozMtp  : Run: MozMtpServer finished
08-22 15:22:36.130   292   490 I AutoMounter: AutoMounter state changed from MTP_STARTED to IDLE
08-22 15:22:36.130   292   490 I AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C0E1 mode:3 usb:0 tryToShare:0 state:IDLE
08-22 15:22:36.130   292   490 I AutoMounter: UpdateState: Volume external is Mounted and inserted @ /storage/sdcard1 gen 1 locked 0 sharing en-n
08-22 15:22:36.130   292   490 I AutoMounter: UpdateState: Volume sdcard is Mounted and inserted @ /storage/sdcard0 gen 2 locked 0 sharing en-n
----> plug USB cable into PC
08-22 15:22:43.020   292   490 I AutoMounter: AutoMounter state changed from IDLE to MTP_STARTED
08-22 15:22:43.020   292   490 I AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C1E1 mode:3 usb:1 tryToShare:0 state:MTP_STARTED
08-22 15:22:43.020   292   490 I AutoMounter: UpdateState: Volume external is Mounted and inserted @ /storage/sdcard1 gen 1 locked 0 sharing en-n
08-22 15:22:43.020   292   490 I AutoMounter: UpdateState: Volume sdcard is Mounted and inserted @ /storage/sdcard0 gen 2 locked 0 sharing en-n
Depends on: 1049240
Here is a easy fix for this symptom.

We will do "StopMtpServer()" after unplugging the USB cable.
Then we will do "StartMtpServer();" after re-plugging the USB cable.

In this case, 
unplug and re-plug USB cable is similar to disable/enable USB sharing.
We all need to new a MtpServer and add storage (including parsing all files in this storage).
To avoid this redundant overhead, maybe we can let "MozMtpDatabase" to be a singleton, make sense?
Attachment #8479775 - Flags: feedback?(dhylands)
Comment on attachment 8479775 [details] [diff] [review]
(0827) keep the functionality after unpluging and re-pluging USB cable

Review of attachment 8479775 [details] [diff] [review]:
-----------------------------------------------------------------

This is on the right track, but wasn't quite sufficient. I'll attached my version for you to review.
Attachment #8479775 - Flags: feedback?(dhylands) → feedback-
Comment on attachment 8480240 [details] [diff] [review]
Properly stop and restart MTP during a cable unplug/replug

Here's what I finally settled on after testing.
Attachment #8480240 - Flags: review?(alchen)
Comment on attachment 8480240 [details] [diff] [review]
Properly stop and restart MTP during a cable unplug/replug

Review of attachment 8480240 [details] [diff] [review]:
-----------------------------------------------------------------

It looks good for me.
Attachment #8480240 - Flags: review?(alchen) → review+
https://hg.mozilla.org/mozilla-central/rev/4eaaa8ce26af
Assignee: nobody → dhylands
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.1 S3 (29aug)
(In reply to Alphan Chen[:Alphan] from comment #1)
> Created attachment 8479775 [details] [diff] [review]
> (0827) keep the functionality after unpluging and re-pluging USB cable
> 
> Here is a easy fix for this symptom.
> 
> We will do "StopMtpServer()" after unplugging the USB cable.
> Then we will do "StartMtpServer();" after re-plugging the USB cable.
> 
> In this case, 
> unplug and re-plug USB cable is similar to disable/enable USB sharing.
> We all need to new a MtpServer and add storage (including parsing all files
> in this storage).
> To avoid this redundant overhead, maybe we can let "MozMtpDatabase" to be a
> singleton, make sense?

I think that we want to drop the memory used by the database when the phone isn't plugged into the PC.

Once we optimize the database to only grab files which the user has actually browsed to (bug 1055693), then the memory requirements should drop, and the parsing time should also drop.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: