Commit 3b77a048 authored by Sebastian Hans's avatar Sebastian Hans
Browse files

REL-9.4.0 as downloaded from the server

parent e44185b8
Loading
Loading
Loading
Loading
+129 −0
Original line number Original line Diff line number Diff line
package uicc.hci.test.framework.api_1_hdv_gpm;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import uicc.hci.framework.HCIDevice;
import uicc.hci.framework.HCIListener;
import uicc.hci.framework.HCIMessage;
import uicc.hci.services.cardemulation.CardEmulationListener;

/**
 * The method with the following header shall be compliant to its definition in the API.<br />
 * <code>public static byte getPowerMode()</code>
 *
 */
public class Api_1_Hdv_Gpm_1 extends Applet implements CardEmulationListener {
	
	 // Define specific SWs
	
	
	/**
	 * Status word: Full power mode 
	 */
	private final static short SW_FULL_POWER_MODE = ISO7816.SW_NO_ERROR + (short) 3;

	/**
	 * Status word: Low power mode 
	 */
	private final static short SW_LOW_POWER_MODE = ISO7816.SW_NO_ERROR + (short) 4;

	/**
	 * Status word: Power mode could't be retrieved
	 */
	private final static short SW_POWER_MODE_COULD_NOT_BE_RETRIEVED = ISO7816.SW_NO_ERROR + (short) 5;
	
	
	 // Define specific INS bytes for HCIDevice tests
	/**
	 * Instruction byte: Retrieve power mode
	 */
	private final static short INS_HELPER = (short) 0x01;
	private final static short INS_RETRIEVE_POWER_MODE = (short) 0x05;

	/**
	 * Default constructor, registers the applet.
	 */
	private Api_1_Hdv_Gpm_1() {		
		register();
	}
	
	/**
	 * To create an instance of the <code>Applet</code> subclass, the Java Card runtime environment will call this static method first.
	 * @see Applet#install(byte[], short, byte)
	 */
	public static void install(byte bArray[], short bOffset, byte bLength)
			throws ISOException {
		new Api_1_Hdv_Gpm_1();
	}

	/**
	 *  Called by the Java Card runtime environment to process an incoming APDU command.
	 *  @see Applet#process(APDU)
	 */
	public void process(APDU apdu) throws ISOException {
		/*
		 * Check for SELECT command
		 */
		if (selectingApplet())
			return;

		
		byte buffer[] = apdu.getBuffer();

		/*
		 * main switch
		 */
	
	    switch (buffer[ISO7816.OFFSET_INS]) {


	      case INS_HELPER:	    	  
	    	  return;	
	      case INS_RETRIEVE_POWER_MODE:	    	  
	    	  ISOException.throwIt(checkPowerMode(HCIDevice.getPowerMode()));	    	  
	    	  

	      default: 
	    	  ISOException.throwIt (ISO7816.SW_INS_NOT_SUPPORTED);
	    }
				

	}

	/**
	 * Checks the power mode an determine the according status word.  
	 * @param powerMode Value, taken from {@link HCIDevice#getPowerMode()}
	 * @return The according status word.
	 */
	private short checkPowerMode(byte powerMode){
		switch (powerMode) {
	      case HCIDevice.FULL_POWER_MODE: 	    	  
	        return SW_FULL_POWER_MODE;
	      case HCIDevice.LOW_POWER_MODE: 	    	  
	        return SW_LOW_POWER_MODE;
	      case (-1):     	  
	        return SW_POWER_MODE_COULD_NOT_BE_RETRIEVED;
	       
	      default: 
	    	  return ISO7816.SW_UNKNOWN;
		}
	}

	/**
	 * Not used
	 * This method is called by the HCI framework to inform the Listener Object about a specific event and pass the corresponding HCIMessage to the Listener Object.
	 * @see HCIListener#onCallback(byte, HCIMessage)
	 */
	public void onCallback(byte arg0, HCIMessage arg1) {
		
	}

}





+2.92 KiB

File added.

No diff preview for this file type.

+74 B

File added.

No diff preview for this file type.

+157 −0
Original line number Original line Diff line number Diff line
// converted by version 1.3
// on Thu Mar 19 11:50:01 CET 2015

.package uicc/hci/test/framework/api_1_hdv_gpm {
	.aid 0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x15:0x2:0x0:0x0;
	.version 1.0;

	.imports {
		0xA0:0x0:0x0:0x0:0x62:0x1:0x1 1.4;		//javacard/framework
		0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x16:0x1:0x0:0x0 1.1;		//uicc/hci/framework
		0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x16:0x2:0x1:0x0 1.0;		//uicc/hci/services/cardemulation
		0xA0:0x0:0x0:0x0:0x62:0x0:0x1 1.0;		//java/lang
	}

	.applet {
		0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x15:0x2:0x1:0x2 Api_1_Hdv_Gpm_1;
	}

	.constantPool {
		// 0
		staticMethodRef 0.3.0()V;		// javacard/framework/Applet.<init>()V
		// 1
		virtualMethodRef 0.3.1()V;		// register()V
		// 2
		classRef Api_1_Hdv_Gpm_1;
		// 3
		staticMethodRef Api_1_Hdv_Gpm_1/<init>()V;
		// 4
		virtualMethodRef 0.3.3()Z;		// selectingApplet()Z
		// 5
		virtualMethodRef 0.10.1()[B;		// getBuffer()[B
		// 6
		staticMethodRef 1.4.1()B;		// uicc/hci/framework/HCIDevice.getPowerMode()B
		// 7
		staticMethodRef Api_1_Hdv_Gpm_1/checkPowerMode(B)S;
		// 8
		staticMethodRef 0.7.1(S)V;		// javacard/framework/ISOException.throwIt(S)V
	}

	.class public Api_1_Hdv_Gpm_1 0 extends 0.3 {		// extends javacard/framework/Applet

		.shareable;

		.fields {
			private static final short SW_FULL_POWER_MODE = -28669;		// S
			private static final short SW_LOW_POWER_MODE = -28668;		// S
			private static final short SW_POWER_MODE_COULD_NOT_BE_RETRIEVED = -28667;		// S
			private static final short INS_HELPER = 1;		// S
			private static final short INS_RETRIEVE_POWER_MODE = 5;		// S
		}

		.publicMethodTable 7 {
			equals(Ljava/lang/Object;)Z;
			register()V;
			register([BSB)V;
			selectingApplet()Z;
			deselect()V;
			getShareableInterfaceObject(Ljavacard/framework/AID;B)Ljavacard/framework/Shareable;;
			select()Z;
			process(Ljavacard/framework/APDU;)V;
			onCallback(BLuicc/hci/framework/HCIMessage;)V;
		}

		.packageMethodTable 0 {
		}

		.implementedInterfaceInfoTable { 
			.interface 0.2 { 		// javacard/framework/Shareable
			}

			.interface 1.0 { 		// uicc/hci/framework/HCIListener
				8;		// onCallback(BLuicc/hci/framework/HCIMessage;)V
			}

			.interface 2.0 { 		// uicc/hci/services/cardemulation/CardEmulationListener
				8;		// onCallback(BLuicc/hci/framework/HCIMessage;)V
			}

		}

		.method private <init>()V {
			.stack 1;
			.locals 0;

				L0:	aload_0;
					invokespecial 0;		// javacard/framework/Applet.<init>()V
					aload_0;
					invokevirtual 1;		// register()V
					return;
		}

		.method public static install([BSB)V 0 {
			.stack 2;
			.locals 0;

				L0:	new 2;		// uicc/hci/test/framework/api_1_hdv_gpm/Api_1_Hdv_Gpm_1
					dup;
					invokespecial 3;		// uicc/hci/test/framework/api_1_hdv_gpm/Api_1_Hdv_Gpm_1.<init>()V
					pop;
					return;
		}

		.method public process(Ljavacard/framework/APDU;)V 7 {
			.stack 2;
			.locals 1;

			.descriptor	Ljavacard/framework/APDU;	0.10;

				L0:	aload_0;
					invokevirtual 4;		// selectingApplet()Z
					ifeq L2;
				L1:	return;
				L2:	aload_1;
					invokevirtual 5;		// getBuffer()[B
					astore_2;
					aload_2;
					sconst_1;
					baload;
					slookupswitch L5 2 1 L3 5 L4;
				L3:	return;
				L4:	aload_0;
					invokestatic 6;		// uicc/hci/framework/HCIDevice.getPowerMode()B
					invokespecial 7;		// uicc/hci/test/framework/api_1_hdv_gpm/Api_1_Hdv_Gpm_1.checkPowerMode(B)S
					invokestatic 8;		// javacard/framework/ISOException.throwIt(S)V
				L5:	sspush 27904;
					invokestatic 8;		// javacard/framework/ISOException.throwIt(S)V
					return;
		}

		.method private checkPowerMode(B)S {
			.stack 1;
			.locals 0;

				L0:	sload_1;
					stableswitch L4 -1 1 L3 L2 L1;
				L1:	sspush -28669;
					sreturn;
				L2:	sspush -28668;
					sreturn;
				L3:	sspush -28667;
					sreturn;
				L4:	sspush 28416;
					sreturn;
		}

		.method public onCallback(BLuicc/hci/framework/HCIMessage;)V 8 {
			.stack 0;
			.locals 0;

			.descriptor	Luicc/hci/framework/HCIMessage;	1.1;

				L0:	return;
		}

	}

}
+11 −0
Original line number Original line Diff line number Diff line
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Package contains Test Area References for the ETSI TS 102 705: Api_1_Hdv_Gpm<br />
    Method <code>getPowerMode</code> 
  </body>
</html>
Loading