The Device APIs Working Group is currently not pursuing the approach outlined in this draft, so it should be considered historical. Please treat this document with caution and do not reference it or use it as the basis for implementation. The domain covered by this document is still within the scope of the Working Group as defined in its Charter. The Working Group may pursue an alternative API design that is based on the current Web browser security model.
This specification defines an API to provide Web applications with access to various properties of the system on which they are running. Specifically, properties pertaining to device information are exposed. Examples of such properties include battery status, current network connection characteristics, and I/O properties. Additionally, some of those properties offer access to the environment around the device, such as ambient brightness or atmospheric pressure.
This document represents the early consensus of the group on the scope and features of the proposed System Information API. Issues and editors notes in the document highlight some of the points on which the group is still working and would particularly like to get feedback.
In order for web applications to gain access to information that is typically available to an operating system's native applications, they must be able to access various system properties present on the device, either related to the hardware state (e.g. CPU usage), software data (e.g. installed codecs) or environment information (e.g. ambient brightness). The APIs defined by the Device APIs and Policy Working Group address this issue. Specifically, the API defined in this specification provides access to System Information and properties from the underlying platform related to Input/Output, AVCodecs, Network, Storage, Sensors, and other Internal device properties. The properties accessed through this API may be static and/or dynamic in nature.
The API defined in this specification can be used to access properties of the user's device and its current context. The distribution of this information could potentially compromise the user's privacy. A conforming implementation of this specification must provide a mechanism that protects the user's privacy and this mechanism should ensure that no system information is retrievable without the user's express permission.
To provide the user with some control over which properties should be exposed, without overwhelming the user with a complex set of choices, this specification groups the properties so users can decide what to make available at least at a group level. The groups are defined below.
Device Characteristics (data points that describe features or limits of the user's device), including:
Sensor Results (data points that describe things about the user's environment external to the device), including:
Network Characteristics (data points that describe features or limits of the network connection(s) that is available to the device), including:
A user agent MUST NOT provide any system information related to these property groups to Web sites without the express permission of the user. A user agent MUST acquire permission through a user interface, unless they have prearranged trust relationships with users, as described below. The user interface MUST include the origin of the document in whose context the callback will be invoked. Those permissions that are acquired through the user interface and that are preserved beyond the current browsing session (i.e. beyond the time when the browsing context, as defined in [[HTML5]], is navigated to another URL) MUST be revocable and a user agent MUST respect revoked permissions.
Obtaining the user's express permission to access one device property group does not imply a grant of permission for the same Web site to access other property groups via this API, as part of the same permission context. The implementation MUST seek the user's express permission when any access is sought to property groups for which the user has not yet expressed permission.
A user agent MUST separately acquire permission through the user interface when the callback is invoked in the context of a document object that is presented in a nested browsing context, if the origin of the nested browsing context is different from the top-level browsing context's origin. In this case, the permission MUST be scoped to the pair consisting of the top-level browsing context's origin, and the origin within which the callback is executed.
Example: Alice has granted a persistent permission for an API to be
accessed by www.example.com. Alice now navigates to evil.example.net,
which includes www.example.com within an iframe
. In this case,
the user agent must separately obtain authorization from the user, since
the API is used within a nested browsing context (the iframe
).
A user agent may have prearranged trust relationships that do not require such user interfaces. For example, while a Web browser will present a user interface when a Web site performs a system information request, a Widget Runtime may have a prearranged, delegated security relationship with the user and, as such, a suitable alternative security and privacy mechanism with which to authorize the access to system information.
For the monitor method, distinct permission to monitor properties MUST be granted, and a maximum monitor period MUST be applied by the user agent. When requesting the user's express permission for use of the monitor method, the user agent MUST clearly indicate that this provides ongoing access to the monitored property, as compared to a one-shot access.
Additional security considerations might apply in the use of the APIs defined in this specfication for collection of quantitative data or from high performance data sources, to avoid side-channel attacks (e.g. sampling AmbientNoise fast enough to be able to interpolate a microphone).
Further to the requirements listed in the previous section, implementors of the System Info API are also advised to consider the following aspects that can negatively affect the privacy of their users: in certain cases, users can inadvertently grant permission to the User Agent to disclose their system information to Web sites. In other cases, the content hosted at a certain URL changes in such a way that the previously granted permissions no longer apply as far as the user is concerned. Or the users might simply change their minds.
Predicting or preventing these situations is inherently difficult. Mitigation and in-depth defensive measures are an implementation responsibility and not prescribed by this specification. However, in designing these measures, implementers are advised to enable user awareness of system information sharing, and to provide easy access to interfaces that enable revocation of permissions.
A property is defined as a set of related device characteristics. For instance, the Power property contains all the characteristics that relate to the device's electrical power supply. Properties are accessible using the functions defined by the SystemInfo interface below. A property is characterized by the following elements:
http://www.w3.org/2009/dap/SysInfo/
with the name of the property.The name of a property (or its URI, interchangeably) is used in the functions of the SystemInfo interface to identify the accessed property. The name of a property or its URI are equivalent for identifying the property. Character-per-character comparison will be used while matching for property, without any normalization. In response to calling one of those functions, the resulting property MUST be an instance of the property's interface i.e. an instance of the WebIDL interface that contains its attributes.
Some of the properties below are defined as
enumerable, meaning that more than one instance of
the property's value type exist on the system. For instance, a
system with more than one hard disk would report one instance
of StorageUnit for each disk. When requesting (through
calls to the get()
or monitor()
functions) the value of an enumerable property, the success callback
function will be passed an array of the property object, one for each
property item. However, if an identifier is passed to the
request, through the id attribute of the
options parameter, then only the property object with
that identifier will be returned.
The non-normative figure below illustrates the contents and relationship of all the properties defined in the following sections.
This interface contains the functions that enable access to
the properties defined in the following sections. Objects
implementing the Navigator interface (e.g. the
window.navigator
object) must also implement the
NavigatorSystem interface [[!NAVIGATOR]]. An instance of
NavigatorSystem would then be obtained by using
binding-specific casting methods on an instance of
Navigator
.
true
if the
user agent is able to report the value of a property, and
false
otherwise.
All functions except has() return a PendingOp object, defined in [[!CORE-DEVICE]], which includes a cancel() function allowing the asynchronous operation to be stopped.
This version of the specification supports read-only access to properties. A further version may introduce read-write functionality (for instance, through as a set
function) for certain properties. Examples would include screen brightness, active loudspeaker or camera aperture.
This interface gathers attributes shared by all properties.
The properties below expose the device's power information, either internal (battery) or external.
// Alert the user when the power level is below 20% if (navigator.system.has("Power")) navigator.system.monitor("Power",success,null,{lowThreshold:0.2, thresholdTarget:"level"}); function success(power) { alert("Low battery level: "+power.level); };
Power
PropertyThis property reflects the general state of the system's power sources. The information provided when requesting this property is described by the PowerAttributes interface.
true
, this value represents the
estimated time remaining in seconds before the battery is
depleted, based upon current power usage, if external
power were removed. This attribute can be used as a
threshold target.true
if the
device is currently powered by a battery, and
false
otherwise.true
if the current power source is a battery
and it is being charged, and false
otherwise.This section defines interfaces that expose the system's CPU information: description and current usage information.
//Monitor and display the CPU usage navigator.system.monitor("CPU",success); function success(cpu) { var s="CPU usage: "+cpu.usage; document.getElementById("cpuIndicator").innerHTML="CPU usage: "+(cpu.usage*100)+"%". }
CPU
PropertyThis property reflects the state of the CPUs available to this system. The information provided when requesting this property is described by the CPUAttributes interface.
The properties described in this section expose the system's temperature, as reported to the various internal thermometers.
// Show the thermal status as an SVG analog dial navigator.system.monitor("Thermal",success); function success(thermal) { document.getElementById("GaugeHand").setAttribute("transform","rotate("+thermal.state*360+")"); };
Thermal
propertyThis property provides information on the global temperature state of the system. The information provided when requesting this property is described by the ThermalAttributes interface.
These properties can be used by applications to determine the state of the network connections used by the system.
// Find the first of the current connections that is on WiFi, and if so monitor its signal strength navigator.system.get("Network",success,null); function success(network) { var activeConnections = network.activeConnections; for (var i=0; i < activeConnections.length; i++) { var active = activeConnections[i]; if (active.type === active.TYPE_WIFI) { navigator.system.monitor("Connection", {id: active.id}, wifiMonitorCB); // wifiMonitorCB is a user defined function that would // monitor the signal strength break; } } } function wifiMonitorCB(connection) { document.getElementById(indicator).innerHTML = "Wireless signal at " + connection.currentSignalStrength*100 + "%"; }
Network
PropertyThis property exposes the network connections that are available on this system. The information provided when requesting this property is described by the NetworkAttributes interface.
Connection
PropertyThis property exposes a network connection which is available on this system. The information provided when requesting this property is described by the ConnectionAttributes interface.
unknown
" if the type of this connection is unknown.ethernet
" if this is an Ethernet connection.usb
" if this is a connection over a USB port.wifi
" if this is a Wi-Fi connection (i.e. IEEE802.11).wimax
" if this is a WiMax connection (i.e. IEEE802.16).2g
" if this is a 2G connection (e.g. GSM, GPRS, EDGE).3g
" if this is a 3G connection (e.g. UMTS, CDMA).4g
" if this is a 4G connection (e.g. LTE, UMB).Updates of this specification may
standardize more values. In the meantime vendors
may define non-standard values, but must use the prefix
x-
.
true
indicates that the connection is
roaming, while false
indicates that it
is not roaming.The properties defined below expose the values of external sensors, reflecting the device's environment such as temperature, ambient brightness or ambient sound.
// Automatically adjust the UI colors if the ambient light gets too bright navigator.system.monitor("AmbientLight",success, null, {highThreshold: 0.9, thresholdTarget:"normalizedValue"}); function success() { setColorScheme('bright'); // user-defined function to set color scheme of the desktop }
The SensorAttributes interface is used as a general interface for sensor values. All the success callbacks for the properties defined in this section return an instance of this interface, with attribute values corresponding to the measurement leading to the callback being invoked.
For an instance of SensorAttributes returned by a callback function, either value or normalizedValue can be null
, but at least one MUST be non-null
. normalizedValue is meant to be used when the API is not able to report a sensor value in the unit specified in this document. In that case, value stays null
and normalizedValue is assigned a value which represents a unit-less measurement, between the minimum and maximum values that the device supports.
Some sensors may only be able to report two values, e.g. corresponding to "near" or "far" in the case of a proximity sensor. In that case, the normalizedValue is set to 0 for the lowest of the two values and to 1 for the greatest.
AmbientLight
PropertyThis property provides information about the global level of ambient light around the device.
AmbientNoise
propertyThis property provides information about the global level of ambient noise around the device.
AmbientTemperature
PropertyThis property provides information about the temperature around the device.
AmbientAtmosphericPressure
PropertyThis property provides information about the atmospheric pressure around the device.
Proximity
PropertyThis property provides information about the distance of objects around the device.
The properties below expose the device's audio and video codec capabilities.
// Find if this device supports MIDI navigator.system.get("AVCodecs",success); function success(codecs) { for (var i=0;i<codecs.length;i++) if (codecs[i].compFormat === "MP3") { // ... use MP3 for encoding ... break; } }
AVCodecs
propertyThis property exposes information about the audio/video codecs available to this system. The information provided when requesting this property is described by the AVCodecsAttributes interface.
AudioCodec
PropertyThis property exposes information on a single audio codec available on this system. The information provided when requesting this property is described by the AudioCodecAttributes interface.
true
if this device supports audio
encoding, false
otherwise.true
if this device supports audio
decoding, false
otherwise.VideoCodec
PropertyThis property exposes information on a single video codec available on this system. The information provided when requesting this property is described by the VideoCodecAttributes interface.
true
if the codec includes hardware acceleration
support, false
otherwise.This section describe properties that expose a device's storage units, like the unit's type (hard Disk, memory card, etc.) or capacity.
// Check each storage and warn if almost full navigator.system.get("Storage", success); function success(units) { for (var i=0;i<units.length;i++) if (units[i].capacity / units[i].availableCapacity > 0.95) alert("Storage unit '"+units[i].info+"' almost full. You may want to free some space."); }
Storage
PropertyThis property exposes the data storage devices connected to this system. When requested through API functions, this property returns an array of objects of type StorageUnitAttributes, corresponding to the storage devices available to this unit.
StorageUnit
PropertyThis property exposes a single data storage device connected to this system. When requested through API functions, this property returns an object of type StorageUnitAttributes, corresponding to the storage unit specified. This property is enumerable, i.e. an id parameter must be passed to the API function call to indicate which unit is requested.
This interface defines the type of object returned by API functions using the Storage and StorageUnit properties.
type
is set to this value if the type of this storage unit is unknown.true
if this device supports software modification, else
otherwise.true
if this unit can be removed from the system (e.g. a memory card unplugged, or a disk ejected), false
otherwise.This section describes system properties related to this device's output devices: screens, sound systems, etc.
// Count the screens navigator.system.get("OutputDevices", function(devices) { alert('this device has '+devices.displayDevices.length+' displays); });
OutputDevices
PropertyThis property provides information on the output devices (displays or audio) available on this system. The information provided when requesting this property is described by the OutputDevicesAttributes interface.
The DisplayDeviceAttributes interface inherits from the Screen interface defined in [[!CSSOM-VIEW]].
true
if this display is currently blanked, false
otherwise.The AudioDeviceAttributes interface exposes information about an audio output device available to this system.
type
is set to this value if the type of this audio device is unknown.type
is set to this value if this device is a loud speaker.type
is set to this value if this device is a set of headphones.The PrintingDeviceAttributes interface defined below describes any device that prints text or pictures on paper.
type
is set to this value if the type of this printing device is unknown.type
is set to this value if this printer uses ink jet technology.type
is set to this value if this device is a laser printer.type
is set to this value if this device prints by carving or molding the printing surface so that the text or pictures stand out in relief.type
is set to this value if this device is a vector graphics printer.true
is this printer is able to print in color, false
otherwise.The BrailleDeviceAttributes interface describes a device for displaying Braille characters.
This section describes system properties related to this device's input devices: keyboards, microphones, mice, etc.
// Check if the device supports multitouch navigator.system.get("InputDevices", function(devices) { for(var i=0; i<pointingDevices.length; i++) { var pointer = pointingDevices[i]; if (pointer.type === pointer.TYPE_TOUCHSCREEN && pointer.supportsMultiTouch) { applicationParams.hazMultiTouch = true; break; } });
InputDevices
PropertyThis property provides information on input devices (cameras, mice) available on this system.
The PointerAttributes interface describes a pointing device attached to the system.
true
if this device supports the multi-touch method of interaction, else
otherwise.The KeyboardAttributes interface describes a keyboard or keypads attached to this system.
true
if this device is a physical keyboard, else
if it is a software keyboard.The CameraAttributes interface property describes a camera or similar video capture device connected to this system.
true
if this device supports recording video, else
otherwise.true
if this device supports has a flash, else
otherwise.null
if the camera does not have a zoom (whether physical or digital).The MicrophoneAttributes interface describes a microphone or similar audio capture device attached to the system.
type
is set to this value if the type of this microphone is unknown to this API.type
is set to this value if this device is a microphone.type
is set to this value if this device is a line-in connector.This specification allows vendor-specific properties to be made
available to the SystemInfo interface. The URI of those
properties MUST NOT start with the string
http://www.w3.org/2009/dap/SysInfo/
.
Implementers should be aware of other standard device APIs when planning extensions, in order to avoid overlapping with existing work, in particular that of the W3C Device API and Policy Working Group.
The table below lists each interface or attribute described in this specification, as well as the corresponding classes or properties from [[DCONTOLOGY]], if it exists.
System Information | Delivery Context Ontology | Notes |
---|---|---|
Power | ||
PowerAttributes.level | hard:batteryLevel | |
PowerAttributes.timeRemaining | ||
PowerAttributes.isExternal | ||
PowerAttributes.batteryBeingCharged | hard:batteryBeingCharged | |
CPU | ||
CPUAttributes.usage | ||
Thermal | ||
ThermalAttributes.state | ||
Network | ||
NetworkAttributes.activeConnections | ||
ConnectionAttributes.currentDownloadBandwidth | ||
ConnectionAttributes.currentUploadBandwidth | ||
ConnectionAttributes.maxDownloadBandwidth | ||
ConnectionAttributes.maxUploadBandwidth | ||
ConnectionAttributes.minDownloadBandwidth | ||
ConnectionAttributes.minUploadBandwidth | ||
ConnectionAttributes.currentSignalStrength | ||
ConnectionAttributes.roaming | ||
SensorAttributes | ||
SensorAttributes.value | ||
SensorAttributes.min | ||
SensorAttributes.max | ||
SensorAttributes.normalizedValue | ||
Codecs | ||
AVCodecsAtributes.audioCodecs | ||
AVCodecsAttributes.videoCodecs | ||
AudioCodecAttributes.compFormat | ||
AudioCodecAttributes.encode | ||
AudioCodecAttributes.decode | ||
VideoCodecAttributes.compFormats | ||
VideoCodecAttributes.containerFormats | ||
VideoCodecAttributes.hwAccel | ||
VideoCodecAttributes.profiles | ||
VideoCodecAttributes.frameTypes | ||
VideoCodecAttributes.rateTypes | ||
Storage | ||
StorageUnitAttributes.type | ||
StorageUnitAttributes.isWritable | ||
StorageUnitAttributes.capacity | ||
StorageUnitAttributes.availableCapacity | ||
StorageUnitAttributes.isRemoveable | ||
Output Devices | ||
OutputDevicesAttributes.displayDevices | ||
OutputDevicesAttributes.activeDisplayDevices | ||
OutputDevicesAttributes.audioDevices | ||
OutputDevicesAttributes.activeAudioDevices | ||
DisplayAttributes.orientation | ||
DisplayAttributes.brightness | ||
DisplayAttributes.contrast | ||
DisplayAttributes.blanked | ||
DisplayAttributes.dotsPerInchW | ||
DisplayAttributes.dotsPerInchH | ||
DisplayAttributes.physicalWidth | ||
DisplayAttributes.physicalHeight | ||
SpeakerAttributes.type | ||
SpeakerAttributes.freqRangeLow | ||
SpeakerAttributes.freqRangeHigh | ||
SpeakerAttributes.volumeLevel | hard:volumeLevel | |
Input Devices | ||
InputDevicesAttributes.pointingDevices | ||
InputDevicesAttributes.activePointingDevices | ||
InputDevicesAttributes.keyboards | ||
InputDevicesAttributes.activeKeyboards | ||
InputDevicesAttributes.cameras | ||
InputDevicesAttributes.activeCameras | ||
InputDevicesAttributes.microphones | ||
InputDevicesAttributes.activeMicrophones | ||
PointingDeviceAttributes.type | ||
PointingDeviceAttributes.supportsMultiTouch | [[DCONTOLOGY]] has hard:tactileDisplay but only covers touchScreen, mice and styluses are normative instances of hard:inputDevice | |
KeyboardAttributes.type | ||
KeyboardisHardware | ||
CameraAttributes.supportsVideo | ||
CameraAttributes.sensorPixels | ||
CameraAttributes.hasFlash | ||
CameraAttributes.maxZoomFactors | ||
MicrophoneAttributes.type | ||
MicrophoneAttributes.freqRangeLow | ||
MicrophoneAttributes.freqRangeHigh |
The table below lists all the properties, the corresponding interface and that interface's attributes
Property | Property Interface | Attributes |
---|---|---|
Power | PowerAttributes | level |
CPU | CPUAttributes | usage |
Thermal | ThermalAttributes | state |
Network | NetworkAttributes | activeConnections |
Connection | ConnectionAttributes | type |
AmbientLight | SensorAttributes | value |
AVCodecs | AVCodecsAttributes | audioCodecs |
AudioCodec | AudioCodecAttributes | compFormat |
VideoCodec | VideoCodecAttributes | compFormats |
Storage | StorageUnitAttributes (array) |
|
StorageUnit | StorageUnitAttributes | type |
OutputDevices | OutputDevicesAttributes | displayDevices |
DisplayDeviceAttributes | orientation | |
AudioDeviceAttributes | type | |
PrintingDeviceAttributes | type | |
BrailleDeviceAttributes | nbCells | |
InputDevices | InputDevicesAttributes | pointingDevices |
PointerAttributes | type | |
KeyboardAttributes | type | |
CameraAttributes | supportsVideo | |
MicrophoneAttributes | type |
The DAP Working Group would like to acknowledge the people outside of the DAP Working Group who helped with the process of developing this specification. Specifically, many thanks to Clayne Robison and Andy Idsinga at Intel Corporation for their contributions.