0

Are there any methods that a Sim Toolkit applet is selected when phone boots or SIM card is inserted on phone?

I want an applet on a SIM card that automatically executes some commands and display a message when SIM is installed on phone or phone boots.

STK Applet got 3 methods 'process','processToolkit'and 'install'. I don't know if each of methods 'process','processToolkit' can be called during phone boot or SIM installation on phone?

VSB
  • 9,825
  • 16
  • 72
  • 145

1 Answers1

1

This is possible. You have to register the event EVENT_PROFILE_DOWNLOAD during the applet installation.

toolkitRegistry = ToolkitRegistrySystem.getEntry();
toolkitRegistry.setEvent(EVENT_PROFILE_DOWNLOAD);
// in case you need a menu later, too:
toolkitRegistry.initMenuEntry( ...

When the SIM is started the modem will always execute the TERMINAL PROFILE commmand. This will trigger the registered EVENT_PROFILE_DOWNLOAD by processToolkit. In case you have a menu the menu selection will be handled also by processToolkit. The event will be EVENT_MENU_SELECTION then.

From processToolkit you can execute any necessary behavior, e.g. displaying a text.

        ProactiveHandlerSystem.getTheHandler().clear();
        ProactiveHandlerSystem.getTheHandler().initDisplayText((byte) 0x81, 0x04, array, offset, (short) (length));
        byte res = ProactiveHandlerSystem.getTheHandler().send();
        return res == RES_CMD_PERF;

The array would be the ASCII encoding of your text.

Consult the UICC API as startign point.

k_o_
  • 5,143
  • 1
  • 34
  • 43
  • Thanks for your answer. The trick was to register event during install. two questions: 1- I tried this but do you know what event will be called when phone return back from flight mode? I don't know why but 'EVENT_PROFILE_DOWNLOAD ' did not called when I switched phone to flight mode and return it back to operational mode. But when I installed SIM or restarted phone 'EVENT_PROFILE_DOWNLOAD' was triggered. 2- Can we register several events during install? If yes, do they have conflicts? – VSB Jun 13 '21 at 09:59
  • 1
    2. Yes, you can install several event during install. There is a different setEvents() methods accepting an events array. – k_o_ Jun 13 '21 at 15:20
  • 1
    1. The phone might just disable the SIM card and antenna but not shut down the SIM completely, i.e. not all the files from the SIM will be re-read. When the flight mode is left the SIM session is just continued and the SIM is re-registered with the network operator. This is not triggering the `EVENT_PROFILE_DOWNLOAD`. Look here for a different event. Look into sect. 8.25 for a complete vent list: https://www.etsi.org/deliver/etsi_ts/102200_102299/102223/14.00.00_60/ts_102223v140000p.pdf and sect. 7.5 for a description. E.g. LOCATION STATUS will be still triggered here. – k_o_ Jun 13 '21 at 15:30
  • 1
    Or Access Technology Change Event or Network Search Mode Change Event . – k_o_ Jun 13 '21 at 15:33