Hi,

As you may know, the official build of Froyo on the Nexus One does not
include the Sim Toolkit application (stk.apk). I really don't want to
diverge from the stock build on my main phone and run CM for example
(which includes stk.apk) but for certain services (online banking) I
do depend on the STK functionality.

So I downloaded the Froyo tree to get the source for the stk app. It
compiled fairly easily. Now to install it: since the app declares
sharedUserId to be android.uid.phone, this wasn't going to work, as
one would need the platform key to sign the apk. Lo and behold,
install fails with INSTALL_FAILED_SHARED_USER_INCOMPATIBLE - but this
I expected.

I wanted to see if I can get the app running with a normal user ID. I
removed the sharedUserId attribute from the manifest, and I also
changed the package name from com.android.stk to my own private
package name. The apk compiled fine, installed fine, but, not entirely
surprisingly, it's not working.

The app successfully registers for STK commands, it receives and
processes them - after boot, with STK-enabed SIM cards, this is
usually just a single SET_UP_MENU command. When I launch my STK app,
it correctly displays the menu that it received this way from the SIM
card. Choosing any menu item, however, causes a null pointer
exception. The problem is that StkAppService in my stk.apk calls
com.android.internal.telephony.gsm.stk.StkService.getInstance() which
is supposed to return a reference to the singleton StkService object.
This StkService object is used to (for example) send menu choices back
to the SIM card. StkService.getInstance() however returns null to my
app, which means that I can "hear" the SIM card, but I can't talk to
it.

Now, from looking at the source of StkService, it seems that when my
application calls the .getInstance() static method, it should get a
reference to the pre-existing StkService object as, by the time my
stk.apk makes this call, GSMPhone had to have initialized StkService:
otherwise my stk.apk would not be receiving the SET_UP_MENU commands
either.

So the question is: how come that I call this static method on the
StkService system class and I get null back? It seems that the same
code, when running as android.uid.phone, would receive a reference to
the StkService singleton. Does running with a different userId mean
that I'm talking to a different instance of StkService?

Oversimplified, this is what StkService.getInstance looks like:

public static StkService getInstance(initparams) {
    if (sInstance == null) {
        if (initparams == null) {
            // my stk.apk runs afoul here:
            return null;
        }
        // ...even though a call from GSMPhone has already executed
this:
        sInstance = new StkService (initparams);
    }
    return sInstance;
}

I apologize for the long-winded question, and the fact that this is
possibly obvious to answer: I'm pretty new to Android development.

-Eric

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to