From b4d9c2712a09721a7ead0e250a9da8e8be640344 Mon Sep 17 00:00:00 2001 From: chloedai Date: Tue, 11 Jan 2022 04:24:35 +0000 Subject: Add methods to check tag availability setTagUpToDate: record the new tag's cookie while creating a tag object, the value could be used to check the tag availability isTagUpToDate: compare the latest cookie to the tag's cookie, which generated when it was created, to check whether the tag object is the latest or not Bug: 199291025 Test: test with some reader apps, test pass Change-Id: Ia1e21a95605020b6af8cceda0869f982048568ba --- src/com/android/nfc/NfcService.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 4b6c0906..2ec29477 100644 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -335,6 +335,9 @@ public class NfcService implements DeviceHostListener { boolean mNotifyDispatchFailed; boolean mNotifyReadFailed; + // for recording the latest Tag object cookie + long mCookieUpToDate = 0; + private NfcDispatcher mNfcDispatcher; private PowerManager mPowerManager; private KeyguardManager mKeyguard; @@ -2051,6 +2054,23 @@ public class NfcService implements DeviceHostListener { public boolean getExtendedLengthApdusSupported() throws RemoteException { return mDeviceHost.getExtendedLengthApdusSupported(); } + + @Override + public void setTagUpToDate(long cookie) throws RemoteException { + if (DBG) Log.d(TAG, "Register Tag " + Long.toString(cookie) + " as the latest"); + mCookieUpToDate = cookie; + } + + @Override + public boolean isTagUpToDate(long cookie) throws RemoteException { + if (mCookieUpToDate == cookie) { + if (DBG) Log.d(TAG, "Tag " + Long.toString(cookie) + " is up to date"); + return true; + } + + if (DBG) Log.d(TAG, "Tag " + Long.toString(cookie) + " is out of date"); + return false; + } } final class NfcDtaService extends INfcDta.Stub { -- cgit v1.2.3