4

My work has assigned me a job to research if it's technically possible to

Launch Browser with specific URL from SIM Application Toolkit using Java Card 2.2.1.

I tried to use ProactiveHandler from sim.toolkit library. The exact code that launches browser from looks something like this

My test applet just shows menu item on screen and when i click it, it's supposed to launch browser. Edited for more complete source code:

The part where i handle events

private final byte[] GOOGLE = {(byte) 'h', (byte) 't', (byte) 't', (byte) 'p', (byte) ':', (byte) '/', (byte) '/', (byte) 'w', (byte) 'w', (byte) 'w', (byte) '.', (byte) 'g', (byte) 'o', (byte) 'o', (byte) 'g', (byte) 'l', (byte) 'e', (byte) '.', (byte) 'c', (byte) 'o', (byte) 'm'};

public void processToolkit(byte event) throws ToolkitException {
        switch (event) {
            case EVENT_MENU_SELECTION:
                displayText(TEXT, (byte) 0, (byte) TEXT.length);
                sendToBrowser(GOOGLE);
                break;
            case EVENT_FORMATTED_SMS_PP_ENV:
                handleSMSComand();
                break;
            default:
                return;
        }
    }

I made it so that when i click on menu item, it will call my sendToBrowser function. displayText function just shows text on screen. And my complete code of function is this:

private byte sendToBrowser(byte[] data) throws ToolkitException {
    if (MEProfile.check(PROFILE_LAUNCH_BROWSER)) {
        try {
            ProactiveHandler ph = ProactiveHandler.getTheHandler();
            displayText(new byte[]{(byte) 'H', (byte) 'S'}, (byte) 0, (byte) 2);
            try {
                ph.init(PRO_CMD_LAUNCH_BROWSER, (byte) 0x00, DEV_ID_ME);
                displayText(new byte[]{(byte) 'C', (byte) 'S'}, (byte) 0, (byte) 2);
                try {
                    ph.appendTLV(TAG_URL, data, (short) 0, (short) data.length);
                    displayText(new byte[]{(byte) 'T', (byte) 'S'}, (byte) 0, (byte) 2);
                    try {
                        ph.send();
                        return displayText(new byte[]{(byte) 'S', (byte) 'S'}, (byte) 0, (byte) 2);
                    } catch (Exception te){
                        return displayText(new byte[]{(byte) 'S'}, (byte) 0, (byte) 1);
                    }
                } catch (Exception te) {
                    return displayText(new byte[]{(byte) 'T'}, (byte) 0, (byte) 1);
                }
            } catch (Exception te) {
                return displayText(new byte[]{(byte) 'C'}, (byte) 0, (byte) 1);
            }
        } catch (Exception te) {
            return displayText(new byte[]{(byte) 'H'}, (byte) 0, (byte) 1);
        }
    } else {
        return displayText(new byte[]{(byte) 'M'}, (byte) 0, (byte) 1);
    }
}

Code runs through on non-iOS devices but it doesn't launch browser. It doesn't throw any error and ph.send(); succesfully works even though browser is not launched. So i'm guessing this method no longer works on latest phones? My test phones are all high-end android devices.

Is there any other method that can launch browser with Java Card 2.2.1? If not i'm gonna report that it's technically impossible and prior method doesn't work on newer phones.

This is my displayText function but it probably irrelevant

private byte displayText(byte[] messageBuffer, short offset, short length) {
        byte result = RES_ERROR_CMD_DATA_NOT_UNDERSTOOD;
        try {
            if (length == 0) {
                return 0;
            }
            ProactiveHandler ph = ProactiveHandler.getTheHandler();
            ph.initDisplayText((byte) 0x81, DCS_8_BIT_DATA, messageBuffer,
                    offset, length);
            result = ph.send();
        } catch (Exception te) {
            result = RES_ERROR_CMD_DATA_NOT_UNDERSTOOD;
        }
        return result;
    }
  • 1
    Are you sure `MEProfile.check(PROFILE_LAUNCH_BROWSER)` returns `true`? – vojta Mar 21 '18 at 13:42
  • 1
    On what event do you call this proactive command? Could you please provide complete source code? – vojta Mar 21 '18 at 13:48
  • @vojta Hi, MEProfile.check(PROFILE_LAUNCH_BROWSER) does return true. I added huge nest of try catch to see where exactly it fails since i have no way of debugging and i edited my post to put more complete code. And if you see, the last of try catch returns S S upon succesful and it does return it except browser is not really called. – Enkhsaikhan Davaatulga Mar 22 '18 at 02:38
  • What response do you get, if you use ProactiveResponseHandler just after your send() method? – vojta Mar 22 '18 at 05:49
  • BTW: I am quite certain your code cannot work as you post it: each `displayText` is also a proactive command, so the buffer of `ProactiveHandler` holding URL is rewritten before you call `send`... There mustn't be any other proactive command between `ph.init(PRO_CMD_LAUNCH_BROWSER, ...)` and its `send()`. – vojta Mar 22 '18 at 12:28
  • 1
    @vojta hi, sorry for the late reply, after i use `ProactiveResponseHandler` after `send()`, `getGeneralResult()` returns `0`. I deleted all `displayText` between `ph.init(PRO_CMD_LAUNCH_BROWSER, ...)` and `send()`. But browser still fails to launch. – Enkhsaikhan Davaatulga Mar 23 '18 at 09:12
  • Could you please add type of your mobile phone and Android version? – vojta Mar 23 '18 at 12:28
  • 1
    @vojta Hello there, been a while. I tried various android phones from galaxy note 4 to some asus phone with android version ranging from 4.4.4 to 6.x.x. But i got my hands on a low-end sony ericson phone (LT15i) today with android version 2.3.4 and it actually worked! lol – Enkhsaikhan Davaatulga Mar 28 '18 at 03:45
  • @Necrowy Did you find any other handsets supporting this feature? I'm trying to compile a list. – John Apr 08 '19 at 21:33

1 Answers1

1

While we were performing testing of our SIM applet to trigger launching browser on terminal with the relevant proactive command(LAUNCH BROWSER), we realized that although terminal was returning positive response for the command, browser has not popped up on the screen. There is terminal vendor dependency for this feature and some of handsets does not support despite of returned ACK.

Kemal Atik
  • 307
  • 3
  • 12
  • Do you know which handsets support this feature? I'm trying to compile a list. – John Apr 08 '19 at 21:31
  • 1
    Hello John, unfortunately we don't have big handset inventory but what I can say that mostly mainstream Samsung series such as J, S series. – Kemal Atik Apr 10 '19 at 06:04