1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/system/gonk/nsIVolume.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsISupports.idl" 1.9 +#include "nsIVolumeStat.idl" 1.10 + 1.11 +[scriptable, uuid(13caa69c-8f1f-11e3-8e36-10bf48d707fb)] 1.12 +interface nsIVolume : nsISupports 1.13 +{ 1.14 + // These MUST match the states from android's system/vold/Volume.h header 1.15 + const long STATE_INIT = -1; 1.16 + const long STATE_NOMEDIA = 0; 1.17 + const long STATE_IDLE = 1; 1.18 + const long STATE_PENDING = 2; 1.19 + const long STATE_CHECKING = 3; 1.20 + const long STATE_MOUNTED = 4; 1.21 + const long STATE_UNMOUNTING = 5; 1.22 + const long STATE_FORMATTING = 6; 1.23 + const long STATE_SHARED = 7; 1.24 + const long STATE_SHAREDMNT = 8; 1.25 + 1.26 + // The name of the volume. Often there is only one volume, called sdcard. 1.27 + // But some phones support multiple volumes. 1.28 + readonly attribute DOMString name; 1.29 + 1.30 + // The mount point is the path on the system where the volume is mounted 1.31 + // and is only valid when state == STATE_MOUNTED. 1.32 + readonly attribute DOMString mountPoint; 1.33 + 1.34 + // Reflects the current state of the volume, using STATE_xxx constants 1.35 + // from above. 1.36 + readonly attribute long state; 1.37 + 1.38 + // mountGeneration is a unique number which is used distinguish between 1.39 + // periods of time that a volume is in the mounted state. Each time a 1.40 + // volume transitions to the mounted state, the mountGeneration will 1.41 + // be different from the last time it transitioned to the mounted state. 1.42 + readonly attribute long mountGeneration; 1.43 + 1.44 + // While a volume is mounted, it can be locked, preventing it from being 1.45 + // shared with the PC. To lock a volume, acquire an MozWakeLock 1.46 + // using the name of this attribute. Note that mountLockName changes 1.47 + // every time the mountGeneration changes, so you'll need to reacquire 1.48 + // the wakelock every time the volume becomes mounted. 1.49 + readonly attribute DOMString mountLockName; 1.50 + 1.51 + // Determines if a mountlock is currently being held against this volume. 1.52 + readonly attribute boolean isMountLocked; 1.53 + 1.54 + // Determines if media is actually present or not. Note, that when an sdcard 1.55 + // is ejected, it may go through several tranistory states before finally 1.56 + // arriving at STATE_NOMEDIA. So isMediaPresent may be false even when the 1.57 + // current state isn't STATE_NOMEDIA. 1.58 + readonly attribute boolean isMediaPresent; 1.59 + 1.60 + // Determines if the volume is currently being shared. This covers off 1.61 + // more than just state == STATE_SHARED. isSharing will return true from the 1.62 + // time that the volume leaves the mounted state, until it gets back to 1.63 + // mounted, nomedia, or formatting states. This attribute is to allow 1.64 + // device storage to suppress unwanted 'unavailable' status when 1.65 + // transitioning from mounted to sharing and back again. 1.66 + readonly attribute boolean isSharing; 1.67 + 1.68 + // Determines if the volume is currently formatting. This sets true once 1.69 + // mFormatRequest == true and mState == STATE_MOUNTED, and sets false 1.70 + // once the volume has been formatted and mounted again. 1.71 + readonly attribute boolean isFormatting; 1.72 + 1.73 + nsIVolumeStat getStats(); 1.74 + 1.75 + // Formats the volume in IO thread, if the volume is ready to be formatted. 1.76 + // Automounter will unmount it, format it and then mount it again. 1.77 + void format(); 1.78 + 1.79 + // Mounts the volume in IO thread, if the volume is already unmounted. 1.80 + // Automounter will mount it. Otherwise Automounter will skip this. 1.81 + void mount(); 1.82 + 1.83 + // Unmounts the volume in IO thread, if the volume is already mounted. 1.84 + // Automounter will unmount it. Otherwise Automounter will skip this. 1.85 + void unmount(); 1.86 + 1.87 + // Whether this is a fake volume. 1.88 + readonly attribute boolean isFake; 1.89 +}; 1.90 + 1.91 +%{C++ 1.92 +// For use with the ObserverService 1.93 +#define NS_VOLUME_STATE_CHANGED "volume-state-changed" 1.94 + 1.95 +namespace mozilla { 1.96 +namespace system { 1.97 + 1.98 +// Convert a state into a loggable/printable string. 1.99 +const char* NS_VolumeStateStr(int32_t aState); 1.100 + 1.101 +} // system 1.102 +} // mozilla 1.103 +%}