WebAPI/WebSTK: Difference between revisions

no edit summary
No edit summary
 
(17 intermediate revisions by one other user not shown)
Line 1: Line 1:
= Overview =
= Overview =
To provide DOM API for the STK(SIM Toolkit), or CAT (Card Application Toolkit), which allows web contents can interact with SIM applications.
To provide DOM API for the STK(SIM Toolkit), or CAT (Card Application Toolkit), which allows web contents can interact with SIM applications.
= Status =
Bugzilla : https://bugzilla.mozilla.org/show_bug.cgi?id=791161 <br>
Feature List: https://docs.google.com/spreadsheet/ccc?key=0AuvgnQ-Iwb6XdGV0aHZWdGdmZVEzZUxmZWNEaGJYWkE


= Interface =
= Interface =
Line 39: Line 43:
   * Command.
   * Command.
   *
   *
  * @param command
  *        Command received from ICC. See MozStkCommand.
   * @param response
   * @param response
   *        The response that will be sent to ICC.
   *        The response that will be sent to ICC.
   * @see nsIDOMMozStkResponse for the detail of response.
   * @see MozStkResponse for the detail of response.
   */
   */
   void sendStkResponse(in jsval response);
   void sendStkResponse(in jsval command, in jsval response);
</pre>
</pre>


=== Send Envelope Command ===
=== Send Envelope Command ===
Currently only support "Menu Selection"
Currently only support "Menu Selection", "Event Download"
<pre>
<pre>
   /**
   /**
Line 59: Line 65:
   void sendStkMenuSelection(in unsigned short itemIdentifier,
   void sendStkMenuSelection(in unsigned short itemIdentifier,
                             in boolean        helpRequested);
                             in boolean        helpRequested);
  /**
  * Send "Event Download" Envelope command to ICC.
  * ICC will not respond with any data for this command.
  *
  * @param event
  *        one of events below:
  *        - MozStkLocationEvent
  *        - MozStkCallEvent
  */
  void sendStkEventDownload(in jsval event);
</pre>
</pre>


Line 167: Line 184:
=== STK command ===
=== STK command ===
<pre>
<pre>
dictionary nsIDOMMozStkCommand
dictionary MozStkCommand
{
{
   /**
   /**
Line 188: Line 205:


   /**
   /**
   * options varies accrording to the typeOfCommand in nsIDOMMozStkCommand.
   * options varies accrording to the typeOfCommand in MozStkCommand.
  *
  * When typeOfCommand is
  * - STK_CMD_DISPLAY_TEXT
  * - STK_CMD_SET_UP_IDLE_MODE_TEXT
  * - STK_CMD_SEND_{SS|USSD|SMS|DTMF},
  * options is MozStkTextMessage.
  *
  * When typeOfCommand is
  * - STK_CMD_SELECT_ITEM
  * - STK_CMD_SET_UP_MENU
  * options is MozStkMenu.
  *
  * When typeOfCommand is
  * - STK_CMD_GET_INKEY
  * - STK_CMD_GET_INPUT,
  * options is MozStkInput.
  *
  * When typeOfCommand is
  * - STK_CMD_LAUNCH_BROWSER
  * options is MozStkBrowserSetting.
  *
  * When typeOfCommand is
  * - STK_CMD_SET_UP_CALL
  * options is MozStkSetUpCall.
   *
   *
   * When typeOfCommand is
   * When typeOfCommand is
   * - STK_DISPLAY_TEXT
   * - STK_CMD_SET_UP_EVENT_LIST
  * - STK_SET_UP_IDLE_MODE_TEXT
   * options is MozStkSetUpEventList.
  * - STK_REFRESH
  * - STK_SEND_{SS|USSD|SMS|DTMF},
   * options is nsIDOMMozStkTextMessage.
   *
   *
   * When typeOfCommand is
   * When typeOfCommand is
   * - STK_SELECT_ITEM
   * - STK_CMD_PLAY_TONE
  * - STK_SET_UP_MENU
   * options is MozStkPlayTone.
   * options is nsIDOMMozStkMenu.
   *
   *
   * When typeOfCommand is
   * When typeOfCommand is
   * - STK_GET_INKEY
   * - STK_CMD_POLL_INTERVAL
  * - STK_GET_INPUT,
   * options is MozStkDuration.
   * options is nsIDOMMozStkInput.
   *
   *
   * When typeOfCommand is
   * When typeOfCommand is
   * - STK_LAUNCH_BROWSER
   * - STK_CMD_POLL_OFF
   * options is nsIDOMMozStkBrowserSetting.
   * options is null.
   *
   *
   * When typeOfCommand is
   * When typeOfCommand is
   * - STK_SET_UP_CALL
   * - STK_CMD_REFRESH
   * options is nsIDOMMozStkSetUpCall.
   * options is null.
   */
   */
   jsval options;
   jsval options;
Line 222: Line 258:
===== Text Message =====
===== Text Message =====
<pre>
<pre>
dictionary nsIDOMMozStkTextMessage
dictionary MozStkTextMessage
{
{
   /**
   /**
Line 279: Line 315:
===== Menu =====
===== Menu =====
<pre>
<pre>
dictionary nsIDOMMozStkItem
dictionary MozStkItem
{
{
   /**
   /**
Line 297: Line 333:


<pre>
<pre>
dictionary nsIDOMMozStkMenu
dictionary MozStkMenu
{
{
   /**
   /**
   * Array of nsIDOMMozStkItem.
   * Array of MozStkItem.
   *
   *
   * @see TS 11.14, clause 12.9
   * @see TS 11.14, clause 12.9
   */
   */
   jsval items; // nsIDOMMozStkItem[]
   jsval items; // MozStkItem[]


   /**
   /**
Line 335: Line 371:
===== Input =====
===== Input =====
<pre>
<pre>
dictionary nsIDOMMozStkInput
dictionary MozStkInput
{
{
   /**
   /**
Line 423: Line 459:
===== Browser Settings =====
===== Browser Settings =====
<pre>
<pre>
dictionary nsIDOMMozStkBrowserSetting
dictionary MozStkBrowserSetting
{
{
   /**
   /**
   * Confirm message to launch browser.
   * Confirm message to launch browser.
   *
   *
   * @see nsIDOMMozStkTextMessage for the detail specification of
   * @see MozStkTextMessage for the detail specification of
   *      confirmMessage.
   *      confirmMessage.
   */
   */
Line 449: Line 485:
===== Set Up Call =====
===== Set Up Call =====
<pre>
<pre>
dictionary nsIDOMMozStkSetUpCall
dictionary MozStkSetUpCall
{
{
   /**
   /**
Line 459: Line 495:
   * The text message used in user confirmation phase.
   * The text message used in user confirmation phase.
   *
   *
   * @see nsIDOMMozStkTextMessage for the detail specification of
   * @see MozStkTextMessage for the detail specification of
   *      confirmMessage.
   *      confirmMessage.
   */
   */
Line 467: Line 503:
   * The text message used in call set up phase.
   * The text message used in call set up phase.
   *
   *
   * @see nsIDOMMozStkTextMessage for the detail specification of
   * @see MozStkTextMessage for the detail specification of
   *      callMessage.
   *      callMessage.
   */
   */
Line 479: Line 515:
=== STK response ===
=== STK response ===
<pre>
<pre>
dictionary nsIDOMMozStkResponse
dictionary MozStkResponse
{
{
  /**
  * commandNumber from MozStkCommand.
  *
  * @see nsIDOMMozStkCommand.commandNumber
  */
  unsigned short commandNumber;
  /**
  * One of nsIDOMMozStkCommand.typeOfCommand
  *
  * @see nsIDOMMozStkCommand.typeOfCommand
  */
  unsigned short typeOfCommand;
  /**
  * Qualifiers specific to the command.
  *
  * @see nsIDOMMozStkCommand.commandQualifier
  */
  unsigned short commandQualifier;
   /**
   /**
   * One of RESULT_*
   * One of RESULT_*
Line 510: Line 525:
   * The identifier of the item selected by user.
   * The identifier of the item selected by user.
   *
   *
   * @see nsIDOMMozStkItem.identifier
   * @see MozStkItem.identifier
   */
   */
   unsigned short itemIdentifier;
   unsigned short itemIdentifier;
Line 518: Line 533:
   */
   */
   DOMString input;
   DOMString input;
  /**
  * Alphabet encoding.
  *
  * @see nsIDOMMozStkInput.isUCS2
  */
  boolean isUCS2;


   /**
   /**
   * YES/NO response.
   * YES/NO response.
   *
   *
   * @see nsIDOMMozStkInput.isYesNoRequested
   * @see MozStkInput.isYesNoRequested
   */
   */
   boolean isYesNo;
   boolean isYesNo;
  /**
  * Packed or unpacked format.
  *
  * @see nsIDOMMozStkInput.isPacked
  */
  boolean isPacked;


   /**
   /**
Line 570: Line 571:
   const unsigned short STK_BROWSER_MODE_USING_EXISTING_BROWSER        = 0x02;
   const unsigned short STK_BROWSER_MODE_USING_EXISTING_BROWSER        = 0x02;
   const unsigned short STK_BROWSER_MODE_USING_NEW_BROWSER              = 0x03;
   const unsigned short STK_BROWSER_MODE_USING_NEW_BROWSER              = 0x03;
 
   /**
   /**
   * STK Proactive commands.
   * STK Proactive commands.
Line 577: Line 578:
   */
   */
   const unsigned short STK_CMD_REFRESH              = 0x01;
   const unsigned short STK_CMD_REFRESH              = 0x01;
  const unsigned short STK_CMD_POLL_INTERVAL        = 0x03;
  const unsigned short STK_CMD_POLL_OFF              = 0x04;
  const unsigned short STK_CMD_SET_UP_EVENT_LIST    = 0x05;
   const unsigned short STK_CMD_SET_UP_CALL          = 0x10;
   const unsigned short STK_CMD_SET_UP_CALL          = 0x10;
   const unsigned short STK_CMD_SEND_SS              = 0x11;
   const unsigned short STK_CMD_SEND_SS              = 0x11;
Line 583: Line 587:
   const unsigned short STK_CMD_SEND_DTMF            = 0x14;
   const unsigned short STK_CMD_SEND_DTMF            = 0x14;
   const unsigned short STK_CMD_LAUNCH_BROWSER        = 0x15;
   const unsigned short STK_CMD_LAUNCH_BROWSER        = 0x15;
  const unsigned short STK_CMD_PLAY_TONE            = 0x20;
   const unsigned short STK_CMD_DISPLAY_TEXT          = 0x21;
   const unsigned short STK_CMD_DISPLAY_TEXT          = 0x21;
   const unsigned short STK_CMD_GET_INKEY            = 0x22;
   const unsigned short STK_CMD_GET_INKEY            = 0x22;
Line 686: Line 691:
   /** Bearer Independent Protocol error */
   /** Bearer Independent Protocol error */
   const unsigned short STK_RESULT_BIP_ERROR                        = 0x3a;
   const unsigned short STK_RESULT_BIP_ERROR                        = 0x3a;
};
 
  /**
  * STK Event List
  */
  const unsigned short STK_EVENT_TYPE_MT_CALL                          = 0x00;
  const unsigned short STK_EVENT_TYPE_CALL_CONNECTED                  = 0x01;
  const unsigned short STK_EVENT_TYPE_CALL_DISCONNECTED                = 0x02;
  const unsigned short STK_EVENT_TYPE_LOCATION_STATUS                  = 0x03;
  const unsigned short STK_EVENT_TYPE_USER_ACTIVITY                    = 0x04;
  const unsigned short STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE            = 0x05;
  const unsigned short STK_EVENT_TYPE_CARD_READER_STATUS              = 0x06;
  const unsigned short STK_EVENT_TYPE_LANGUAGE_SELECTION              = 0x07;
  const unsigned short STK_EVENT_TYPE_BROWSER_TERMINATION              = 0x08;
  const unsigned short STK_EVENT_TYPE_DATA_AVAILABLE                  = 0x09;
  const unsigned short STK_EVENT_TYPE_CHANNEL_STATUS                  = 0x0a;
  const unsigned short STK_EVENT_TYPE_SINGLE_ACCESS_TECHNOLOGY_CHANGED = 0x0b;
  const unsigned short STK_EVENT_TYPE_DISPLAY_PARAMETER_CHANGED        = 0x0c;
  const unsigned short STK_EVENT_TYPE_LOCAL_CONNECTION                = 0x0d;
  const unsigned short STK_EVENT_TYPE_NETWORK_SEARCH_MODE_CHANGED      = 0x0e;
  const unsigned short STK_EVENT_TYPE_BROWSING_STATUS                  = 0x0f;
  const unsigned short STK_EVENT_TYPE_FRAMES_INFORMATION_CHANGED      = 0x10;
 
  /**
    * The service state of STK Location Status.
    */
  const unsigned short STK_SERVICE_STATE_NORMAL      = 0x00;
  const unsigned short STK_SERVICE_STATE_LIMITED    = 0x01;
  const unsigned short STK_SERVICE_STATE_UNAVAILABLE = 0x02;
 
  /**
  * Tone type.
  */
  const unsigned short STK_TONE_TYPE_DIAL_TONE                = 0x01;
  const unsigned short STK_TONE_TYPE_CALLED_SUBSCRIBER_BUSY  = 0x02;
  const unsigned short STK_TONE_TYPE_CONGESTION              = 0x03;
  const unsigned short STK_TONE_TYPE_RADIO_PATH_ACK          = 0x04;
  const unsigned short STK_TONE_TYPE_RADIO_PATH_NOT_AVAILABLE = 0x05;
  const unsigned short STK_TONE_TYPE_ERROR                    = 0x06;
  const unsigned short STK_TONE_TYPE_CALL_WAITING_TONE        = 0x07;
  const unsigned short STK_TONE_TYPE_RINGING_TONE            = 0x08;
  const unsigned short STK_TONE_TYPE_GENERAL_BEEP            = 0x10;
  const unsigned short STK_TONE_TYPE_POSITIVE_ACK_TONE        = 0x11;
  const unsigned short STK_TONE_TYPE_NEGATIVE_ACK_TONE        = 0x12;
 
  /**
  * Time unit
  */
  const unsigned short STK_TIME_UNIT_MINUTE      = 0x00;
  const unsigned short STK_TIME_UNIT_SECOND      = 0x01;
  const unsigned short STK_TIME_UNIT_TENTH_SECOND = 0x02;
}
</pre>
</pre>


Line 692: Line 747:
== Show STK menu ==
== Show STK menu ==
<pre>
<pre>
mozIcc.onstkcommand = function (command) {
var icc = navigator.mozMobileConnection.icc;
   switch (command.type) {
icc.onstkcommand = function (evt) {
     case mozIcc.STK_CMD_SET_UP_MENU:
  var command = evt.command
   switch (command.typeOfCommand) {
     case icc.STK_CMD_SET_UP_MENU:
       var menu = command.options;
       var menu = command.options;
       // create a Menu-like UI according to 'menu'
       // create a Menu-like UI according to 'menu'
Line 704: Line 761:
== Menu Selection ==  
== Menu Selection ==  
<pre>
<pre>
function menuSelection(id, helpRequested) {
/**
   mozIcc.sendMenuSelection(id, helpRequested);
* onMenuSelected is the callback when some item of the menu is selected.
* @param id    The index of the item being selected.
* @param helpRequested    Request for help.
*/
function onMenuSelected(id, helpRequested) {
   var icc = navigator.mozMobileConnection.icc;
  icc.sendStkMenuSelection(id, helpRequested);
}
}
</pre>
</pre>
Line 713: Line 776:
// 'command' is got from onstkcommand
// 'command' is got from onstkcommand
// and assume it's a Select Item command.
// and assume it's a Select Item command.
var icc = navigator.mozMobileConnection.icc;
var response = {
var response = {
  commandNumber: command.commandNumber,
   resultCode : icc.STK_RESULT_OK,
  typeOfCommandL command.typeOfCommand,
   // 'id' is got from the choosed item identifier (menu.item[].identifier)
  commandQualifier: command.commandQualifier,
   resultCode : mozICC.STK_RESULT_OK;
   // 'id' is got from the chosen item identifier (menu.item[].identifier)
   itemIdentifier: id
   itemIdentifier: id
};
};
mozIcc.sendStkResponse(response);
mozIcc.sendStkResponse(command, response);
</pre>
</pre>


== Get Input ==
== Get Input ==
<pre>
<pre>
mozIcc.onstkcommand = function (command) {
var icc = navigator.mozMobileConnection.icc;
   switch (command.type) {
icc.onstkcommand = function (evt) {
     case MozStkCommand.CMD_GET_INPUT:
  var command = evt.command
       var input = command.input;
   switch (command.typeOfCommand) {
     case icc.STK_CMD_GET_INPUT:
       var input = command.options;
       // create a TextInput-like UI according to 'input'
       // create a TextInput-like UI according to 'input'
     break;
     break;
Line 736: Line 799:


// onTextInput is the callback when user inputs complete.
// onTextInput is the callback when user inputs complete.
var icc = navigator.mozMobileConnection.icc;
function onTextInput(input) {
function onTextInput(input) {
   var response = new MozStkResponse(command.number, command.type, command.qualifier);
   var response = {
  response.resultCode = MozStkResponse.RESULT_OK;
     resultCode : mozICC.STK_RESULT_OK,
  response.input = input;
     input: input
  mozIcc.sendStkResponse(response);
   };
}
   mozIcc.sendStkResponse(command, response);
</pre>
 
== Set Up Call ==
<pre>
mozIcc.onstkcommand = function (command) {
  switch (command.type) {
     case MozStkCommand.CMD_SET_UP_CALL:
      var call = command.call;
      // create a Text Message UI to ask user confirmation
      // for make the MO call.
     break;
   }
};
 
// onUserConfirm is the callback when user confirms the call.
function onUserConfirm(confirm) {
  var response = new MozStkResponse(command.number, command.type, command.qualifier);
  response.resultCode = MozStkResponse.RESULT_OK;
  response.confirmation = confirm;
   mozIcc.sendStkResponse(response);
}
}
</pre>
</pre>
Line 767: Line 811:
= TODO =
= TODO =
* Icon
* Icon
* Duration
* Timer
* Tone
* Command Qualifier in CALL_SET_UP
* multi-SIM


= Reference =
= Reference =
Line 776: Line 817:
* TS 102.223
* TS 102.223
* http://www.kandroid.org/online-pdk/guide/stk.html
* http://www.kandroid.org/online-pdk/guide/stk.html
[[Category:Web APIs]]
Confirmed users
1,340

edits