This API is available on Firefox OS for internal applications 仅。

This API is used to get information about the current mobile voice and data connection states of the device. It is accessible through navigator.mozMobileConnections , which returns an array of MozMobileConnection 对象。

注意 : The syntax used to be window.navigator.mozMobileConnection , returning a single MozMobileConnection object, but this was updated in Firefox 1.3 due to the introduction of Multi-SIM support (Dual-SIM-Dual-Standby or DSDS).

Interface overview

callback EventHandler = any (Event event);
interface MozMobileConnection : EventTarget
{
  const long ICC_SERVICE_CLASS_VOICE = (1 << 0);
  const long ICC_SERVICE_CLASS_DATA = (1 << 1);
  const long ICC_SERVICE_CLASS_FAX = (1 << 2);
  const long ICC_SERVICE_CLASS_SMS = (1 << 3);
  const long ICC_SERVICE_CLASS_DATA_SYNC = (1 << 4);
  const long ICC_SERVICE_CLASS_DATA_ASYNC = (1 << 5);
  const long ICC_SERVICE_CLASS_PACKET = (1 << 6);
  const long ICC_SERVICE_CLASS_PAD = (1 << 7);
  const long ICC_SERVICE_CLASS_MAX = (1 << 7);
  readonly attribute MozMobileConnectionInfo voice;
  readonly attribute MozMobileConnectionInfo data;
  readonly attribute DOMString networkSelectionMode;
  readonly attribute DOMString iccId;
  DOMRequest getNetworks();
  DOMRequest selectNetwork(MozMobileNetworkInfo network);
  DOMRequest selectNetworkAutomatically();
  DOMRequest sendMMI(DOMString mmi);
  DOMRequest cancelMMI();
  DOMRequest setCallForwardingOption(MozMobileCFInfo CFInfo);
  DOMRequest getCallForwardingOption(unsigned short reason);
  attribute EventHandler onvoicechange;
  attribute EventHandler ondatachange;
  attribute EventHandler onussdreceived;
  attribute EventHandler ondataerror;
  attribute EventHandler oncfstatechange;
};
					

特性

MozMobileConnection.voice 只读
A MozMobileConnectionInfo object that gives access to information about the voice connection.
MozMobileConnection.data 只读
A MozMobileConnectionInfo object that gives access to information about the data connection.
MozMobileConnection.iccId 只读

A string that indicates the Integrated Circuit Card Identifier of the SIM this mobile connection corresponds to.

MozMobileConnection.networkSelectionMode 只读

A string that indicates the selection mode of the voice and data networks.

MozMobileConnection.oncfstatechange
处理程序为 cfstatechange event. This event is fired when the call forwarding state changes.
MozMobileConnection.ondatachange
处理程序为 datachange event. This event is fired whenever the data connection object changes values.
MozMobileConnection.ondataerror
处理程序为 dataerror event. This event is fired whenever the data connection object receive an error from the RIL .
MozMobileConnection.onussdreceived
处理程序为 ussdreceived event. This event is fired whenever a new USSD message is received.
MozMobileConnection.onvoicechange
处理程序为 voicechange event. This event is fired whenever the voice connection object changes.

常量

  • ICC_SERVICE_CLASS_VOICE
  • ICC_SERVICE_CLASS_DATA
  • ICC_SERVICE_CLASS_FAX
  • ICC_SERVICE_CLASS_SMS
  • ICC_SERVICE_CLASS_DATA_SYNC
  • ICC_SERVICE_CLASS_DATA_ASYNC
  • ICC_SERVICE_CLASS_PACKET
  • ICC_SERVICE_CLASS_PAD
  • ICC_SERVICE_CLASS_MAX

方法

注意: All original methods from the MozMobileConnection interface are fully asynchronous. They all return a DOMRequest which has a onsuccess and onerror event handler to handle the success or failur of the method call.

MozMobileConnection.cancelMMI()
Cancel the current MMI request if one exists.
MozMobileConnection.getCallForwardingOption()

Queries current call forward options.

MozMobileConnection.getNetworks()

Search for available networks.

MozMobileConnection.selectNetwork()

Manually selects a network, overriding the radio's current selection.

MozMobileConnection.selectNetworkAutomatically()

Tell the radio to automatically select a network.

MozMobileConnection.sendMMI()
发送 MMI 消息。
MozMobileConnection.setCallForwardingOption()

Configures call forward options.

MozMobileConnection interface also inherit from the EventTarget interface

EventTarget.addEventListener()
Register an event handler of a specific event type on the EventTarget .
EventTarget.removeEventListener()
移除事件监听器从 EventTarget .
EventTarget.dispatchEvent()
Dispatch an event to this EventTarget .

Additional methods for Mozilla chrome code

Mozilla extensions for use by JS-implemented event targets to implement on* properties. See also WebIDL 绑定 .

  • void setEventHandler (DOMString type, EventHandler handler)
  • EventHandler getEventHandler (DOMString type)

范例

The following snippet returns an array of strings that correspond to MCCs, which can be mapped back to countries or even continents based on the first digit (see Mobile country code for a useful reference.) This is useful for redirection logic.

var mcc_mnc = (function () {
 function f (c) { return !!c.lastKnownHomeNetwork && !!c.lastKnownNetwork; };
 function m (c) {
   var s = (c.lastKnownHomeNetwork || c.lastKnownNetwork).split("-");
   return { mcc: s[0], mnc: s[1], };
 };
 return function () {
   if ("mozMobileConnections" in navigator) {
     return Array.prototype.filter.call(navigator.mozMobileConnections, f).map(m);
   } else if ("mozMobileConnection" in navigator) {
     return [navigator.mozMobileConnection].filter(f).map(m);
   } else {
     return [];
   }
 };
})();
					

规范

Not part of any specification

另请参阅

元数据

  • 最后修改: