diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/nfc/NfcService.java | 32 |
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) { |