diff options
author | Nick Pelly <npelly@google.com> | 2012-03-29 09:58:51 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-03-29 09:58:51 -0700 |
commit | 28d3d2df015a44b293e648036ebfd609363158aa (patch) | |
tree | eacc92709a12376d19cb00d3b51e98c73264b794 /src/com | |
parent | 950030f3ec899dc201bf22be62e2c590a79e7685 (diff) | |
parent | c96f982f8c0fa061701143a27395acf3b24dfb54 (diff) | |
download | packages_apps_nfc-28d3d2df015a44b293e648036ebfd609363158aa.zip packages_apps_nfc-28d3d2df015a44b293e648036ebfd609363158aa.tar.gz packages_apps_nfc-28d3d2df015a44b293e648036ebfd609363158aa.tar.bz2 |
Merge "Keep static NDEF in application rather than NFC Service."
Diffstat (limited to 'src/com')
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 4 | ||||
-rwxr-xr-x | src/com/android/nfc/P2pLinkManager.java | 20 |
2 files changed, 9 insertions, 15 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 9cd5503..b046cfb 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -768,9 +768,9 @@ public class NfcService extends Application implements DeviceHostListener { } @Override - public void setForegroundNdefPush(NdefMessage msg, INdefPushCallback callback) { + public void setNdefPushCallback(INdefPushCallback callback) { mContext.enforceCallingOrSelfPermission(NFC_PERM, NFC_PERM_ERROR); - mP2pLinkManager.setNdefToSend(msg, callback); + mP2pLinkManager.setNdefCallback(callback); } @Override diff --git a/src/com/android/nfc/P2pLinkManager.java b/src/com/android/nfc/P2pLinkManager.java index ee0473f..499a52b 100755 --- a/src/com/android/nfc/P2pLinkManager.java +++ b/src/com/android/nfc/P2pLinkManager.java @@ -144,7 +144,6 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba boolean mIsSendEnabled; boolean mIsReceiveEnabled; NdefMessage mMessageToSend; // valid during SEND_STATE_NEED_CONFIRMATION or SEND_STATE_SENDING - NdefMessage mStaticNdef; INdefPushCallback mCallbackNdef; SendTask mSendTask; SharedPreferences mPrefs; @@ -196,15 +195,14 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba } /** - * Set NDEF message or callback for sending. + * Set NDEF callback for sending. * May be called from any thread. - * NDEF messages or callbacks may be set at any time (even if NFC is + * NDEF callbacks may be set at any time (even if NFC is * currently off or P2P send is currently off). They will become * active as soon as P2P send is enabled. */ - public void setNdefToSend(NdefMessage staticNdef, INdefPushCallback callbackNdef) { + public void setNdefCallback(INdefPushCallback callbackNdef) { synchronized (this) { - mStaticNdef = staticNdef; mCallbackNdef = callbackNdef; } } @@ -257,8 +255,8 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba return; } - // Look for a callback, if it does not exist or fails, fall back - // to pushed messages + // Try application callback first + //TODO: Check that mCallbackNdef refers to the foreground activity if (mCallbackNdef != null) { try { mMessageToSend = mCallbackNdef.createMessage(); @@ -268,11 +266,8 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba } } - if (mStaticNdef != null) { - mMessageToSend = mStaticNdef; - } else { - mMessageToSend = createDefaultNdef(); - } + // fall back to default NDEF for this activity + mMessageToSend = createDefaultNdef(); } } @@ -602,7 +597,6 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba pw.println("mLinkState=" + linkStateToString(mLinkState)); pw.println("mSendState=" + sendStateToString(mSendState)); - pw.println("mStaticNdef=" + mStaticNdef); pw.println("mCallbackNdef=" + mCallbackNdef); pw.println("mMessageToSend=" + mMessageToSend); } |