WebAPI/WebMobileConnection/Multi-SIM

From MozillaWiki
Jump to navigation Jump to search

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. API users can use 'serviceId' as an index to access corresponding service object.

We don't modify the existed interface, like nsIDOMMozMobileConnection, nsIDOMMozMobileConnectionInfo ...etc, to minimize the coding effort of gaia.

interface nsIDOMMozMobileConnection : nsIDOMEventTarget
{
  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 DOMString lastKnownNetwork;
  readonly attribute DOMString lastKnownHomeNetwork;
  readonly attribute nsIDOMMozMobileConnectionInfo voice;
  readonly attribute nsIDOMMozMobileConnectionInfo data;
  readonly attribute DOMString networkSelectionMode;
  readonly attribute DOMString iccId;

  nsIDOMDOMRequest getNetworks();
  nsIDOMDOMRequest selectNetwork(in nsIDOMMozMobileNetworkInfo network);
  nsIDOMDOMRequest selectNetworkAutomatically();
  nsIDOMDOMRequest sendMMI(in DOMString mmi);
  nsIDOMDOMRequest cancelMMI();
  nsIDOMDOMRequest setCallForwardingOption(in nsIDOMMozMobileCFInfo CFInfo);
  nsIDOMDOMRequest getCallForwardingOption(in unsigned short reason);

  [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;
};
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.mozMobileConnection[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.mozMobileConnection.length;

Get ICC Lock Status

  • Current B2G (Single SIM)
       var mobileConnection=window.navigator.mozMobileConnection;
       var req = mobileConnection.getCardLock('pin');
  • Multi-SIMs
     // Get ICC lock status of default SIM slot.
     var mobileConnection= window.navigator.mozMobileConnectionManager.defaultMobileConnection;
     var req = mobileConnection.getCardLock('pin');
     // Get ICC lock status of specific SIM slot.
     var mobileConnection= window.navigator.mozMobileConnectionManager.mobileConnections[index];
     var req = mobileConnection.getCardLock('pin');

SIM Toolkit

     // Access STK of default SIM slot
     var icc = window.navigator.mozMobileConnectionManager.defaultMobileConnection.icc;
     // Access STK of specific SIM slot
     var icc = window.navigator.mozMobileConnectionManager.MobileConnections[index].icc;

Implementation

Replace nsIMozNavigatorMobileConnection by nsIMozNavigatorMobileConnectionManager in nsINavigatorMobileConnection.idl

interface nsIMozNavigatorMobileConnectionManager: nsISupports
{
  readonly attribute nsIDOMMozMobileConnectionManager mozMobileConnectionManager;
};

Add subscriptionId in the interface of nsIMobileConnectionProvider.idl and change the implementation of getCardState, getIccInfo, getVoiceConnectionInfo, getDataConnectionInfo, and getNetworkSelectionMode.

interface nsIMobileConnectionProvider: nsISupports
{
  void registerMobileConnectionMsg(in unsigned long subscriptionId);
  DOMString getCardState(in unsigned long subscriptionId);
  nsIDOMMozMobileICCInfo getIccInfo(in unsigned long subscriptionId);
  nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long subscriptionId);
  nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long subscriptionId);
  DOMString getNetworkSelectionMode(in unsigned long subscriptionId);
  nsIDOMDOMRequest getNetworks(in nsIDOMWindow window, in unsigned long subscriptionId);
  nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network, in unsigned long subscriptionId);
  nsIDOMDOMRequest selectNetworkAutomatically(in nsIDOMWindow window, in unsigned long subscriptionId);
  nsIDOMDOMRequest getCardLock(in nsIDOMWindow window, in DOMString lockType, in unsigned long subscriptionId);
  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 sendMMI(in nsIDOMWindow window, in DOMString mmi, in unsigned long subscriptionId);
  nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window, in unsigned long subscriptionId);
  void sendStkResponse(in nsIDOMWindow window, in jsval command, in jsval response);
  void sendStkMenuSelection(in nsIDOMWindow   window, in unsigned short itemIdentifier, in boolean helpRequested);
  void sendStkEventDownload(in nsIDOMWindow window, in jsval event);
};

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.

 // nsIRILContentHelper
 cardState:            [],
 iccInfo:              [],
 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 ICC/Network/Data functions.

MobileConnection Architecture

Proposal Architecture for Multi-SIM

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.

New MobileConnection Architecture

RIL Implementation

Status

  • bug 814629 for WebMobileConnection API. (Ongoing)
  • bug 818353 for adding subscriptId in backend implementation. (Ongoing)