Reputation: 67
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;
}
Upvotes: 4
Views: 1837
Reputation: 337
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.
Upvotes: 1