diff options
author | chloedai <chloedai@google.com> | 2022-01-11 04:24:35 +0000 |
---|---|---|
committer | chloedai <chloedai@google.com> | 2022-01-19 18:23:12 +0000 |
commit | b4d9c2712a09721a7ead0e250a9da8e8be640344 (patch) | |
tree | fc456a5e63851d1f8b60bb56c11590cdc126b0fb /src | |
parent | da0d8b9d571feb144c8d8b6a2b43fc0078f3043d (diff) | |
download | Nfc-b4d9c2712a09721a7ead0e250a9da8e8be640344.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/nfc/NfcService.java | 20 |
1 files changed, 20 insertions, 0 deletions
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 { |