WebAPI/WebIccManager/Multi-SIM: Difference between revisions

no edit summary
No edit summary
 
(10 intermediate revisions by one other user not shown)
Line 34: Line 34:
     nsIDOMDOMRequest getCardLockRetryCount(in DOMString lockType);
     nsIDOMDOMRequest getCardLockRetryCount(in DOMString lockType);
    
    
     <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].
     <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].
    
    
     // UICC Phonebook Interfaces.
     // UICC Phonebook Interfaces.
Line 85: Line 85:
Remark: In either single-SIM or multi-SIM scenario, a system message 'icc-stkcommand' is required to launch STK app.
Remark: In either single-SIM or multi-SIM scenario, a system message 'icc-stkcommand' is required to launch STK app.


==== Enumerate icc cards inserted in device ====
==== 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 93: 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 99: 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 detected.)
     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 107: 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 Life Cycle ====
Icc object only be created when corresponding icc is detected by system. And becomes invalid after the it can not be detected by system any more.
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.
* You can use IccManager to monitor this.
     var iccManager = navigator.mozIccManager;
     var iccManager = navigator.mozIccManager;
Line 127: Line 145:
     }
     }


* If you already hold a reference for a specific icc object, you still can know it becomes to invalid via cardState or iccInfo.
* If you already hold a reference for a specific icc object, you can monitor this via cardState or iccInfo.
     var icc = iccManager.getIccById(iccId);
     var icc = iccManager.getIccById(iccId);
      
      
     icc.oncardstatechange = function () {
     icc.oncardstatechange = function () {
       if (icc.cardState === null) {
       if (icc.cardState === null) {
           // System can not detect this icc any more, this icc object becomes to invalid.
           // System can not detect this icc any more, this icc object becomes invalid.
       }
       }
     }
     }
Line 138: Line 156:
     icc.oniccinfochange = function () {
     icc.oniccinfochange = function () {
       if (icc.iccInfo === null) {
       if (icc.iccInfo === null) {
           // System can not detect this icc any more, this icc object becomes to invalid.
           // 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 149: 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 191: 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)
* [https://bugzilla.mozilla.org/show_bug.cgi?id=926343 Bug 926343] for IccProvider interface. (Landed)
 
[[Category:Web APIs]]
Confirmed users
1,340

edits