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

Commit 63b108b3 authored by Roshan Pius's avatar Roshan Pius Committed by Gerrit Code Review
Browse files

Merge "Implementing support for NFC observe mode, polling loop fingerprints...

Merge "Implementing support for NFC observe mode, polling loop fingerprints and field strength along with their associated APIs." into main
parents 3ded04f4 b8c4f9bf
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -121,6 +121,18 @@ aconfig_declarations {
    srcs: ["core/java/android/nfc/*.aconfig"],
}

cc_aconfig_library {
    name: "android_nfc_flags_aconfig_c_lib",
    vendor_available: true,
    aconfig_declarations: "android.nfc.flags-aconfig",
    apex_available: [
        "//apex_available:platform",
        "com.android.nfcservices",
        "nfc_nci.st21nfc.default",
    ],
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

java_aconfig_library {
    name: "android.nfc.flags-aconfig-java",
    aconfig_declarations: "android.nfc.flags-aconfig",
+15 −0
Original line number Diff line number Diff line
@@ -29105,14 +29105,17 @@ package android.nfc {
  }
  public final class NfcAdapter {
    method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean allowTransaction();
    method public void disableForegroundDispatch(android.app.Activity);
    method public void disableReaderMode(android.app.Activity);
    method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean disallowTransaction();
    method public void enableForegroundDispatch(android.app.Activity, android.app.PendingIntent, android.content.IntentFilter[], String[][]);
    method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle);
    method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context);
    method @Nullable public android.nfc.NfcAntennaInfo getNfcAntennaInfo();
    method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler);
    method public boolean isEnabled();
    method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean isObserveModeSupported();
    method @FlaggedApi("android.nfc.enable_nfc_reader_option") public boolean isReaderOptionEnabled();
    method @FlaggedApi("android.nfc.enable_nfc_reader_option") public boolean isReaderOptionSupported();
    method public boolean isSecureNfcEnabled();
@@ -29220,6 +29223,7 @@ package android.nfc.cardemulation {
    method public boolean removeAidsForService(android.content.ComponentName, String);
    method @NonNull @RequiresPermission(android.Manifest.permission.NFC) public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String);
    method public boolean setPreferredService(android.app.Activity, android.content.ComponentName);
    method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean setServiceObserveModeDefault(@NonNull android.content.ComponentName, boolean);
    method public boolean supportsAidPrefixRegistration();
    method @NonNull @RequiresPermission(android.Manifest.permission.NFC) public boolean unsetOffHostForService(@NonNull android.content.ComponentName);
    method public boolean unsetPreferredService(android.app.Activity);
@@ -29239,9 +29243,20 @@ package android.nfc.cardemulation {
    method public final android.os.IBinder onBind(android.content.Intent);
    method public abstract void onDeactivated(int);
    method public abstract byte[] processCommandApdu(byte[], android.os.Bundle);
    method @FlaggedApi("android.nfc.nfc_read_polling_loop") public void processPollingFrames(@NonNull java.util.List<android.os.Bundle>);
    method public final void sendResponseApdu(byte[]);
    field public static final int DEACTIVATION_DESELECTED = 1; // 0x1
    field public static final int DEACTIVATION_LINK_LOSS = 0; // 0x0
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final String POLLING_LOOP_DATA_KEY = "android.nfc.cardemulation.DATA";
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final String POLLING_LOOP_GAIN_KEY = "android.nfc.cardemulation.GAIN";
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final String POLLING_LOOP_TIMESTAMP_KEY = "android.nfc.cardemulation.TIMESTAMP";
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final char POLLING_LOOP_TYPE_A = 65; // 0x0041 'A'
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final char POLLING_LOOP_TYPE_B = 66; // 0x0042 'B'
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final char POLLING_LOOP_TYPE_F = 70; // 0x0046 'F'
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final String POLLING_LOOP_TYPE_KEY = "android.nfc.cardemulation.TYPE";
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final char POLLING_LOOP_TYPE_OFF = 88; // 0x0058 'X'
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final char POLLING_LOOP_TYPE_ON = 79; // 0x004f 'O'
    field @FlaggedApi("android.nfc.nfc_read_polling_loop") public static final char POLLING_LOOP_TYPE_UNKNOWN = 85; // 0x0055 'U'
    field public static final String SERVICE_INTERFACE = "android.nfc.cardemulation.action.HOST_APDU_SERVICE";
    field public static final String SERVICE_META_DATA = "android.nfc.cardemulation.host_apdu_service";
  }
+2 −0
Original line number Diff line number Diff line
@@ -84,4 +84,6 @@ interface INfcAdapter
    boolean isReaderOptionSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)")
    boolean enableReaderOption(boolean enable);
    boolean isObserveModeSupported();
    boolean setObserveMode(boolean enabled);
}
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ interface INfcCardEmulation
    boolean isDefaultServiceForAid(int userHandle, in ComponentName service, String aid);
    boolean setDefaultServiceForCategory(int userHandle, in ComponentName service, String category);
    boolean setDefaultForNextTap(int userHandle, in ComponentName service);
    boolean setServiceObserveModeDefault(int userId, in android.content.ComponentName service, boolean enable);
    boolean registerAidGroupForService(int userHandle, in ComponentName service, in AidGroup aidGroup);
    boolean setOffHostForService(int userHandle, in ComponentName service, in String offHostSecureElement);
    boolean unsetOffHostForService(int userHandle, in ComponentName service);
+55 −0
Original line number Diff line number Diff line
@@ -1081,6 +1081,61 @@ public final class NfcAdapter {
        }
    }


    /**
     * Returns whether the device supports observer mode or not. When observe
     * mode is enabled, the NFC hardware will listen for NFC readers, but not
     * respond to them. When observe mode is disabled, the NFC hardware will
     * resoond to the reader and proceed with the transaction.
     * @return true if the mode is supported, false otherwise.
     */
    @FlaggedApi(Flags.FLAG_NFC_OBSERVE_MODE)
    public boolean isObserveModeSupported() {
        try {
            return sService.isObserveModeSupported();
        } catch (RemoteException e) {
            attemptDeadServiceRecovery(e);
            return false;
        }
    }

   /**
    * Disables observe mode to allow the transaction to proceed. See
    * {@link #isObserveModeSupported()} for a description of observe mode and
    * use {@link #disallowTransaction()} to enable observe mode and block
    * transactions again.
    *
    * @return boolean indicating success or failure.
    */
    @FlaggedApi(Flags.FLAG_NFC_OBSERVE_MODE)
    public boolean allowTransaction() {
        try {
            return sService.setObserveMode(false);
        } catch (RemoteException e) {
            attemptDeadServiceRecovery(e);
            return false;
        }
    }

    /**
    * Signals that the transaction has completed and observe mode may be
    * reenabled. See {@link #isObserveModeSupported()} for a description of
    * observe mode and use {@link #allowTransaction()} to disable observe
    * mode and allow transactions to proceed.
    *
    * @return boolean indicating success or failure.
    */

    @FlaggedApi(Flags.FLAG_NFC_OBSERVE_MODE)
    public boolean disallowTransaction() {
        try {
            return sService.setObserveMode(true);
        } catch (RemoteException e) {
            attemptDeadServiceRecovery(e);
            return false;
        }
    }

    /**
     * Resumes default polling for the current device state if polling is paused. Calling
     * this while polling is not paused is a no-op.
Loading