WebAPI/WebIccManager/Multi-SIM: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 96: Line 96:
=== Implementation ===
=== Implementation ===
Add iccId in the interface of nsIIccProvider.idl and change the implementation of getting iccInfo, cardState.
Add iccId in the interface of nsIIccProvider.idl and change the implementation of getting iccInfo, cardState.
  interface nsIIccListener : nsISupports
  {
    void notifyStkCommand(in DOMString aMessage);
    void notifyStkSessionEnd();
    <del>void notifyIccCardLockError(in DOMString lockType, in unsigned long retryCount);</del> // We are going to remove this in [https://bugzilla.mozilla.org/show_bug.cgi?id=873380 bug 873380]
    void notifyCardStateChanged();
    void notifyIccInfoChanged();
  };


   interface nsIIccProvider: nsISupports
   interface nsIIccProvider: nsISupports

Revision as of 07:54, 1 October 2013

Proposal: WebIccManager API for Multi-SIM

Currently B2G supports a single SIM architecture. This proposal wants to extend WebIccManager to support multi-SIMs. In multi-SIM device, each SIM card is independent and has it own information and operation. Here we introduce multiple nsIDOMMozIcc objects, each instance represents a icc card, you can use iccId as index to get corresponding icc object from nsIDOMMozIccManager.

Web API

 interface nsIDOMMozIcc : nsIDOMEventTarget
 {
   readonly attribute nsIDOMMozIccInfo iccInfo;
   readonly attribute DOMString cardState;
 
   nsIDOMDOMRequest getCardLock(in DOMString lockType);
   nsIDOMDOMRequest unlockCardLock(in jsval info);
   nsIDOMDOMRequest setCardLock(in jsval info);
   nsIDOMDOMRequest getCardLockRetryCount(in DOMString lockType);
 
   void sendStkResponse(in jsval command, in jsval response);
   void sendStkMenuSelection(in unsigned short itemIdentifier, in boolean helpRequested);
   void sendStkTimerExpiration(in jsval timer);
   void sendStkEventDownload(in jsval event);
 
   nsIDOMDOMRequest readContacts(in DOMString contactType);
   nsIDOMDOMRequest updateContact(in DOMString contactType, in nsIDOMContact contact, [optional] in DOMString pin2);
 
   nsIDOMDOMRequest iccOpenChannel(in DOMString aid);
   nsIDOMDOMRequest iccExchangeAPDU(in long channel, in jsval apdu);
   nsIDOMDOMRequest iccCloseChannel(in long channe);
 
   [implicit_jscontext] attribute jsval onstkcommand;
   [implicit_jscontext] attribute jsval onstksessionend;
   [implicit_jscontext] attribute jsval onicccardlockerror; // We are going to remove this in bug 873380.
   [implicit_jscontext] attribute jsval oniccinfochange;
   [implicit_jscontext] attribute jsval oncardstatechange;
 }
 interface nsIDOMMozIccManager : nsIDOMEventTarget
 {
   readonly attribute jsval iccIds;
   nsIDOMMozIcc getIccById(in DOMString iccId);
 
   [implicit_jscontext] attribute jsval oniccadd;
   [implicit_jscontext] attribute jsval oniccremove;
 }

Use Case

Stk

  • Current B2G:
   var icc = navigator.mozIccManager;
   icc.onstkcommand = function (evt) {
     var command = evt.command;
     switch (command.typeOfCommand) {
       ...
     }
   }
   icc.sendStkResponse(command, response);
  • Multi-SIM:
   var iccManager = navigator.mozIccManager;
   var icc = iccManager.getIccById(iccId);
   icc.onstkcommand = function (evt) {
     var command = evt.command;
     switch (command.typeOfCommand) {
       ...
     }
   }
   icc.sendStkResponse(command, response);

Enumerate icc cards inserted in device

  • iccIds:
   var iccIds = navigator.mozIccManager.iccIds;
   for (let iccId in iccIds) {
     var icc = navigator.mozIccManager.getIccById(iccId);
     ....
   }
  • Nmber of icc cards which is inserted in device:
  var numberOfIcc = navigator.mozIccManager.iccIds.length;

Get iccId

  • Enumerate from iccManager:
   var iccManager = navigator.mozIccManager;
   var iccId = iccManager.iccIds[0]; // The iccId of the first icc card, not the iccId of the first client, client 0. (Note that client 0 may not have icc card inserted.)
   var icc = iccManager.getIccById(iccId);
   
   icc.iccInfo;
   icc.cardState;
   ...
  • Get from MobileConnection:
   var iccId = navigator.mozMobileConnections[1].iccId;
   var icc = iccManager.getIccById(iccId);
   
   iccService.cardState;

Implementation

Add iccId in the interface of nsIIccProvider.idl and change the implementation of getting iccInfo, cardState.

 interface nsIIccListener : nsISupports
 {
   void notifyStkCommand(in DOMString aMessage);
   void notifyStkSessionEnd();
   void notifyIccCardLockError(in DOMString lockType, in unsigned long retryCount); // We are going to remove this in bug 873380
   void notifyCardStateChanged();
   void notifyIccInfoChanged();
 };
 interface nsIIccProvider: nsISupports
 {
   void registerIccMsg(in DOMString iccId, in nsIIccListener listener);
   void unregisterIccMsg(in DOMString iccId, in nsIIccListener listener);
   
   DOMString getCardState(in DOMString iccId);
   nsIDOMMozIccInfo getIccInfo(in DOMString iccId);
   
   void sendStkResponse(in DOMString iccId, in nsIDOMWindow window, in jsval command, in jsval response);
   void sendStkMenuSelection(in DOMString iccId, in nsIDOMWindow window, in unsigned short itemIdentifier, in boolean helpRequested);
   void sendStkTimerExpiration(in DOMString iccId, in nsIDOMWindow window, in jsval timer);
   void sendStkEventDownload(in DOMString iccId, in nsIDOMWindow window, in jsval event);
   
   nsIDOMDOMRequest readContacts(in DOMString iccId, in nsIDOMWindow window, in DOMString contactType);
   nsIDOMDOMRequest updateContact(in DOMString iccId, in nsIDOMWindow window, in DOMString contactType, in nsIDOMContact contact, in DOMString pin2);
   
   nsIDOMDOMRequest iccOpenChannel(in DOMString iccId, in nsIDOMWindow window, in DOMString aid);
   nsIDOMDOMRequest iccExchangeAPDU(in DOMString iccId, in nsIDOMWindow window, in long channel, in jsval apdu);
   nsIDOMDOMRequest iccCloseChannel(in DOMString iccId, in nsIDOMWindow window, in long channel);
   
   nsIDOMDOMRequest getCardLock(in DOMString iccId, in nsIDOMWindow window, in DOMString lockType);
   nsIDOMDOMRequest unlockCardLock(in DOMString iccId, in nsIDOMWindow window, in jsval info);
   nsIDOMDOMRequest setCardLock(in DOMString iccId, in nsIDOMWindow window, in jsval info);
 }

RILContentHelper needs to implement a table for the mapping between iccId and serviceId.

Proposal: Architecture

Current Architecture

This is the current architecture supporting a single SIM card. API user uses IccManager to get the icc information and handle icc related operation.

Proposal Architecture for Multi-SIM

New IccManager Architecture

Status