WebAPI/WebIccManager/Multi-SIM: Difference between revisions

no edit summary
No edit summary
 
(18 intermediate revisions by 2 users not shown)
Line 5: Line 5:
   interface nsIDOMMozIcc : nsIDOMEventTarget
   interface nsIDOMMozIcc : nsIDOMEventTarget
   {
   {
    // UICC Card Information.
 
     readonly attribute nsIDOMMozIccInfo iccInfo;
     readonly attribute nsIDOMMozIccInfo iccInfo;
 
    [implicit_jscontext] attribute jsval oniccinfochange;
 
    // UICC Card State.
 
     readonly attribute DOMString cardState;
     readonly attribute DOMString cardState;
 
    [implicit_jscontext] attribute jsval oncardstatechange;
 
    // UICC Card STK.
 
    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);
 
    [implicit_jscontext] attribute jsval onstkcommand;
    [implicit_jscontext] attribute jsval onstksessionend;
 
    // UICC Card Lock interfaces.
    
    
     nsIDOMDOMRequest getCardLock(in DOMString lockType);
     nsIDOMDOMRequest getCardLock(in DOMString lockType);
Line 13: Line 34:
     nsIDOMDOMRequest getCardLockRetryCount(in DOMString lockType);
     nsIDOMDOMRequest getCardLockRetryCount(in DOMString lockType);
    
    
     void sendStkResponse(in jsval command, in jsval response);
     <del>[implicit_jscontext] attribute jsval onicccardlockerror;</del> // this event has already been removed in [https://bugzilla.mozilla.org/show_bug.cgi?id=873380 bug 873380].
    void sendStkMenuSelection(in unsigned short itemIdentifier, in boolean helpRequested);
 
    void sendStkTimerExpiration(in jsval timer);
     // UICC Phonebook Interfaces.
     void sendStkEventDownload(in jsval event);
    
    
     nsIDOMDOMRequest readContacts(in DOMString contactType);
     nsIDOMDOMRequest readContacts(in DOMString contactType);
     nsIDOMDOMRequest updateContact(in DOMString contactType, in nsIDOMContact contact, [optional] in DOMString pin2);
     nsIDOMDOMRequest updateContact(in DOMString contactType, in nsIDOMContact contact, [optional] in DOMString pin2);
 
    // UICC Secure Element Interfaces.
    
    
     nsIDOMDOMRequest iccOpenChannel(in DOMString aid);
     nsIDOMDOMRequest iccOpenChannel(in DOMString aid);
     nsIDOMDOMRequest iccExchangeAPDU(in long channel, in jsval apdu);
     nsIDOMDOMRequest iccExchangeAPDU(in long channel, in jsval apdu);
     nsIDOMDOMRequest iccCloseChannel(in long channe);
     nsIDOMDOMRequest iccCloseChannel(in long channe);
 
    [implicit_jscontext] attribute jsval onstkcommand;
    [implicit_jscontext] attribute jsval onstksessionend;
    <del>[implicit_jscontext] attribute jsval onicccardlockerror;</del> // We are going to remove this in [https://bugzilla.mozilla.org/show_bug.cgi?id=873380 bug 873380].
    [implicit_jscontext] attribute jsval oniccinfochange;
    [implicit_jscontext] attribute jsval oncardstatechange;
   }
   }


Line 37: Line 53:
     nsIDOMMozIcc getIccById(in DOMString iccId);
     nsIDOMMozIcc getIccById(in DOMString iccId);
    
    
     [implicit_jscontext] attribute jsval oniccadd;
     [implicit_jscontext] attribute jsval oniccdetected;
     [implicit_jscontext] attribute jsval oniccremove;
     [implicit_jscontext] attribute jsval oniccundetected;
   }
   }


Line 67: Line 83:
     icc.sendStkResponse(command, response);
     icc.sendStkResponse(command, response);


==== Enumerate icc cards inserted in device ====
Remark: In either single-SIM or multi-SIM scenario, a system message 'icc-stkcommand' is required to launch STK app.
 
==== Stk system message ====
*Current B2G:
    window.navigator.mozSetMessageHandler('icc-stkcommand',
      function callHandleSTKCommand(message) {
        var command = message;
        ......
      });
 
* Multi-SIM:
    window.navigator.mozSetMessageHandler('icc-stkcommand',
      function callHandleSTKCommand(message) {
        var iccId = message.iccId; // The iccId of sim card that propagates this stk command.
        var command = message.command;
        ......
      });
 
==== Enumerate icc cards detected in device ====
* iccIds:
* iccIds:
     var iccIds = navigator.mozIccManager.iccIds;
     var iccIds = navigator.mozIccManager.iccIds;
Line 75: Line 109:
     }
     }


* Nmber of icc cards which is inserted in device:
* Nmber of icc cards which are detected in device:
   var numberOfIcc = navigator.mozIccManager.iccIds.length;
   var numberOfIcc = navigator.mozIccManager.iccIds.length;


Line 81: Line 115:
* Enumerate from iccManager:
* Enumerate from iccManager:
     var iccManager = navigator.mozIccManager;
     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 iccId = iccManager.iccIds[0]; // The iccId of the first icc card, not the iccId of the first service, service 0. (Note that service 0 may not have icc card detected.)
     var icc = iccManager.getIccById(iccId);
     var icc = iccManager.getIccById(iccId);
      
      
Line 89: Line 123:


* Get from MobileConnection:
* Get from MobileConnection:
     var iccId = navigator.mozMobileConnections[1].iccId; // The iccId of the icc card that is inserted in client 1.
     var iccId = navigator.mozMobileConnections[1].iccId; // The iccId of the icc card that is detected in service 1.
     var icc = iccManager.getIccById(iccId);
     var icc = iccManager.getIccById(iccId);
      
      
     icc.cardState;
     icc.cardState;
Remark: the index of iccIds may not map to service id directly.
==== Icc Object Life Cycle ====
Icc object only be created when corresponding icc is detected by system. And becomes invalid after it can not be detected by system.
* You can use IccManager to monitor this.
    var iccManager = navigator.mozIccManager;
    iccManager.oniccdetected = function (evt) {
        var iccId = evt.iccId;
        // A new icc is detected by device.
        // You can use this iccId to get icc object from iccManager.
    }
   
    iccManager.oniccundetected = function (evt) {
        var iccId = evt.iccId;
        // An icc becomes undetected.
    }
* If you already hold a reference for a specific icc object, you can monitor this via cardState or iccInfo.
    var icc = iccManager.getIccById(iccId);
   
    icc.oncardstatechange = function () {
      if (icc.cardState === null) {
          // System can not detect this icc any more, this icc object becomes invalid.
      }
    }
   
    icc.oniccinfochange = function () {
      if (icc.iccInfo === null) {
          // System can not detect this icc any more, this icc object becomes invalid.
      }
    }
Remark: Once the icc object becomes invalid, calling asynchronous functions raises exception.


=== Implementation ===
=== Implementation ===
Line 101: Line 169:
     void notifyStkCommand(in DOMString aMessage);
     void notifyStkCommand(in DOMString aMessage);
     void notifyStkSessionEnd();
     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]
     <del>void notifyIccCardLockError(in DOMString lockType, in unsigned long retryCount);</del> // This event has already been removed in bug 873380.
     void notifyCardStateChanged();
     void notifyCardStateChanged();
     void notifyIccInfoChanged();
     void notifyIccInfoChanged();
Line 108: Line 176:
   interface nsIIccProvider: nsISupports
   interface nsIIccProvider: nsISupports
   {
   {
     void registerIccMsg(in DOMString iccId, in nsIIccListener listener);
     void registerIccMsg(in unsigned long clientId, in nsIIccListener listener);
     void unregisterIccMsg(in DOMString iccId, in nsIIccListener listener);
     void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener);
      
      
     DOMString getCardState(in DOMString iccId);
     DOMString getCardState(in unsigned long clientId);
     nsIDOMMozIccInfo getIccInfo(in DOMString iccId);
     nsIDOMMozIccInfo getIccInfo(in unsigned long clientId);
      
      
     void sendStkResponse(in DOMString iccId, in nsIDOMWindow window, in jsval command, in jsval response);
     void sendStkResponse(in unsigned long clientId, 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 sendStkMenuSelection(in unsigned long clientId, in nsIDOMWindow window, in unsigned short itemIdentifier, in boolean helpRequested);
     void sendStkTimerExpiration(in DOMString iccId, in nsIDOMWindow window, in jsval timer);
     void sendStkTimerExpiration(in unsigned long clientId, in nsIDOMWindow window, in jsval timer);
     void sendStkEventDownload(in DOMString iccId, in nsIDOMWindow window, in jsval event);
     void sendStkEventDownload(in unsigned long clientId, in nsIDOMWindow window, in jsval event);
      
      
     nsIDOMDOMRequest readContacts(in DOMString iccId, in nsIDOMWindow window, in DOMString contactType);
     nsIDOMDOMRequest readContacts(in unsigned long clientId, in nsIDOMWindow window, in DOMString contactType);
     nsIDOMDOMRequest updateContact(in DOMString iccId, in nsIDOMWindow window, in DOMString contactType, in nsIDOMContact contact, in DOMString pin2);
     nsIDOMDOMRequest updateContact(in unsigned long clientId, in nsIDOMWindow window, in DOMString contactType, in nsIDOMContact contact, in DOMString pin2);
      
      
     nsIDOMDOMRequest iccOpenChannel(in DOMString iccId, in nsIDOMWindow window, in DOMString aid);
     nsIDOMDOMRequest iccOpenChannel(in unsigned long clientId, in nsIDOMWindow window, in DOMString aid);
     nsIDOMDOMRequest iccExchangeAPDU(in DOMString iccId, in nsIDOMWindow window, in long channel, in jsval apdu);
     nsIDOMDOMRequest iccExchangeAPDU(in unsigned long clientId, in nsIDOMWindow window, in long channel, in jsval apdu);
     nsIDOMDOMRequest iccCloseChannel(in DOMString iccId, in nsIDOMWindow window, in long channel);
     nsIDOMDOMRequest iccCloseChannel(in unsigned long clientId, in nsIDOMWindow window, in long channel);
      
      
     nsIDOMDOMRequest getCardLock(in DOMString iccId, in nsIDOMWindow window, in DOMString lockType);
     nsIDOMDOMRequest getCardLock(in unsigned long clientId, in nsIDOMWindow window, in DOMString lockType);
     nsIDOMDOMRequest unlockCardLock(in DOMString iccId, in nsIDOMWindow window, in jsval info);
     nsIDOMDOMRequest unlockCardLock(in unsigned long clientId, in nsIDOMWindow window, in jsval info);
     nsIDOMDOMRequest setCardLock(in DOMString iccId, in nsIDOMWindow window, in jsval info);
     nsIDOMDOMRequest setCardLock(in unsigned long clientId, in nsIDOMWindow window, in jsval info);
   }
   }


RILContentHelper needs to implement a table for the mapping between iccId and serviceId.
DOM needs to implement the mapping between iccId and clientId. And need to dispatch event to correct icc object.


== Proposal: Architecture ==
== Proposal: Architecture ==
Line 143: Line 211:


== Status ==
== Status ==
* [https://bugzilla.mozilla.org/show_bug.cgi?id=814637 bug 814637] for WebIccManager API. (Ongoing)
* [https://bugzilla.mozilla.org/show_bug.cgi?id=814637 Bug 814637] for WebIccManager API. (Ongoing)
* [https://bugzilla.mozilla.org/show_bug.cgi?id=926343 Bug 926343] for IccProvider interface. (Landed)
 
[[Category:Web APIs]]
Confirmed users
1,340

edits