aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornxf50051 <dinesh.ambati@nxp.com>2019-03-29 11:09:43 +0530
committernxf35421 <sangeetha.agarwal@nxp.com>2019-04-12 17:07:53 +0530
commitd766de039ca01fbee7510dc44a37cd3bfd39869d (patch)
treeef9b5a315260f3bf03f579b422c32c2dde8dbddf
parent00a8afb0b0b96339129c797a27c3c7e150b3fe02 (diff)
downloadandroid_vendor_nxp_opensource_frameworks-d766de039ca01fbee7510dc44a37cd3bfd39869d.tar.gz
android_vendor_nxp_opensource_frameworks-d766de039ca01fbee7510dc44a37cd3bfd39869d.tar.bz2
android_vendor_nxp_opensource_frameworks-d766de039ca01fbee7510dc44a37cd3bfd39869d.zip
Code cleanup & alignment with GSMAV14
Code clean up for existing GSMA module as the latest AOSP code supports GSMA functionalities.
-rwxr-xr-xAndroid.mk4
-rwxr-xr-xcom/nxp/nfc/INxpNfcAdapter.aidl2
-rw-r--r--com/nxp/nfc/NfcConstants.java7
-rwxr-xr-xcom/nxp/nfc/NxpNfcAdapter.java16
-rwxr-xr-xcom/nxp/nfc/gsma/internal/INxpNfcController.aidl31
-rwxr-xr-xcom/nxp/nfc/gsma/internal/NxpHandset.java201
-rwxr-xr-xcom/nxp/nfc/gsma/internal/NxpNfcController.java590
-rwxr-xr-xcom/nxp/nfc/gsma/internal/NxpOffHostService.java125
-rw-r--r--nxp-nfc-gsma/Android.mk11
-rw-r--r--nxp-nfc-gsma/com.gsma.services.nfc.xml20
-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
16 files changed, 2 insertions, 2099 deletions
diff --git a/Android.mk b/Android.mk
index 37a0976..199cfe5 100755
--- a/Android.mk
+++ b/Android.mk
@@ -52,8 +52,8 @@ LOCAL_JAVA_LIBRARIES:= com.nxp.nfc
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_DROIDDOC_USE_STANDARD_DOCLET := true
-include $(BUILD_DROIDDOC)
+# include $(BUILD_DROIDDOC)
# uncomment for NXP gsma-nfc-service
# ============================================================
-include $(call all-makefiles-under,$(LOCAL_PATH))
+#include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/com/nxp/nfc/INxpNfcAdapter.aidl b/com/nxp/nfc/INxpNfcAdapter.aidl
index 5dc8607..468087c 100755
--- a/com/nxp/nfc/INxpNfcAdapter.aidl
+++ b/com/nxp/nfc/INxpNfcAdapter.aidl
@@ -15,7 +15,6 @@
*/
package com.nxp.nfc;
-import com.nxp.nfc.gsma.internal.INxpNfcController;
import com.nxp.nfc.INxpNfcAdapterExtras;
import com.nxp.nfc.NfcAidServiceInfo;
/**
@@ -23,7 +22,6 @@ import com.nxp.nfc.NfcAidServiceInfo;
*/
interface INxpNfcAdapter
{
- INxpNfcController getNxpNfcControllerInterface();
void DefaultRouteSet(int routeLoc, boolean fullPower, boolean lowPower, boolean noPower);
void MifareDesfireRouteSet(int routeLoc, boolean fullPower, boolean lowPower, boolean noPower);
void MifareCLTRouteSet(int routeLoc, boolean fullPower, boolean lowPower, boolean noPower);
diff --git a/com/nxp/nfc/NfcConstants.java b/com/nxp/nfc/NfcConstants.java
index 6b083cf..ec1cffc 100644
--- a/com/nxp/nfc/NfcConstants.java
+++ b/com/nxp/nfc/NfcConstants.java
@@ -207,7 +207,6 @@ public final class NfcConstants {
public static final String PERMISSIONS_NFC = "android.permission.NFC";
- public static final String ACTION_MULTI_EVT_TRANSACTION = "com.gsma.services.nfc.action.TRANSACTION_EVENT";
public static final String ACTION_CHECK_X509 = "org.simalliance.openmobileapi.service.ACTION_CHECK_X509";
public static final String SET_PACKAGE_NAME = "org.simalliance.openmobileapi.service";
public static final String EXTRA_SE_NAME = "org.simalliance.openmobileapi.service.EXTRA_SE_NAME";
@@ -215,12 +214,6 @@ public final class NfcConstants {
public static final String EXTRA_RESULT = "org.simalliance.openmobileapi.service.extra.EXTRA_RESULT";
public static final String ACTION_CHECK_X509_RESULT = "org.simalliance.openmobileapi.service.ACTION_CHECK_X509_RESULT";
- public static final String PERMISSIONS_TRANSACTION_EVENT = "com.gsma.services.nfc.permission.TRANSACTION_EVENT";
- public static final String EXTRA_GSMA_AID = "com.gsma.services.nfc.extra.AID";
- public static final String EXTRA_GSMA_DATA = "com.gsma.services.nfc.extra.DATA";
- public static final String EXTRA_GSMA_PREV_PAYMENT_COMPONENT = "com.gsma.services.nfc.extra.PREV_PAYMENT_COMPONENT";
- public static final String ACTION_GSMA_ENABLE_NFC = "com.gsma.services.nfc.action.ENABLE_NFC";
- public static final String ACTION_GSMA_ENABLE_SET_FLAG = "com.gsma.services.nfc.action.ENABLE_NFC_SET_FALG";
/**
* Indicates the states of an APDU service.
diff --git a/com/nxp/nfc/NxpNfcAdapter.java b/com/nxp/nfc/NxpNfcAdapter.java
index bafa19a..069654c 100755
--- a/com/nxp/nfc/NxpNfcAdapter.java
+++ b/com/nxp/nfc/NxpNfcAdapter.java
@@ -30,7 +30,6 @@ import android.os.ServiceManager;
import java.io.IOException;
import android.os.UserHandle;
import android.os.RemoteException;
-import com.nxp.nfc.gsma.internal.INxpNfcController;
import android.util.Log;
import java.util.List;
@@ -353,21 +352,6 @@ public final class NxpNfcAdapter {
}
}
- /**
- * Get the handle to an INxpNfcController Interface
- * @hide
- */
- public INxpNfcController getNxpNfcControllerInterface() {
- if(sService == null) {
- throw new UnsupportedOperationException("You need a reference from NfcAdapter to use the "
- + " NXP NFC APIs");
- }
- try {
- return sNxpService.getNxpNfcControllerInterface();
- }catch(RemoteException e) {
- return null;
- }
- }
/**
* Get the Active Secure Element List
* <p>Requires {@link android.Manifest.permission#NFC} permission.
diff --git a/com/nxp/nfc/gsma/internal/INxpNfcController.aidl b/com/nxp/nfc/gsma/internal/INxpNfcController.aidl
deleted file mode 100755
index a864b6c..0000000
--- a/com/nxp/nfc/gsma/internal/INxpNfcController.aidl
+++ /dev/null
@@ -1,31 +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.nxp.nfc.gsma.internal;
-import android.nfc.cardemulation.NfcApduServiceInfo;
-import android.content.Intent;
-/**
- * @hide
- */
-interface INxpNfcController {
- boolean deleteOffHostService(int userId, String packageName, in NfcApduServiceInfo service);
- List<NfcApduServiceInfo> getOffHostServices(int userId, String packageName);
- NfcApduServiceInfo getDefaultOffHostService(int userId, String packageName);
- boolean commitOffHostService(int userId, String packageName, String serviceName, in NfcApduServiceInfo service);
- boolean enableMultiEvt_NxptransactionReception(String packageName, String seName);
- void enableMultiReception(String pkg, String seName);
-}
diff --git a/com/nxp/nfc/gsma/internal/NxpHandset.java b/com/nxp/nfc/gsma/internal/NxpHandset.java
deleted file mode 100755
index 20feb1d..0000000
--- a/com/nxp/nfc/gsma/internal/NxpHandset.java
+++ /dev/null
@@ -1,201 +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.nxp.nfc.gsma.internal;
-
-import com.nxp.nfc.gsma.internal.NxpNfcController;
-import android.os.RemoteException;
-import java.lang.SecurityException;
-import android.util.Log;
-import com.nxp.nfc.NfcConstants;
-import android.nfc.NfcAdapter;
-import com.nxp.nfc.NxpNfcAdapter;
-import android.content.Context;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.io.IOException;
-/**
- * This class handles the handset configuration & properties
- */
-public class NxpHandset {
-
- /** Device property [Contactless Frontend]*/
- private static final int HCI_SWP=0x00;
- /** Device property [Contactless Frontend]*/
- private static final int MULTIPLE_ACTIVE_CEE=0x01;
-
- /** Device property [NFC Technologies]*/
- private static final int FELICA=0x20;
- /** Device property [NFC Technologies]*/
- private static final int MIFARE_CLASSIC=0x21;
- /** Device property [NFC Technologies]*/
- private static final int MIFARE_DESFIRE=0x22;
- /** Device property [NFC Technologies]*/
- private static final int NFC_FORUM_TYPE3=0x23;
-
- /** Device property [Framework components]*/
- public static final int OMAPI=0x50;
-
- /** Device property [Battery Levels]*/
- private static final int BATTERY_LOW_MODE=0x90;
- /** Device property [Battery levels]*/
- private static final int BATTERY_POWER_OFF_MODE=0x91;
- /** Device property [Battery levels]*/
- private static final int BATTERY_OPERATIONAL_MODE=0x92;
- private String TAG = "NxpHandset";
-
- private NfcAdapter mNfcAdapter = null;
- private NxpNfcAdapter mNxpNfcAdapter = null;
- private INxpNfcController mNfcControllerService = null;
- private Context mContext;
-
-
-
- private final int GSMA_NFCHST = 9000;
-
- public NxpHandset() {
- mContext = getContext();
- if(mNfcAdapter == null)
- mNfcAdapter = NfcAdapter.getNfcAdapter(mContext);
- if((mNxpNfcAdapter == null) && (mNfcAdapter != null))
- mNxpNfcAdapter = NxpNfcAdapter.getNxpNfcAdapter(mNfcAdapter);
-
- if(mNfcControllerService == null) {
- mNfcControllerService = mNxpNfcAdapter.getNxpNfcControllerInterface();
- }
- }
-
- private Context getContext() {
- Context context = null;
- try {
- context = (Context) Class.forName("android.app.ActivityThread")
- .getMethod("currentApplication").invoke(null, (Object[]) null);
- } catch (final Exception e1) {
- try {
- context = (Context) Class.forName("android.app.AppGlobals")
- .getMethod("getInitialApplication").invoke(null, (Object[]) null);
- } catch (final Exception e2) {
- throw new RuntimeException("Failed to get application instance");
- }
- }
- return context;
- }
-
- /**
- * Return the version of device requirements supported.
- */
- public int getNxpVersion() {
- return GSMA_NFCHST;
- }
-
- /**
- * Return handset status for the following features
- * HCI_SWP, MULTIPLE_ACTIVE_CEE FELICA,
- * MIFARE_CLASSIC, MIFARE_DESFIRE,
- * NFC_FORUM_TYPE3, OMAPI, BATTERY_LOW_MODE,
- * BATTERY_POWER_OFF_MODE
- */
- public boolean getNxpProperty(int feature) {
- boolean result = false;
- if((feature != HCI_SWP) && (feature != MULTIPLE_ACTIVE_CEE) && (feature != FELICA) && (feature != MIFARE_CLASSIC)
- && (feature != MIFARE_DESFIRE) && (feature != NFC_FORUM_TYPE3) && (feature != BATTERY_LOW_MODE) && (feature != OMAPI)
- && (feature != BATTERY_POWER_OFF_MODE))
- throw new IllegalArgumentException("Feature is inappropriate argument");
-
- switch(feature) {
- case HCI_SWP:
- case MULTIPLE_ACTIVE_CEE:
- case FELICA:
- case MIFARE_CLASSIC:
- case MIFARE_DESFIRE:
- case NFC_FORUM_TYPE3:
- case BATTERY_LOW_MODE:
- case OMAPI:
- result = true;
- break;
- case BATTERY_POWER_OFF_MODE:
- result = false;
- break;
- default:
- result = false;
- }
- return result;
- }
-
- public List<String> getAvailableSecureElements(int batteryLevel) {
- String pkg = mContext.getPackageName();
- String[] secureElemArray = null;
- List<String> secureElementList = new ArrayList<String>(0x03);
- switch(batteryLevel) {
-
- case BATTERY_LOW_MODE:
- case BATTERY_POWER_OFF_MODE:
- case BATTERY_OPERATIONAL_MODE:
- try {
- secureElemArray = mNxpNfcAdapter.getActiveSecureElementList(pkg);
- } catch(IOException e) {
- secureElemArray = null;
- }
- break;
- default:
- throw new IllegalArgumentException("Wrong value for batteryLevel");
- }
- if(secureElemArray != null && secureElemArray.length > 0x00) {
- Collections.addAll(secureElementList , secureElemArray);
- for(int i =0; i< secureElementList.size(); i++) {
- if(secureElementList.get(i).equals(NfcConstants.UICC_ID))
- {
- secureElementList.set(i,"SIM1");
- }
- else if(secureElementList.get(i).equals(NfcConstants.UICC2_ID))
- {
- secureElementList.set(i,"SIM2");
- }
- else if(secureElementList.get(i).equals(NfcConstants.SMART_MX_ID))
- {
- secureElementList.set(i,"eSE");
- }
- }
- return secureElementList;
- }
- return Collections.emptyList();
- }
- /**
- * 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>
- */
- public void enableMultiEvt_transactionReception() {
- String pkg = mContext.getPackageName();
- boolean isEnabled = false;
- Log.d(TAG,"pkg " + pkg);
- try {
- isEnabled = mNfcControllerService.enableMultiEvt_NxptransactionReception(pkg, "SIM");
-
- if(!isEnabled) {
- isEnabled = mNfcControllerService.enableMultiEvt_NxptransactionReception(pkg, "SIM1");
- }
-
- } catch (RemoteException e) {
- Log.e(TAG, "Exception:commitOffHostService failed", e);
- }
-
- if(!isEnabled)
- throw new SecurityException("Application is not allowed to use this API");
- }
-}
diff --git a/com/nxp/nfc/gsma/internal/NxpNfcController.java b/com/nxp/nfc/gsma/internal/NxpNfcController.java
deleted file mode 100755
index 3b84e8d..0000000
--- a/com/nxp/nfc/gsma/internal/NxpNfcController.java
+++ /dev/null
@@ -1,590 +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.nxp.nfc.gsma.internal;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-import android.content.pm.ApplicationInfo;
-import android.graphics.drawable.Drawable;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.BroadcastReceiver;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
-import java.util.Arrays;
-import java.util.Random;
-import android.nfc.NfcAdapter;
-import com.nxp.nfc.NxpNfcAdapter;
-import android.annotation.SystemApi;
-import android.util.Log;
-import android.nfc.cardemulation.NfcAidGroup;
-import android.nfc.cardemulation.AidGroup;
-import android.nfc.cardemulation.NfcApduServiceInfo;
-import android.nfc.cardemulation.NfcApduServiceInfo.ESeInfo;
-import android.os.UserHandle;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.RemoteException;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import com.nxp.nfc.gsma.internal.INxpNfcController;
-import com.nxp.nfc.NfcConstants;
-import java.io.ByteArrayOutputStream;
-
-public class NxpNfcController {
-
- public static final int TECHNOLOGY_NFC_A=0x01;
- public static final int TECHNOLOGY_NFC_B=0x02;
- public static final int TECHNOLOGY_NFC_F=0x04;
- public static final int PROTOCOL_ISO_DEP=0x10;
- private static final int MW_PROTOCOL_MASK_ISO_DEP = 0x08;
-
- static final String TAG = "NxpNfcController";
-
- /** 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;
-
- Context mContext;
- private NfcAdapter mNfcAdapter = null;
- private NxpNfcAdapter mNxpNfcAdapter = null;
- private INxpNfcController mNfcControllerService = null;
- private ESeInfo seExtension;
- private boolean mEnable = false;
- private boolean mState = false;
- private boolean mDialogBoxFlag = false;
- private NxpNfcController.NxpCallbacks mCallBack = null;
-
- // Map between SE name and NfcApduServiceInfo
- private final HashMap<String, NfcApduServiceInfo> mSeNameApduService = new HashMap<String, NfcApduServiceInfo>();//Maps.newHashMap();
-
- public static interface NxpCallbacks {
- /**
- * Called when process for enabling the NFC Controller is finished.
- */
- public abstract void onNxpEnableNfcController(boolean success);
-
- }
-
- // For QC
- public static interface Callbacks {
- /**
- * Called when process for enabling the NFC Controller is finished.
- * @hide
- */
- public void onGetOffHostService(boolean isLast, String description, String seName, int bannerResId,
- List<String> dynamicAidGroupDescriptions,
- List<android.nfc.cardemulation.AidGroup> dynamicAidGroups);
-
- }
-
- private final BroadcastReceiver mOwnerReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE,0);
- Log.d(TAG,"onReceive: action: " + action + "mState: "+ mState);
- if((state == NfcAdapter.STATE_ON) && (mState == true) && (mDialogBoxFlag == true)) {
- mEnable = true;
- mCallBack.onNxpEnableNfcController(true);
- mDialogBoxFlag = false;
- mState = false;
- mContext.unregisterReceiver(mOwnerReceiver);
- mContext.unregisterReceiver(mReceiver);
- }
- }
- };
-
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if(action.equals(NfcConstants.ACTION_GSMA_ENABLE_SET_FLAG)) {
- mState = intent.getExtras().getBoolean("ENABLE_STATE");
- }
- if(mState == false) {
- mCallBack.onNxpEnableNfcController(false);
- mContext.unregisterReceiver(mOwnerReceiver);
- mContext.unregisterReceiver(mReceiver);
- } else {
- mDialogBoxFlag = true;
- }
- }
- };
-
- public NxpNfcController() {}
-
- public NxpNfcController(Context context) {
- mContext = context;
- if(mNfcAdapter == null)
- mNfcAdapter = NfcAdapter.getNfcAdapter(mContext);
- if((mNxpNfcAdapter == null) && (mNfcAdapter != null))
- mNxpNfcAdapter = NxpNfcAdapter.getNxpNfcAdapter(mNfcAdapter);
-
- if(mNfcControllerService == null) {
- mNfcControllerService = mNxpNfcAdapter.getNxpNfcControllerInterface();
- }
- }
-
- /**
- * Check if the NFC Controller is enabled or disabled.
- * return true,if the NFC adapter is enabled and false otherwise
-
- */
- public boolean isNxpNfcEnabled() {
- return mNfcAdapter.isEnabled ();
- }
-
- /**
- * Asks the system to enable the NFC Controller.
- */
- public void enableNxpNfcController(NxpNfcController.NxpCallbacks cb) {
-
- mCallBack = cb;
- IntentFilter ownerFilter = new IntentFilter();
- ownerFilter.addAction(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
- mContext.registerReceiver(mOwnerReceiver, ownerFilter);
-
- IntentFilter filter = new IntentFilter();
- filter.addAction(NfcConstants.ACTION_GSMA_ENABLE_SET_FLAG);
- mContext.registerReceiver(mReceiver, filter);
-
- // To Enable NfC
- Intent enableNfc = new Intent();
- enableNfc.setAction(NfcConstants.ACTION_GSMA_ENABLE_NFC);
- mContext.sendBroadcast(enableNfc);
- }
-
- /**
- * Converting from apdu service to off host service.
- * return Off-Host service object
- */
- private NxpOffHostService ConvertApduServiceToOffHostService(PackageManager pm, NfcApduServiceInfo apduService) {
- NxpOffHostService mService;
- int seId=0;
- String sEname =null;
- ResolveInfo resolveInfo = apduService.getResolveInfo();
- String description = apduService.getDescription();
- seId = apduService.getSEInfo().getSeId();
- if (NfcConstants.UICC_ID_TYPE == seId) {
- sEname = "SIM1";
- } else if (NfcConstants.UICC2_ID_TYPE == seId) {
- sEname = "SIM2";
- } else if (NfcConstants.SMART_MX_ID_TYPE == seId) {
- sEname = "eSE";
- } else {
- Log.e(TAG,"Wrong SE ID");
- }
- Drawable banner = null; //apduService.loadBanner(pm);
- boolean modifiable = apduService.getModifiable();
- int bannerId = apduService.getBannerId();
- banner = apduService.loadBanner(pm);
- int userId = apduService.getUid();
- ArrayList<String> ApduAids = apduService.getAids();
- mService = new NxpOffHostService(userId,description, sEname, resolveInfo.serviceInfo.packageName,
- resolveInfo.serviceInfo.name, modifiable);
- if(modifiable) {
- for(android.nfc.cardemulation.NfcAidGroup group : apduService.getDynamicNfcAidGroups()) {
- mService.mNfcAidGroupList.add(group);
- }
- } else {
- for(android.nfc.cardemulation.NfcAidGroup group : apduService.getStaticNfcAidGroups()) {
- mService.mNfcAidGroupList.add(group);
- }
- }
- //mService.setBanner(banner);
- mService.setContext(mContext);
- mService.setBannerId(bannerId);
- mService.setBanner(banner);
- mService.setNxpNfcController(this);
- return mService;
- }
-
- /**
- * Converting from Off_Host service object to Apdu Service object
- * return APDU service Object
- */
- private NfcApduServiceInfo ConvertOffhostServiceToApduService(NxpOffHostService mService, int userId, String pkg) {
- NfcApduServiceInfo apduService =null;
- boolean onHost = false;
- String description = mService.getDescription();
- boolean modifiable = mService.getModifiable();
- ArrayList<android.nfc.cardemulation.NfcAidGroup> staticNfcAidGroups = null;
- ArrayList<NfcAidGroup> dynamicNfcAidGroup = new ArrayList<NfcAidGroup>();
- dynamicNfcAidGroup.addAll(mService.mNfcAidGroupList);
- boolean requiresUnlock = false;
- Drawable banner = mService.getBanner();
- byte[] byteArrayBanner = null;
-
- if(banner != null){
- Bitmap bitmap = (Bitmap)((BitmapDrawable)banner).getBitmap();
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
- byteArrayBanner = stream.toByteArray();
- }
-
- int seId = 0;
- String seName = mService.getLocation();
- int powerstate = -1;
- int bannerId = mService.mBannerId;
- /* creating Resolveinfo object */
- ResolveInfo resolveInfo = new ResolveInfo();
- resolveInfo.serviceInfo = new ServiceInfo();
- resolveInfo.serviceInfo.applicationInfo = new ApplicationInfo();
- resolveInfo.serviceInfo.packageName = pkg;
- resolveInfo.serviceInfo.name = mService.getServiceName();
- if(seName != null) {
- if(seName.equals("SIM") || seName.equals("SIM1")) {
- seId = NfcConstants.UICC_ID_TYPE;
- } else if (seName.equals("SIM2")) {
- seId = NfcConstants.UICC2_ID_TYPE;
- } else if (seName.equals("eSE")) {
- seId = NfcConstants.SMART_MX_ID_TYPE;
- } else {
- Log.e(TAG,"wrong Se name");
- }
- }
- NfcApduServiceInfo.ESeInfo mEseInfo = new NfcApduServiceInfo.ESeInfo(seId,powerstate);
- apduService = new NfcApduServiceInfo(resolveInfo,onHost,description,staticNfcAidGroups, dynamicNfcAidGroup,
- requiresUnlock,bannerId,userId, "Fixme: NXP:<Activity Name>", mEseInfo, modifiable);
- return apduService;
- }
-
- /**
- * Delete Off-Host service from routing table
- * return true or flase
- */
- public boolean deleteOffHostService(int userId, String packageName, NxpOffHostService service) {
- boolean result = false;
- NfcApduServiceInfo apduService;
- apduService = ConvertOffhostServiceToApduService(service, userId, packageName);
- try {
- result = mNfcControllerService.deleteOffHostService(userId, packageName, apduService);
- } catch (RemoteException e) {
- Log.e(TAG, "Exception:deleteOffHostService failed", e);
- }
- if(result != true) {
- Log.d(TAG, "GSMA: deleteOffHostService failed");
- return false;
- }
- return true;
- }
-
- /**
- * Get the list Off-Host services
- * return off-Host service List
- */
- public ArrayList<NxpOffHostService> getOffHostServices(int userId, String packageName) {
- List<NfcApduServiceInfo> apduServices = new ArrayList<NfcApduServiceInfo>();
- ArrayList<NxpOffHostService> mService = new ArrayList<NxpOffHostService>();
- PackageManager pm = mContext.getPackageManager();
- try {
- apduServices = mNfcControllerService.getOffHostServices(userId, packageName);
- if((apduServices == null)||(apduServices.isEmpty())){
- return null;
- }
- } catch (RemoteException e) {
- Log.e(TAG, "getOffHostServices failed", e);
- return null;
- }
- for(NfcApduServiceInfo service: apduServices) {
- mService.add(ConvertApduServiceToOffHostService(pm, service));
- }
- return mService;
- }
-
- /**
- * Get the Default Off-Host services
- * return default off-Host service
- */
- public NxpOffHostService getDefaultOffHostService(int userId, String packageName) {
- NfcApduServiceInfo apduService;
- NxpOffHostService mService;
- PackageManager pm = mContext.getPackageManager();
- try {
- apduService = mNfcControllerService.getDefaultOffHostService(userId, packageName);
- } catch (RemoteException e) {
- Log.e(TAG, "getDefaultOffHostService failed", e);
- return null;
- }
- if(apduService != null) {
- mService = ConvertApduServiceToOffHostService(pm, apduService);
- return mService;
- }
- Log.d(TAG, "getDefaultOffHostService: Service is NULL");
- return null;
- }
-
- /**
- * add the Off-Host service to routing tableh
- * return true
- */
- public boolean commitOffHostService(int userId, String packageName, NxpOffHostService service) {
- boolean result = false;
- NfcApduServiceInfo newService;
- String serviceName = service.getServiceName();
- newService = ConvertOffhostServiceToApduService(service, userId, packageName);
- try {
- if(mNfcControllerService != null) {
- result = mNfcControllerService.commitOffHostService(userId, packageName, serviceName, newService);
- }
- } catch (RemoteException e) {
- Log.e(TAG, "Exception:commitOffHostService failed", e);
- return false;
- }
- if(result != true) {
- Log.d(TAG, "GSMA: commitOffHostService Failed");
- return false;
- }
- return true;
- }
-
-
- /**
- * add the Off-Host service to routing tableh
- * return true
- * @hide
- */
- public boolean commitOffHostService(String packageName, String seName, String description,
- int bannerResId, int uid, List<String> aidGroupDescriptions,
- List<android.nfc.cardemulation.NfcAidGroup> nfcAidGroups) {
-
- boolean result = false;
- int userId = UserHandle.myUserId();
- NfcApduServiceInfo service = null;
- boolean onHost = false;
- ArrayList<android.nfc.cardemulation.NfcAidGroup> staticNfcAidGroups = null;
- ArrayList<NfcAidGroup> dynamicNfcAidGroup = new ArrayList<NfcAidGroup>();
- dynamicNfcAidGroup.addAll(nfcAidGroups);
- boolean requiresUnlock = false;
- int seId = 0;
- int powerstate = -1;
- boolean modifiable = true;
-
- /* creating Resolveinfo object */
- ResolveInfo resolveInfo = new ResolveInfo();
- resolveInfo.serviceInfo = new ServiceInfo();
- resolveInfo.serviceInfo.applicationInfo = new ApplicationInfo();
- resolveInfo.serviceInfo.packageName = packageName;
- resolveInfo.serviceInfo.name = seName;
-
- //Temp for SE conversion
- String secureElement = null;
- if((seName.equals("SIM")) || (seName.equals("SIM1"))) {
- secureElement = NfcConstants.UICC_ID;
- } else if (seName.equals("SIM2")){
- secureElement = NfcConstants.UICC2_ID;
- } else if ((seName.equals("eSE1")) || (seName.equals("eSE"))){
- secureElement = NfcConstants.SMART_MX_ID;
- } else {
- Log.e(TAG,"wrong Se name");
- }
-
- if(secureElement.equals(NfcConstants.UICC_ID)) {
- seId = NfcConstants.UICC_ID_TYPE;
- } else if (secureElement.equals(NfcConstants.UICC2_ID)) {
- seId = NfcConstants.UICC2_ID_TYPE;
- } else if (secureElement.equals(NfcConstants.SMART_MX_ID)) {
- seId = NfcConstants.SMART_MX_ID_TYPE;
- } else if (secureElement.equals(NfcConstants.HOST_ID)) {
- seId = NfcConstants.HOST_ID_TYPE;
- } else {
- Log.e(TAG,"wrong Se name");
- }
-
- NfcApduServiceInfo.ESeInfo mEseInfo = new NfcApduServiceInfo.ESeInfo(seId,powerstate);
- NfcApduServiceInfo newService = new NfcApduServiceInfo(resolveInfo, onHost, description, staticNfcAidGroups, dynamicNfcAidGroup,
- requiresUnlock, bannerResId, userId, "Fixme: NXP:<Activity Name>", mEseInfo,
- modifiable);
-
- mSeNameApduService.put(seName, newService);
-
- try {
- if(mNfcControllerService != null) {
- result = mNfcControllerService.commitOffHostService(userId, packageName, seName, newService);
- }
- } catch (RemoteException e) {
- Log.e(TAG, "Exception:commitOffHostService failed", e);
- return false;
- }
- if(result != true) {
- Log.d(TAG, "GSMA: commitOffHostService Failed");
- return false;
- }
- return true;
- }
-
- /**
- * Delete Off-Host service from routing table
- * return true or flase
- */
- public boolean deleteOffHostService(String packageName, String seName) {
-
- boolean result = false;
- int userId = UserHandle.myUserId();
-
- try {
- result = mNfcControllerService.deleteOffHostService(userId, packageName, mSeNameApduService.get(seName));
- } catch (RemoteException e) {
- Log.e(TAG, "Exception:deleteOffHostService failed", e);
- }
- if(result != true) {
- Log.d(TAG, "GSMA: deleteOffHostService failed");
- return false;
- }
- return true;
- }
-
- /**
- * Get the list Off-Host services
- * return off-Host service List
- */
- public boolean getOffHostServices(String packageName, Callbacks callbacks) {
-
- int userId = UserHandle.myUserId();
- boolean isLast = false;
- String seName = null;
- int seId=0;
-
- List<NfcApduServiceInfo> apduServices = new ArrayList<NfcApduServiceInfo>();
- try {
- apduServices = mNfcControllerService.getOffHostServices(userId, packageName);
-
- for(int i =0; i< apduServices.size(); i++) {
-
- if( i == apduServices.size() -1 ) {
- isLast = true;
- }
- seId = apduServices.get(i).getSEInfo().getSeId();
- if (NfcConstants.UICC_ID_TYPE == seId) {
- seName = "SIM1";
- } else if (NfcConstants.UICC2_ID_TYPE == seId) {
- seName = "SIM2";
- } else if (NfcConstants.SMART_MX_ID_TYPE == seId) {
- seName = "eSE";
- } else {
- seName = null;
- Log.e(TAG,"Wrong SE ID");
- }
-
- Log.d(TAG, "getOffHostServices: seName = " + seName);
- ArrayList<String> groupDescription = new ArrayList<String>();
- for (NfcAidGroup nfcAidGroup : apduServices.get(i).getNfcAidGroups()) {
- groupDescription.add(nfcAidGroup.getDescription());
- }
-
- callbacks.onGetOffHostService(isLast, apduServices.get(i).getDescription(), seName, apduServices.get(i).getBannerId(),
- groupDescription,
- apduServices.get(i).getAidGroups());
- }
- } catch (RemoteException e) {
- Log.e(TAG, "getOffHostServices failed", e);
- return false;
- }
-
- return true;
- }
-
- /**
- * Get the Default Off-Host services
- * return default off-Host service
- */
- public boolean getDefaultOffHostService(String packageName, Callbacks callbacks) {
-
- Log.d(TAG, "getDefaultOffHostService: Enter");
-
- NfcApduServiceInfo apduService;
- boolean isLast = true;
- int userId = UserHandle.myUserId();
- String seName = null;
- int seId=0;
- try {
- apduService = mNfcControllerService.getDefaultOffHostService(userId, packageName);
- seId = apduService.getSEInfo().getSeId();
- if (NfcConstants.UICC_ID_TYPE == seId) {
- seName = "SIM1";
- } else if (NfcConstants.UICC2_ID_TYPE == seId) {
- seName = "SIM2";
- } else if (NfcConstants.SMART_MX_ID_TYPE== seId) {
- seName = "eSE";
- } else {
- Log.e(TAG,"Wrong SE ID");
- }
- Log.d(TAG, "getDefaultOffHostService: seName = " + seName);
- ArrayList<String> groupDescription = new ArrayList<String>();
- for (NfcAidGroup nfcAidGroup : apduService.getNfcAidGroups()) {
- groupDescription.add(nfcAidGroup.getDescription());
- }
-
- callbacks.onGetOffHostService(isLast, apduService.getDescription(), seName, apduService.getBannerId(),
- groupDescription,
- apduService.getAidGroups());
- } catch (RemoteException e) {
- Log.e(TAG, "getDefaultOffHostService failed", e);
- return false;
- }
-
- Log.d(TAG, "getDefaultOffHostService: End");
- return true;
- }
-
- /**
- * To enable the the system to inform "transaction events" to any authorized/registered components
- * via BroadcastReceiver
- *
- */
- public void enableMultiReception(String seName, String packageName) {
- try {
- mNfcControllerService.enableMultiReception(packageName, seName);
- } catch (RemoteException e) {
- Log.e(TAG, "enableMultiReception failed", e);
- return;
- }
- }
-
- public boolean isStaticOffhostService(int userId, String packageName, NxpOffHostService service) {
- boolean isStatic = false;
- List<NfcApduServiceInfo> nxpApduServices = new ArrayList<NfcApduServiceInfo>();
-
- try {
- nxpApduServices = mNfcControllerService.getOffHostServices(userId, packageName);
-
- for(int i=0; i< nxpApduServices.size(); i++) {
- NfcApduServiceInfo sService = nxpApduServices.get(i);
- if(sService.getModifiable() == false && service.getServiceName().compareTo((sService.getResolveInfo()).serviceInfo.name)==0){
- isStatic = true;
- }
- }
- } catch (RemoteException e) {
- Log.e(TAG, "getOffHostServices failed", e);
- isStatic = true;
- }
- return isStatic;
- }
-}
diff --git a/com/nxp/nfc/gsma/internal/NxpOffHostService.java b/com/nxp/nfc/gsma/internal/NxpOffHostService.java
deleted file mode 100755
index 99f66a1..0000000
--- a/com/nxp/nfc/gsma/internal/NxpOffHostService.java
+++ /dev/null
@@ -1,125 +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.nxp.nfc.gsma.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.util.Log;
-import android.graphics.drawable.Drawable;
-import android.nfc.cardemulation.NfcAidGroup;
-
-public class NxpOffHostService {
- public int mUserId;
- public String mDescription = null;
- public String mSEName = null;
- public Drawable mBanner;
- public String mPackageName = null;
- public String mServiceName = null;
- public boolean mModifiable = true;
- public List<NfcAidGroup> mNfcAidGroupList = new ArrayList<NfcAidGroup>();
- public NxpNfcController mNxpNfcController;
- public int mBannerId;
- public Context mContext = null;
- public NxpOffHostService(int userId, String description, String SELocation,String packageName,
- String serviceName, boolean modifiable) {
- mUserId = userId;
- mDescription = description;
- mSEName = SELocation;
- mPackageName = packageName;
- mServiceName = serviceName;
- mModifiable = modifiable;
- }
-
- /**
- * Return the Secure Element name which holds the "Off-Host" service.
- * @return Secure Element name holding the "Off-Host" service
- */
- public String getLocation() {
- return mSEName;
- }
-
- /**
- * Return the description of the "NxpOff-Host" service.
- * @return The Description of the "NxpOff-Host" service
- */
- public String getDescription() {
- return mDescription;
- }
-
- /**
- * Return the Service Name of the "NxpOff-Host" service.
- * @return The Service name of the "NxpOff-Host" service
- */
- protected String getServiceName() {
- return mServiceName;
- }
-
- /**
- * Set a banner for the "NxpOff-Host" service.
- * @param banner A {@link Drawable} object representing the banner
- */
- public void setBanner(Drawable banner) {
- mBanner = banner;
- }
-
-
- /**
- * Set a banner for the "NxpOff-Host" service.
- * @param bannerid representing the banner
- */
- public void setBannerId(int bannerid) {
- mBannerId = bannerid;
- }
- /**
- * Get a modifiable for dynamic "NxpOff-Host" service.
- * @return modifiable for "NxpOff-Host service
- */
- protected boolean getModifiable() {
- return mModifiable;
- }
-
- /**
- * Return the banner linked to the "NxpOff-Host" service.
- * @return {@link Drawable} object representing the banner or <code>null</code> if no banner has been set
- */
- public Drawable getBanner() {
- return mBanner;
- }
-
- public int getBannerId() {
- return mBannerId;
- }
-
-
- public void setContext(Context context) {
- mContext = context;
- }
-
-
- public Context getContext() {
- return mContext;
- }
-
- public void setNxpNfcController(NxpNfcController nxpNfcController) {
- mNxpNfcController = nxpNfcController;
- }
-
- }
diff --git a/nxp-nfc-gsma/Android.mk b/nxp-nfc-gsma/Android.mk
deleted file mode 100644
index 8745ff5..0000000
--- a/nxp-nfc-gsma/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
-
-LOCAL_MODULE:= com.gsma.services.nfc
-LOCAL_JAVA_LIBRARIES := com.nxp.nfc
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_JAVA_LIBRARY)
diff --git a/nxp-nfc-gsma/com.gsma.services.nfc.xml b/nxp-nfc-gsma/com.gsma.services.nfc.xml
deleted file mode 100644
index c83c321..0000000
--- a/nxp-nfc-gsma/com.gsma.services.nfc.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- 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.
--->
-
-<permissions>
- <library name="com.gsma.services.nfc"
- file="/system/framework/com.gsma.services.nfc.jar" />
-</permissions>
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) {};
-
-}