This specification defines an API to provide Web applications with access to various properties of the system which they are running on. Specifically, properties pertaining to the device hardware are addressed. Examples include battery status, current network bandwidth. 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 only available to an operating system's native applications, they must be able to access various data present on the device, either related to the hardware state (e.g. CPU load), software data (e.g. pictures stored) 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 hardware devices, either internal (CPU, Thermometers) or ambient (light, noise or temperature).
A Web application using this API has access to device specific data which may contain information that the user considers private. For instance a user may object to a Web application transmitting the device's CPU load to an untrusted server, or letting another application modify the device's screen brightness without the user's consent. Therefore, a conforming implementation of this specification MUST provide a mechanism that protects the user's privacy and this mechanism SHOULD ensure that no information exposed by this API is retrievable or modifiable without the user's express permission
User Agents MUST NOT retrieve or update system information to Web sites without the express permission of the user. User Agents MUST acquire permission through a user interface, unless they have prearranged trust relationships with users, as described below. The user interface MUST include the URI of the document origin, as defined in [[!HTML5]]. 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 User Agents MUST respect revoked permissions.
Obtaining the user's express permission to access one API method does not imply the user has granted permission for the same Web site to access other methods provided by this API, or to access the same method with a different set of arguments, as part of the same permission context. If a user has expressed permission for an implementation to, e.g. access the device's battery level, the implementation MUST seek the user's express permission if and when any additional function is called on this API.
Some User Agents will 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 access to system information.
Recipients should only request system information when necessary. Recipients should only use the system information for the task for which it was provided to them. Recipients should dispose of system information once that task is completed, unless expressly permitted to retain it by the user. Recipients should also take measures to protect this information against unauthorized access. If system information is stored, users SHOULD be allowed to update and delete this information.
The recipient of system information should not retransmit the system information without the user’s express permission. Care should be taken when retransmitting and use of encryption is encouraged.
Recipients should clearly and conspicuously disclose the fact that they are collecting system data, the purpose for the collection, how long the data is retained, how the data is secured, how the data is shared if it is shared, how users can access, update and delete the data, and any other choices that users have with respect to the data. This disclosure should include an explanation of any exceptions to the guidelines listed above.
Further to the requirements listed in the previous section, implementors of this 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 mind.
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 propertyThe name of a property (or its URI, interchangeably) is used in the functions of the SystemInfo interface to identify the property accessed. When a success callback resulting from calling one of those functions is invoked, the API MUST pass an instance of the property's interface.
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 multi-processor system would report as many instances of Cpu as the number of processors. When requesting the value of an enumerable property, the id attribute of the Options interface is used to differentiate between multiple instances.
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.
Not all property attributes can be modified. Each
property interface definitions indicates, through the
readonly keyword whether an attribute is
allowed to be modified.
All functions return a PendingOp object, defined in [[!CORE-DEVICE]], which has a cancel function allowing the asynchronous operation to be interrupted.
This interface gathers attributes shared by all properties describing system devices (i.e. all the enumerable properties). Examples: single battery units, CPU, or network connections.
The properties below expose the device's power information, either internal (battery) or external.
// Alert the user when the power level is below 20%
navigator.system.watch("Power",success,null,{lowThreshold:0.2});
function success(power) {
alert("Low battery level: "+power.level);
};
This property reflects the general state of the system's power sources
Find the corresponding DCO properties everywhere
true, this
value MUST be null, meaning that there is
essentially infinite time remaining.
true the device is currently powered by an
external source. If false the device is
currently powered by an internal source.
false,
this value MUST be false, meaning that the
battery is currently powering the system, and is
therefore depleting.
This section defines interfaces that expose the system's CPU information, including type, specifications, current system load information.
//Monitor and display the CPU load
navigator.system.watch("Processing",success);
function success(cpu) {
var s="CPU load: "+cpu.load;
document.getElementById("cpuIndicator").innerHTML="CPU load: "+(cpu.load*100)+"%".
}
This property reflects the state of the CPUs available to this system.
The properties described in this section expose the system's temperature, as reported to the various internal thermometers.
// Check the thermal state and display a warning if it is above a certain level
navigator.system.get("Thermal",success);
function success(thermal) {
if (thermal.state > 0.9)
document.getElementById("tempIndicator").style.background-color = "red";
};
This property provides information on the global temperature state of the system
This interface can be used by applications to determine the state of the network interface used by the system.
// Find if the current connection is WiFi, and if so monitor its signal strength
navigator.system.get("Network",success,null);
function success(connection) {
if (connection.type===connection.TYPE_IEEE802_11)
navigator.system.watch("WifiConnection",wifiWatchCB);
}
function wifiWatchCB(connection) {
document.getElementById(indicator, "Wireless "+connection.essid+" at "+(connection.signalStrength*100)+"%");
}
This property provides information on the system's connection to the network
The associated Connection object is a CellularConnection object.
The associated Connection object is a CellularConnection object.
null if this connection is wired.null
otherwise.null otherwise.null otherwisenull otherwiseShould we gather all of GSM, GPRS, EDGE, CDMA, TETRA, UMTS under a singe "CELL" type? They could be differentiated by maxBandwidth, if needed.
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 screen brightness if the ambient brightness is above a certain level
navigator.system.watch("AmbientLight",success, {maxThreshold: 0.9});
function success() {
navigator.system.get("OutputDevices",
function(devices) {
for(var i=0; i<devices.displays.length; i++)
navigator.system.set("Display",{id: devices.displays[i].id, brightness: 0.9});
});
}
This 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.
This property provides information about the temperature around the device.
This property provides information about the atmospheric pressure around the device.
This 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;
}
}
This property exposes information about the audio/video codecs available to this system
This property exposes information on a single audio codec available to this system. Is it enumerable.
true if this device supports audio
encoding, false otherwise.true if this device supports audio
decoding, false otherwise.true if the codec includes hardware acceleration support, false otherwise.This set of properties expose a device's storage units and their properties, like type (hard Disk, memory card, etc.) and 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.");
}
This property exposes the data storage devices connected to this system.
This property exposes a single storage device connected to this system. It is enumerable.
type is set to this value when the type of this device is unknown to this API.true when 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 otherwiseThis section gathers system properties related to this device's output devices: screens, sound systems, etc.
Do we need information about active devices, e.g. in order to be able to see which screen is currently being in use, or to control which set of speakers should be activated? If so how do we specify it? Through an "active" flag on each device (hard to watch), or through a pointer (e.g. currentDisplay in OutputDevices) which would mean only one device is active at a time, which might not always be correct in cases like several active keyboards
// Set the brightness of all the displays to their maximum value
navigator.system.get("OutputDevices",
function(devices) {
for(var i=0; i<devices.displays.length; i++)
navigator.system.set("Display",{id: devices.displays[i].id, brightness: 1});
});
This property provides information on the output devices (displays, audio) available on this system
This property exposes information on a single display device available to the system. Is it enumerable.
The Display interface defined below inherits from the Screen interface as defined in [[!CSSOM-VIEW]]
true if this display is currently blanked, false otherwiseAre we being short-sighted in only listing four orientations? Would it make sense to have it be an angle, except that in most cases it would only change in 90° increments?
This property exposes information on a single audio output device available to this system. It is enumerable.
type is set to this value when the type of this device is unknowntype is set to this value when this device is a loud speakertype is set to this value when this device is a set of headphonesThe properties defines below expose the input devices connected to the system (e.g. mouse, keyboard, camera).
Should we have a notion of active or selected device, e.g. which camera is currently used, or which display is the one currently drawn on. We could use current* like with Power, but that restricts to one active device at a time. Alternatively, there could be an active flag in each device. But that would make watch() messy, since we would have to extend the definition of watched events to sub-sub-field modifications
// Check if the device supports multitouch
navigator.system.get("InputDevices",
function(devices) {
for(var i=0; i<devices.pointingDevices.length; i++)
if (devices.pointingDevices[i].supportsMultiTouch) {
applicationParams.hazMultiTouch = true;
break;
}
});
This property exposes the pointing devices (mouse, touch screen, gesture sensor). It is enumerable.
true when this device supports the multi-touch method of interaction, else otherwise.This property exposes the keyboards and keypads connected to this system. It is enumerable.
true when this device is a physical keyboard, else if it is a software keyboard.This property exposes the cameras connected to this system. It is enumerable.
true when this device supports recording video, else otherwise.true when this device supports has a flash, else otherwise.null if the camera does not have a zoom (whether physical or digital)
Use focal length instead? And shutter speed/aperture/ISO/sensor type?
This property exposes the microphones connected to this system. It is enumerable.
type is set to this value when the type of this device is unknown to this API.type is set to this value when this device is a microphonetype is set to this value when this device is a line-in connectorThis 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.
extensibility of enumerated constants, e.g. connection types
make a separate document?
Add examples
The use cases for this module are critical to forming a realistic picture of what kinds of information are going to be valuable for the web application that wants delivery context network information. The primary use case is: application wants to know about the network connection so that it can adjust its behavior.
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.