summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/nfc/P2pEventManager.java19
-rwxr-xr-xsrc/com/android/nfc/P2pLinkManager.java5
2 files changed, 18 insertions, 6 deletions
diff --git a/src/com/android/nfc/P2pEventManager.java b/src/com/android/nfc/P2pEventManager.java
index 65e428ea..2e42b1b1 100644
--- a/src/com/android/nfc/P2pEventManager.java
+++ b/src/com/android/nfc/P2pEventManager.java
@@ -41,6 +41,7 @@ public class P2pEventManager implements P2pEventListener, SendUi.Callback {
boolean mSending;
boolean mNdefSent;
boolean mNdefReceived;
+ boolean mInDebounce;
public P2pEventManager(Context context, P2pEventListener.Callback callback) {
mNfcService = NfcService.getInstance();
@@ -68,6 +69,7 @@ public class P2pEventManager implements P2pEventListener, SendUi.Callback {
mNfcService.playSound(NfcService.SOUND_START);
mNdefSent = false;
mNdefReceived = false;
+ mInDebounce = false;
mVibrator.vibrate(VIBRATION_PATTERN, -1);
if (mSendUi != null) {
@@ -131,6 +133,7 @@ public class P2pEventManager implements P2pEventListener, SendUi.Callback {
if (!mNdefSent && !mNdefReceived && mSendUi != null) {
mSendUi.finish(SendUi.FINISH_SCALE_UP);
}
+ mInDebounce = false;
}
@Override
@@ -147,14 +150,22 @@ public class P2pEventManager implements P2pEventListener, SendUi.Callback {
@Override
public void onP2pSendDebounce() {
+ mInDebounce = true;
mNfcService.playSound(NfcService.SOUND_ERROR);
- mSendUi.showSendHint();
+ if (mSendUi != null) {
+ mSendUi.showSendHint();
+ }
}
@Override
public void onP2pResumeSend() {
- mVibrator.vibrate(VIBRATION_PATTERN, -1);
- mNfcService.playSound(NfcService.SOUND_START);
- mSendUi.showStartSend();
+ if (mInDebounce) {
+ mVibrator.vibrate(VIBRATION_PATTERN, -1);
+ mNfcService.playSound(NfcService.SOUND_START);
+ if (mSendUi != null) {
+ mSendUi.showStartSend();
+ }
+ }
+ mInDebounce = false;
}
}
diff --git a/src/com/android/nfc/P2pLinkManager.java b/src/com/android/nfc/P2pLinkManager.java
index 6c6a1b87..4e8dfaa7 100755
--- a/src/com/android/nfc/P2pLinkManager.java
+++ b/src/com/android/nfc/P2pLinkManager.java
@@ -587,7 +587,8 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba
}
mLlcpServicesConnected = true;
if (mSendState == SEND_STATE_SENDING) {
- // Send was previously confirmed, we probably cycled through a debounce
+ // FIXME Keep state to make sure this is only called when in debounce
+ // and remove logic in P2pEventManager to keep track.
mEventListener.onP2pResumeSend();
sendNdefMessage();
} else {
@@ -1018,7 +1019,7 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba
if (mLinkState == LINK_STATE_WAITING_PDU) {
// We could decide to wait for the first PDU here; but
// that makes us vulnerable to cases where for some reason
- // this event is not propogated up by the stack. Instead,
+ // this event is not propagated up by the stack. Instead,
// try to connect now.
mLinkState = LINK_STATE_UP;
connectLlcpServices();