WebAPI/WebMobileConnection/Multi-SIM: Difference between revisions
No edit summary |
|||
(16 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
=== Web API === | === Web API === | ||
The change is quite simple | The change is quite simple -- navigator.mozMobileConnection becomes an array of nsIDOMMozMobileConnection obect, i.e. navigator.mozMobileConnections. The length of the array is actually the number of services provided on a device. And the index of the array is used as 'serviceId.' | ||
We don't modify the | We don't modify the existing interface, like nsIDOMMozMobileConnection, nsIDOMMozMobileConnectionInfo ...etc, to minimize the coding effort of gaia. | ||
interface nsIMozNavigatorMobileConnectionManager: nsISupports | |||
{ | |||
// An array of nsIDOMMozMobileConnection. | |||
readonly attribute jsval mozMobileConnections; | |||
}; | |||
interface nsIDOMMozMobileConnection : nsIDOMEventTarget | interface nsIDOMMozMobileConnection : nsIDOMEventTarget | ||
{ | { | ||
const long | const long ICC_SERVICE_CLASS_VOICE = (1 << 0); | ||
.... | |||
readonly attribute DOMString lastKnownNetwork; | readonly attribute DOMString lastKnownNetwork; | ||
Line 23: | Line 23: | ||
readonly attribute nsIDOMMozMobileConnectionInfo data; | readonly attribute nsIDOMMozMobileConnectionInfo data; | ||
readonly attribute DOMString networkSelectionMode; | readonly attribute DOMString networkSelectionMode; | ||
readonly attribute DOMString iccId; | readonly attribute DOMString iccId; // The iccId of the icc card which is inserted in this client. | ||
nsIDOMDOMRequest getNetworks(); | nsIDOMDOMRequest getNetworks(); | ||
nsIDOMDOMRequest selectNetwork(in nsIDOMMozMobileNetworkInfo network); | nsIDOMDOMRequest selectNetwork(in nsIDOMMozMobileNetworkInfo network); | ||
nsIDOMDOMRequest selectNetworkAutomatically(); | nsIDOMDOMRequest selectNetworkAutomatically(); | ||
nsIDOMDOMRequest setRoamingPreference(in DOMString mode); | |||
nsIDOMDOMRequest getRoamingPreference(); | |||
nsIDOMDOMRequest setVoicePrivacyMode(in bool enabled); | |||
nsIDOMDOMRequest getVoicePrivacyMode(); | |||
nsIDOMDOMRequest sendMMI(in DOMString mmi); | nsIDOMDOMRequest sendMMI(in DOMString mmi); | ||
nsIDOMDOMRequest cancelMMI(); | nsIDOMDOMRequest cancelMMI(); | ||
nsIDOMDOMRequest setCallForwardingOption(in nsIDOMMozMobileCFInfo CFInfo); | nsIDOMDOMRequest setCallForwardingOption(in nsIDOMMozMobileCFInfo CFInfo); | ||
nsIDOMDOMRequest getCallForwardingOption(in unsigned short reason); | nsIDOMDOMRequest getCallForwardingOption(in unsigned short reason); | ||
nsIDOMDOMRequest setCallBarringOption(in jsval option); | |||
nsIDOMDOMRequest getCallBarringOption(in jsval option); | |||
nsIDOMDOMRequest changeCallBarringPassword(in jsval info); | |||
nsIDOMDOMRequest setCallWaitingOption(in bool enabled); | |||
nsIDOMDOMRequest getCallWaitingOption(); | |||
nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned short clirMode); | |||
nsIDOMDOMRequest getCallingLineIdRestriction(); | |||
nsIDOMDOMRequest exitEmergencyCbMode(); | |||
[implicit_jscontext] attribute jsval onvoicechange; | [implicit_jscontext] attribute jsval onvoicechange; | ||
[implicit_jscontext] attribute jsval ondatachange; | [implicit_jscontext] attribute jsval ondatachange; | ||
Line 38: | Line 58: | ||
[implicit_jscontext] attribute jsval ondataerror; | [implicit_jscontext] attribute jsval ondataerror; | ||
[implicit_jscontext] attribute jsval oncfstatechange; | [implicit_jscontext] attribute jsval oncfstatechange; | ||
[implicit_jscontext] attribute jsval onemergencycbmodechange; | |||
[implicit_jscontext] attribute jsval onotastatuschange; | |||
[implicit_jscontext] attribute jsval oniccchange; // Icc card is inserted or removed. | |||
}; | }; | ||
Line 64: | Line 87: | ||
*Multi-SIMs | *Multi-SIMs | ||
// Listen connection status for specific service | // Listen connection status for specific service | ||
var conn = window.navigator. | var conn = window.navigator.mozMobileConnections[serviceId]; | ||
Once the mobile connection object is obtained, the follow work is the same. We can get notification when voice/data connection change occurs in specific SIM. | Once the mobile connection object is obtained, the follow work is the same. We can get notification when voice/data connection change occurs in specific SIM. | ||
Line 81: | Line 104: | ||
And also you can get total number of service via | And also you can get total number of service via | ||
var numberOfServices = window.navigator. | var numberOfServices = window.navigator.mozMobileConnections.length; | ||
=== | === Internal API and Implementation === | ||
Add clientId in the interface of nsIMobileConnectionProvider.idl and change the implementation of getVoiceConnectionInfo, getDataConnectionInfo, and getNetworkSelectionMode. | |||
interface nsIMobileConnectionListener : nsISupports | |||
interface | |||
{ | { | ||
void notifyVoiceChanged(); | |||
void notifyDataChanged(); | |||
void notifyUssdReceived(in DOMString message, in boolean sessionEnded); | |||
void notifyDataError(in DOMString message); | |||
void notifyCFStateChange(in boolean success, in unsigned short action, in unsigned short reason, in DOMString number, in unsigned short timeSeconds, in unsigned short serviceClass); | |||
void notifyEmergencyCbModeChanged(in boolean active, in unsigned long timeoutMs); | |||
void notifyOtaStatusChanged(in DOMString status); | |||
void notifyIccChanged(); | |||
}; | }; | ||
interface nsIMobileConnectionProvider: nsISupports | interface nsIMobileConnectionProvider: nsISupports | ||
{ | { | ||
void registerMobileConnectionMsg(in unsigned long | void registerMobileConnectionMsg(in unsigned long clientId, in nsIMobileConnectionListener listener); | ||
void unregisterMobileConnectionMsg(in unsigned long clientId, in nsIMobileConnectionListener listener); | |||
nsIDOMMozMobileConnectionInfo | nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId); | ||
nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId); | |||
DOMString | DOMString getNetworkSelectionMode(in unsigned long clientId); | ||
nsIDOMDOMRequest getNetworks(in nsIDOMWindow window | DOMString getIccId(in unsigned long clientId); | ||
nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network | |||
nsIDOMDOMRequest | nsIDOMDOMRequest getNetworks(in unsigned long clientId, in nsIDOMWindow window); | ||
nsIDOMDOMRequest | nsIDOMDOMRequest selectNetwork(in unsigned long clientId, in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network); | ||
nsIDOMDOMRequest | nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId, in nsIDOMWindow window); | ||
nsIDOMDOMRequest | |||
nsIDOMDOMRequest | nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId, in nsIDOMWindow window, in DOMString mode); | ||
nsIDOMDOMRequest | nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId, in nsIDOMWindow window); | ||
nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId, in nsIDOMWindow window, in bool enabled); | |||
nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId, in nsIDOMWindow window); | |||
nsIDOMDOMRequest sendMMI(in unsigned long clientId, in nsIDOMWindow window, in DOMString mmi); | |||
nsIDOMDOMRequest cancelMMI(in unsigned long clientId, in nsIDOMWindow window); | |||
nsIDOMDOMRequest getCallForwardingOption(in unsigned long clientId, in nsIDOMWindow window, in unsigned short reason); | |||
nsIDOMDOMRequest setCallForwardingOption(in unsigned long clientId, in nsIDOMWindow window, in nsIDOMMozMobileCFInfo CFInfo); | |||
nsIDOMDOMRequest getCallBarringOption(in unsigned long clientId, in nsIDOMWindow window, in jsval option); | |||
nsIDOMDOMRequest setCallBarringOption(in unsigned long clientId, in nsIDOMWindow window, in jsval option); | |||
nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId, in nsIDOMWindow window, in jsval info); | |||
nsIDOMDOMRequest setCallWaitingOption(in unsigned long clientId, in nsIDOMWindow window, in bool enabled); | |||
nsIDOMDOMRequest getCallWaitingOption(in unsigned long clientId, in nsIDOMWindow window); | |||
nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId, in nsIDOMWindow window, in unsigned short clirMode); | |||
nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId, in nsIDOMWindow window); | |||
nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId, in nsIDOMWindow window); | |||
}; | }; | ||
The data structures of | The data structures of voiceConnectionInfo, dataConnectionInfo, and networkSelectionMode may need to change to be an array format in RILContentHelper.js for storing the information among different SIM. | ||
// nsIRILContentHelper | // nsIRILContentHelper | ||
voiceConnectionInfo: [], | voiceConnectionInfo: [], | ||
dataConnectionInfo: [], | dataConnectionInfo: [], | ||
Line 150: | Line 170: | ||
=== Current Architecture === | === Current Architecture === | ||
This is the current architecture supporting a single SIM card. Only one mobile connection to handle all events for | This is the current architecture supporting a single SIM card. Only one mobile connection to handle all events for Network/Data functions. | ||
[[File: | [[File:MobileConnectionCurrent.jpg|480x360px|MobileConnection Architecture]] | ||
=== Proposal Architecture for Multi-SIM=== | === Proposal Architecture for Multi-SIM=== | ||
This is the proposal architecture supporting the multi-SIM card. | This is the proposal architecture supporting the multi-SIM card. | ||
MobileConnection becomes an array of nsIDOMMozMobileConnection obect. API users can use 'serviceId' as an index to access corresponding service object. | |||
[[File: | [[File:MobileConnection.jpg|480x360px|New MobileConnection Architecture]] | ||
=== RIL Implementation === | === RIL Implementation === | ||
Line 166: | Line 186: | ||
== Status == | == Status == | ||
* [https://bugzilla.mozilla.org/show_bug.cgi?id=814629 bug 814629] for WebMobileConnection API. ( | * [https://bugzilla.mozilla.org/show_bug.cgi?id=814629 bug 814629] for WebMobileConnection API. (Landed) | ||
* [https://bugzilla.mozilla.org/show_bug.cgi?id=818353 bug 818353] for adding subscriptId in backend implementation. ( | * [https://bugzilla.mozilla.org/show_bug.cgi?id=818353 bug 818353] for adding subscriptId in backend implementation. (Landed) | ||
[[Category:Web APIs]] |
Latest revision as of 23:23, 1 October 2014
Proposal: WebMobileConnectionManager API for Multi-SIM
Currently B2G supports a single SIM architecture. This proposal wants to extend it for supporting multi-SIMs. In multi-SIM device, each service is independent and has it own status and information. Here we introduce multiple nsIDOMMozMobileConnection objects architecture. One nsIDOMMozMobileConnection object is binded to a service. You can use serviceId as index to get corresponding service object.
Web API
The change is quite simple -- navigator.mozMobileConnection becomes an array of nsIDOMMozMobileConnection obect, i.e. navigator.mozMobileConnections. The length of the array is actually the number of services provided on a device. And the index of the array is used as 'serviceId.'
We don't modify the existing interface, like nsIDOMMozMobileConnection, nsIDOMMozMobileConnectionInfo ...etc, to minimize the coding effort of gaia.
interface nsIMozNavigatorMobileConnectionManager: nsISupports { // An array of nsIDOMMozMobileConnection. readonly attribute jsval mozMobileConnections; }; interface nsIDOMMozMobileConnection : nsIDOMEventTarget { const long ICC_SERVICE_CLASS_VOICE = (1 << 0); .... readonly attribute DOMString lastKnownNetwork; readonly attribute DOMString lastKnownHomeNetwork; readonly attribute nsIDOMMozMobileConnectionInfo voice; readonly attribute nsIDOMMozMobileConnectionInfo data; readonly attribute DOMString networkSelectionMode; readonly attribute DOMString iccId; // The iccId of the icc card which is inserted in this client. nsIDOMDOMRequest getNetworks(); nsIDOMDOMRequest selectNetwork(in nsIDOMMozMobileNetworkInfo network); nsIDOMDOMRequest selectNetworkAutomatically(); nsIDOMDOMRequest setRoamingPreference(in DOMString mode); nsIDOMDOMRequest getRoamingPreference(); nsIDOMDOMRequest setVoicePrivacyMode(in bool enabled); nsIDOMDOMRequest getVoicePrivacyMode(); nsIDOMDOMRequest sendMMI(in DOMString mmi); nsIDOMDOMRequest cancelMMI(); nsIDOMDOMRequest setCallForwardingOption(in nsIDOMMozMobileCFInfo CFInfo); nsIDOMDOMRequest getCallForwardingOption(in unsigned short reason); nsIDOMDOMRequest setCallBarringOption(in jsval option); nsIDOMDOMRequest getCallBarringOption(in jsval option); nsIDOMDOMRequest changeCallBarringPassword(in jsval info); nsIDOMDOMRequest setCallWaitingOption(in bool enabled); nsIDOMDOMRequest getCallWaitingOption(); nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned short clirMode); nsIDOMDOMRequest getCallingLineIdRestriction(); nsIDOMDOMRequest exitEmergencyCbMode(); [implicit_jscontext] attribute jsval onvoicechange; [implicit_jscontext] attribute jsval ondatachange; [implicit_jscontext] attribute jsval onussdreceived; [implicit_jscontext] attribute jsval ondataerror; [implicit_jscontext] attribute jsval oncfstatechange; [implicit_jscontext] attribute jsval onemergencycbmodechange; [implicit_jscontext] attribute jsval onotastatuschange; [implicit_jscontext] attribute jsval oniccchange; // Icc card is inserted or removed. };
interface nsIDOMMozMobileConnectionInfo : nsISupports { readonly attribute DOMString state; readonly attribute bool connected; readonly attribute bool emergencyCallsOnly; readonly attribute bool roaming; readonly attribute nsIDOMMozMobileNetworkInfo network; readonly attribute DOMString type; readonly attribute jsval signalStrength; readonly attribute jsval relSignalStrength; readonly attribute nsIDOMMozMobileCellInfo cell; };
...
Use Case
Listen Connection Status
- Current B2G (Single SIM)
var conn = window.navigator.mozMobileConnection;
- Multi-SIMs
// Listen connection status for specific service var conn = window.navigator.mozMobileConnections[serviceId];
Once the mobile connection object is obtained, the follow work is the same. We can get notification when voice/data connection change occurs in specific SIM.
if (conn) { conn.addEventListener('voicechange', this); conn.onvoicechange = function onvoicechange() { ... } conn.addEventListener('datachange', this); conn.ondatachange = function ondatachange() { ... } }
And also you can get total number of service via
var numberOfServices = window.navigator.mozMobileConnections.length;
Internal API and Implementation
Add clientId in the interface of nsIMobileConnectionProvider.idl and change the implementation of getVoiceConnectionInfo, getDataConnectionInfo, and getNetworkSelectionMode.
interface nsIMobileConnectionListener : nsISupports { void notifyVoiceChanged(); void notifyDataChanged(); void notifyUssdReceived(in DOMString message, in boolean sessionEnded); void notifyDataError(in DOMString message); void notifyCFStateChange(in boolean success, in unsigned short action, in unsigned short reason, in DOMString number, in unsigned short timeSeconds, in unsigned short serviceClass); void notifyEmergencyCbModeChanged(in boolean active, in unsigned long timeoutMs); void notifyOtaStatusChanged(in DOMString status); void notifyIccChanged(); };
interface nsIMobileConnectionProvider: nsISupports { void registerMobileConnectionMsg(in unsigned long clientId, in nsIMobileConnectionListener listener); void unregisterMobileConnectionMsg(in unsigned long clientId, in nsIMobileConnectionListener listener); nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId); nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId); DOMString getNetworkSelectionMode(in unsigned long clientId); DOMString getIccId(in unsigned long clientId); nsIDOMDOMRequest getNetworks(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest selectNetwork(in unsigned long clientId, in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network); nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId, in nsIDOMWindow window, in DOMString mode); nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId, in nsIDOMWindow window, in bool enabled); nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest sendMMI(in unsigned long clientId, in nsIDOMWindow window, in DOMString mmi); nsIDOMDOMRequest cancelMMI(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest getCallForwardingOption(in unsigned long clientId, in nsIDOMWindow window, in unsigned short reason); nsIDOMDOMRequest setCallForwardingOption(in unsigned long clientId, in nsIDOMWindow window, in nsIDOMMozMobileCFInfo CFInfo); nsIDOMDOMRequest getCallBarringOption(in unsigned long clientId, in nsIDOMWindow window, in jsval option); nsIDOMDOMRequest setCallBarringOption(in unsigned long clientId, in nsIDOMWindow window, in jsval option); nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId, in nsIDOMWindow window, in jsval info); nsIDOMDOMRequest setCallWaitingOption(in unsigned long clientId, in nsIDOMWindow window, in bool enabled); nsIDOMDOMRequest getCallWaitingOption(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId, in nsIDOMWindow window, in unsigned short clirMode); nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId, in nsIDOMWindow window); nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId, in nsIDOMWindow window); };
The data structures of voiceConnectionInfo, dataConnectionInfo, and networkSelectionMode may need to change to be an array format in RILContentHelper.js for storing the information among different SIM.
// nsIRILContentHelper voiceConnectionInfo: [], dataConnectionInfo: [], networkSelectionMode: [],
Proposal: Architecture
Current Architecture
This is the current architecture supporting a single SIM card. Only one mobile connection to handle all events for Network/Data functions.
Proposal Architecture for Multi-SIM
This is the proposal architecture supporting the multi-SIM card.
MobileConnection becomes an array of nsIDOMMozMobileConnection obect. API users can use 'serviceId' as an index to access corresponding service object.
RIL Implementation
- Please refer to WebTelephony/Multi-SIM RIL implementation .
Status
- bug 814629 for WebMobileConnection API. (Landed)
- bug 818353 for adding subscriptId in backend implementation. (Landed)