1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include
"nsISupports.idl"
6 #include
"nsIVolumeStat.idl"
8 [scriptable
, uuid(9B5E27F4
-601C
-11E4
-B541
-3E2D1D5D46B0
)]
9 interface nsIVolume
: nsISupports
11 // These MUST match the states from android's system/vold/Volume.h header
12 const long STATE_INIT
= -1;
13 const long STATE_NOMEDIA
= 0;
14 const long STATE_IDLE
= 1;
15 const long STATE_PENDING
= 2;
16 const long STATE_CHECKING
= 3;
17 const long STATE_MOUNTED
= 4;
18 const long STATE_UNMOUNTING
= 5;
19 const long STATE_FORMATTING
= 6;
20 const long STATE_SHARED
= 7;
21 const long STATE_SHAREDMNT
= 8;
22 const long STATE_CHECKMNT
= 100;
24 // The name of the volume. Often there is only one volume, called sdcard.
25 // But some phones support multiple volumes.
26 readonly attribute DOMString name
;
28 // The mount point is the path on the system where the volume is mounted
29 // and is only valid when state == STATE_MOUNTED.
30 readonly attribute DOMString mountPoint
;
32 // Reflects the current state of the volume, using STATE_xxx constants
34 readonly attribute
long state
;
36 // mountGeneration is a unique number which is used distinguish between
37 // periods of time that a volume is in the mounted state. Each time a
38 // volume transitions to the mounted state, the mountGeneration will
39 // be different from the last time it transitioned to the mounted state.
40 readonly attribute
long mountGeneration
;
42 // While a volume is mounted, it can be locked, preventing it from being
43 // shared with the PC. To lock a volume, acquire an MozWakeLock
44 // using the name of this attribute. Note that mountLockName changes
45 // every time the mountGeneration changes, so you'll need to reacquire
46 // the wakelock every time the volume becomes mounted.
47 readonly attribute DOMString mountLockName
;
49 // Determines if a mountlock is currently being held against this volume.
50 readonly attribute
boolean isMountLocked
;
52 // Determines if media is actually present or not. Note, that when an sdcard
53 // is ejected, it may go through several tranistory states before finally
54 // arriving at STATE_NOMEDIA. So isMediaPresent may be false even when the
55 // current state isn't STATE_NOMEDIA.
56 readonly attribute
boolean isMediaPresent
;
58 // Determines if the volume is currently being shared. This covers off
59 // more than just state == STATE_SHARED. isSharing will return true from the
60 // time that the volume leaves the mounted state, until it gets back to
61 // mounted, nomedia, or formatting states. This attribute is to allow
62 // device storage to suppress unwanted 'unavailable' status when
63 // transitioning from mounted to sharing and back again.
64 readonly attribute
boolean isSharing
;
66 // Determines if the volume is currently formatting. This sets true once
67 // mFormatRequest == true and mState == STATE_MOUNTED, and sets false
68 // once the volume has been formatted and mounted again.
69 readonly attribute
boolean isFormatting
;
71 readonly attribute
boolean isUnmounting
;
73 nsIVolumeStat getStats
();
75 // Formats the volume in IO thread, if the volume is ready to be formatted.
76 // Automounter will unmount it, format it and then mount it again.
79 // Mounts the volume in IO thread, if the volume is already unmounted.
80 // Automounter will mount it. Otherwise Automounter will skip this.
83 // Unmounts the volume in IO thread, if the volume is already mounted.
84 // Automounter will unmount it. Otherwise Automounter will skip this.
87 // Whether this is a fake volume.
88 readonly attribute
boolean isFake
;
92 // For use with the ObserverService
93 #define NS_VOLUME_STATE_CHANGED
"volume-state-changed"
98 // Convert a state into a loggable/printable string.
99 const char* NS_VolumeStateStr
(int32_t aState
);