title: Applet uninstall not working when SIM Card inserted in Mobile Phone, received 0x6985
body: <p>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.</p>
  
  <p><strong>Scenario:</strong> <br></p>
  
  <ol>
  <li>An applet X is present in Sim card.</li>
  <li>Sim card is inserted in mobile phone.</li>
  <li>An android application will receive commands from server and will send these commands to Sim Card via Telephony Manager.</li>
  <li>Server controls all the commands and has all required KEYS for authentication and all AID's are known.</li>
  <li>Android application works as a bridge to channel the commands to Sim card and send response back to server.</li>
  </ol>
  
  <p><strong>How applets are connected to each other in my ecosystem?</strong></p>
  
  <ul>
  <li>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]</li>
  <li>In X applet's <strong><em>uninstall()</em></strong> method i am calling Y applet(via shared interface) and there i am releasing the reference of X applet.</li>
  </ul>
  
  <p><strong>Problem Scenario:</strong></p>
  
  <ul>
  <li>In offline mode via reader any time when i send delete command for X applet. It gets deleted successfully.</li>
  <li>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.] </li>
  </ul>
  
  <p><strong>Situation when Sim card in mobile</strong></p>
  
  <ul>
  <li><p>When server sends delete command for an X applet, in response i get 0x6985.</p></li>
  <li><p>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. </p></li>
  </ul>
  
  <p><strong>Situation when done with card reader not in mobile</strong></p>
  
  <ul>
  <li><p>With PCSC reader when delete command is sent to X. Applet X gets delete successfully.</p></li>
  <li><p>Y applet's buffer data confirms that call was received from X applet.</p></li>
  </ul>
  
  <blockquote>
    <p><strong>My Observation:</strong><br> 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.<br> 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. <br> Any help on this topic is much appreciated.</p>
  </blockquote>