2
votes

I am struggling with a strange situation over past week. I am trying to delete an applet and i get 0x6985 in response of delete command.

Scenario:

  1. An applet X is present in Sim card.
  2. Sim card is inserted in mobile phone.
  3. An android application will receive commands from server and will send these commands to Sim Card via Telephony Manager.
  4. Server controls all the commands and has all required KEYS for authentication and all AID's are known.
  5. Android application works as a bridge to channel the commands to Sim card and send response back to server.

How applets are connected to each other in my ecosystem?

  • There is one more applet i.e. Y, which holds the reference of an applet i.e. X. [It is known to me that delete will not work until Y releases the reference of X applet]
  • In X applet's uninstall() method i am calling Y applet(via shared interface) and there i am releasing the reference of X applet.

Problem Scenario:

  • In offline mode via reader any time when i send delete command for X applet. It gets deleted successfully.
  • To verify that Y applet is getting call from X applet i set some data in one of buffer present in Y applet. [That confirms Y applet got the call and reference was released in that way successfully. I get this buffer data by some in house designed command by me, which confirms that happened or not.]

Situation when Sim card in mobile

  • When server sends delete command for an X applet, in response i get 0x6985.

  • I call the Y applet and check what data is present in Y's buffer that holds accountability of call received by X. There, call from X is never received.

Situation when done with card reader not in mobile

  • With PCSC reader when delete command is sent to X. Applet X gets delete successfully.

  • Y applet's buffer data confirms that call was received from X applet.

My Observation:
I tried every possible way to get this done but failed every time. The cap file of both applet X and Y is same i.e. used in Mobile phone and via card reader.
I feel there is some issue with Telephony manager as i couldn't find any other culprit here but i lack in experience with telephony manager.
Any help on this topic is much appreciated.

1

1 Answers

0
votes

There could be an implementation difference if you use different cards. Generally an Applet should only be deleted if there is no reference to it from another Applet. Even if removing the reference at the time of deletion is a valid option, I'd wonder if the OS manufacturer would always get that part right: you only call uninstall after you've chosen to delete, and you only delete if you know there are no more references - a rather perfect catch 22.

The problem could also be that one of the instances of the Applet X (or possibly even Y) are in use. If that's the case then deletion would be unavailable either. I'm not sure if having two contexts is an option for your card implementation; these are not multi-core beasts.

In the end debugging 6985 is hard. ISO 7816 status words are more about syntax than semantics; they only give you a minimum amount of information. 6985 is the equivalent of "runtime error" so yeah, you can spend a lot of time debugging, I'm afraid.