Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 367f41f8 authored by Nick Pelly's avatar Nick Pelly
Browse files

Implement new NFC-EE API's as shared library (frameworks/base).

Change-Id: I45c4eaf59ec78167fc236fdd59676465a5e1bcb7
parent dfcb8c51
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -121,10 +121,10 @@ LOCAL_SRC_FILES += \
	core/java/android/nfc/ILlcpServiceSocket.aidl \
	core/java/android/nfc/ILlcpSocket.aidl \
	core/java/android/nfc/INfcAdapter.aidl \
	core/java/android/nfc/INfcAdapterExtras.aidl \
	core/java/android/nfc/INfcTag.aidl \
	core/java/android/nfc/IP2pInitiator.aidl \
	core/java/android/nfc/IP2pTarget.aidl \
    core/java/android/nfc/INfcSecureElement.aidl \
	core/java/android/os/IHardwareService.aidl \
	core/java/android/os/IMessenger.aidl \
	core/java/android/os/INetworkManagementService.aidl \
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/androi
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/trustedlogic)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/com/trustedlogic)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc/INdefTag.java)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc)

# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+3 −8
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.nfc.ILlcpConnectionlessSocket;
import android.nfc.INfcTag;
import android.nfc.IP2pTarget;
import android.nfc.IP2pInitiator;
import android.nfc.INfcSecureElement;
import android.nfc.INfcAdapterExtras;

/**
 * @hide
@@ -41,13 +41,12 @@ interface INfcAdapter
    INfcTag getNfcTagInterface();
    IP2pTarget getP2pTargetInterface();
    IP2pInitiator getP2pInitiatorInterface();
    INfcSecureElement getNfcSecureElementInterface();
    INfcAdapterExtras getNfcAdapterExtrasInterface();

    // NfcAdapter-class related methods
    boolean isEnabled();
    NdefMessage localGet();
    void localSet(in NdefMessage message);
    void openTagConnection(in Tag tag);
    void enableForegroundDispatch(in ComponentName activity, in PendingIntent intent,
            in IntentFilter[] filters, in TechListParcel techLists);
    void disableForegroundDispatch(in ComponentName activity);
@@ -59,12 +58,8 @@ interface INfcAdapter
    int createLlcpConnectionlessSocket(int sap);
    int createLlcpServiceSocket(int sap, String sn, int miu, int rw, int linearBufferLength);
    int createLlcpSocket(int sap, int miu, int rw, int linearBufferLength);
    int deselectSecureElement();
    boolean disable();
    boolean enable();
    String getProperties(String param);
    int[] getSecureElementList();
    int getSelectedSecureElement();
    int selectSecureElement(int seId);
    int setProperties(String param, String value);
}
+10 −8
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 * 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.
@@ -16,13 +16,15 @@

package android.nfc;

import android.os.Bundle;

/**
 * {@hide}
 */
interface INfcSecureElement {
    int openSecureElementConnection();
    int closeSecureElementConnection(int nativeHandle);
    byte[] exchangeAPDU(int nativeHandle, in byte[] data);
    int[] getSecureElementTechList(int nativeHandle);
    byte[] getSecureElementUid(int nativeHandle);
interface INfcAdapterExtras {
    Bundle open(IBinder b);
    Bundle close();
    Bundle transceive(in byte[] data_in);
    int getCardEmulationRoute();
    void setCardEmulationRoute(int route);    
}
+3 −62
Original line number Diff line number Diff line
@@ -156,31 +156,6 @@ public final class NfcAdapter {
     */
    public static final String EXTRA_ID = "android.nfc.extra.ID";

    /**
     * Broadcast Action: a transaction with a secure element has been detected.
     * <p>
     * Always contains the extra field
     * {@link android.nfc.NfcAdapter#EXTRA_AID}
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_TRANSACTION_DETECTED =
            "android.nfc.action.TRANSACTION_DETECTED";

    /**
     * Broadcast Action: an RF field ON has been detected.
     * @hide
     */
    public static final String ACTION_RF_FIELD_ON_DETECTED =
            "android.nfc.action.RF_FIELD_ON_DETECTED";

    /**
     * Broadcast Action: an RF Field OFF has been detected.
     * @hide
     */
    public static final String ACTION_RF_FIELD_OFF_DETECTED =
            "android.nfc.action.RF_FIELD_OFF_DETECTED";

    /**
     * Broadcast Action: an adapter's state changed between enabled and disabled.
     *
@@ -200,15 +175,6 @@ public final class NfcAdapter {
     */
    public static final String EXTRA_NEW_BOOLEAN_STATE = "android.nfc.isEnabled";

    /**
     * Mandatory byte array extra field in
     * {@link android.nfc.NfcAdapter#ACTION_TRANSACTION_DETECTED}.
     * <p>
     * Contains the AID of the applet involved in the transaction.
     * @hide
     */
    public static final String EXTRA_AID = "android.nfc.extra.AID";

    /**
     * LLCP link status: The LLCP link is activated.
     * @hide
@@ -691,39 +657,14 @@ public final class NfcAdapter {
    }

    /**
     * Create an Nfc Secure Element Connection
     * @hide
     */
    public NfcSecureElement createNfcSecureElementConnection() {
    public INfcAdapterExtras getNfcAdapterExtrasInterface() {
        try {
            return new NfcSecureElement(sService.getNfcSecureElementInterface());
            return sService.getNfcAdapterExtrasInterface();
        } catch (RemoteException e) {
            Log.e(TAG, "createNfcSecureElementConnection failed", e);
            attemptDeadServiceRecovery(e);
            return null;
        }
    }

    /**
     * To change the Secure Element Card Emulation state (ON/OFF)
     * @hide
     */
    public void changeNfcSecureElementCardEmulationState(boolean state)
    {
        int seId = 11259375;
        if(state){
            /* Enable card emulation */
            try {
                sService.selectSecureElement(seId);
            } catch (RemoteException e) {
                Log.e(TAG, "Enable card emulation failed", e);
            }
        }else{
            /* Disable card emulation */
            try {
                sService.deselectSecureElement();
            } catch (RemoteException e) {
                Log.e(TAG, " card emulation failed", e);
            }
        }
    }
}
Loading