WebAPI/WebMobileConnection/Multi-SIM: Difference between revisions

no edit summary
No edit summary
 
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Proposal: WebMobileConnectionManager API for Multi-SIM  ==
== Proposal: WebMobileConnectionManager API for Multi-SIM  ==
Currently B2G supports a single SIM architecture. This proposal wants to extend it for supporting multi-SIMs. Here, we introduce a central 'nsIDOMMozMobileConnectionManager' to manage several nsIDOMMozMobileConnection objects. One nsIDOMMozMobileConnection object is binded to a physical SIM slot.
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.


nsIDOMMozMobileConnectionManager will handle the interactive and synchronizing functions between nsIDOMMozMobileConnection objects in the future. For example, when data connection via SIM1 is no longer available, nsIDOMMobileConnectionManager will establish data connection via SIM2 for upper layers.
=== 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.'


=== Web API ===
We don't modify the existing interface, like nsIDOMMozMobileConnection, nsIDOMMozMobileConnectionInfo ...etc, to minimize the coding effort of gaia.
Following are what we create for nsIDOMMozMobileConnectionManager.


  interface nsIDOMMozMobileConnectionManager : nsIDOMEventTarget
  interface nsIMozNavigatorMobileConnectionManager: nsISupports
  {
  {
   readonly attribute jsval mobileConnections;
   // An array of nsIDOMMozMobileConnection.
   readonly attribute nsIDOMMozMobileConnection defaultMobileConnection;
   readonly attribute jsval mozMobileConnections;
  };
  };
 
We don't modify the existed interface, like nsIDOMMozMobileConnection, nsIDOMMozMobileConnectionInfo ...etc, to minimize the coding effort of gaia.
 
  interface nsIDOMMozMobileConnection : nsIDOMEventTarget
  interface nsIDOMMozMobileConnection : nsIDOMEventTarget
  {
  {
   const long ICC_SERVICE_CLASS_DATA = (1 << 1);
   const long ICC_SERVICE_CLASS_VOICE = (1 << 0);
  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 DOMString cardState;
   readonly attribute DOMString lastKnownNetwork;
   readonly attribute nsIDOMMozMobileICCInfo iccInfo;
   readonly attribute DOMString lastKnownHomeNetwork;
   readonly attribute nsIDOMMozMobileConnectionInfo voice;
   readonly attribute nsIDOMMozMobileConnectionInfo voice;
   readonly attribute nsIDOMMozMobileConnectionInfo data;
   readonly attribute nsIDOMMozMobileConnectionInfo data;
   readonly attribute DOMString networkSelectionMode;
   readonly attribute DOMString networkSelectionMode;
   readonly attribute nsIDOMMozIccManager icc;
   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 getCardLock(in DOMString lockType);
 
   nsIDOMDOMRequest unlockCardLock(in jsval info);
   nsIDOMDOMRequest setRoamingPreference(in DOMString mode);
   nsIDOMDOMRequest setCardLock(in jsval info);
   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);
   
   [implicit_jscontext] attribute jsval oncardstatechange;
   nsIDOMDOMRequest setCallBarringOption(in jsval option);
   [implicit_jscontext] attribute jsval oniccinfochange;
   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;
   [implicit_jscontext] attribute jsval onussdreceived;
   [implicit_jscontext] attribute jsval onussdreceived;
   [implicit_jscontext] attribute jsval ondataerror;
   [implicit_jscontext] attribute jsval ondataerror;
  [implicit_jscontext] attribute jsval onicccardlockerror;
   [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 74: Line 83:


*Current B2G (Single SIM)
*Current B2G (Single SIM)
      ...
       var conn = window.navigator.mozMobileConnection;
       var conn = window.navigator.mozMobileConnection;
      if (conn) {
        conn.addEventListener('voicechange', this);
        conn.addEventListener('datachange', this);
      ...


*Multi-SIMs
*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.


      ...
      var conn = window.navigator.mozMobileConnectionManager.defaultMobileConnection;
       if (conn) {
       if (conn) {
         conn.addEventListener('voicechange', this);
         conn.addEventListener('voicechange', this);
        conn.onvoicechange = function onvoicechange() {
          ...
        }
       
         conn.addEventListener('datachange', this);
         conn.addEventListener('datachange', this);
      ...
        conn.ondatachange = function ondatachange() {
          ...
        }
      }


==== Get ICC Status  ====
And also you can get total number of service via
      var numberOfServices = window.navigator.mozMobileConnections.length;


*Current B2G (Single SIM)
=== Internal API and Implementation ===
Add clientId in the interface of nsIMobileConnectionProvider.idl and change the implementation of getVoiceConnectionInfo, getDataConnectionInfo, and getNetworkSelectionMode.


      ...
interface nsIMobileConnectionListener : nsISupports
        var mobileConnection=window.navigator.mozMobileConnection;
{
        var req = mobileConnection.getCardLock('pin');
  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();
};


*Multi-SIMs
interface nsIMobileConnectionProvider: nsISupports
 
{
      ...
  void registerMobileConnectionMsg(in unsigned long clientId, in nsIMobileConnectionListener listener);
      var mobileConnection= window.navigator.mozMobileConnectionManager.defaultMobileConnection;
  void unregisterMobileConnectionMsg(in unsigned long clientId, in nsIMobileConnectionListener listener);
      var req = mobileConnection.getCardLock('pin');
 
      ...
  nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId);
 
  nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId);
=== Implementation ===
  DOMString getNetworkSelectionMode(in unsigned long clientId);
Use nsIMozNavigatorMobileConnectionManager to instead of nsIMozNavigatorMobileConnection in nsINavigatorMobileConnection.idl.
  DOMString getIccId(in unsigned long clientId);
 
 
interface nsIMozNavigatorMobileConnectionManager: nsISupports
  nsIDOMDOMRequest getNetworks(in unsigned long clientId, in nsIDOMWindow window);
{
  nsIDOMDOMRequest selectNetwork(in unsigned long clientId, in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network);
  readonly attribute nsIDOMMozMobileConnectionManager mozMobileConnectionManager;
  nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId, in nsIDOMWindow window);
};
 
 
  nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId, in nsIDOMWindow window, in DOMString mode);
Add subscription ID in the interface of nsIMobileConnectionProvider.idl and change the implementation of getCardState, getIccInfo, getVoiceConnectionInfo, getDataConnectionInfo, and getNetworkSelectionMode.
  nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId, in nsIDOMWindow window);
 
 
interface nsIMobileConnectionProvider: nsISupports
  nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId, in nsIDOMWindow window, in bool enabled);
{
  nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId, in nsIDOMWindow window);
  void registerMobileConnectionMsg(in unsigned long subscriptionId);
 
  DOMString getCardState(in unsigned long subscriptionId);
  nsIDOMDOMRequest sendMMI(in unsigned long clientId, in nsIDOMWindow window, in DOMString mmi);
  nsIDOMMozMobileICCInfo getIccInfo(in unsigned long subscriptionId);
  nsIDOMDOMRequest cancelMMI(in unsigned long clientId, in nsIDOMWindow window);
  nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long subscriptionId);
 
  nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long subscriptionId);
  nsIDOMDOMRequest getCallForwardingOption(in unsigned long clientId, in nsIDOMWindow window, in unsigned short reason);
  DOMString getNetworkSelectionMode(in unsigned long subscriptionId);
  nsIDOMDOMRequest setCallForwardingOption(in unsigned long clientId, in nsIDOMWindow window, in nsIDOMMozMobileCFInfo CFInfo);
  nsIDOMDOMRequest getNetworks(in nsIDOMWindow window, in unsigned long subscriptionId);
 
  nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network, in unsigned long subscriptionId);
  nsIDOMDOMRequest getCallBarringOption(in unsigned long clientId, in nsIDOMWindow window, in jsval option);
  nsIDOMDOMRequest selectNetworkAutomatically(in nsIDOMWindow window, in unsigned long subscriptionId);
  nsIDOMDOMRequest setCallBarringOption(in unsigned long clientId, in nsIDOMWindow window, in jsval option);
  nsIDOMDOMRequest getCardLock(in nsIDOMWindow window, in DOMString lockType, in unsigned long subscriptionId);
  nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId, in nsIDOMWindow window, in jsval info);
  nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info, in unsigned long subscriptionId);
 
  nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info, in unsigned long subscriptionId);
  nsIDOMDOMRequest setCallWaitingOption(in unsigned long clientId, in nsIDOMWindow window, in bool enabled);
  nsIDOMDOMRequest sendMMI(in nsIDOMWindow window, in DOMString mmi, in unsigned long subscriptionId);
  nsIDOMDOMRequest getCallWaitingOption(in unsigned long clientId, in nsIDOMWindow window);
  nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window, in unsigned long subscriptionId);
 
  void sendStkResponse(in nsIDOMWindow window, in jsval command, in jsval response);
  nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId, in nsIDOMWindow window, in unsigned short clirMode);
  void sendStkMenuSelection(in nsIDOMWindow   window, in unsigned short itemIdentifier, in boolean helpRequested);
  nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId, in nsIDOMWindow window);
  void sendStkEventDownload(in nsIDOMWindow window, in jsval event);
 
};
  nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId, in nsIDOMWindow window);
};


The data structures of cardState, iccInfo, voiceConnectionInfo, dataConnectionInfo, and networkSelectionMode are changed to be the array format in RILContentHelper.js for storing the information among different SIM.
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
  cardState:            [],
  iccInfo:              [],
   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 ICC/Network/Data functions.
This is the current architecture supporting a single SIM card. Only one mobile connection to handle all events for Network/Data functions.


[[File:CurrMobileConnectionMgr.png|480x640px|MobileConnection Architecture]]
[[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.  


The 'MobileConnectionManager' creates and manages all MobileConnection objects for every SIM and the main task of MobileConnectionManager is to handle the interactive and synchronizing functions between MobileConnections. All ICC/Network/Data functions of each SIM are still handled by each MobileConnection.
MobileConnection becomes an array of nsIDOMMozMobileConnection obect. API users can use 'serviceId' as an index to access corresponding service object.


[[File:ProposalMobileConnMgr.png|480x640px|New MobileConnection Architecture]]
[[File:MobileConnection.jpg|480x360px|New MobileConnection Architecture]]


=== RIL Implementation ===
=== RIL Implementation ===


* Please refer to [https://wiki.mozilla.org/WebAPI/WebTelephony/Multi-SIM WebTelephony/Multi-SIM RIL implementation ].
* Please refer to [https://wiki.mozilla.org/WebAPI/WebTelephony/Multi-SIM#Proposal_for_Multi-SIMs WebTelephony/Multi-SIM RIL implementation ].
 
== Status ==
* [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. (Landed)
 
[[Category:Web APIs]]
Confirmed users
1,340

edits