WebAPI/WebSTK: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
(76 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 =
Event handler for STK events.
* These interface will be added in MozIccManager
 
== Event handlers for receiving messages from ICC to ME ==
These event handlers will be invoked when there are proactive commands or session end notification sent from ICC.
 
=== Proactive Command ===
<pre>
<pre>
   /**
   /**
Line 10: Line 19:
   */  
   */  
   attribute nsIDOMEventListener onstkcommand;
   attribute nsIDOMEventListener onstkcommand;
 
</pre>
 
=== Session End Notificaiton ===
<pre>
   /**
   /**
   * 'stksessionend' event is notified whenever STK Session is terminated by  
   * 'stksessionend' event is notified whenever STK Session is terminated by  
Line 18: Line 30:
</pre>
</pre>


Send Response from ME to SIM
== Send Message from ME to ICC ==
There are two kinds of messages will be sent from ME to ICC
* Terminal Response  
** Once the ME has made its attempt to execute a proactive command from the ICC, the ME shall inform the ICC of the success or otherwise of that command, by using TERMINAL RESPONSE.
* Envelope command
** Envelope command is used to transfer STK information from ME to ICC.
 
=== Send Terminal Response ===
<pre>
<pre>
   /**
   /**
   * Send the response back to ICC after an attempt to execute STK Proactive  
   * Send the response back to ICC after an attempt to execute STK Proactive
   * Command.
   * Command.
   */  
  *
   void sendStkResponse(in nsIDOMMozStkResponse response);
  * @param command
  *        Command received from ICC. See MozStkCommand.
  * @param response
  *        The response that will be sent to ICC.
  * @see MozStkResponse for the detail of response.
   */
   void sendStkResponse(in jsval command, in jsval response);
</pre>
 
=== Send Envelope Command ===
Currently only support "Menu Selection", "Event Download"
<pre>
  /**
  * Send the "Menu Selection" Envelope command to ICC for menu selection.
  *
  * @param itemIdentifier
  *        The identifier of the item selected by user.
  * @param helpRequested
  *        true if user requests to provide help information, false otherwise.
  */
  void sendStkMenuSelection(in unsigned short itemIdentifier,
                            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>
 
= STK message format =
* TS 102.223, Annex C for the structure of STK communications
The specification of the message received from ICC and sent to ICC.
 
Basically, a STK message is of a BER-TLV object, which contains several Comprehension-TLV objects
(TLV : Tag-Length-Value)
 
<pre>
                      ----- ----- ------------------------------------
            BER-TLV  |  T  |  L  |  V - Several Comprehension-TLVs    |
                      ----- ----- ------------------------------------
                                /                                    \
                                /                                      \
                                ----- ----- -----      ----- ----- -----
Comprehension-TLV              |  T  |  L  |  V  | ... |  T  |  L  |  V  |
                                ----- ----- -----      ----- ----- -----
 
</pre>
 
Each STK message consists of at least two mandatory Comprehension-TLVs
* Command Details
* Device Identities
 
The remaining Comprehension-TLVs varies according to different type of STK message.
 
 
For the "Command Details" data object,<br>
this data object shall be identical to the command details data object (including the comprehension required flag) given
by the UICC in the proactive command to which the terminal is giving the result.
<br>
 
And there two kinds of STK messages
* From ICC to ME
** MozStkCommand
* From ME to ICC
** MozStkResponse
 
In both MozStkCommand and MozStkResponse, we expose the content of 'Command Details' as:
* number
* type
* qualifier
So when a webapp tries to create a MozStkResponse, the webapp needs to create exactly the same 'Command Details' as it got from MozStkCommand.
 
== From ICC to ME ==
The STK message sent from ICC to ME called 'Proactive Command'.
And we use MozStkCommand to represent 'Proactive Command'.
<br>
For example, a Proactive Command SET_UP_MENU whose Comprehension-TLVs will be looked like
 
<pre>
  ---------------- -------------- ------------- ----------      ----------
  | CmdDetails-TLV | DeviceId-TLV | AlphaId-TLV | Item-TLV | ... | Item-TLV |
  ---------------- -------------- ------------- ----------      ----------
</pre>
 
* CmdDetails - Details of this proactive command.
** typeOfCommand is SET_UP_MENU
* DeviceId - The source and destination of this proactive command.
* AlphaId - The title of this menu
* Item - The items in this menu
 
In designing this message format, we wrap up the Comprehension-TLVs other than
"Command Details" and "Device Identities" to a more high level UI component according
to the typeOfCommand.
<pre>
  ---------------- -------------- --------------
  | CmdDetails-TLV | DeviceId-TLV | UI Component |
  ---------------- -------------- --------------
</pre>
The UI componet includes
* Text Message
* Menu
* Input
* Call set up
* Launch Browser
 
So web apps can parse the UI componet according to the typeOfCommand.
<br>
 
In this case, web apps can display a Menu-like UI according to this UI component.
 
<pre>
  --------
  | Title  |
  --------
  | Item 1 |
  --------
  | Item 2 |
  --------
</pre>
 
=== STK Command Event ===
StkCommandEvent will be the parameter passed in onstkcommand handler
 
<pre>
interface nsIDOMMozStkCommandEvent : nsIDOMEvent
{
  /**
  * See nsIDOMMozStkCommand for the detail of command.
  */
  readonly attribute jsval command;
};
</pre>
</pre>


STK constants
=== STK command ===
<pre>
<pre>
interface nsIDOMMozStkConstants : nsISupports
dictionary MozStkCommand
{
{
   /**
   /**
   * STK Proactive commands.
   * The number of command issued by ICC. And it is assigned
  * by ICC may take any hexadecimal value betweean '01' and 'FE'.
   *
   *
   * @see TS 11.14, clause 13.4
   * @see TS 11.14, clause 6.5.1
   */  
   */
   const unsigned short STK_CMD_REFRESH              = 0x01;
   unsigned short commandNumber;
  const unsigned short STK_CMD_SET_UP_CALL          = 0x10;
 
   const unsigned short STK_CMD_SEND_SS              = 0x11;
   /**
  const unsigned short STK_CMD_SEND_USSD            = 0x12;
  * One of STK_CMD_*
  const unsigned short STK_CMD_SEND_SMS              = 0x13;
  */
  const unsigned short STK_CMD_SEND_DTMF            = 0x14;
   unsigned short typeOfCommand;
  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_GET_INKEY            = 0x22;
  const unsigned short STK_CMD_GET_INPUT            = 0x23;
  const unsigned short STK_CMD_SELECT_ITEM          = 0x24;
  const unsigned short STK_CMD_SET_UP_MENU          = 0x25;
   const unsigned short STK_CMD_SET_UP_IDLE_MODE_TEXT = 0x28;


   /**
   /**
   * STK Result code.
   * Qualifiers specific to the command.
  *
   */
  * @see TS 11.14, clause 12.12
   unsigned short commandQualifier;
   */  
   const unsigned short STK_RESULT_OK = 0x00;
  const unsigned short STK_RESULT_PRFRMD_WITH_PARTIAL_COMPREHENSION = 0x01;
  const unsigned short STK_RESULT_PRFRMD_WITH_MISSING_INFO = 0x02;
  const unsigned short STK_RESULT_PRFRMD_WITH_ADDITIONAL_EFS_READ = 0x03;
  const unsigned short STK_RESULT_PRFRMD_ICON_NOT_DISPLAYED = 0x04;
  const unsigned short STK_RESULT_PRFRMD_MODIFIED_BY_NAA = 0x05;
  const unsigned short STK_RESULT_PRFRMD_LIMITED_SERVICE = 0x06;
  const unsigned short STK_RESULT_PRFRMD_WITH_MODIFICATION = 0x07;
  const unsigned short STK_RESULT_PRFRMD_NAA_NOT_ACTIVE = 0x08;
  const unsigned short STK_RESULT_PRFRMD_TONE_NOT_PLAYED = 0x09;
  const unsigned short STK_RESULT_UICC_SESSION_TERM_BY_USER = 0x10;
  const unsigned short STK_RESULT_BACKWARD_MOVE_BY_USER = 0x11;
  const unsigned short STK_RESULT_NO_RESPONSE_FROM_USER = 0x12;
  const unsigned short STK_RESULT_HELP_INFO_REQUIRED = 0x13;
  const unsigned short STK_RESULT_USSD_SS_SESSION_TERM_BY_USER = 0x14;
  const unsigned short STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS = 0x20;
  const unsigned short STK_RESULT_NETWORK_CRNTLY_UNABLE_TO_PROCESS = 0x21;
  const unsigned short STK_RESULT_USER_NOT_ACCEPT = 0x22;
  const unsigned short STK_RESULT_USER_CLEAR_DOWN_CALL = 0x23;
  const unsigned short STK_RESULT_CONTRADICTION_WITH_TIMER = 0x24;
  const unsigned short STK_RESULT_NAA_CALL_CONTROL_TEMPORARY = 0x25;
  const unsigned short STK_RESULT_LAUNCH_BROWSER_ERROR = 0x26;
  const unsigned short STK_RESULT_MMS_TEMPORARY = 0x27;
  const unsigned short STK_RESULT_BEYOND_TERMINAL_CAPABILITY = 0x30;
  const unsigned short STK_RESULT_CMD_TYPE_NOT_UNDERSTOOD = 0x31;
  const unsigned short STK_RESULT_CMD_DATA_NOT_UNDERSTOOD = 0x32;
  const unsigned short STK_RESULT_CMD_NUM_NOT_KNOWN = 0x33;
  const unsigned short STK_RESULT_SS_RETURN_ERROR = 0x34;
  const unsigned short STK_RESULT_SMS_RP_ERROR = 0x35;
  const unsigned short STK_RESULT_REQUIRED_VALUES_MISSING = 0x36;
  const unsigned short STK_RESULT_USSD_RETURN_ERROR = 0x37;
  const unsigned short STK_RESULT_MULTI_CARDS_CMD_ERROR = 0x38;
  const unsigned short STK_RESULT_USIM_CALL_CONTROL_PERMANENT = 0x39;
  const unsigned short STK_RESULT_BIP_ERROR = 0x3a;
  const unsigned short STK_RESULT_ACCESS_TECH_UNABLE_TO_PROCESS = 0x3b;
  const unsigned short STK_RESULT_FRAMES_ERROR = 0x3c;
  const unsigned short STK_RESULT_MMS_ERROR = 0x3d;


   /**
   /**
   * STK Menu Presentation types.
   * options varies accrording to the typeOfCommand in MozStkCommand.
   */
   *
  const unsigned short STK_MENU_PRESENTATION_TYPE_NOT_SPECIFIED = 0x00;
  * When typeOfCommand is
  const unsigned short STK_MENU_PRESENTATION_TYPE_DATA_VALUES = 0x01;
  * - STK_CMD_DISPLAY_TEXT
   const unsigned short STK_MENU_PRESENTATION_TYPE_NAVIGATION_OPTIONS = 0x03;
  * - 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
  * - STK_CMD_SET_UP_EVENT_LIST
  * options is MozStkSetUpEventList.
  *
  * When typeOfCommand is
  * - STK_CMD_PLAY_TONE
  * options is MozStkPlayTone.
  *
  * When typeOfCommand is
  * - STK_CMD_POLL_INTERVAL
  * options is MozStkDuration.
  *
  * When typeOfCommand is
  * - STK_CMD_POLL_OFF
  * options is null.
  *
  * When typeOfCommand is
  * - STK_CMD_REFRESH
  * options is null.
  */
   jsval options;
};
};
</pre>
</pre>


UI parts:
==== UI parts - The UI Component contained in MozStkCommand ====
===== Text Message =====
<pre>
<pre>
interface nsIDOMMozStkTextMessage : nsISupports
dictionary MozStkTextMessage
{
{
   /**
   /**
Line 111: Line 264:
   *
   *
   * @see TS 11.14, clause 12.15, Text String.
   * @see TS 11.14, clause 12.15, Text String.
   */  
   */
   readonly attribute DOMString text;
   DOMString text;


   /**
   /**
Line 118: Line 271:
   *
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 1.
   * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 1.
  *
  * High priority text shall be displayed on the screen immediately, except if
  * there is a conflict of priority level of alerting such as incoming calls
  * or a low battery warning. In that situation, the resolution is left to
  * the terminal. If the command is rejected in spite of the high priority,
  * the terminal shall inform the ICC with resultCode is
  * TERMINAL_CRNTLY_UNABLE_TO_PROCESS in MozStkResponse.
  *
   * true: high priority
   * true: high priority
   * false: normal priority
   * false: normal priority
   */  
   */
   readonly attribute boolean isHighPriority;
   boolean isHighPriority;


   /**
   /**
Line 127: Line 288:
   *
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 8.
   * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 8.
  *
  * If this attribute is true, but user doesn't give any input within a period
  * of time(said 30 secs), the terminal shall inform the ICC with resultCode
  * is NO_RESPONSE_FROM_USER in MozStkResponse.
   *
   *
   * true: Wait for user to clear message.
   * true: Wait for user to clear message.
   * false: clear message after a delay.
   * false: clear message after a delay.
   */  
   */
   readonly attribute boolean userClear;
   boolean userClear;


   /**
   /**
Line 137: Line 302:
   *
   *
   * @see TS 11.14, clause 12.43, Immediate response.
   * @see TS 11.14, clause 12.43, Immediate response.
  *
  * When this attribute is true, the terminal shall immediately send
  * MozStkResponse with resultCode is OK.
  *
  * true: The terminal shall send response immediately.
  * false: otherwise.
   */
   */
   readonly attribute boolean responseNeeded;
   boolean responseNeeded;
 
  //TODO: duration
  //TODO: title
  //TODO: icon
};
};
</pre>
</pre>


===== Menu =====
<pre>
<pre>
interface nsIDOMMozStkItem : nsISupports
dictionary MozStkItem
{
{
   /**
   /**
   * Identifier of item.
   * Identifier of item.
   *
   *
   * The identifier is a single byte between '01' and 'FF'. Each item shall  
   * The identifier is a single byte between '01' and 'FF'. Each item shall
   * have a unique identifier within an Item list.
   * have a unique identifier within an Item list.
   */  
   */
   readonly attribute unsigned short identifier;
   unsigned short identifier;
 
 
   /**
   /**
   * Text string of item.
   * Text string of item.
   */  
   */
   readonly attribute DOMString text;
   DOMString text;
 
  //TODO: icon
};
};
</pre>
</pre>


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


   /**
   /**
   * Presentation type, one of STK_MENU_PRESENTATION_TYPE_*.
   * Presentation type, one of TYPE_*.
   */  
   */
   readonly attribute unsigned short presentationType;
   unsigned short presentationType;
 
 
   /**
   /**
   * Title of the menu.
   * Title of the menu.
   */  
   */
   readonly attribute DOMString title;
   DOMString title;


   /**
   /**
   * Default item identifier of the menu.
   * Default item identifier of the menu.
   */  
   */
   readonly attribute unsigned short defaultItem;
   unsigned short defaultItem;


   /**
   /**
   * Selection preference.
   * Help information available or not.
   *
   *
  * @see TS 11.14, clause 12.6, Command Qualifier, SET UP MENU, bit 1.
  *
  * true: selection using soft key preferred.
  * false: no selection preference.
  */
  readonly attribute boolean isSoftKeyPreferred;
  /**
  * Help information available or not.
  *
   * @see TS 11.14, clause 12.6, Command Qualifier, SET UP MENU, bit 8.
   * @see TS 11.14, clause 12.6, Command Qualifier, SET UP MENU, bit 8.
   *
   *
   * true: help information available.
   * true: help information available.
   * false: no help information available.
   * false: no help information available.
   */  
   */
   readonly attribute boolean isHelpAvailable;
   boolean isHelpAvailable;
 
  // TODO
  // title icon
  // items icon
};
};
</pre>
</pre>


===== Input =====
<pre>
<pre>
/**
dictionary MozStkInput
* RESPONSE LENGTH data object.
* TS 11.14, clause 12.11
*/
interface nsIDOMMozStkResponseLength : nsISupports
{
{
  /**
  * Text for the ME to display in conjunction with asking the user to respond.
  */
  DOMString text;
   /**
   /**
   * Minimum length of response.
   * Minimum length of response.
   */  
   */
   readonly attribute unsigned short minLength;
   unsigned short minLength;


   /**
   /**
   * Maximum length of response.
   * Maximum length of response.
   */
   */
   readonly attribute unsigned short maxLength;
   unsigned short maxLength;
};
</pre>


<pre>
interface nsIDOMMozStkInput : nsISupports
{
   /**
   /**
   * Text for the ME to display in conjunction with asking the user to respond.
   * Text for the ME to display, corresponds to a default text string offered
  */
   * by the ICC.
  readonly attribute DOMString text;
 
  /**
  * The minimum and maximum acceptable lengths in characters for the response
   * from the user.
   */
   */
   readonly attribute nsIDOMMozStkResponseLength responseLength;
   DOMString defaultText;
 
  /**
  * Text for the ME to display, corresponds to a default text string offered
  * by the SIM.
  */
  readonly attribute DOMString defaultText;


   /**
   /**
Line 263: Line 401:
   * true: Alphabet set.
   * true: Alphabet set.
   * false: Digits only.
   * false: Digits only.
   */  
   */
   readonly attribute boolean isAlphabet;
   boolean isAlphabet;


   /**
   /**
Line 273: Line 411:
   * true: UCS2 alphabet.
   * true: UCS2 alphabet.
   * false: default SMS alphabet.
   * false: default SMS alphabet.
   */  
   */
   readonly attribute boolean isUCS2;
   boolean isUCS2;
 
 
   /**
   /**
   * Visibility of input.
   * Visibility of input.
Line 283: Line 421:
   * true: User input shall not be revealed in any way.
   * true: User input shall not be revealed in any way.
   * false: ME may echo user input on the display.
   * false: ME may echo user input on the display.
   */  
   */
   readonly attribute boolean hideInput;
   boolean hideInput;
 
 
   /**
   /**
   * Yes/No response is requested.
   * Yes/No response is requested.
Line 291: Line 429:
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INKEY, bit 3.
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INKEY, bit 3.
   *
   *
   * true: Yes/No response is requested.
   * true: Yes/No response is requested, and character sets
  *      (Alphabet set and UCS2) are disabled.
   * false: Character sets (Alphabet set and UCS2) are enabled.
   * false: Character sets (Alphabet set and UCS2) are enabled.
   */  
   */
   readonly attribute boolean yesNo;
   boolean isYesNoRequested;


   /**
   /**
   * Packed or unpacked.
   * User input in packed or unpacked format.
   *
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 4.
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 4.
Line 303: Line 442:
   * true: User input to be in SMS packed format.
   * true: User input to be in SMS packed format.
   * false: User input to be in unpacked format.
   * false: User input to be in unpacked format.
   */  
   */
   readonly attribute boolean isPacked;
   boolean isPacked;


   //TODO icon
   /**
  * Help information available or not.
  *
  * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT/GET INKEY, bit 8.
  *
  * true: help information available.
  * false: no help information available.
  */
  boolean isHelpAvailable;
};
};
</pre>
</pre>


For vaious parameters contained in StkCommand
===== Browser Settings =====
<pre>
<pre>
interface nsIDOMMozStkCmdParameter : nsISupports
dictionary MozStkBrowserSetting
{
{
   //TODO icon
   /**
  * Confirm message to launch browser.
  *
  * @see MozStkTextMessage for the detail specification of
  *      confirmMessage.
  */
  jsval confirmMessage;
 
  /**
  * The URL to be opened by browser.
  */
  DOMString url;
 
  /**
  * One of STK_BROWSER_MODE_*.
  *
  * @see nsIDOMMozIccManager.STK_BROWSER_MODE_*
  */
  unsigned short mode;
};
};
</pre>
</pre>


===== Set Up Call =====
<pre>
<pre>
/**
dictionary MozStkSetUpCall
* Used as command parameter when typeOfCommand in nsIDOMMozStkCommand is
* STK_CMD_DISPLAY_TEXT, STK_CMD_SET_UP_IDLE_MODE_TEXT, STK_CMD_REFRESH and
* STK_CMD_SEND_*.
*/
interface nsIDOMMozStkCmdDisplayTextParam : nsIDOMMozStkCmdParameter
{
{
   readonly attribute nsIDOMMozStkTextMessage textMessage;
   /**
};
  * The Dialling number.
</pre>
  */
  DOMString address;


<pre>
  /**
/**
  * The text message used in user confirmation phase.
* Used as command parameter when typeOfCommand in nsIDOMMozStkCommand is
  *
* STK_CMD_SELECT_ITEM or STK_CMD_SET_UP_MENU.
  * @see MozStkTextMessage for the detail specification of
*/  
  *      confirmMessage.
interface nsIDOMMozStkCmdSelectItemParam : nsIDOMMozStkCmdParameter
  */
{
   jsval confirmMessage;
   readonly attribute nsIDOMMozStkMenu menu;


   readonly attribute boolean loadTitleIcon;
   /**
  * The text message used in call set up phase.
  *
  * @see MozStkTextMessage for the detail specification of
  *      callMessage.
  */
  jsval callMessage;
};
};
</pre>
</pre>


== From ME to ICC ==
* Terminal Response
* Envelope Command
=== STK response ===
<pre>
<pre>
/**
dictionary MozStkResponse
* Used as command parameter when typeOfCommand in nsIDOMMozStkCommand is
* STK_CMD_GET_INKEY or STK_CMD_GET_INPUT.
*/
interface nsIDOMMozStkCmdGetInputParam : nsIDOMMozStkCmdParameter
{
{
   readonly attribute nsIDOMMozStkInput input;
   /**
};
  * One of RESULT_*
</pre>
  */
  unsigned short resultCode;


<pre>
  /**
/**
  * The identifier of the item selected by user.
* Used as command parameter when typeOfCommand in nsIDOMMozStkCommand is
  *
* STK_CMD_LAUNCH_BROWSER.
  * @see MozStkItem.identifier
*/
  */
/* TODO
  unsigned short itemIdentifier;
interface nsIDOMMozStkCmdLaunchBrowserParam : nsIDOMMozStkCmdParameter
{


};
  /**
*/
  * User input.
</pre>
  */
  DOMString input;


<pre>
  /**
/**
  * YES/NO response.
* Used as command parameter when typeOfCommand in nsIDOMMozStkCommand is
  *
* STK_CMD_SET_UP_CALL.
  * @see MozStkInput.isYesNoRequested
*/
  */
/* TODO
  boolean isYesNo;
interface nsIDOMMozStkCmdSetupCallParam : nsIDOMMozStkCmdParameter
{


  /**
  * User has confirmed or rejected the call during STK_CMD_CALL_SET_UP.
  *
  * @see RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
  *
  * true: Confirmed by User.
  * false: Rejected by User.
  */
  boolean hasConfirmed;
};
};
*/
</pre>
</pre>


== STK constants ==
For simplicity, constants are listed here.
<pre>
<pre>
/**
partial interface nsIDOMMozIccManager : nsIDOMEventTarget
* Used as command parameter when typeOfCommand in nsIDOMMozStkCommand is
* STK_CMD_PLAY_TONE.
*/
/*
interface nsIDOMMozStkCmdPlayToneParam : nsIDOMMozStkCmdParameter
{
{
  /**
  * STK Menu Presentation types.
  */
  const unsigned short STK_MENU_TYPE_NOT_SPECIFIED      = 0x00;
  const unsigned short STK_MENU_TYPE_DATA_VALUES        = 0x01;
  const unsigned short STK_MENU_TYPE_NAVIGATION_OPTIONS = 0x03;


};
  /**
*/
  * Browser launch mode.
</pre>
  */
  const unsigned short STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED = 0x00;
  const unsigned short STK_BROWSER_MODE_USING_EXISTING_BROWSER        = 0x02;
  const unsigned short STK_BROWSER_MODE_USING_NEW_BROWSER              = 0x03;
 
  /**
  * STK Proactive commands.
  *
  * @see TS 11.14, clause 13.4
  */
  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_SEND_SS              = 0x11;
  const unsigned short STK_CMD_SEND_USSD            = 0x12;
  const unsigned short STK_CMD_SEND_SMS              = 0x13;
  const unsigned short STK_CMD_SEND_DTMF            = 0x14;
  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_GET_INKEY            = 0x22;
  const unsigned short STK_CMD_GET_INPUT            = 0x23;
  const unsigned short STK_CMD_SELECT_ITEM          = 0x24;
  const unsigned short STK_CMD_SET_UP_MENU          = 0x25;
  const unsigned short STK_CMD_SET_UP_IDLE_MODE_TEXT = 0x28;


STK commands.
<pre>
interface nsIDOMMozStkCmdDetails : nsIDOMMozStkConstants
{
   /**
   /**
   * Command number is the number of command issued by ICC. And it is assigned
   * STK Result code.
   * by ICC may take any hexadecimal value betweean '01' and 'FE'.
   *
  * @see TS 11.14, clause 12.12
   *
   *
   * @see TS 11.14, clause 6.5.1
   * Results '0X' and '1X' indicate that the command has been performed.
   */  
  */
   readonly attribute unsigned short commandNumber;
  /** Command performed successfully */
  const unsigned short STK_RESULT_OK                                = 0x00;
 
  /** Command performed with partial comprehension */
  const unsigned short STK_RESULT_PRFRMD_WITH_PARTIAL_COMPREHENSION = 0x01;
 
  /** Command performed, with missing information */
  const unsigned short STK_RESULT_PRFRMD_WITH_MISSING_INFO          = 0x02;
 
  /** REFRESH performed with additional EFs read */
  const unsigned short STK_RESULT_PRFRMD_WITH_ADDITIONAL_EFS_READ  = 0x03;
 
  /** Command performed successfully, limited service */
  const unsigned short STK_RESULT_PRFRMD_LIMITED_SERVICE            = 0x06;
 
  /** Proactive UICC session terminated by the user */
  const unsigned short STK_RESULT_UICC_SESSION_TERM_BY_USER        = 0x10;
 
  /** Backward move in the proactive UICC session requested by the user */
  const unsigned short STK_RESULT_BACKWARD_MOVE_BY_USER            = 0x11;
 
  /** No response from user */
  const unsigned short STK_RESULT_NO_RESPONSE_FROM_USER            = 0x12;
 
  /** Help information required by the user */
  const unsigned short STK_RESULT_HELP_INFO_REQUIRED                = 0x13;
 
  /** USSD or SS transaction terminated by the user */
  const unsigned short STK_RESULT_USSD_SS_SESSION_TERM_BY_USER      = 0x14;
 
  /**
  * Results '2X' indicate to the UICC that it may be worth re-trying the
  * command at a later opportunity.
   */
   /** Terminal currently unable to process command */
  const unsigned short STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS = 0x20;
 
  /** Network currently unable to process command */
  const unsigned short STK_RESULT_NETWORK_CRNTLY_UNABLE_TO_PROCESS  = 0x21;
 
  /** User did not accept the proactive command */
  const unsigned short STK_RESULT_USER_NOT_ACCEPT                  = 0x22;
 
  /** User cleared down call before connection or network release */
  const unsigned short STK_RESULT_USER_CLEAR_DOWN_CALL              = 0x23;
 
  /** Launch browser generic error code */
  const unsigned short STK_RESULT_LAUNCH_BROWSER_ERROR              = 0x26;


   /**
   /**
   * One of STK_CMD_*.
   * Results '3X' indicate that it is not worth the UICC re-trying with an
   */
  * identical command, as it will only get the same response. However, the
   readonly attribute unsigned short typeOfCommand;  
   * decision to retry lies with the application.
  */
  /** Command beyond terminal's capabilities */
  const unsigned short STK_RESULT_BEYOND_TERMINAL_CAPABILITY        = 0x30;
 
  /** Command type not understood by terminal */
  const unsigned short STK_RESULT_CMD_TYPE_NOT_UNDERSTOOD          = 0x31;
 
  /** Command data not understood by terminal */
  const unsigned short STK_RESULT_CMD_DATA_NOT_UNDERSTOOD          = 0x32;
 
  /** Command number not known by terminal */
  const unsigned short STK_RESULT_CMD_NUM_NOT_KNOWN                = 0x33;
 
  /** SS Return Error */
  const unsigned short STK_RESULT_SS_RETURN_ERROR                  = 0x34;
 
  /** SMS RP-ERROR */
  const unsigned short STK_RESULT_SMS_RP_ERROR                      = 0x35;
 
  /** Error, required values are missing */
  const unsigned short STK_RESULT_REQUIRED_VALUES_MISSING          = 0x36;
 
  /** USSD Return Error */
  const unsigned short STK_RESULT_USSD_RETURN_ERROR                = 0x37;
 
  /** MultipleCard commands error */
   const unsigned short STK_RESULT_MULTI_CARDS_CMD_ERROR            = 0x38;


   /**
   /**
   * Qualifiers specific to the command.
   * Interaction with call control by USIM or MO short message control by
   */  
  * USIM, permanent problem
   readonly attribute unsigned short commandQualifier;
   */
};
   const unsigned short STK_RESULT_USIM_CALL_CONTROL_PERMANENT      = 0x39;
</pre>
 
  /** Bearer Independent Protocol error */
  const unsigned short STK_RESULT_BIP_ERROR                        = 0x3a;


<pre>
interface nsIDOMMozStkCommand : nsIDOMMozStkConstants
{
   /**
   /**
   * The detail information of the proactive command issued by ICC.
   * STK Event List
  */  
  */
  readonly attribute nsIDOMMozStkCmdDetails cmdDetails;
  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;


   /**
   /**
   * One of nsIDOMMozStkCmd*Param.
   * Tone type.
   */  
   */
   readonly attribute nsIDOMMozStkCmdParameter param;
   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;


   //TODO: add deviceId for multi-SIM
   /**
};
  * 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>


= Examples =
== Show STK menu ==
<pre>
<pre>
interface nsIDOMMozStkCommandEvent : nsIDOMEvent
var icc = navigator.mozMobileConnection.icc;
{
icc.onstkcommand = function (evt) {
   readonly attribute nsIDOMMozStkCommand command;
   var command = evt.command
  switch (command.typeOfCommand) {
    case icc.STK_CMD_SET_UP_MENU:
      var menu = command.options;
      // create a Menu-like UI according to 'menu'
    break;
  }
};
};
</pre>
</pre>


STK response.
== Menu Selection ==
<pre>
<pre>
interface nsIDOMMozStkResponse : nsIDOMMozStkConstants
/**
{
* onMenuSelected is the callback when some item of the menu is selected.
  /**
* @param id   The index of the item being selected.
   * The detail information of the proactive command issued by ICC.
* @param helpRequested    Request for help.
  */  
*/  
   readonly attribute nsIDOMMozStkCmdDetails cmdDetails;
function onMenuSelected(id, helpRequested) {
    
   var icc = navigator.mozMobileConnection.icc;
  /**
   icc.sendStkMenuSelection(id, helpRequested);
  * One of STK_RESULT_*.
}
  */  
</pre>
  attribute unsigned short resultCode;


   /**
== Select Item ==
  * The identifier of the menu item selected by user.
<pre>
  */
// 'command' is got from onstkcommand
  attribute unsigned short  menuSelection;
// and assume it's a Select Item command.
var icc = navigator.mozMobileConnection.icc;
var response = {
  resultCode : icc.STK_RESULT_OK,
   // 'id' is got from the choosed item identifier (menu.item[].identifier)
  itemIdentifier: id
};
mozIcc.sendStkResponse(command, response);
</pre>


   /**
== Get Input ==
  * User input.
<pre>
  */  
var icc = navigator.mozMobileConnection.icc;
   attribute DOMString input;
icc.onstkcommand = function (evt) {
   var command = evt.command
  switch (command.typeOfCommand) {
    case icc.STK_CMD_GET_INPUT:
      var input = command.options;
      // create a TextInput-like UI according to 'input'
    break;
   }
};


  /**
// onTextInput is the callback when user inputs complete.
  * YES/NO response.
var icc = navigator.mozMobileConnection.icc;
  *
function onTextInput(input) {
  * @see TS 11.14, clause 12.6, Command Qualifier, GET INKEY, bit 3.  
  var response = {
  *
    resultCode : mozICC.STK_RESULT_OK,
  * true: User selects 'Yes'.
    input: input
  * false: User selects 'No'.
  };
  */
   mozIcc.sendStkResponse(command, response);
   attribute boolean yesNo;
}
</pre>


  /**
= TODO =
  * User has accepted or rejected the call during STK_CMD_CALL_SET_UP.
* Icon
  *  
* Timer
  * @see RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
  *
  * true: Confirmed by User.
  * false: Rejected by User.
  */
  attribute boolean confirmation;


  //TODO add deviceId for multi-SIM
= Reference =
};
* TS 11.14
</pre>
* TS 102.223
* http://www.kandroid.org/online-pdk/guide/stk.html


= Examples =
[[Category:Web APIs]]

Latest revision as of 23:27, 1 October 2014

Overview

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
Feature List: https://docs.google.com/spreadsheet/ccc?key=0AuvgnQ-Iwb6XdGV0aHZWdGdmZVEzZUxmZWNEaGJYWkE

Interface

  • These interface will be added in MozIccManager

Event handlers for receiving messages from ICC to ME

These event handlers will be invoked when there are proactive commands or session end notification sent from ICC.

Proactive Command

  /**
   * The 'stkcommand' event is notified whenever STK Proactive Command is
   * issued from ICC.
   */ 
  attribute nsIDOMEventListener onstkcommand;

Session End Notificaiton

  /**
   * 'stksessionend' event is notified whenever STK Session is terminated by 
   * ICC.
   */ 
  attribute nsIDOMEventListener onstksessionend;

Send Message from ME to ICC

There are two kinds of messages will be sent from ME to ICC

  • Terminal Response
    • Once the ME has made its attempt to execute a proactive command from the ICC, the ME shall inform the ICC of the success or otherwise of that command, by using TERMINAL RESPONSE.
  • Envelope command
    • Envelope command is used to transfer STK information from ME to ICC.

Send Terminal Response

  /**
   * Send the response back to ICC after an attempt to execute STK Proactive
   * Command.
   *
   * @param command
   *        Command received from ICC. See MozStkCommand.
   * @param response
   *        The response that will be sent to ICC.
   * @see MozStkResponse for the detail of response.
   */
  void sendStkResponse(in jsval command, in jsval response);

Send Envelope Command

Currently only support "Menu Selection", "Event Download"

  /**
   * Send the "Menu Selection" Envelope command to ICC for menu selection.
   *
   * @param itemIdentifier
   *        The identifier of the item selected by user.
   * @param helpRequested
   *        true if user requests to provide help information, false otherwise.
   */
  void sendStkMenuSelection(in unsigned short itemIdentifier,
                            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);

STK message format

  • TS 102.223, Annex C for the structure of STK communications

The specification of the message received from ICC and sent to ICC.

Basically, a STK message is of a BER-TLV object, which contains several Comprehension-TLV objects (TLV : Tag-Length-Value)

                      ----- ----- ------------------------------------
            BER-TLV  |  T  |  L  |  V - Several Comprehension-TLVs    |
                      ----- ----- ------------------------------------
                                 /                                     \
                                /                                       \
                                ----- ----- -----       ----- ----- -----
Comprehension-TLV              |  T  |  L  |  V  | ... |  T  |  L  |  V  |
                                ----- ----- -----       ----- ----- -----

Each STK message consists of at least two mandatory Comprehension-TLVs

  • Command Details
  • Device Identities

The remaining Comprehension-TLVs varies according to different type of STK message.


For the "Command Details" data object,
this data object shall be identical to the command details data object (including the comprehension required flag) given by the UICC in the proactive command to which the terminal is giving the result.

And there two kinds of STK messages

  • From ICC to ME
    • MozStkCommand
  • From ME to ICC
    • MozStkResponse

In both MozStkCommand and MozStkResponse, we expose the content of 'Command Details' as:

  • number
  • type
  • qualifier

So when a webapp tries to create a MozStkResponse, the webapp needs to create exactly the same 'Command Details' as it got from MozStkCommand.

From ICC to ME

The STK message sent from ICC to ME called 'Proactive Command'. And we use MozStkCommand to represent 'Proactive Command'.
For example, a Proactive Command SET_UP_MENU whose Comprehension-TLVs will be looked like

   ---------------- -------------- ------------- ----------       ----------
  | CmdDetails-TLV | DeviceId-TLV | AlphaId-TLV | Item-TLV | ... | Item-TLV |
   ---------------- -------------- ------------- ----------       ----------
  • CmdDetails - Details of this proactive command.
    • typeOfCommand is SET_UP_MENU
  • DeviceId - The source and destination of this proactive command.
  • AlphaId - The title of this menu
  • Item - The items in this menu

In designing this message format, we wrap up the Comprehension-TLVs other than "Command Details" and "Device Identities" to a more high level UI component according to the typeOfCommand.

   ---------------- -------------- --------------
  | CmdDetails-TLV | DeviceId-TLV | UI Component |
   ---------------- -------------- --------------

The UI componet includes

  • Text Message
  • Menu
  • Input
  • Call set up
  • Launch Browser

So web apps can parse the UI componet according to the typeOfCommand.

In this case, web apps can display a Menu-like UI according to this UI component.

   --------
  | Title  |
   --------
  | Item 1 |
   --------
  | Item 2 |
   --------

STK Command Event

StkCommandEvent will be the parameter passed in onstkcommand handler

interface nsIDOMMozStkCommandEvent : nsIDOMEvent
{
  /**
   * See nsIDOMMozStkCommand for the detail of command.
   */
  readonly attribute jsval command;
};

STK command

dictionary MozStkCommand
{
  /**
   * The number of command issued by ICC. And it is assigned
   * by ICC may take any hexadecimal value betweean '01' and 'FE'.
   *
   * @see TS 11.14, clause 6.5.1
   */
  unsigned short commandNumber;

  /**
   * One of STK_CMD_*
   */
  unsigned short typeOfCommand;

  /**
   * Qualifiers specific to the command.
   */
  unsigned short commandQualifier;

  /**
   * 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
   * - STK_CMD_SET_UP_EVENT_LIST
   * options is MozStkSetUpEventList.
   *
   * When typeOfCommand is
   * - STK_CMD_PLAY_TONE
   * options is MozStkPlayTone.
   *
   * When typeOfCommand is
   * - STK_CMD_POLL_INTERVAL
   * options is MozStkDuration.
   *
   * When typeOfCommand is
   * - STK_CMD_POLL_OFF
   * options is null.
   *
   * When typeOfCommand is
   * - STK_CMD_REFRESH
   * options is null.
   */
  jsval options;
};

UI parts - The UI Component contained in MozStkCommand

Text Message
dictionary MozStkTextMessage
{
  /**
   * Text String.
   *
   * @see TS 11.14, clause 12.15, Text String.
   */
  DOMString text;

  /**
   * Indicate this text message is high priority or normal priority.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 1.
   *
   * High priority text shall be displayed on the screen immediately, except if
   * there is a conflict of priority level of alerting such as incoming calls
   * or a low battery warning. In that situation, the resolution is left to
   * the terminal. If the command is rejected in spite of the high priority,
   * the terminal shall inform the ICC with resultCode is
   * TERMINAL_CRNTLY_UNABLE_TO_PROCESS in MozStkResponse.
   *
   * true: high priority
   * false: normal priority
   */
  boolean isHighPriority;

  /**
   * Need to wait for user to clear message or not.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, Display Text, bit 8.
   *
   * If this attribute is true, but user doesn't give any input within a period
   * of time(said 30 secs), the terminal shall inform the ICC with resultCode
   * is NO_RESPONSE_FROM_USER in MozStkResponse.
   *
   * true: Wait for user to clear message.
   * false: clear message after a delay.
   */
  boolean userClear;

  /**
   * Need to response immediately or not.
   *
   * @see TS 11.14, clause 12.43, Immediate response.
   *
   * When this attribute is true, the terminal shall immediately send
   * MozStkResponse with resultCode is OK.
   *
   * true: The terminal shall send response immediately.
   * false: otherwise.
   */
  boolean responseNeeded;
};
Menu
dictionary MozStkItem
{
  /**
   * Identifier of item.
   *
   * The identifier is a single byte between '01' and 'FF'. Each item shall
   * have a unique identifier within an Item list.
   */
  unsigned short identifier;

  /**
   * Text string of item.
   */
  DOMString text;
};
dictionary MozStkMenu
{
  /**
   * Array of MozStkItem.
   *
   * @see TS 11.14, clause 12.9
   */
  jsval items; // MozStkItem[]

  /**
   * Presentation type, one of TYPE_*.
   */
  unsigned short presentationType;

  /**
   * Title of the menu.
   */
  DOMString title;

  /**
   * Default item identifier of the menu.
   */
  unsigned short defaultItem;

  /**
   * Help information available or not.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, SET UP MENU, bit 8.
   *
   * true: help information available.
   * false: no help information available.
   */
  boolean isHelpAvailable;
};
Input
dictionary MozStkInput
{
  /**
   * Text for the ME to display in conjunction with asking the user to respond.
   */
  DOMString text;

  /**
   * Minimum length of response.
   */
  unsigned short minLength;

  /**
   * Maximum length of response.
   */
  unsigned short maxLength;

  /**
   * Text for the ME to display, corresponds to a default text string offered
   * by the ICC.
   */
  DOMString defaultText;

  /**
   * Input format.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 1.
   *
   * true: Alphabet set.
   * false: Digits only.
   */
  boolean isAlphabet;

  /**
   * Alphabet encoding.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 2.
   *
   * true: UCS2 alphabet.
   * false: default SMS alphabet.
   */
  boolean isUCS2;

  /**
   * Visibility of input.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 3.
   *
   * true: User input shall not be revealed in any way.
   * false: ME may echo user input on the display.
   */
  boolean hideInput;

  /**
   * Yes/No response is requested.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INKEY, bit 3.
   *
   * true: Yes/No response is requested, and character sets
   *       (Alphabet set and UCS2) are disabled.
   * false: Character sets (Alphabet set and UCS2) are enabled.
   */
  boolean isYesNoRequested;

  /**
   * User input in packed or unpacked format.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT, bit 4.
   *
   * true: User input to be in SMS packed format.
   * false: User input to be in unpacked format.
   */
  boolean isPacked;

  /**
   * Help information available or not.
   *
   * @see TS 11.14, clause 12.6, Command Qualifier, GET INPUT/GET INKEY, bit 8.
   *
   * true: help information available.
   * false: no help information available.
   */
  boolean isHelpAvailable;
};
Browser Settings
dictionary MozStkBrowserSetting
{
  /**
   * Confirm message to launch browser.
   *
   * @see MozStkTextMessage for the detail specification of
   *      confirmMessage.
   */
  jsval confirmMessage;

  /**
   * The URL to be opened by browser.
   */
  DOMString url;

  /**
   * One of STK_BROWSER_MODE_*.
   *
   * @see nsIDOMMozIccManager.STK_BROWSER_MODE_*
   */
  unsigned short mode;
};
Set Up Call
dictionary MozStkSetUpCall
{
  /**
   * The Dialling number.
   */
  DOMString address;

  /**
   * The text message used in user confirmation phase.
   *
   * @see MozStkTextMessage for the detail specification of
   *      confirmMessage.
   */
  jsval confirmMessage;

  /**
   * The text message used in call set up phase.
   *
   * @see MozStkTextMessage for the detail specification of
   *      callMessage.
   */
  jsval callMessage;
};

From ME to ICC

  • Terminal Response
  • Envelope Command

STK response

dictionary MozStkResponse
{
  /**
   * One of RESULT_*
   */
  unsigned short resultCode;

  /**
   * The identifier of the item selected by user.
   *
   * @see MozStkItem.identifier
   */
  unsigned short itemIdentifier;

  /**
   * User input.
   */
  DOMString input;

  /**
   * YES/NO response.
   *
   * @see MozStkInput.isYesNoRequested
   */
  boolean isYesNo;

  /**
   * User has confirmed or rejected the call during STK_CMD_CALL_SET_UP.
   *
   * @see RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
   *
   * true: Confirmed by User.
   * false: Rejected by User.
   */
  boolean hasConfirmed;
};

STK constants

For simplicity, constants are listed here.

partial interface nsIDOMMozIccManager : nsIDOMEventTarget
{
  /**
   * STK Menu Presentation types.
   */
  const unsigned short STK_MENU_TYPE_NOT_SPECIFIED      = 0x00;
  const unsigned short STK_MENU_TYPE_DATA_VALUES        = 0x01;
  const unsigned short STK_MENU_TYPE_NAVIGATION_OPTIONS = 0x03;

  /**
   * Browser launch mode.
   */
  const unsigned short STK_BROWSER_MODE_LAUNCH_IF_NOT_ALREADY_LAUNCHED = 0x00;
  const unsigned short STK_BROWSER_MODE_USING_EXISTING_BROWSER         = 0x02;
  const unsigned short STK_BROWSER_MODE_USING_NEW_BROWSER              = 0x03;

  /**
   * STK Proactive commands.
   *
   * @see TS 11.14, clause 13.4
   */
  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_SEND_SS               = 0x11;
  const unsigned short STK_CMD_SEND_USSD             = 0x12;
  const unsigned short STK_CMD_SEND_SMS              = 0x13;
  const unsigned short STK_CMD_SEND_DTMF             = 0x14;
  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_GET_INKEY             = 0x22;
  const unsigned short STK_CMD_GET_INPUT             = 0x23;
  const unsigned short STK_CMD_SELECT_ITEM           = 0x24;
  const unsigned short STK_CMD_SET_UP_MENU           = 0x25;
  const unsigned short STK_CMD_SET_UP_IDLE_MODE_TEXT = 0x28;

  /**
   * STK Result code.
   *
   * @see TS 11.14, clause 12.12
   *
   * Results '0X' and '1X' indicate that the command has been performed.
   */
  /** Command performed successfully */
  const unsigned short STK_RESULT_OK                                = 0x00;

  /** Command performed with partial comprehension */
  const unsigned short STK_RESULT_PRFRMD_WITH_PARTIAL_COMPREHENSION = 0x01;

  /** Command performed, with missing information */
  const unsigned short STK_RESULT_PRFRMD_WITH_MISSING_INFO          = 0x02;

  /** REFRESH performed with additional EFs read */
  const unsigned short STK_RESULT_PRFRMD_WITH_ADDITIONAL_EFS_READ   = 0x03;

  /** Command performed successfully, limited service */
  const unsigned short STK_RESULT_PRFRMD_LIMITED_SERVICE            = 0x06;

  /** Proactive UICC session terminated by the user */
  const unsigned short STK_RESULT_UICC_SESSION_TERM_BY_USER         = 0x10;

  /** Backward move in the proactive UICC session requested by the user */
  const unsigned short STK_RESULT_BACKWARD_MOVE_BY_USER             = 0x11;

  /** No response from user */
  const unsigned short STK_RESULT_NO_RESPONSE_FROM_USER             = 0x12;

  /** Help information required by the user */
  const unsigned short STK_RESULT_HELP_INFO_REQUIRED                = 0x13;

  /** USSD or SS transaction terminated by the user */
  const unsigned short STK_RESULT_USSD_SS_SESSION_TERM_BY_USER      = 0x14;

  /**
   * Results '2X' indicate to the UICC that it may be worth re-trying the
   * command at a later opportunity.
   */
  /** Terminal currently unable to process command */
  const unsigned short STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS = 0x20;

  /** Network currently unable to process command */
  const unsigned short STK_RESULT_NETWORK_CRNTLY_UNABLE_TO_PROCESS  = 0x21;

  /** User did not accept the proactive command */
  const unsigned short STK_RESULT_USER_NOT_ACCEPT                   = 0x22;

  /** User cleared down call before connection or network release */
  const unsigned short STK_RESULT_USER_CLEAR_DOWN_CALL              = 0x23;

  /** Launch browser generic error code */
  const unsigned short STK_RESULT_LAUNCH_BROWSER_ERROR              = 0x26;

  /**
   * Results '3X' indicate that it is not worth the UICC re-trying with an
   * identical command, as it will only get the same response. However, the
   * decision to retry lies with the application.
   */
  /** Command beyond terminal's capabilities */
  const unsigned short STK_RESULT_BEYOND_TERMINAL_CAPABILITY        = 0x30;

  /** Command type not understood by terminal */
  const unsigned short STK_RESULT_CMD_TYPE_NOT_UNDERSTOOD           = 0x31;

  /** Command data not understood by terminal */
  const unsigned short STK_RESULT_CMD_DATA_NOT_UNDERSTOOD           = 0x32;

  /** Command number not known by terminal */
  const unsigned short STK_RESULT_CMD_NUM_NOT_KNOWN                 = 0x33;

  /** SS Return Error */
  const unsigned short STK_RESULT_SS_RETURN_ERROR                   = 0x34;

  /** SMS RP-ERROR */
  const unsigned short STK_RESULT_SMS_RP_ERROR                      = 0x35;

  /** Error, required values are missing */
  const unsigned short STK_RESULT_REQUIRED_VALUES_MISSING           = 0x36;

  /** USSD Return Error */
  const unsigned short STK_RESULT_USSD_RETURN_ERROR                 = 0x37;

  /** MultipleCard commands error */
  const unsigned short STK_RESULT_MULTI_CARDS_CMD_ERROR             = 0x38;

  /**
   * Interaction with call control by USIM or MO short message control by
   * USIM, permanent problem
   */
  const unsigned short STK_RESULT_USIM_CALL_CONTROL_PERMANENT       = 0x39;

  /** Bearer Independent Protocol error */
  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;
}

Examples

Show STK menu

var icc = navigator.mozMobileConnection.icc;
icc.onstkcommand = function (evt) {
  var command = evt.command
  switch (command.typeOfCommand) {
    case icc.STK_CMD_SET_UP_MENU:
      var menu = command.options;
      // create a Menu-like UI according to 'menu'
    break;
  }
};

Menu Selection

/**
 * 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);
}

Select Item

// 'command' is got from onstkcommand
// and assume it's a Select Item command.
var icc = navigator.mozMobileConnection.icc;
var response = {
  resultCode : icc.STK_RESULT_OK,
  // 'id' is got from the choosed item identifier (menu.item[].identifier)
  itemIdentifier: id
};
mozIcc.sendStkResponse(command, response);

Get Input

var icc = navigator.mozMobileConnection.icc;
icc.onstkcommand = function (evt) {
  var command = evt.command
  switch (command.typeOfCommand) {
    case icc.STK_CMD_GET_INPUT:
      var input = command.options;
      // create a TextInput-like UI according to 'input'
    break;
  }
};

// onTextInput is the callback when user inputs complete.
var icc = navigator.mozMobileConnection.icc;
function onTextInput(input) {
  var response = {
    resultCode : mozICC.STK_RESULT_OK,
    input: input
  };
  mozIcc.sendStkResponse(command, response);
}

TODO

  • Icon
  • Timer

Reference