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

Commit a8926f09 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add T4T Ndef Nfceee feature support" into main am: f3e2a345 am: fd3b8fa2

parents 6e86ae83 fd3b8fa2
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ package android.nfc {
    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public java.util.List<java.lang.String> getActiveNfceeList();
    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public android.nfc.RoutingStatus getRoutingStatus();
    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public java.util.List<android.nfc.NfcRoutingTableEntry> getRoutingTable();
    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public android.nfc.T4tNdefNfcee getT4tNdefNfcee();
    method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean hasUserEnabledNfc();
    method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isAutoChangeEnabled();
    method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isTagPresent();
@@ -186,6 +187,47 @@ package android.nfc {
    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int TECHNOLOGY_V = 3; // 0x3
  }

  @FlaggedApi("android.nfc.nfc_oem_extension") public final class T4tNdefNfcee {
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) @WorkerThread public int clearData();
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isOperationOngoing();
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isSupported();
    method @Nullable @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) @WorkerThread public android.nfc.T4tNdefNfceeCcFileInfo readCcfile();
    method @NonNull @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) @WorkerThread public byte[] readData(@IntRange(from=0, to=65535) int);
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) @WorkerThread public int writeData(@IntRange(from=0, to=65535) int, @NonNull byte[]);
    field public static final int CLEAR_DATA_FAILED_INTERNAL = 0; // 0x0
    field public static final int CLEAR_DATA_SUCCESS = 1; // 0x1
    field public static final int WRITE_DATA_ERROR_CONNECTION_FAILED = -6; // 0xfffffffa
    field public static final int WRITE_DATA_ERROR_EMPTY_PAYLOAD = -7; // 0xfffffff9
    field public static final int WRITE_DATA_ERROR_INTERNAL = -1; // 0xffffffff
    field public static final int WRITE_DATA_ERROR_INVALID_FILE_ID = -4; // 0xfffffffc
    field public static final int WRITE_DATA_ERROR_INVALID_LENGTH = -5; // 0xfffffffb
    field public static final int WRITE_DATA_ERROR_NDEF_VALIDATION_FAILED = -8; // 0xfffffff8
    field public static final int WRITE_DATA_ERROR_NFC_NOT_ON = -3; // 0xfffffffd
    field public static final int WRITE_DATA_ERROR_RF_ACTIVATED = -2; // 0xfffffffe
    field public static final int WRITE_DATA_SUCCESS = 0; // 0x0
  }

  @FlaggedApi("android.nfc.nfc_oem_extension") public final class T4tNdefNfceeCcFileInfo implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=15, to=32767) public int getCcFileLength();
    method @IntRange(from=0xffffffff, to=65535) public int getFileId();
    method @IntRange(from=15, to=65535) public int getMaxReadLength();
    method @IntRange(from=5, to=32767) public int getMaxSize();
    method @IntRange(from=13, to=65535) public int getMaxWriteLength();
    method public int getReadAccess();
    method public int getVersion();
    method public int getWriteAccess();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nfc.T4tNdefNfceeCcFileInfo> CREATOR;
    field public static final int READ_ACCESS_GRANTED_RESTRICTED = 128; // 0x80
    field public static final int READ_ACCESS_GRANTED_UNRESTRICTED = 0; // 0x0
    field public static final int VERSION_2_0 = 32; // 0x20
    field public static final int VERSION_3_0 = 48; // 0x30
    field public static final int WRITE_ACCESS_GRANTED_RESTRICTED = 128; // 0x80
    field public static final int WRITE_ACCESS_GRANTED_UNRESTRICTED = 0; // 0x0
    field public static final int WRITE_ACCESS_NOT_GRANTED = 255; // 0xff
  }

}

package android.nfc.cardemulation {
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.nfc.INfcCardEmulation;
import android.nfc.INfcFCardEmulation;
import android.nfc.INfcOemExtensionCallback;
import android.nfc.INfcUnlockHandler;
import android.nfc.IT4tNdefNfcee;
import android.nfc.ITagRemovedCallback;
import android.nfc.INfcDta;
import android.nfc.INfcWlcStateListener;
@@ -122,4 +123,5 @@ interface INfcAdapter
    void indicateDataMigration(boolean inProgress, String pkg);
    int commitRouting();
    boolean isTagIntentAllowed(in String pkg, in int Userid);
    IT4tNdefNfcee getT4tNdefNfceeInterface();
}
+33 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2024 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.
 *
 ******************************************************************************/

package android.nfc;

import android.nfc.T4tNdefNfceeCcFileInfo;

/**
 * @hide
 */
interface IT4tNdefNfcee {
    int writeData(in int fileId, in byte[] data);
    byte[] readData(in int fileId);
    int clearNdefData();
    boolean isNdefOperationOngoing();
    boolean isNdefNfceeEmulationSupported();
    T4tNdefNfceeCcFileInfo readCcfile();
}
+8 −1
Original line number Diff line number Diff line
@@ -589,6 +589,7 @@ public final class NfcAdapter {
    static INfcTag sTagService;
    static INfcCardEmulation sCardEmulationService;
    static INfcFCardEmulation sNfcFCardEmulationService;
    static IT4tNdefNfcee sNdefNfceeService;

    /**
     * The NfcAdapter object for each application context.
@@ -827,7 +828,13 @@ public final class NfcAdapter {
                    throw new UnsupportedOperationException();
                }
            }

            try {
                sNdefNfceeService = sService.getT4tNdefNfceeInterface();
            } catch (RemoteException e) {
                sNdefNfceeService = null;
                Log.e(TAG, "could not retrieve NDEF NFCEE service");
                throw new UnsupportedOperationException();
            }
            sIsInitialized = true;
        }
        NfcAdapter adapter = sNfcAdapters.get(context);
+22 −0
Original line number Diff line number Diff line
@@ -491,6 +491,28 @@ public final class NfcOemExtension {
        mOemNfcExtensionCallback = new NfcOemExtensionCallback();
    }

    /**
     * Get an instance of {@link T4tNdefNfcee} object for performing T4T (Type-4 Tag)
     * NDEF (NFC Data Exchange Format) NFCEE (NFC Execution Environment) operations.
     * This can be used to write NDEF data to emulate a T4T tag in an NFCEE
     * (NFC Execution Environment - eSE, SIM, etc). Refer to the NFC forum specification
     * "NFCForum-TS-NCI-2.3 section 10.4" and "NFCForum-TS-T4T-1.1 section 4.2" for more details.
     *
     * This is a singleton object which shall be used by OEM extension module to do NDEF-NFCEE
     * read/write operations.
     *
     * <p>Returns {@link T4tNdefNfcee}
     * <p>Does not cause any RF activity and does not block.
     * @return NFC Data Exchange Format (NDEF) NFC Execution Environment (NFCEE) object
     * @hide
     */
    @SystemApi
    @NonNull
    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
    public T4tNdefNfcee getT4tNdefNfcee() {
        return T4tNdefNfcee.getInstance();
    }

    /**
     * Register an {@link Callback} to listen for NFC oem extension callbacks
     * Multiple clients can register and callbacks will be invoked asynchronously.
Loading