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).
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
只读
MozMobileConnectionInfo
object that gives access to information about the voice connection.
MozMobileConnection.data
只读
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()
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()
MozMobileConnection.setCallForwardingOption()
Configures call forward options.
MozMobileConnection
interface also inherit from the
EventTarget
interface
EventTarget.addEventListener()
EventTarget
.
EventTarget.removeEventListener()
EventTarget
.
EventTarget.dispatchEvent()
EventTarget
.
Mozilla extensions for use by JS-implemented event targets to implement on* properties. See also WebIDL 绑定 .
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
navigator.mozMobileConnection
MozMobileConnectionInfo
MozIccManager
MozMobileNetworkInfo
MozMobileCFInfo
MozMobileCellInfo
EventTarget
Archive
CFStateChangeEvent
DataErrorEvent
IccCardLockError
IccCardLockErrorEvent
MozCellBroadcastEvent
MozEmergencyCbModeEvent
MozIccManager
MozMobileCFInfo
MozMobileCellInfo
MozMobileConnection
MozMobileConnectionInfo
MozMobileICCInfo
MozMobileNetworkInfo
MozOtaStatusEvent
MozStkCommandEvent
USSDReceivedEvent