aboutsummaryrefslogtreecommitdiffstats
path: root/nxp-nfc-gsma/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'nxp-nfc-gsma/java/com')
-rwxr-xr-xnxp-nfc-gsma/java/com/gsma/services/nfc/AidGroup.java96
-rwxr-xr-xnxp-nfc-gsma/java/com/gsma/services/nfc/NfcController.java392
-rwxr-xr-xnxp-nfc-gsma/java/com/gsma/services/nfc/OffHostService.java346
-rwxr-xr-xnxp-nfc-gsma/java/com/gsma/services/nfc/SEController.java94
-rwxr-xr-xnxp-nfc-gsma/java/com/gsma/services/utils/Handset.java126
-rwxr-xr-xnxp-nfc-gsma/java/com/gsma/services/utils/InsufficientResourcesException.java40
6 files changed, 0 insertions, 1094 deletions
diff --git a/nxp-nfc-gsma/java/com/gsma/services/nfc/AidGroup.java b/nxp-nfc-gsma/java/com/gsma/services/nfc/AidGroup.java
deleted file mode 100755
index 48f7fa2..0000000
--- a/nxp-nfc-gsma/java/com/gsma/services/nfc/AidGroup.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/******************************************************************************
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Copyright 2018 NXP
-*
-******************************************************************************/
-package com.gsma.services.nfc;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class handles group of AID defined in an "Off-Host" service
- * @since NFCHST6.0 <I>(REQ_127)</I>
- */
-public class AidGroup {
- private String mDescription = null;
- private String mCategory = null;
- private List<String> mAidList = new ArrayList<String>();
-
- AidGroup() {}
-
- AidGroup(String description, String category) {
- mDescription = description;
- mCategory = category;
- }
-
- /**
- * Return the category of the group of AIDs.
- * @return Category of the group of AIDs:<BR><UL>
- * <LI><code>android.nfc.cardemulation.CardEmulation.CATEGORY_PAYMENT</code></LI>
- * <LI><code>android.nfc.cardemulation.CardEmulation.CATEGORY_OTHER</code></IL></UL>
- * @since NFCHST6.0
- */
- public String getCategory() {
- return mCategory;
- }
-
- /**
- * Return the description of the group of AIDs.
- * @return The description of the group of AIDs
- * @since NFCHST6.0
- */
- public String getDescription() {
- return mDescription;
- }
-
- /**
- * Add a new AID to the current group.
- * @param aid Application IDentifier to add to the current group
- * @exception IllegalArgumentException <BR>Indicate that a method has been passed an illegal or inappropriate argument.
- * @since NFCHST6.0
- */
- public void addNewAid(String aid) {
- if((aid != null) && !(aid.isEmpty())){
- mAidList.add(aid.toUpperCase());
- }else{
- throw new IllegalArgumentException("Invalid AID");
- }
- }
-
- /**
- * Remove an AID from the current group.
- * @param aid Application IDentifier to remove from the current group
- * @exception IllegalArgumentException <BR>Indicate that a method has been passed an illegal or inappropriate argument.
- * @since NFCHST6.0
- */
- public void removeAid(String aid) {
- if((aid != null) && !(aid.isEmpty())){
- mAidList.remove(aid);
- }else{
- throw new IllegalArgumentException("Invalid AID");
- }
- }
-
- public List<String> getAidList() {
- return mAidList;
- }
-
- public String[] getAids() {
- String [] aidArray = mAidList.toArray(new String[mAidList.size()]);
- return aidArray;
- }
-
-}
diff --git a/nxp-nfc-gsma/java/com/gsma/services/nfc/NfcController.java b/nxp-nfc-gsma/java/com/gsma/services/nfc/NfcController.java
deleted file mode 100755
index 6a1e31f..0000000
--- a/nxp-nfc-gsma/java/com/gsma/services/nfc/NfcController.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/******************************************************************************
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Copyright 2018 NXP
-*
-******************************************************************************/
-package com.gsma.services.nfc;
-
-import android.content.Context;
-import android.util.Log;
-import android.app.AlertDialog;
-import android.app.ActivityManager;
-import android.content.Intent;
-import android.widget.Toast;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.HashMap;
-import java.util.Random;
-
-import android.util.Log;
-import android.view.View.OnClickListener;
-import android.content.DialogInterface;
-import android.app.Activity;
-import com.nxp.nfc.gsma.internal.NxpHandset;
-import com.nxp.nfc.gsma.internal.NxpNfcController;
-import com.nxp.nfc.gsma.internal.NxpNfcController.NxpCallbacks;
-import com.nxp.nfc.gsma.internal.NxpOffHostService;
-import com.gsma.services.utils.InsufficientResourcesException;
-import android.os.UserHandle;
-/**
- * This class handles the NFC Controller
- * @since NFCHST4.1
- */
-public class NfcController {
-
- static final String TAG = "NfcController";
- /**
- * The NfcController object for each application context.
- * There is a 1-1 relationship between application context and
- * NfcController object.
- */
- private static HashMap<Context, NfcController> sNfcController = new HashMap();
-
- /** Device property [Battery levels]*/
- private static final int BATTERY_OPERATIONAL_MODE=0x92;
-
- private ArrayList<OffHostService> mOffHostServiceList = new ArrayList<OffHostService>();
- private NxpNfcController mNxpNfcController = null;
- private HashMap<String, OffHostService> mOffhostService = new HashMap<String, OffHostService>();
- private Context mContext;
- private NfcController.Callbacks mCb;
- private int mUserId;
- private NxpHandset mNxpHandset = null;
- private NxpNfcControllerCallback mNxpCallback = null;
-
- NfcController() {
- mUserId = UserHandle.myUserId();
- mNxpHandset = new NxpHandset();
- mNxpCallback = new NxpNfcControllerCallback();
- mNxpNfcController = new NxpNfcController();
- }
-
- NfcController(Context context) {
- mContext = context;
- mNxpHandset = new NxpHandset();
- mNxpCallback = new NxpNfcControllerCallback();
- mNxpNfcController = new NxpNfcController(context);
- mUserId = UserHandle.myUserId();
- }
-
- /** <code>NFC_RF_TECHNOLOGY_A</code> as defined by
- * <a href="http://www.nfc-forum.org" target="_blank">NFC Controller Interface (NCI)</a> specification*/
- public static final int TECHNOLOGY_NFC_A=0x01;
- /** <code>NFC_RF_TECHNOLOGY_B</code> as defined by
- * <a href="http://www.nfc-forum.org" target="_blank">NFC Controller Interface (NCI)</a> specification*/
- public static final int TECHNOLOGY_NFC_B=0x02;
- /** <code>NFC_RF_TECHNOLOGY_F</code> as defined by
- * <a href="http://www.nfc-forum.org" target="_blank">NFC Controller Interface (NCI)</a> specification*/
- public static final int TECHNOLOGY_NFC_F=0x04;
-
- /** <code>PROTOCOL_ISO_DEP</code> as defined by
- * <a href="http://www.nfc-forum.org" target="_blank">NFC Controller Interface (NCI)</a> specification*/
- public static final int PROTOCOL_ISO_DEP=0x10;
-
- /** Battery of the handset is in "Operational" mode*/
- public static final int BATTERY_OPERATIONAL_STATE=0x01;
- /** Any battery power levels*/
- public static final int BATTERY_ALL_STATES=0x02;
-
- /** Screen is "ON" (not in "Screen Off" mode) and locked*/
- public static final int SCREEN_ON_AND_LOCKED_MODE=0x01;
- /** Any screen mode*/
- public static final int SCREEN_ALL_MODES=0x02;
-
-
- // Callback interface
-
- /**
- * This interface provide callback methods for {@link NfcController} class
- * @since NFCHST4.1
- */
- public static interface Callbacks {
-
- /** Card Emulation mode has been disabled*/
- public static final int CARD_EMULATION_DISABLED=0x00;
- /** Card Emulation mode has been enabled*/
- public static final int CARD_EMULATION_ENABLED=0x01;
- /** An error occurred when handset tried to enable/disable Card Emulation mode*/
- public static final int CARD_EMULATION_ERROR=0x100;
-
- /**
- * Called when process for getting the default Controller is finished.
- * @param controller Instance of default controller or <code>null</code> if an error occurred
- * @since NFCHST5.0
- */
- public abstract void onGetDefaultController(NfcController controller);
-
- /**
- * Called when process for enabling the NFC Controller is finished.
- * @param success <code>true</code> if the NFC adapter is enabled; <code>false</code> otherwise
- * @since NFCHST5.0
- */
- public abstract void onEnableNfcController(boolean success);
-
- /**
- * Called when process for enabling/disabling the Card Emulation mode is finished.
- * @param status Status of the Card Emulation mode as defined below<BR>
- * {@link Callbacks#CARD_EMULATION_DISABLED}, {@link Callbacks#CARD_EMULATION_ENABLED},
- * {@link Callbacks#CARD_EMULATION_ERROR}
- * @since NFCHST4.1
- * @deprecated <a style="color:#FF0000">When Host Card Emulation (HCE) is supported</a>
- */
- public abstract void onCardEmulationMode(int status);
-
- }
-
-
- public class NxpNfcControllerCallback implements NxpCallbacks {
-
- public void onNxpEnableNfcController(boolean success) {
- if(success == true) {
- mCb.onEnableNfcController(true);
- Log.d(TAG, "NFC Enabled");
- } else {
- mCb.onEnableNfcController(false);
- Log.d(TAG, "NFC Not Enabled");
- }
- }
- }
-
- // Handling the NFC Controller
-
- /**
- * Helper for getting an instance of the NFC Controller.
- * @param context Calling application's context
- * @param callbacks Callback interface
- * @since NFCHST4.1
- */
- public static void getDefaultController(Context context, NfcController.Callbacks callbacks) {
- if (context == null || callbacks == null) {
- throw new IllegalArgumentException("context or NfcController.Callbacks cannot be null");
- }
- NfcController controller = new NfcController(context);
- callbacks.onGetDefaultController(controller);
- }
-
-
- /**
- * Check if the NFC Controller is enabled or disabled.
- * @return <code>true</code> if the NFC adapter is enabled; <code>false</code> otherwise
- * @since NFCHST4.1 <I>(REQ_093)</I>
- */
- public boolean isEnabled() {
- return mNxpNfcController.isNxpNfcEnabled();
- }
-
- /**
- * Asks the system to enable the NFC Controller. User input is required to enable NFC.<BR>
- * A question will be asked if the user wants to enable NFC or not.
- * <center><img src="EnableNfcController.png" width="40%" height="40%"/></center><BR>
- * This question shall be generated within the OS context.
- * @param cb Callback interface
- * @since NFCHST4.1 <I>(REQ_093)</I>
- */
- public void enableNfcController(NfcController.Callbacks cb) {
- mCb =cb;
- if(isEnabled()) {
- mCb.onEnableNfcController(true);
- } else {
- mNxpNfcController.enableNxpNfcController(mNxpCallback);
- }
- }
-
- // Handling Card Emulation
- /**
- * Check if the Card Emulation mode is enabled or disabled.
- * @return <code>true</code> if the Card Emulation mode is enabled; <code>false</code> otherwise
- * @since NFCHST4.1 <I>(REQ_126)</I>
- * @deprecated <a style="color:#FF0000">When Host Card Emulation (HCE) is supported</a>
- */
- @Deprecated
- public boolean isCardEmulationEnabled() throws Exception {
- throw new InsufficientResourcesException("Host Card Emulation (HCE) is supported");
- }
-
- /**
- * Asks the system to enable the Card Emulation mode.<BR>
- * Change is not persistent and SHALL be overridden by the following events:<UL>
- * <LI>Turning OFF and ON the NFC Controller</LI>
- * <LI>Full power cycle of the handset</LI></UL>
- * @param cb Callback interface
- * @exception IllegalStateException <BR>Indicate that NFC Controller is not enabled.
- * @exception SecurityEception <BR>Indicate that application is not allowed to use this API.<UL>
- * <LI>When UICC is the "active" SE,
- * <BR>only applications signed with certificates stored in the UICC are granted to call this API.</LI>
- * <LI>When eSE is the "active" SE,
- * <BR>only applications signed with system certificates are granted to call this API.</LI></UL>
- * @since NFCHST4.1 <I>(REQ_126)</I>
- * @deprecated <a style="color:#FF0000">When Host Card Emulation (HCE) is supported</a>
- */
- @Deprecated
- public void enableCardEmulationMode(NfcController.Callbacks cb) throws Exception {
- throw new InsufficientResourcesException("Host Card Emulation (HCE) is supported");
-
- }
-
- /**
- * Asks the system to disable the Card Emulation mode.<BR>
- * Change is not persistent and SHALL be overridden by the following events:<UL>
- * <LI>Turning OFF and ON the NFC Controller</LI>
- * <LI>Full power cycle of the handset</LI></UL>
- * @param cb Callback interface
- * @exception SecurityException <BR>Indicate that application is not allowed to use this API.<UL>
- * <LI>When UICC is the "active" SE,
- * <BR>only applications signed with certificates stored in the UICC are granted to call this API.</LI>
- * <LI>When eSE is the "active" SE,
- * <BR>only applications signed with system certificates are granted to call this API.</LI></UL>
- * @since NFCHST4.1 <I>(REQ_126)</I>
- * @deprecated <a style="color:#FF0000">When Host Card Emulation (HCE) is supported</a>
- */
- @Deprecated
- public void disableCardEmulationMode(NfcController.Callbacks cb) throws Exception {
- throw new InsufficientResourcesException("Host Card Emulation (HCE) is supported");
- }
-
- /**
- * Generate random number for creating service name
- */
- private String getRandomString() {
- Random random = new Random();
- int randomNum = 10000 + random.nextInt(10000);
- return new String("service" + Integer.toString(randomNum));
- }
-
- // Handling AID routes
- /**
- * Create a new "Off-Host" service.
- * @param description Description of the "Off-Host" service
- * @param SEName Secure Element name holding the "Off-Host" service
- * @exception UnsupportedOperationException <BR>Indicate that Host Card Emulation (HCE) is not supported.
- * @return An instance of an {@link OffHostService} class
- * @since NFCHST6.0 <I>(REQ_127)</I>
- */
- public OffHostService defineOffHostService(String description, String SEName) {
- boolean modifiable = true;
- int i = 0;
- if(description == null){
- throw new IllegalArgumentException("Invalid description provided");
- }
-
- if((SEName == null) || (SEName.isEmpty())){
- throw new IllegalArgumentException("Invalid SEName provided");
- }
- String sSEName = SEName;
- if(sSEName.equals("SIM")){
- sSEName+=Integer.toString(1);
- }
- List<String> secureElementList = new ArrayList<String>(0x03);
- secureElementList = mNxpHandset.getAvailableSecureElements(BATTERY_OPERATIONAL_MODE);
-
- if(secureElementList.size() > 0)
- {
- for(i =0; i< secureElementList.size(); i++) {
- if(secureElementList.get(i).equals(sSEName))
- break;
- }
- if(i == secureElementList.size())
- {
- throw new IllegalArgumentException("Invalid SEName provided");
- }
- }
-
- String packageName = mContext.getPackageName();
- String serviceName = getRandomString();
- NxpOffHostService offHostService = new NxpOffHostService(mUserId, description, SEName, packageName,serviceName, modifiable);
- offHostService.setContext(mContext);
- offHostService.setNxpNfcController(mNxpNfcController);
- return new OffHostService(offHostService);
- }
-
- /**
- * Delete an existing dynamically created "Off-Host" service.
- * @param service Instance of an {@link OffHostService} class to be deleted
- * @since NFCHST6.0 <I>(REQ_127)</I>
- */
- public void deleteOffHostService(OffHostService service) {
- String packageName = mContext.getPackageName();
-
- if(service == null){
- throw new IllegalArgumentException("Invalid service provided");
- } else if(mNxpNfcController.isStaticOffhostService(mUserId, packageName, convertToNxpOffhostService(service))) {
- throw new UnsupportedOperationException("Service has been defined in Manifest and cannot be deleted");
- }
-
- mNxpNfcController.deleteOffHostService(mUserId, packageName, convertToNxpOffhostService(service));
- }
-
- /**
- * Return a list of "Off-Host" services created dynamically by the calling application.<BR>
- * <BR><I>Note: In the next release, if it is not breaking "Android CDD",<BR>
- * it is planned also to support "Off-Host" services registered statically (Manifest)</I>
- * @return A list of {@link OffHostService} instances or <code>null</code> if no such instance exists.
- * @since NFCHST6.0 <I>(REQ_127)</I>
- */
- public OffHostService[] getOffHostServices() {
- String packageName = mContext.getPackageName();
- ArrayList<NxpOffHostService> mNxpOffhost = mNxpNfcController.getOffHostServices(mUserId, packageName);
- if((mNxpOffhost == null) ||(mNxpOffhost.isEmpty())){
- return null;
- }
- ArrayList<OffHostService> mOffHostList = new ArrayList<OffHostService>();
- for(NxpOffHostService mHost : mNxpOffhost) {
- OffHostService mOffHost = new OffHostService(mHost);
- mOffHostList.add(mOffHost);
- }
- OffHostService offHostServices[] = new OffHostService[mOffHostList.size()];
- return mOffHostList.toArray(offHostServices);
- }
-
- /**
- * Return the "Off-Host" service related to the current selected "Tap&Pay" menu entry.
- * @return A {@link OffHostService} instance or <code>null</code> if<UL>
- * <LI>The "Tap&Pay" menu entry has not been created by the calling application</IL>
- * <LI>The "Tap&Pay" menu entry has not been created dynamically</IL></UL>
- * @since NFCHST6.0 <I>(REQ_127)</I>
- */
- public OffHostService getDefaultOffHostService() {
- String packageName = mContext.getPackageName();
- NxpOffHostService service = mNxpNfcController.getDefaultOffHostService(mUserId, packageName);
- if(service != null) {
- return new OffHostService(service);
- }
- return null;
- }
- private ArrayList<android.nfc.cardemulation.NfcAidGroup> convertToCeAidGroupList(List<com.gsma.services.nfc.AidGroup> mAidGroups) {
- ArrayList<android.nfc.cardemulation.NfcAidGroup> mApduAidGroupList = new ArrayList<android.nfc.cardemulation.NfcAidGroup>();
- android.nfc.cardemulation.NfcAidGroup mCeAidGroup = null;
- List<String> aidList = new ArrayList<String>();
- for(com.gsma.services.nfc.AidGroup mGroup : mAidGroups) {
- if(!mGroup.getAidList().isEmpty())
- {
- mCeAidGroup = new android.nfc.cardemulation.NfcAidGroup(mGroup.getCategory(), mGroup.getDescription());
- aidList = mCeAidGroup.getAids();
- for(String aid :mGroup.getAidList()) {
- aidList.add(aid);
- }
- mApduAidGroupList.add(mCeAidGroup);
- }
- }
- return mApduAidGroupList;
- }
- private NxpOffHostService convertToNxpOffhostService(OffHostService service) {
- ArrayList<android.nfc.cardemulation.NfcAidGroup> mAidGroupList = convertToCeAidGroupList(service.mAidGroupList);
- NxpOffHostService mNxpOffHostService = new NxpOffHostService(service.mUserId,service.mDescription, service.mSEName, service.mPackageName, service.mServiceName, service.mModifiable);
- mNxpOffHostService.setBanner(service.mBanner);
- mNxpOffHostService.setContext(mContext);
- mNxpOffHostService.setBannerId(service.mBannerResId);
- mNxpOffHostService.mNfcAidGroupList.addAll(mAidGroupList);
- return mNxpOffHostService;
- }
-}
diff --git a/nxp-nfc-gsma/java/com/gsma/services/nfc/OffHostService.java b/nxp-nfc-gsma/java/com/gsma/services/nfc/OffHostService.java
deleted file mode 100755
index 16cd958..0000000
--- a/nxp-nfc-gsma/java/com/gsma/services/nfc/OffHostService.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/******************************************************************************
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Copyright 2018 NXP
-*
-******************************************************************************/
-package com.gsma.services.nfc;
-
-import android.app.ActivityThread;
-import android.content.pm.PackageManager;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.Bitmap;
-import dalvik.system.DexClassLoader;
-import android.nfc.cardemulation.CardEmulation;
-import android.util.Log;
-
-import com.gsma.services.utils.InsufficientResourcesException;
-import com.gsma.services.nfc.OffHostService;
-
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import com.nxp.nfc.gsma.internal.NxpNfcController;
-import com.nxp.nfc.gsma.internal.NxpOffHostService;
-/**
- * This class handles "Off-Host" services
- * @since NFCHST6.0 <I>(REQ_127)</I>
- */
-public class OffHostService {
- int mUserId;
- String mDescription = null;
- String mSEName = null;
- Drawable mBanner;
- String mPackageName = null;
- String mServiceName = null;
- boolean mModifiable = true;
- List<AidGroup> mAidGroupList = new ArrayList<AidGroup>();
- NxpNfcController mNxpNfcController = null;
- int mBannerResId;
- Context mContext = null;
- static final String TAG = "OffHostService";
-
- protected OffHostService(int userId, String description, String SELocation,String packageName,
- String serviceName, boolean modifiable) {
- mBannerResId = 0x00;
- mUserId = userId;
- mDescription = description;
- mSEName = SELocation;
- mPackageName = packageName;
- mServiceName = serviceName;
- mModifiable = modifiable; // It will distinguish between static service and dynamic services
- }
-
- protected OffHostService(NxpOffHostService service) {
- mUserId = service.mUserId;
- mDescription = service.mDescription;
- mSEName = service.mSEName;
- mPackageName = service.mPackageName;
- mServiceName = service.mServiceName;
- mModifiable = service.mModifiable; // It will distinguish between static service and dynamic services
- mAidGroupList = convertToOffHostAidGroupList(service.mNfcAidGroupList);
- mBanner = service.mBanner;
- mBannerResId = service.getBannerId();
- mContext = service.getContext();
- mNxpNfcController = service.mNxpNfcController;
-
- PackageManager pManager = mContext.getPackageManager();
- //final String packName = mContext.getPackageName();
- if (mBannerResId > 0) {
- try {
- Log.d(TAG, "setBannerResId(): getDrawable() with mBannerResId=" + String.valueOf(mBannerResId));
- mBanner = pManager.getResourcesForApplication(mPackageName).getDrawable(mBannerResId,null);
- } catch (Exception e) {
- Log.e(TAG, "Exception : " + e.getMessage());
- }
- }
- }
-
- /**
- * Return the Secure Element name which holds the "Off-Host" service.
- * @return Secure Element name holding the "Off-Host" service
- * @since NFCHST6.0
- */
- public String getLocation() {
- return mSEName;
- }
-
- /**
- * Return the description of the "Off-Host" service.
- * @return The Description of the "Off-Host" service
- * @since NFCHST6.0
- */
- public String getDescription() {
- return mDescription;
- }
-
- /**
- * Return the Service Name of the "Off-Host" service.
- * @return The Service name of the "Off-Host" service
- * @since NFCHST6.0
- */
- protected String getServiceName() {
- return mServiceName;
- }
-
- /**
- * Set a banner for the "Off-Host" service.
- * @param banner A {@link Drawable} object representing the banner
- * @since NFCHST6.0
- */
- public void setBanner(Drawable banner) {
- //mBanner = banner;
- PackageManager pManager = mContext.getPackageManager();
- final String packName = mPackageName; //mNfcController.mContext.getPackageName();
- Log.d(TAG, "setBanner() Resources packName: " + packName);
- try {
- for (int i = 0; i < Class.forName(packName + ".R").getClasses().length; i++) {
- if(Class.forName(packName + ".R").getClasses()[i].getName().split("\\$")[1].equals("drawable")) {
- if(Class.forName(packName + ".R").getClasses()[i] != null) {
- Field[] f = Class.forName(packName + ".R").getClasses()[i].getDeclaredFields();
- for (int counter = 0, max = f.length; counter < max; counter++) {
- int resId = f[counter].getInt(null);
- Drawable d = pManager.getResourcesForApplication(packName).getDrawable(resId,null);
- if ( areDrawablesEqual(banner,d) ) {
- mBannerResId = resId;
- mBanner = d;
- Log.d(TAG, "setBanner() Resources GOT THE DRAWABLE On loop "
- + String.valueOf(counter) + "got resId : " + String.valueOf(resId));
- break;
- }
- }
- break;
- }
- }
- }
- } catch (Exception e) {
- Log.d(TAG, "setBanner() Resources exception ..." + e.getMessage());
- e.printStackTrace();
- }
- if(mBannerResId == 0x00) {
- Log.d(TAG, "bannerId set to 0");
- mBannerResId = -1;
- mBanner = banner;
- }
- }
-
- /**
- * Set a banner for the "Off-Host" service.
- * @param resourceId The desired resource identifier.
- * <LI> The value 0 is an invalid identifier </LI>
- * @exception Resources.NotFoundException <BR>Indicate that the given resourceId does not exist.
- * @since NFCHST8.0
- */
- //Set a banner for the "Off-Host" service.
- public void setBanner(int bannerResId){
- Log.d(TAG, "setBannerResId() with " + String.valueOf(bannerResId));
- mBannerResId = bannerResId;
-
- PackageManager pManager = mContext.getPackageManager();
- final String packName = mContext.getPackageName();
- if (mBannerResId > 0) {
- try {
- Log.d(TAG, "setBannerResId(): getDrawable() with mBannerResId=" + String.valueOf(mBannerResId));
- mBanner = pManager.getResourcesForApplication(packName).getDrawable(mBannerResId,null);
- } catch (Exception e) {
- Log.e(TAG, "Exception : " + e.getMessage());
- }
- }
- }
-
- /**
- * Get a modifiable for dynamic "Off-Host" service.
- * @return modifiable for "Off-Host service
- * @since NFCHST6.0
- */
- protected boolean getModifiable() {
- return mModifiable;
- }
-
- /**
- * Return the banner linked to the "Off-Host" service.
- * @return {@link Drawable} object representing the banner or <code>null</code> if no banner has been set
- * @since NFCHST6.0
- */
- public Drawable getBanner() {
- return mBanner;
- }
-
- /**
- * Create a new empty group of AIDs for the "Off-Host" service.
- * @param description Description of the group of AIDs
- * @param category Category the "Off-Host" service belongs to:<BR><UL>
- * <LI><code>android.nfc.cardemulation.CardEmulation.CATEGORY_PAYMENT</code></IL>
- * <LI><code>android.nfc.cardemulation.CardEmulation.CATEGORY_OTHER</code></IL></UL>
- * @return An instance of an {@link AidGroup} class
- * @since NFCHST6.0
- */
- public AidGroup defineAidGroup(String description, String category) {
- if(description == null){
- throw new IllegalArgumentException("Invalid description provided");
- }
- if((category == null) || (category.isEmpty()) ||
- ((category.compareTo(CardEmulation.CATEGORY_OTHER)!=0) &&
- (category.compareTo(CardEmulation.CATEGORY_PAYMENT)!=0))){
- throw new IllegalArgumentException("Invalid category provided");
- }
- AidGroup aidGroup = new AidGroup(description,category);
- mAidGroupList.add(aidGroup);
- return aidGroup;
- }
-
- /**
- * Delete an existing AID group from the "Off-Host" service.
- * @param group Instance of an {@link AidGroup} class to be deleted
- * @since NFCHST6.0
- */
- public void deleteAidGroup(AidGroup group) {
- mAidGroupList.remove(group);
- }
-
- /**
- * Return a list of the AID groups linked to the "Off-Host" service.
- * @return A list of {@link AidGroup} instances or <code>null</code> if no such instance exists.
- * @since NFCHST6.0
- */
- public AidGroup[] getAidGroups() {
- if(mAidGroupList.size() != 0){
- AidGroup aidGroup[] = new AidGroup[mAidGroupList.size()];
- return mAidGroupList.toArray(aidGroup);
- } else {
- return null;
- }
- }
-
- private ArrayList<android.nfc.cardemulation.NfcAidGroup> convertToCeAidGroupList(List<com.gsma.services.nfc.AidGroup> mAidGroups) {
- ArrayList<android.nfc.cardemulation.NfcAidGroup> mApduAidGroupList = new ArrayList<android.nfc.cardemulation.NfcAidGroup>();
- android.nfc.cardemulation.NfcAidGroup mCeAidGroup = null;
- List<String> aidList = new ArrayList<String>();
- for(com.gsma.services.nfc.AidGroup mGroup : mAidGroups) {
- for(String aid :mGroup.getAidList()) {
- aidList.add(aid);
- }
- mCeAidGroup = new android.nfc.cardemulation.NfcAidGroup(aidList, mGroup.getCategory(), mGroup.getDescription());
- mApduAidGroupList.add(mCeAidGroup);
- }
- return mApduAidGroupList;
- }
-
- private NxpOffHostService convertToNxpOffhostService(OffHostService service) {
- ArrayList<android.nfc.cardemulation.NfcAidGroup> mAidGroupList = convertToCeAidGroupList(service.mAidGroupList);
- NxpOffHostService mNxpOffHostService = new NxpOffHostService(service.mUserId,service.mDescription, service.mSEName, service.mPackageName, service.mServiceName,
- service.mModifiable);
- mNxpOffHostService.setBanner(service.mBanner);
- mNxpOffHostService.setBannerId(service.mBannerResId);
- mNxpOffHostService.mNfcAidGroupList.addAll(mAidGroupList);
- return mNxpOffHostService;
- }
-
- /**
- * Update the Android Framework with all pending updates.
- * @exception InsufficientResourcesException <BR>Indicate that insufficient resources are available in the routing table.
- * @since NFCHST6.0
- */
- public void commit() throws InsufficientResourcesException{
- boolean status = false;
- // if(mModifiable ==true) {
- Log.d(TAG, "GSMA: banner ResId=" + String.valueOf(mBannerResId));
- Log.d(TAG, "GSMA: banner =" + String.valueOf(mBanner));
- status = mNxpNfcController.commitOffHostService(mUserId, mPackageName, convertToNxpOffhostService(this));
- Log.d("GSMA", " commit status value" + status);
- if(status == false)
- throw new InsufficientResourcesException("Routing Table is Full, Cannot Commit");
- // } else {
- // throw new InsufficientResourcesException("OffHostService: Cannot Commit static off host Service");
- // }
- }
- private void setNxpNfcController(NxpNfcController nxpNfcController) {
- mNxpNfcController = nxpNfcController;
- }
-
- private ArrayList<com.gsma.services.nfc.AidGroup> convertToOffHostAidGroupList(List<android.nfc.cardemulation.NfcAidGroup> mAidGroups) {
- ArrayList<com.gsma.services.nfc.AidGroup> mOffHostAidGroups= new ArrayList<com.gsma.services.nfc.AidGroup>();
- com.gsma.services.nfc.AidGroup mAidGroup;
- String aidGroupDescription = "";
- for(android.nfc.cardemulation.NfcAidGroup mCeAidGroup: mAidGroups) {
- if(mCeAidGroup.getDescription() == null) {
- aidGroupDescription = "";
- }
- else {
- aidGroupDescription = mCeAidGroup.getDescription();
- }
- mAidGroup = defineAidGroup(aidGroupDescription, mCeAidGroup.getCategory());
- for(String aid : mCeAidGroup.getAids()) {
- mAidGroup.addNewAid(aid);
- }
- mOffHostAidGroups.add(mAidGroup);
- }
- return mOffHostAidGroups;
- }
-
- /*Compare drawable resources(ex: .png/.jpg/.bmp/..)
- * Description: if constantState of two drawables are equal, then Drawables are equal
- * However converse of it is not necessarily true.
- * In case ConstantState's are not equal, their bitmaps are compared.*/
- private boolean areDrawablesEqual(Drawable drawableA, Drawable drawableB) {
- Drawable.ConstantState stateA = drawableA.getConstantState();
- Drawable.ConstantState stateB = drawableB.getConstantState();
- if(stateA != null && stateB != null && stateA.equals(stateB))
- return true;
- else if(areDrawableBitmapsEqual(drawableA,drawableB))
- return true;
- else
- return false;
- }
-
- private boolean areDrawableBitmapsEqual(Drawable drawableA, Drawable drawableB) {
- boolean result =false;
- if (drawableA instanceof BitmapDrawable) {
- if (drawableB instanceof BitmapDrawable) {
- Bitmap bitmapA = ((BitmapDrawable) drawableA).getBitmap();
- Bitmap bitmapB = ((BitmapDrawable) drawableB).getBitmap();
- if (bitmapA.getWidth() == bitmapB.getWidth() &&
- bitmapA.getHeight() == bitmapB.getHeight()) {
- if(bitmapA.sameAs(bitmapB))
- result =true;
- }
- }
- }
- return result;
- }
-
-}
diff --git a/nxp-nfc-gsma/java/com/gsma/services/nfc/SEController.java b/nxp-nfc-gsma/java/com/gsma/services/nfc/SEController.java
deleted file mode 100755
index 43d9c8e..0000000
--- a/nxp-nfc-gsma/java/com/gsma/services/nfc/SEController.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/******************************************************************************
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Copyright 2018 NXP
-*
-******************************************************************************/
-package com.gsma.services.nfc;
-
-import android.content.Context;
-import java.io.IOException;
-
-/**
- * This class handles the available Secure Elements
- * @since NFCHST4.1 <I>(REQ_126)</I>
- * @deprecated <a style="color:#FF0000">When Host Card Emulation (HCE) is supported</a>
- */
-@Deprecated
-public class SEController {
-
- SEController() {}
-
-
- // Callback interface
-
- /**
- * This interface provide callback methods for {@link SEController} class
- * @since NFCHST4.1
- * @deprecated <a style="color:#FF0000">When Host Card Emulation (HCE) is supported</a>
- */
- public static interface Callbacks {
-
- /**
- * Called when process for getting the default Controller is finished.
- * @param controller Instance of default controller or <code>null</code> if an error occurred
- * @since NFCHST4.1
- */
- public abstract void onGetDefaultController(SEController controller);
-
- }
-
-
- // Handling the SE Controller
-
- /**
- * Helper for getting an instance of the SE Controller.
- * @param context Calling application's context
- * @param cb Callback interface
- * @since NFCHST4.1
- * @deprecated .
- * @throws IOException
- */
- @Deprecated
- public static void getDefaultController(Context context, SEController.Callbacks cb) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the name of the active Secure Element.
- * @return Name of the active Secure Element
- * @since NFCHST4.1 <I>(REQ_126)</I>
- * @deprecated .
- * @throws IOException
- */
- @Deprecated
- public String getActiveSecureElement() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Set a specified Secure Element as "active" one.
- * @param SEName Secure Element name
- * @exception IllegalStateException <BR>Indicate that NFC Controller is not enabled.
- * @exception SecurityException <BR>Indicate that application SHALL be signed with a trusted certificate for using this API.
- * @since NFCHST4.1 <I>(REQ_126)</I>
- * @deprecated .
- * @throws IOException
- */
- @Deprecated
- public void setActiveSecureElement(String SEName) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/nxp-nfc-gsma/java/com/gsma/services/utils/Handset.java b/nxp-nfc-gsma/java/com/gsma/services/utils/Handset.java
deleted file mode 100755
index 687cf65..0000000
--- a/nxp-nfc-gsma/java/com/gsma/services/utils/Handset.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/******************************************************************************
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Copyright 2018 NXP
-*
-******************************************************************************/
-package com.gsma.services.utils;
-
-import com.nxp.nfc.gsma.internal.NxpHandset;
-import android.content.Context;
-import android.util.Log;
-import java.util.List;
-/**
- * This class handles the handset configuration & properties
- * @since NFCHST6.0
- */
-public class Handset {
-
- /** Device property [Contactless Frontend]*/
- public static final int HCI_SWP=0x00;
- /** Device property [Contactless Frontend]*/
- public static final int MULTIPLE_ACTIVE_CEE=0x01;
-
- /** Device property [NFC Technologies]*/
- public static final int FELICA=0x20;
- /** Device property [NFC Technologies]*/
- public static final int MIFARE_CLASSIC=0x21;
- /** Device property [NFC Technologies]*/
- public static final int MIFARE_DESFIRE=0x22;
- /** Device property [NFC Technologies]*/
- public static final int NFC_FORUM_TYPE3=0x23;
-
- /** Device property [Framework components]*/
- public static final int OMAPI=0x50;
-
- /** Device property [Battery Levels]*/
- public static final int BATTERY_LOW_MODE=0x90;
- /** Device property [Battery levels]*/
- public static final int BATTERY_POWER_OFF_MODE=0x91;
-
- /**
- * Device property [Battery levels]
- * @since NFCHST8.0
- */
- public static final int BATTERY_OPERATIONAL_MODE=0x92;
- /** Device property [Remote Access]*/
- public static final int BIP=0x93;
- /** Device property [Remote Access]*/
- public static final int CAT_TP=0x94;
-
- private NxpHandset mNxpHandset = null;
- private String TAG = "Handset";
-
-
- public Handset() {
- mNxpHandset = new NxpHandset();
- if(mNxpHandset == null){
- Log.d(TAG,"mNxpHandset is Null ");
- }
- }
-
- /**
- * Return the version of device requirements supported.
- * @since NFCHST6.0 <I>(REQ_132)</I>
- */
- public int getVersion() {
- return mNxpHandset.getNxpVersion();
- }
-
- /**
- * Return handset status for the following features:<BR><UL>
- * <LI>{@link Handset#HCI_SWP}, {@link Handset#MULTIPLE_ACTIVE_CEE}</LI>
- * <LI>{@link Handset#FELICA}, {@link Handset#MIFARE_CLASSIC}, {@link Handset#MIFARE_DESFIRE},
- * {@link Handset#NFC_FORUM_TYPE3}</LI>
- * <LI>{@link Handset#OMAPI}</LI>
- * <LI>{@link Handset#BATTERY_LOW_MODE}, {@link Handset#BATTERY_POWER_OFF_MODE}</LI>
- * <LI>{@link Handset#BIP}, {@link Handset#CAT_TP}</LI></UL>
- * @param feature Requested feature
- * @return <code>true</code> if the feature is supported; <code>false</code> otherwise
- * @exception IllegalArgumentException <BR>Indicate that a method has been passed an illegal or inappropriate argument.
- * @since NFCHST6.0 <I>(REQ_132)</I>
- */
- public boolean getProperty(int feature) {
- return mNxpHandset.getNxpProperty(feature);
- }
-
- /**
- * Return the list of Secure Elements which can be used by the NFC Controller
- * when handset is operating in a following battery level.<BR><UL>
- * <LI>{@link Handset#BATTERY_LOW_MODE}</LI>
- * <LI>{@link Handset#BATTERY_POWER_OFF_MODE}</LI>
- * <LI>{@link Handset#BATTERY_OPERATIONAL_MODE}</LI></UL>
- * @param batteryLevel Battery level the handset is operating
- * @return The list of secure Element names , or Collections.emptyList () if none of them are supported.
- * @since TNFCHST8.0 <I>(REQ_059/REQ_060)</I>
- * */
- public List<String> getAvailableSecureElements(int batteryLevel) {
- return mNxpHandset.getAvailableSecureElements(batteryLevel);
- }
- /**
- * Asks the system to inform "transaction events" to any authorized/registered components via <code>BroadcastReceiver</code>.<BR>
- * Change SHALL not imply a power cycle and SHALL be valid until next handset reboot.<BR><BR>
- * <I>Applications SHALL register to <code>com.gsma.services.nfc.TRANSACTION_EVENT</code> for receiving related events.</I>
- * @exception SecurityException <BR>Indicate that application is not allowed to use this API.<UL>
- * <LI>When UICC is the "active" SE,
- * <BR>only applications signed with certificates stored in the UICC are granted to call this API.</LI>
- * <LI>When eSE is the "active" SE,
- * <BR>only applications signed with system certificates are granted to call this API.</LI></UL>
- * @since NFCHST6.0 <I>(REQ_99)</I>
- */
- public void enableMultiEvt_transactionReception() throws SecurityException {
- mNxpHandset.enableMultiEvt_transactionReception();
- }
-
-}
diff --git a/nxp-nfc-gsma/java/com/gsma/services/utils/InsufficientResourcesException.java b/nxp-nfc-gsma/java/com/gsma/services/utils/InsufficientResourcesException.java
deleted file mode 100755
index a56fb76..0000000
--- a/nxp-nfc-gsma/java/com/gsma/services/utils/InsufficientResourcesException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/******************************************************************************
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Copyright 2018 NXP
-*
-******************************************************************************/
-package com.gsma.services.utils;
-
-/**
- * This class handles exception raised from the commit method when CLF routing table has no more free space.
- * @since NFCHST6.0
- */
-@SuppressWarnings("serial")
-public class InsufficientResourcesException extends Exception {
-
- /**
- * Constructs a new <code>InsufficientResourcesException</code> that includes the current stack trace.
- * @since NFCHST6.0
- */
- public InsufficientResourcesException() {};
-
- /**
- * Constructs a new <code>InsufficientResourcesException</code> with the current stack trace and the specified detail message.
- * @param detailMessage The detail message for this exception
- * @since NFCHST6.0
- */
- public InsufficientResourcesException(String detailMessage) {};
-
-}