Class: ExternalStorageMonitor

ExternalStorageMonitor

new ExternalStorageMonitor()

ExternalStorageMonitor listens to external storage(should be insterted/removed SD card slot) for the volume chagne event.

ExternalStorageMonitor listens to external storage(should be insterted/removed SD card slot) for the volume chagne event. According to the status activity, we use regular expression to indentify storage actions.

Source:

Members

"Mount-Fail" :Integer

Volume state "Mount-Fail".

Volume state "Mount-Fail".

Type:
  • Integer
Source:

_debug

On/Off flag for enable debug message.

On/Off flag for enable debug message.

Source:

_storage :Object

An variable for maintain the storage status.

An variable for maintain the storage status.

Type:
  • Object
Source:

actionRecognised :RegExp

Volume RegExp "actionRecognised".

Volume RegExp "actionRecognised". If a user inserted formatted and raedable SD card, Volume State Machine will run in this flow. State flow: NoMedia --> Pending --> Idle(Unmounted) --> Checking --> Mounted

Enumerate value: 0 --> 2 --> 1 --> 3 --> 4

Type:
  • RegExp
Source:

actionRemoved :RegExp

Volume RegExp "actionRemoved".

Volume RegExp "actionRemoved". If a user unmount SD card successfully, Volume State Machine will run in this flow. State flow: Mounted --> Unmounting --> Idle(Unmounted) --> NoMedia

Enumerate value: 4 --> 5 --> 1 --> 0

Type:
  • RegExp
Source:

actionUnrecognised :RegExp

Volume RegExp "actionUnrecognised".

Volume RegExp "actionUnrecognised". If there is an unformatted or format-not-readable SD card in slot, and the storage is not able to be mounted, Volume State Machine will run in this flow. State flow: Checking --> Mount-Fail(Unmounted)

Enumerate value: 3 --> 9

Type:
  • RegExp
Source:

actionUnrecognisedStorageRemoved :RegExp

Volume RegExp "actionUnrecognisedStorageRemoved".

Volume RegExp "actionUnrecognisedStorageRemoved". If a user unmount SD card successfully, Volume State Machine will run in this flow. State flow: Mount-Fail --> NoMedia

Enumerate value: 9 --> 0

Type:
  • RegExp
Source:

Checking :Integer

Volume state "Checking".

Volume state "Checking".

Type:
  • Integer
Source:

Formatting :Integer

Volume state "Formatting".

Volume state "Formatting".

Type:
  • Integer
Source:

Idle :Integer

Volume state "Idle"(Unmounted).

Volume state "Idle"(Unmounted).

Type:
  • Integer
Source:

Init :Integer

Volume state "Init".

Volume state "Init".

Type:
  • Integer
Source:

justEnterIdleLessThanOneSecond :Boolean

A flag to identify the storage status has been into Idle(Unmounted).

A flag to identify the storage status has been into Idle(Unmounted). We will use the flag to distinguish removal SD card manually or not.

Type:
  • Boolean
Source:

Mounted :Integer

Volume state "Mounted".

Volume state "Mounted".

Type:
  • Integer
Source:

NoMedia :Integer

Volume state "NoMedia"(Removed).

Volume state "NoMedia"(Removed).

Type:
  • Integer
Source:

Pending :Integer

Volume state "Pending".

Volume state "Pending".

Type:
  • Integer
Source:

resetJustEnterIdleFlagTimer :Integer

An integer with the ID value of the timer that is set.

An integer with the ID value of the timer that is set. We will clean the timer if create a new timer.

Type:
  • Integer
Source:

Shared :Integer

Volume state "Shared"(Unmounted in shared mode).

Volume state "Shared"(Unmounted in shared mode).

Type:
  • Integer
Source:

statusStack :Integer

ums.mode setting value when the automounter is disabled.

ums.mode setting value when the automounter is disabled.

Type:
  • Integer
Source:

Unmounting :Integer

Volume state "Unmounting".

Volume state "Unmounting".

Type:
  • Integer
Source:

Methods

clearStatus()

The function keep the latest storage status.

The function keep the latest storage status. And put the status be the the first element in a new array.

Source:

createMessage(str)

Create message for the storage activity.

Create message for the storage activity.

Parameters:
Name Type Description
str action

The string we figure out the storage action

Source:

debug(str)

Dump console log for debug message.

Dump console log for debug message.

Parameters:
Name Type Description
str string

The error message for debugging.

Source:

enableEnterIdleStateTimer(str)

Trigger a timer to set flag 'justEnterIdleLessThanOneSecond' be true.

Trigger a timer to set flag 'justEnterIdleLessThanOneSecond' be true. We will use the flag to speculate the action of storage removal manually or not.

Parameters:
Name Type Description
str

The value we are pushing in stack.

Source:

enableStorageUnrecognised()

Set settings key 'volume.external.unrecognised' to be boolean.

Set settings key 'volume.external.unrecognised' to be boolean.

Source:

fireNotification(str, str)

Notify user what the storage is activate.

Notify user what the storage is activate.

Parameters:
Name Type Description
str title

The string we show on the title of notification

str body

The string we show on the body of notification

Source:

formatSize(bytes)

Helper function to format the value returned by the nsIDOMDeviceStorage.freeSpace call in a more readable way.

Helper function to format the value returned by the nsIDOMDeviceStorage.freeSpace call in a more readable way.

Parameters:
Name Type Description
bytes size

The size of specific storage space

Source:

getTotalSpace(function)

Get total space via the sum of the used space and free space.

Get total space via the sum of the used space and free space.

Parameters:
Name Type Description
function callback

The callback will be run while get total space

Source:

handleEvent(evt)

General event handler interface.

General event handler interface.

Parameters:
Name Type Description
evt DOMEvent

The event.

Source:

(private) notificationHandler()

Handle notification while it be triggered 'onclick' event.

Handle notification while it be triggered 'onclick' event.

Source:

pushStatus(str)

Push latest storage status in statusStack

.

Push latest storage status in statusStack

Parameters:
Name Type Description
str string

The value we are pushing in stack. The string is mapping to the storage status. And the status are defined in ExternalStorageMonitor property.

Source:

(private) recogniseStorageActions()

Recognise storage actions.

Recognise storage actions.

Source:

(private) start()

Listene to storage 'change' event.

Listene to storage 'change' event.

Source: