This discussion is archived
0 Replies Latest reply: Aug 13, 2012 8:03 AM by 955490 RSS

How to trig an applet when a file is updated

955490 Newbie
Currently Being Moderated
I'm trying to develop an Applet which is triged each time a file is updated, using the event EVENT_EXTERNAL_FILE_UPDATE, I'm trying by the following code to update the file FPLMN (6F53) each time the file LOCIGPRS is updated, but it doesn’t work, could someone tell me what's wrong in my code? Thank you in advance:

package smRM2M ;

import javacard.framework.*;
import uicc.toolkit.*;
import uicc.toolkit.ToolkitException;
import uicc.access.*;

public class SmRM2M extends Applet implements ToolkitInterface, uicc.toolkit.ToolkitConstants
{
     private static FileView uiccView;
     private ToolkitRegistry reg;
     private static byte[] FPLMNContent={(byte) 0x01,(byte) 0x02,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF,(byte) 0xFF};
     
     private SmRM2M ()
     {
          register();          
          reg = ToolkitRegistrySystem.getEntry();
          uiccView = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT);
          uiccView.select((short) 0x3F00);
     uiccView.select((short) 0x7F20);
          uiccView.select((short) 0x6F53);
          reg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccView);
     }

     public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException
     {
          new SmRM2M ();
     }

     public void process(APDU arg0) throws ISOException
     {
          ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
     }
     
     public void processToolkit(short event) throws ToolkitException
     {
               switch (event)
               {
                    case EVENT_EXTERNAL_FILE_UPDATE:
               {     
                    uiccView = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT);
                         uiccView.select((short) 0x3F00);
                    uiccView.select((short) 0x7F20);
                    uiccView.select((short) 0x6F7B);
                         uiccView.updateBinary((short)0, FPLMNContent, (short)0, (short)12);
                         break;
                    }
               }
     }
     
     public Shareable getShareableInterfaceObject(AID aid, byte p)
     {
               if (aid == null && p == (byte)1)
               {
               return this ;
               }
               return null ;
     }
}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points