summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Chang <georgekgchang@google.com>2022-05-04 17:46:10 +0800
committerGeorge Chang <georgekgchang@google.com>2022-05-04 23:35:33 +0800
commitf371742957349619043185f5a5f4cde8295c0519 (patch)
treec7e8319690dbefe8261be1d3e2ea2f5f25a40625 /src
parent3b1b320f5e0bfdf0b354dea7e65e1af6ad56290b (diff)
downloadNfc-f371742957349619043185f5a5f4cde8295c0519.tar.gz
Refine MSG_DELAY_POLLING enqueue condition
Bug: 231411134 Test: manual Merged-In: I0b2526c56b51f7d8e43ed412d44f04410a7e7a19 Change-Id: I0b2526c56b51f7d8e43ed412d44f04410a7e7a19
Diffstat (limited to 'src')
-rw-r--r--src/com/android/nfc/NfcService.java32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index d82a6d4a..c273123c 100644
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -938,10 +938,6 @@ public class NfcService implements DeviceHostListener {
mP2pLinkManager.enableDisable(false, false);
}
- // Disable delay polling when disabling
- mPollingDelayed = false;
- mHandler.removeMessages(MSG_DELAY_POLLING);
-
// Stop watchdog if tag present
// A convenient way to stop the watchdog properly consists of
// disconnecting the tag. The polling loop shall be stopped before
@@ -949,6 +945,9 @@ public class NfcService implements DeviceHostListener {
maybeDisconnectTarget();
synchronized (NfcService.this) {
+ // Disable delay polling when disabling
+ mPollingDelayed = false;
+ mHandler.removeMessages(MSG_DELAY_POLLING);
mPollingDisableDeathRecipients.clear();
mReaderModeParams = null;
}
@@ -2827,12 +2826,11 @@ public class NfcService implements DeviceHostListener {
mScreenState = (Integer)msg.obj;
Log.d(TAG, "MSG_APPLY_SCREEN_STATE " + mScreenState);
- // Disable delay polling when screen state changed
- mPollingDelayed = false;
- mHandler.removeMessages(MSG_DELAY_POLLING);
-
- // If NFC is turning off, we shouldn't need any changes here
synchronized (NfcService.this) {
+ // Disable delay polling when screen state changed
+ mPollingDelayed = false;
+ mHandler.removeMessages(MSG_DELAY_POLLING);
+ // If NFC is turning off, we shouldn't need any changes here
if (mState == NfcAdapter.STATE_TURNING_OFF)
return;
}
@@ -3138,12 +3136,18 @@ public class NfcService implements DeviceHostListener {
if (mPollDelay > NO_POLL_DELAY) {
tagEndpoint.stopPresenceChecking();
mDeviceHost.startStopPolling(false);
- mPollingDelayed = true;
- if (DBG) Log.d(TAG, "Polling delayed");
- mHandler.sendMessageDelayed(
- mHandler.obtainMessage(MSG_DELAY_POLLING), mPollDelay);
+ synchronized (NfcService.this) {
+ if (!mPollingDelayed) {
+ mPollingDelayed = true;
+ if (DBG) Log.d(TAG, "Polling delayed");
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MSG_DELAY_POLLING), mPollDelay);
+ } else {
+ if (DBG) Log.d(TAG, "Keep waiting for polling delay");
+ }
+ }
} else {
- Log.e(TAG, "Keep presence checking.");
+ Log.d(TAG, "Keep presence checking.");
}
if (mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED && mNotifyDispatchFailed) {
if (!sToast_debounce) {