summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Chang <georgekgchang@google.com>2022-05-11 08:43:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-05-11 08:43:37 +0000
commitf5f7b7db5d7857c3bb7dcae4174b37cdc0e25119 (patch)
treebcec15534f34a14c424594ab06e2243c4363300e
parent7c7c8ca90b7cc47ae58802278300da7390eecfb1 (diff)
parent89964af018a58b0f4f4c5d10328e9a76c4868325 (diff)
downloadNfc-f5f7b7db5d7857c3bb7dcae4174b37cdc0e25119.tar.gz
Merge changes I3371d1b3,I0b2526c5 into tm-dev
* changes: Refine delay polling control flow Refine MSG_DELAY_POLLING enqueue condition
-rw-r--r--src/com/android/nfc/NfcService.java34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index d82a6d4a..5cdd148f 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;
}
@@ -3137,13 +3135,19 @@ public class NfcService implements DeviceHostListener {
unregisterObject(tagEndpoint.getHandle());
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;
+ mDeviceHost.startStopPolling(false);
+ 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) {