Closed Bug 1131927 Opened 11 years ago Closed 11 years ago

[DeviceStorage] Use about:service for automounter to know the current storage status

Categories

(Firefox OS Graveyard :: MTP/UMS, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(firefox40 fixed)

RESOLVED FIXED
2.2 S11 (1may)
Tracking Status
firefox40 --- fixed

People

(Reporter: alchen, Assigned: alchen)

References

Details

Attachments

(2 files, 4 obsolete files)

In Bug 964636 and Bug 1000755, I introduce a mechanism called about service. It is similar to the dumpsys on Android. In this bug, I would use this mechanism in automounter to check storage status.
Assignee: nobody → alchen
I need to monitor the storage status for these cases. 1. Turn on/off UMS 2. Turn on/off MTP 3. Switch UMS to MTP.
Do UMS sharing : // Unmounting sdcard (Mounted -> Unmounting) AutoMounter: UpdateState: ums:A1C1E1 mtp:A1C0E0 mode:1 usb:1 tryToShare:1 state:UMS_CONFIGURED AutoMounter: UpdateState: Unmounting sdcard VolumeManager: Volume sdcard: IsSharing set to 1 state Mounted AutoMounter: UpdateState: Unmounting sdcard VolumeManager: Volume sdcard (1): changing state from Mounted to Unmounting (2 observers) Vold : Volume sdcard state changing 4 (Mounted) -> 5 (Unmounting) // Unmounting sdcard (Unmounting -> Idle) VolumeManager: Volume sdcard (1): changing state from Unmounting to Idle (2 observers) Vold : Volume sdcard state changing 5 (Unmounting) -> 1 (Idle-Unmounted) AutoMounter: UpdateState: Volume sdcard is Idle and inserted AutoMounter: UpdateState: Volume sdcard is Idle // Sharing sdcard (Idle -> Shared) AutoMounter: UpdateState: Sharing sdcard Volume sdcard (1): changing state from Idle to Shared (2 observers) Vold : Volume sdcard state changing 1 (Idle-Unmounted) -> 7 (Shared-Unmounted) // Update Volume State AutoMounter: UpdateState: Volume sdcard is Shared and inserted AutoMounter: UpdateState: Volume sdcard1 is Mounted and inserted @ /storage/sdcard1 gen 2 locked 0 sharing // Unmounting sdcard1 (Mounted -> Unmounting) VolumeManager: Volume sdcard1: IsSharing set to 1 state Mounted AutoMounter: UpdateState: Unmounting sdcard1 VolumeManager: Volume sdcard1 (2): changing state from Mounted to Unmounting (2 observers) Vold : Volume sdcard1 state changing 4 (Mounted) -> 5 (Unmounting) // Unmounting sdcard1 (Unmounting -> Idle) Volume sdcard1 (2): changing state from Unmounting to Idle (2 observers) Vold : Volume sdcard1 state changing 5 (Unmounting) -> 1 (Idle-Unmounted) AutoMounter: UpdateState: ums:A1C1E1 mtp:A1C0E0 mode:1 usb:1 tryToShare:1 state:UMS_CONFIGURED AutoMounter: UpdateState: Volume sdcard is Shared and inserted AutoMounter: UpdateState: Volume sdcard1 is Idle and inserted AutoMounter: UpdateState: Volume sdcard1 is Idle // Sharing sdcard1 (Idle -> Shared) AutoMounter: UpdateState: Sharing sdcard1 VolumeManager: Volume sdcard1 (2): changing state from Idle to Shared (2 observers) AutoMounter: UpdateState: ums:A1C1E1 mtp:A1C0E0 mode:1 usb:1 tryToShare:1 state:UMS_CONFIGURED AutoMounter: UpdateState: Volume sdcard is Shared and inserted AutoMounter: UpdateState: Volume sdcard1 is Shared and inserted // Changing status from 'Disabled' to 'Enabled' AutoMounterSetting: Changing status from 'Disabled' to 'Enabled' Vold : Volume sdcard1 state changing 1 (Idle-Unmounted) -> 7 (Shared-Unmounted) 03-24 03:39:54.220
Disable UMS : // UI turn off UMS AutoMounter: Changing mode from 'Enable-UMS' to 'DisableWhenUnplugged' AutoMounter: UpdateState: ums:A1C1E1 mtp:A1C0E0 mode:2 usb:1 tryToShare:1 state:UMS_CONFIGURED AutoMounter: UpdateState: Volume sdcard is Shared and inserted AutoMounter: UpdateState: Volume sdcard1 is Shared and inserted // vold log of sdcard Vold : Volume sdcard state changing 7 (Shared-Unmounted) -> 1 (Idle-Unmounted) Vold : Volume sdcard state changing 1 (Idle-Unmounted) -> 3 (Checking) Vold : Volume sdcard state changing 3 (Checking) -> 4 (Mounted) // vold log of sdcard1 Vold : Volume sdcard1 state changing 7 (Shared-Unmounted) -> 1 (Idle-Unmounted) Vold : Volume sdcard1 state changing 1 (Idle-Unmounted) -> 3 (Checking) Vold : Volume sdcard1 state changing 3 (Checking) -> 4 (Mounted) // Changing status from 'Enabled' to 'Disabled' VolumeManager: Volume sdcard1 (2): changing state from Check-Mounted to Mounted @ '/storage/sdcard1' (2 observers) mountGeneration = 10, locked = 0 AutoMounterSetting: Changing status from 'Enabled' to 'Disabled' AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C0E0 mode:0 usb:0 tryToShare:0 state:IDLE AutoMounter: UpdateState: Volume sdcard is Mounted and inserted @ /storage/sdcard gen 9 locked 0 sharing en-n AutoMounter: UpdateState: Volume sdcard1 is Mounted and inserted @ /storage/sdcard1 gen 10 locked 0 sharing en-n AutoMounter: AutoMounter state changed from IDLE to UMS_CONFIGURED AutoMounter: UpdateState: ums:A1C1E0 mtp:A1C0E0 mode:0 usb:1 tryToShare:0 state:UMS_CONFIGURED AutoMounter: UpdateState: Volume sdcard is Mounted and inserted @ /storage/sdcard gen 9 locked 0 sharing en-n AutoMounter: UpdateState: Volume sdcard1 is Mounted and inserted @ /storage/sdcard1 gen 10 locked 0 sharing en-n
Switch UMS to MTP // UI change from UMS to MTP AutoMounter: AutoMounter state changed from UMS_CONFIGURED to MTP_CONFIGURING AutoMounter: SetUsbFunction(mtp) sys.usb.config from 'diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb' to 'mtp,adb' // Unsharing sdcard AutoMounter: UpdateState: ums:A1C1E0 mtp:A1C0E1 mode:3 usb:1 tryToShare:0 state:MTP_CONFIGURING AutoMounter: UpdateState: Volume sdcard is Shared and inserted AutoMounter: UpdateState: Unsharing sdcard VolumeManager: Volume sdcard (1): changing state from Shared to Idle (2 observers) // Mounting sdcard AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C0E1 mode:3 usb:1 tryToShare:0 state:MTP_CONFIGURING AutoMounter: UpdateState: Volume sdcard is Idle and inserted AutoMounter: UpdateState: Mounting sdcard VolumeManager: Volume sdcard (1): changing state from Idle to Checking (2 observers) // vold log for sdcard Vold : Volume sdcard state changing 7 (Shared-Unmounted) -> 1 (Idle-Unmounted) Vold : /dev/block/vold/179:30 being considered for volume sdcard Vold : Volume sdcard state changing 1 (Idle-Unmounted) -> 3 (Checking) VolumeManager: Volume sdcard (1): changing state from Checking to Check-Mounted (2 observers) // sdcard is Check-Mounted AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C0E1 mode:3 usb:1 tryToShare:0 state:MTP_CONFIGURING AutoMounter: UpdateState: Volume sdcard is Check-Mounted and inserted AutoMounter: UpdateState: Volume 'sdcard' is inaccessible, checking again in 250 msec // Unsharing sdcard1 AutoMounter: UpdateState: Volume sdcard1 is Shared and inserted AutoMounter: UpdateState: Unsharing sdcard1 Volume sdcard state changing 3 (Checking) -> 4 (Mounted) VolumeManager: Volume sdcard1 (2): changing state from Shared to Idle (2 observers) Vold : Volume sdcard1 state changing 7 (Shared-Unmounted) -> 1 (Idle-Unmounted) VolumeManager: Volume sdcard (1): changing state from Check-Mounted to Mounted @ '/storage/sdcard' (2 observers) mountGeneration = 3, locked = 0 // Mounting sdcard AutoMounter: UpdateState: Volume sdcard1 is Idle and inserted AutoMounter: UpdateState: Mounting sdcard1 VolumeManager: Volume sdcard1 (2): changing state from Idle to Checking (2 observers) // vold log for sdcard1 Vold : Volume sdcard1 state changing 1 (Idle-Unmounted) -> 3 (Checking) VolumeManager: Volume sdcard1 (2): changing state from Checking to Check-Mounted (2 observers) // Start MtpServer AutoMounter: Starting MtpServer MozMtp : Init: Opened '/dev/mtp_usb' fd 166 MozMtp : MozMtpStorage: Storage constructed for Volume sdcard mStorageID 0x00010001 // storage status (sdcard) MozMtp : Notify: Volume sdcard mStorageID 0x00010001 state changed to Mounted SharingEnabled: 1 MozMtp : StorageAvailable: Adding Volume sdcard mStorageID 0x00010001 mountPoint /storage/sdcard to MozMtpDatabase MozMtp : AddStorage: added 4 items from tree '/storage/sdcard' MozMtp : StorageAvailable: Adding Volume sdcard mStorageID 0x00010001 mountPoint /storage/sdcard to MtpServer MozMtp : Notify: Volume sdcard mStorageID 0x00010001 state changed to Mounted SharingEnabled: 1 MozMtp : MozMtpStorage: Storage constructed for Volume sdcard1 mStorageID 0x00020001 MozMtp : Notify: Volume sdcard1 mStorageID 0x00020001 state changed to Check-Mounted SharingEnabled: 1 MozMtp : Notify: Volume sdcard1 mStorageID 0x00020001 state changed to Check-Mounted SharingEnabled: 1 // vold log for sdcard1 Vold : Volume sdcard1 state changing 3 (Checking) -> 4 (Mounted) // MTP_CONFIGURING to MTP_STARTED AutoMounter: AutoMounter state changed from MTP_CONFIGURING to MTP_STARTED AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C1E1 mode:3 usb:1 tryToShare:0 state:MTP_STARTED // sdcard and sdcard1 state AutoMounter: UpdateState: Volume sdcard is Mounted and inserted @ /storage/sdcard gen 3 locked 0 sharing en-n AutoMounter: UpdateState: Volume sdcard1 is Check-Mounted and inserted AutoMounter: UpdateState: Volume 'sdcard1' is inaccessible, checking again in 250 msec // Run MozMtpServer MozMtp : Run: MozMtpServer started // sdcard and sdcard1 state AutoMounter: UpdateState: ums:A1C0E0 mtp:A1C1E1 mode:3 usb:1 tryToShare:0 state:MTP_STARTED AutoMounter: UpdateState: Volume sdcard is Mounted and inserted @ /storage/sdcard gen 3 locked 0 sharing en-n AutoMounter: UpdateState: Volume sdcard1 is Check-Mounted and inserted // MozMtp storage status MozMtp : Notify: Volume sdcard1 mStorageID 0x00020001 state changed to Mounted SharingEnabled: 1 MozMtp : StorageAvailable: Adding Volume sdcard1 mStorageID 0x00020001 mountPoint /storage/sdcard1 to MozMtpDatabase MozMtp : StorageAvailable: Adding Volume sdcard1 mStorageID 0x00020001 mountPoint /storage/sdcard1 to MtpServer
In my opinion, there are two parts we need to show. 1. Automounter information -> Changing mode : Enable-UMS, DisableWhenUnplugged -> Current Automounter State: IDLE, UMS_CONFIGURED, MTP_CONFIGURING, MTP_STARTED -> Set what usb function (mtp, ums) the value of "sys,usb.config" -> ums status : Availabled, Configured, Enabled mtp status : Availabled, Configured, Enabled -> Action : Unsharing #volume, Mounting #volume, Starting MtpServer 2. Volume information -> volume state ?
Depends on: 1000755
This is the first version. In this reporter, it will output automounter and volume information. Hi Dave and Eden, could you feedback about this patch?
Attachment #8592660 - Flags: feedback?(echuang)
Attachment #8592660 - Flags: feedback?(dhylands)
This is the output by normal json parser.
Comment on attachment 8592660 [details] [diff] [review] (0415) Add reporter in automounter to get current information Review of attachment 8592660 [details] [diff] [review]: ----------------------------------------------------------------- In general, I have no concern about the patch. BTW, we might be able to apply the about service to dump the MTP related information for debugging. ::: dom/system/gonk/AutoMounter.cpp @@ +1126,5 @@ > + if (!ReadSysFile(ICS_SYS_USB_FUNCTIONS, functionsStr, sizeof(functionsStr))) { > + ERR("Error reading file '%s': %s", ICS_SYS_USB_FUNCTIONS, strerror(errno)); > + functionsStr[0] = '\0'; > + } > + DBG("UpdateState: USB functions: '%s'", functionsStr); Typo, UpdateState should be GetStatus. @@ +1247,5 @@ > + desc += "inserted"; > + } else { > + desc += "missing"; > + } > + } I think we can dump more volume information for debugging. For example, IsFake, CanBeShared, CanBeFormatted, CanBeMounted, IsRemovable and IsHotswappable.
Attachment #8592660 - Flags: feedback?(echuang) → feedback+
Comment on attachment 8592660 [details] [diff] [review] (0415) Add reporter in automounter to get current information Review of attachment 8592660 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/system/gonk/AutoMounter.cpp @@ +2,1 @@ > /* This Source Code Form is subject to the terms of the Mozilla Public Whoops. Probably unintended blank line. @@ +261,5 @@ > } > > void UpdateState(); > + void GetStatus(bool &umsAvail, bool &umsConfigured, bool &umsEnabled, bool &mtpAvail, > + bool &mtpConfigured, bool &mtpEnabled, bool &rndisConfigured); nit: swpa & and space for all parameters. @@ +263,5 @@ > void UpdateState(); > + void GetStatus(bool &umsAvail, bool &umsConfigured, bool &umsEnabled, bool &mtpAvail, > + bool &mtpConfigured, bool &mtpEnabled, bool &rndisConfigured); > + > + nsresult Dump(nsACString &desc); nit: & should cuddle nsACString @@ +464,5 @@ > > static StaticRefPtr<AutoMounter> sAutoMounter; > static StaticRefPtr<MozMtpServer> sMozMtpServer; > > +// The following are for status reporter nit: "are" reads wrong. I think it should be "is". I think it should say The following is for the status reporter. @@ +1111,5 @@ > /***************************************************************************/ > > +void AutoMounter::GetStatus(bool &umsAvail, bool &umsConfigured, bool &umsEnabled, > + bool &mtpAvail, bool &mtpConfigured, bool &mtpEnabled, > + bool &rndisConfigured) nit: & @@ +1120,5 @@ > + mtpConfigured = false; > + mtpEnabled = false; > + rndisConfigured = false; > + > + if (access(ICS_SYS_USB_FUNCTIONS, F_OK) == 0) { nit: Do an early return if access returns !=0 and unindent the rest of the function. @@ +1162,5 @@ > + } > +} > + > + > +nsresult AutoMounter::Dump(nsACString &desc) nit: & @@ +1262,5 @@ > > sAutoMounter = new AutoMounter(); > + > + // Register status reporter into reporter manager > + if(status_reporter_progress == 1) { Rather than using hardcoded 1 and 2, you make status_reporter_prgoress be an enum and use enumerations.
Attachment #8592660 - Flags: feedback?(dhylands) → feedback+
In this version, I output more volume information and revised the patch based on comment 9.
Attachment #8592660 - Attachment is obsolete: true
Attachment #8593863 - Flags: review?(dhylands)
Output on latest version.
Attachment #8592668 - Attachment is obsolete: true
Comment on attachment 8593863 [details] [diff] [review] (0417) Add reporter in automounter to get current information Review of attachment 8593863 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/system/gonk/AutoMounter.cpp @@ +1246,5 @@ > + > + desc += "|"; > + desc += vol->NameStr(); > + desc += ":"; > + desc += vol->StateStr(); If the volume is mounted, I think it would be useful to print out the mount point as well. Perhaps use @ between the State and the mount point, so it will look like: sdcard:Mounted@/mnt/storage/sdcard,...
Attachment #8593863 - Flags: review?(dhylands) → review+
Here is try server result. It looks fine.
Attachment #8593863 - Attachment is obsolete: true
(In reply to Alphan Chen [:alchen] from comment #14) > Created attachment 8594582 [details] [diff] [review] > Add reporter in automounter to get current information. r=dhylands > > Remove empty lines from attachment 8594581 [details] [diff] [review]. Here is try server result. https://treeherder.mozilla.org/#/jobs?repo=try&revision=b84a474e4892 It looks fine.
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.2 S11 (1may)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: