WebAPI/WebMobileConnection

From MozillaWiki
Jump to navigation Jump to search

This exposes information about the current mobile data connection to (certain) HTML content. The primary use case for this is the status bar of the main phone UI. It typically shows the operator name, signal strength, data connection type, etc.

Proposed API

 interface MobileConnection : EventTarget
 {
   /**
    * Indicates the state of the device's ICC card.
    *
    * Possible values: 'unavailable', 'absent', 'pin_required', 'puk_required',
    * 'network_locked', 'not_ready', 'ready'.
    */
   readonly attribute string cardState;
   
   /**
    * Indicates whether the device is connected to a mobile network.
    */
   readonly attribute bool connected;
   
   /**
    * Indicates whether the connection is going through a foreign operator
    * (roaming) or not.
    */
   readonly attribute bool roaming;
   
   /**
    * Operator name.
    */
   readonly attribute string operator?;
   
   /**
    * Type of connection.
    *
    * Possible values: 'gprs', 'edge', 'umts', 'hsdpa', 'evdo0', 'evdoa', 'evdob', etc.
    */
   readonly attribute string type?;
   
   /**
    * Signal strength as defined by 3GPP TS 27.007 specification, section 8.5.
    *
    * Possible values:
    *   0       -113 dBm or less
    *   1       -111 dBm
    *   2...30  -109 ... -53 dBm
    *   31      -51 dBm or greater
    *   null    if no signal strength (or signal) is available.
    */
   readonly attribute short signalStrength?;
   
   /**
    * Signal strength expressed as number of "bars".
    *
    * Possible values: 0 (weakest signal) to 4 (full signal).
    */
   readonly attribute short bars?;
   
   /**
    * The 'cardstatechange' event is notified when the 'cardState' attribute
    * changes value.
    */
   attribute EventListener oncardstatechange;
   
   /**
    * The 'connectionchange' event is notified whenever one of the 'connected',
    * 'roaming', 'operator', 'type' attributes change, since typically many or
    * all of them change together.
    */
   attribute EventListener onconnectionchange;
    
   /**
    * The 'signalstrengthchange' event is notified whenever the signal strength
    * changes value. The 'bars' attribute is updated accordingly.
    */
   attribute EventListener onsignalstrengthchange;
 };