Class: UsbStorage

UsbStorage

new UsbStorage()

UsbStorage listens to lock and unlock events and changes the setting which controls automount behavior of USB storage.

UsbStorage listens to lock and unlock events and changes the setting which controls automount behavior of USB storage. Storage operates both on lock/unlock events, as well as the ums.enabled setting which is set in the settings app.

Once storage has been enabled (which requires the phone to be unlocked), we want to keep it enabled, even if the phone is locked afterwards. However, unplugging the USB cable should then require being unlocked before enabling again.

This also needs to work properly if the lockscreen is disabled.

Some further potential wrinkles:

  • MTP can be enabled/disabled at will
  • UMS can be enabled at will, but requires a USB cable unplug to complete.
Source:

Members

_enabled :Boolean

The current value of whether or not USB storage is enabled.

The current value of whether or not USB storage is enabled.

Type:
  • Boolean
Source:

_mode :String

The current value of USB tranfer mode.

The current value of USB tranfer mode.

Type:
  • String
Source:

_protocol :String

The current value of current USB transfer protocol.

The current value of current USB transfer protocol.

Type:
  • String
Source:

automounterDisable :Number

ums.mode setting value when the automounter is disabled.

ums.mode setting value when the automounter is disabled.

Type:
  • Number
Source:

automounterDisableWhenUnplugged :Number

ums.mode setting value when the automounter is disabled during the lock event.

ums.mode setting value when the automounter is disabled during the lock event.

Type:
  • Number
Source:

automounterMtpEnable :Number

ums.mode setting value when the automounter is in mtp modenot mcuy

.

ums.mode setting value when the automounter is in mtp modenot mcuy

Type:
  • Number
Source:

automounterUmsEnable :Number

ums.mode setting value when the automounter is enabled.

ums.mode setting value when the automounter is enabled.

Type:
  • Number
Source:

protocolMTP :String

ums.mode setting value for mtp mode

.

ums.mode setting value for mtp mode

Type:
  • String
Source:

protocolUMS :String

usb.transter setting value for ums mode

.

usb.transter setting value for ums mode

Type:
  • String
Source:

umsEnabled :String

The name of the setting to enable or disable USB storage.

The name of the setting to enable or disable USB storage.

Type:
  • String
Source:

umsMode :String

The name of the setting that defines automount behavior.

The name of the setting that defines automount behavior.

Type:
  • String
Source:

usbTransferProtocol :String

The name of the setting that defines usb transfer protocol.

The name of the setting that defines usb transfer protocol.

Type:
  • String
Source:

Methods

_getUsbProtocol()

Retrieve the protocol so that that we know whether MTP or UMS was enabled/disabled.

Retrieve the protocol so that that we know whether MTP or UMS was enabled/disabled.

Source:

_keyMigration(protocol)

Set mtp mode as default value.

Set mtp mode as default value.

Parameters:
Name Type Description
protocol Number

current protocol denotes ums or mtp.

Source:

_modeStr(mode)

Get a string version of the mode.

Get a string version of the mode.

Parameters:
Name Type Description
mode Number

for automounter.

Source:

_protocolStr(protocol)

Get a string version of the protocol.

Get a string version of the protocol.

Parameters:
Name Type Description
protocol Number

current protocol denotes ums or mtp.

Source:

_setMode(val)

Sets the automount mode.

Sets the automount mode. This is split into a separate function to facilitate testing, and should only be called from _updateMode().

Parameters:
Name Type Description
val Number

The value we are setting automount to.

Source:

_updateMode()

Sets the mode to agree with the current state of things.

Sets the mode to agree with the current state of things.

Source:

_usbStorageChanged(enabled)

Handle USB storage enabled/disabled functionality.

Handle USB storage enabled/disabled functionality.

Parameters:
Name Type Description
enabled Boolean

enables/disables automounting.

Source:

handleEvent(evt)

General event handler interface.

General event handler interface. Updates the overlay with as we receive load events.

Parameters:
Name Type Description
evt DOMEvent

The event.

Source:

start()

start usb storage

.

start usb storage

Source:

stop()

stop usb storage

.

stop usb storage

Source: