summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-04-12 16:37:18 -0700
committerMartijn Coenen <maco@google.com>2012-04-12 16:37:18 -0700
commit20e8dd9f9e7cff63c83e36a1761538a04c224cc1 (patch)
treea78453544d4475ba56eb960294c4b2b74725fd07 /core
parentd76008ace14dfa3b60193eaccdc7a60162d64624 (diff)
downloadframeworks_base-20e8dd9f9e7cff63c83e36a1761538a04c224cc1.zip
frameworks_base-20e8dd9f9e7cff63c83e36a1761538a04c224cc1.tar.gz
frameworks_base-20e8dd9f9e7cff63c83e36a1761538a04c224cc1.tar.bz2
Unhide new Beam push APIs.
Also added support for multiple Uris, removed mimeType argument. Change-Id: Iad2c4d0e36a174080d7bc9c9c8ab893f90231d02
Diffstat (limited to 'core')
-rw-r--r--core/java/android/nfc/INdefPushCallback.aidl3
-rw-r--r--core/java/android/nfc/NfcActivityManager.java57
-rw-r--r--core/java/android/nfc/NfcAdapter.java43
3 files changed, 76 insertions, 27 deletions
diff --git a/core/java/android/nfc/INdefPushCallback.aidl b/core/java/android/nfc/INdefPushCallback.aidl
index 4e79822..1c6d5d0 100644
--- a/core/java/android/nfc/INdefPushCallback.aidl
+++ b/core/java/android/nfc/INdefPushCallback.aidl
@@ -25,7 +25,6 @@ import android.net.Uri;
interface INdefPushCallback
{
NdefMessage createMessage();
- Uri getUri();
- String getMimeType();
+ Uri[] getUris();
void onNdefPushComplete();
}
diff --git a/core/java/android/nfc/NfcActivityManager.java b/core/java/android/nfc/NfcActivityManager.java
index f80dae4..7ffa575 100644
--- a/core/java/android/nfc/NfcActivityManager.java
+++ b/core/java/android/nfc/NfcActivityManager.java
@@ -108,8 +108,8 @@ public final class NfcActivityManager extends INdefPushCallback.Stub
NdefMessage ndefMessage = null; // static NDEF message
NfcAdapter.CreateNdefMessageCallback ndefMessageCallback = null;
NfcAdapter.OnNdefPushCompleteCallback onNdefPushCompleteCallback = null;
- Uri uri = null;
- String mimeType = null;
+ NfcAdapter.CreateBeamUrisCallback uriCallback = null;
+ Uri[] uris = null;
public NfcActivityState(Activity activity) {
if (activity.getWindow().isDestroyed()) {
throw new IllegalStateException("activity is already destroyed");
@@ -128,14 +128,19 @@ public final class NfcActivityManager extends INdefPushCallback.Stub
ndefMessage = null;
ndefMessageCallback = null;
onNdefPushCompleteCallback = null;
- uri = null;
- mimeType = null;
+ uriCallback = null;
+ uris = null;
}
@Override
public String toString() {
StringBuilder s = new StringBuilder("[").append(" ");
s.append(ndefMessage).append(" ").append(ndefMessageCallback).append(" ");
- s.append(onNdefPushCompleteCallback).append(" ").append(uri).append("]");
+ s.append(uriCallback).append(" ");
+ if (uris != null) {
+ for (Uri uri : uris) {
+ s.append(onNdefPushCompleteCallback).append(" ").append(uri).append("]");
+ }
+ }
return s.toString();
}
}
@@ -184,12 +189,25 @@ public final class NfcActivityManager extends INdefPushCallback.Stub
mDefaultEvent = new NfcEvent(mAdapter);
}
- public void setNdefPushContentUri(Activity activity, String mimeType, Uri uri) {
+ public void setNdefPushContentUri(Activity activity, Uri[] uris) {
+ boolean isResumed;
+ synchronized (NfcActivityManager.this) {
+ NfcActivityState state = getActivityState(activity);
+ state.uris = uris;
+ isResumed = state.resumed;
+ }
+ if (isResumed) {
+ requestNfcServiceCallback(true);
+ }
+ }
+
+
+ public void setNdefPushContentUriCallback(Activity activity,
+ NfcAdapter.CreateBeamUrisCallback callback) {
boolean isResumed;
synchronized (NfcActivityManager.this) {
NfcActivityState state = getActivityState(activity);
- state.uri = uri;
- state.mimeType = mimeType;
+ state.uriCallback = callback;
isResumed = state.resumed;
}
if (isResumed) {
@@ -271,24 +289,22 @@ public final class NfcActivityManager extends INdefPushCallback.Stub
/** Callback from NFC service, usually on binder thread */
@Override
- public Uri getUri() {
+ public Uri[] getUris() {
+ Uri[] uris;
+ NfcAdapter.CreateBeamUrisCallback callback;
synchronized (NfcActivityManager.this) {
NfcActivityState state = findResumedActivityState();
if (state == null) return null;
-
- return state.uri;
+ uris = state.uris;
+ callback = state.uriCallback;
}
- }
- /** Callback from NFC service, usually on binder thread */
- @Override
- public String getMimeType() {
- synchronized (NfcActivityManager.this) {
- NfcActivityState state = findResumedActivityState();
- if (state == null) return null;
-
- return state.mimeType;
+ if (callback != null) {
+ return callback.createBeamUris(mDefaultEvent);
+ } else {
+ return uris;
}
}
+
/** Callback from NFC service, usually on binder thread */
@Override
public void onNdefPushComplete() {
@@ -358,4 +374,5 @@ public final class NfcActivityManager extends INdefPushCallback.Stub
}
}
}
+
}
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index 917751c..90f5bef 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -203,6 +203,27 @@ public final class NfcAdapter {
/** @hide */
public static final int STATE_TURNING_OFF = 4;
+ /** @hide */
+ public static final String ACTION_HANDOVER_TRANSFER_STARTED =
+ "android.nfc.action.HANDOVER_TRANSFER_STARTED";
+
+ /** @hide */
+ public static final String ACTION_HANDOVER_TRANSFER_DONE =
+ "android.nfc.action.HANDOVER_TRANSFER_DONE";
+
+ /** @hide */
+ public static final String EXTRA_HANDOVER_TRANSFER_STATUS =
+ "android.nfc.extra.HANDOVER_TRANSFER_STATUS";
+
+ /** @hide */
+ public static final int HANDOVER_TRANSFER_STATUS_SUCCESS = 0;
+ /** @hide */
+ public static final int HANDOVER_TRANSFER_STATUS_FAILURE = 1;
+
+ /** @hide */
+ public static final String EXTRA_HANDOVER_TRANSFER_URI =
+ "android.nfc.extra.HANDOVER_TRANSFER_URI";
+
// Guarded by NfcAdapter.class
static boolean sIsInitialized = false;
@@ -281,6 +302,12 @@ public final class NfcAdapter {
public NdefMessage createNdefMessage(NfcEvent event);
}
+
+ // TODO javadoc
+ public interface CreateBeamUrisCallback {
+ public Uri[] createBeamUris(NfcEvent event);
+ }
+
/**
* Helper to check if this device has FEATURE_NFC, but without using
* a context.
@@ -556,16 +583,22 @@ public final class NfcAdapter {
}
}
- //TODO: Consider a callback alternative
- //TOOD: See if we get rid of mimeType
//TODO: make sure NFC service has permission for URI
+ //TODO: see if we will eventually support multiple URIs
//TODO: javadoc
- /** @hide */
- public void setBeamPushUri(String mimeType, Uri uri, Activity activity) {
+ public void setBeamPushUris(Uri[] uris, Activity activity) {
+ if (activity == null) {
+ throw new NullPointerException("activity cannot be null");
+ }
+ mNfcActivityManager.setNdefPushContentUri(activity, uris);
+ }
+
+ // TODO javadoc
+ public void setBeamPushUrisCallback(CreateBeamUrisCallback callback, Activity activity) {
if (activity == null) {
throw new NullPointerException("activity cannot be null");
}
- mNfcActivityManager.setNdefPushContentUri(activity, mimeType, uri);
+ mNfcActivityManager.setNdefPushContentUriCallback(activity, callback);
}
/**