From 861472d106fd7fd4ba7da9deab421769cdd32f41 Mon Sep 17 00:00:00 2001 From: ziyiw Date: Wed, 20 Nov 2024 19:37:07 +0000 Subject: [framework] Add an API to get max pause polling timeout. Bug: 370911124 Test: atest CtsNfcTestCases Change-Id: Ie8eb72e0727b1ac1aff541ebf572cabe0d5366a5 --- nfc/api/system-current.txt | 3 ++- nfc/java/android/nfc/INfcAdapter.aidl | 3 ++- nfc/java/android/nfc/NfcOemExtension.java | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt index 031ed73e18ea..3ed9b7667be7 100644 --- a/nfc/api/system-current.txt +++ b/nfc/api/system-current.txt @@ -58,6 +58,7 @@ package android.nfc { method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void clearPreference(); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int forceRoutingTableCommit(); method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public java.util.Map getActiveNfceeList(); + method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public long getMaxPausePollingTimeoutMills(); 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 getRoutingTable(); method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public android.nfc.T4tNdefNfcee getT4tNdefNfcee(); @@ -66,7 +67,7 @@ package android.nfc { method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isTagPresent(); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void maybeTriggerFirmwareUpdate(); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void overwriteRoutingTable(int, int, int, int); - method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int pausePolling(int); + method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int pausePolling(long); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcOemExtension.Callback); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int resumePolling(); method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setAutoChangeEnabled(boolean); diff --git a/nfc/java/android/nfc/INfcAdapter.aidl b/nfc/java/android/nfc/INfcAdapter.aidl index 5ae1be201088..ac0a5aaaa195 100644 --- a/nfc/java/android/nfc/INfcAdapter.aidl +++ b/nfc/java/android/nfc/INfcAdapter.aidl @@ -53,7 +53,7 @@ interface INfcAdapter int getState(); boolean disable(boolean saveState, in String pkg); boolean enable(in String pkg); - int pausePolling(int timeoutInMs); + int pausePolling(long timeoutInMs); int resumePolling(); void setForegroundDispatch(in PendingIntent intent, @@ -124,4 +124,5 @@ interface INfcAdapter int commitRouting(); boolean isTagIntentAllowed(in String pkg, in int Userid); IT4tNdefNfcee getT4tNdefNfceeInterface(); + long getMaxPausePollingTimeoutMs(); } diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java index f1198ed92cff..f78161e7cad0 100644 --- a/nfc/java/android/nfc/NfcOemExtension.java +++ b/nfc/java/android/nfc/NfcOemExtension.java @@ -748,15 +748,16 @@ public final class NfcOemExtension { /** * Pauses NFC tag reader mode polling for a {@code timeoutInMs} millisecond. * In case of {@code timeoutInMs} is zero or invalid polling will be stopped indefinitely. - * Use {@link #resumePolling() to resume the polling. - * @param timeoutInMs the pause polling duration in millisecond, ranging from 0 to 40000. + * Use {@link #resumePolling()} to resume the polling. + * Use {@link #getMaxPausePollingTimeoutMs()} to check the max timeout value. + * @param timeoutInMs the pause polling duration in millisecond. * @return status of the operation * @throws IllegalArgumentException if timeoutInMs value is invalid * (0 < timeoutInMs < max). */ @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) - public @PollingStateChangeStatusCode int pausePolling(@DurationMillisLong int timeoutInMs) { + public @PollingStateChangeStatusCode int pausePolling(@DurationMillisLong long timeoutInMs) { return NfcAdapter.callServiceReturn(() -> NfcAdapter.sService.pausePolling(timeoutInMs), POLLING_STATE_CHANGE_ALREADY_IN_REQUESTED_STATE); @@ -775,6 +776,18 @@ public final class NfcOemExtension { POLLING_STATE_CHANGE_ALREADY_IN_REQUESTED_STATE); } + /** + * Gets the max pause polling timeout value in millisecond. + * @return long integer representing the max timeout + */ + @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) + @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) + @DurationMillisLong + public long getMaxPausePollingTimeoutMills() { + return NfcAdapter.callServiceReturn(() -> + NfcAdapter.sService.getMaxPausePollingTimeoutMs(), 0L); + } + /** * Set whether to enable auto routing change or not (enabled by default). * If disabled, routing targets are limited to a single off-host destination. -- cgit v1.2.3-59-g8ed1b