diff options
| -rwxr-xr-x | api/current.txt | 21 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageManager.java | 7 | ||||
| -rw-r--r-- | core/java/android/nfc/NfcAdapter.java | 72 |
3 files changed, 89 insertions, 11 deletions
diff --git a/api/current.txt b/api/current.txt index ff297d9a46cb..1d60e8ffd0a0 100755 --- a/api/current.txt +++ b/api/current.txt @@ -11315,6 +11315,7 @@ package android.content.pm { field public static final java.lang.String FEATURE_MICROPHONE = "android.hardware.microphone"; field public static final java.lang.String FEATURE_MIDI = "android.software.midi"; field public static final java.lang.String FEATURE_NFC = "android.hardware.nfc"; + field public static final java.lang.String FEATURE_NFC_BEAM = "android.sofware.nfc.beam"; field public static final java.lang.String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; field public static final java.lang.String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; field public static final java.lang.String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese"; @@ -29169,14 +29170,14 @@ package android.nfc { method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context); method public java.util.List<java.lang.String> getSupportedOffHostSecureElements(); method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler); - method public boolean invokeBeam(android.app.Activity); + method public deprecated boolean invokeBeam(android.app.Activity); method public boolean isEnabled(); - method public boolean isNdefPushEnabled(); - method public void setBeamPushUris(android.net.Uri[], android.app.Activity); - method public void setBeamPushUrisCallback(android.nfc.NfcAdapter.CreateBeamUrisCallback, android.app.Activity); - method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...); - method public void setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity, android.app.Activity...); - method public void setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity, android.app.Activity...); + method public deprecated boolean isNdefPushEnabled(); + method public deprecated void setBeamPushUris(android.net.Uri[], android.app.Activity); + method public deprecated void setBeamPushUrisCallback(android.nfc.NfcAdapter.CreateBeamUrisCallback, android.app.Activity); + method public deprecated void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...); + method public deprecated void setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity, android.app.Activity...); + method public deprecated void setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity, android.app.Activity...); field public static final java.lang.String ACTION_ADAPTER_STATE_CHANGED = "android.nfc.action.ADAPTER_STATE_CHANGED"; field public static final java.lang.String ACTION_NDEF_DISCOVERED = "android.nfc.action.NDEF_DISCOVERED"; field public static final java.lang.String ACTION_TAG_DISCOVERED = "android.nfc.action.TAG_DISCOVERED"; @@ -29203,15 +29204,15 @@ package android.nfc { field public static final int STATE_TURNING_ON = 2; // 0x2 } - public static abstract interface NfcAdapter.CreateBeamUrisCallback { + public static abstract deprecated interface NfcAdapter.CreateBeamUrisCallback { method public abstract android.net.Uri[] createBeamUris(android.nfc.NfcEvent); } - public static abstract interface NfcAdapter.CreateNdefMessageCallback { + public static abstract deprecated interface NfcAdapter.CreateNdefMessageCallback { method public abstract android.nfc.NdefMessage createNdefMessage(android.nfc.NfcEvent); } - public static abstract interface NfcAdapter.OnNdefPushCompleteCallback { + public static abstract deprecated interface NfcAdapter.OnNdefPushCompleteCallback { method public abstract void onNdefPushComplete(android.nfc.NfcEvent); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 25edf9cff5c7..83e8785f29f1 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -1931,6 +1931,13 @@ public abstract class PackageManager { /** * Feature for {@link #getSystemAvailableFeatures} and + * {@link #hasSystemFeature}: The Beam API is enabled on the device. + */ + @SdkConstant(SdkConstantType.FEATURE) + public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam"; + + /** + * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device supports any * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features. diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index 877187053486..e55e0364f5d4 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -325,6 +325,7 @@ public final class NfcAdapter { // Guarded by NfcAdapter.class static boolean sIsInitialized = false; static boolean sHasNfcFeature; + static boolean sHasBeamFeature; // Final after first constructor, except for // attemptDeadServiceRecovery() when NFC crashes - we accept a best effort @@ -372,7 +373,9 @@ public final class NfcAdapter { * A callback to be invoked when the system successfully delivers your {@link NdefMessage} * to another device. * @see #setOnNdefPushCompleteCallback + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public interface OnNdefPushCompleteCallback { /** * Called on successful NDEF push. @@ -395,7 +398,9 @@ public final class NfcAdapter { * content currently visible to the user. Alternatively, you can call {@link * #setNdefPushMessage setNdefPushMessage()} if the {@link NdefMessage} always contains the * same data. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public interface CreateNdefMessageCallback { /** * Called to provide a {@link NdefMessage} to push. @@ -421,7 +426,10 @@ public final class NfcAdapter { } - // TODO javadoc + /** + * @deprecated this feature is deprecated. + */ + @java.lang.Deprecated public interface CreateBeamUrisCallback { public Uri[] createBeamUris(NfcEvent event); } @@ -449,6 +457,25 @@ public final class NfcAdapter { public boolean onUnlockAttempted(Tag tag); } + /** + * Helper to check if this device has FEATURE_NFC_BEAM, but without using + * a context. + * Equivalent to + * context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_BEAM) + */ + private static boolean hasBeamFeature() { + IPackageManager pm = ActivityThread.getPackageManager(); + if (pm == null) { + Log.e(TAG, "Cannot get package manager, assuming no Android Beam feature"); + return false; + } + try { + return pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM, 0); + } catch (RemoteException e) { + Log.e(TAG, "Package manager query failed, assuming no Android Beam feature", e); + return false; + } + } /** * Helper to check if this device has FEATURE_NFC, but without using @@ -528,6 +555,7 @@ public final class NfcAdapter { public static synchronized NfcAdapter getNfcAdapter(Context context) { if (!sIsInitialized) { sHasNfcFeature = hasNfcFeature(); + sHasBeamFeature = hasBeamFeature(); boolean hasHceFeature = hasNfcHceFeature(); /* is this device meant to have NFC */ if (!sHasNfcFeature && !hasHceFeature) { @@ -953,12 +981,17 @@ public final class NfcAdapter { * @param uris an array of Uri(s) to push over Android Beam * @param activity activity for which the Uri(s) will be pushed * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public void setBeamPushUris(Uri[] uris, Activity activity) { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } if (activity == null) { throw new NullPointerException("activity cannot be null"); @@ -1035,12 +1068,17 @@ public final class NfcAdapter { * @param callback callback, or null to disable * @param activity activity for which the Uri(s) will be pushed * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public void setBeamPushUrisCallback(CreateBeamUrisCallback callback, Activity activity) { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } if (activity == null) { throw new NullPointerException("activity cannot be null"); @@ -1119,13 +1157,18 @@ public final class NfcAdapter { * to only register one at a time, and to do so in that activity's * {@link Activity#onCreate} * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public void setNdefPushMessage(NdefMessage message, Activity activity, Activity ... activities) { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } int targetSdkVersion = getSdkVersion(); try { @@ -1232,13 +1275,18 @@ public final class NfcAdapter { * to only register one at a time, and to do so in that activity's * {@link Activity#onCreate} * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public void setNdefPushMessageCallback(CreateNdefMessageCallback callback, Activity activity, Activity ... activities) { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } int targetSdkVersion = getSdkVersion(); try { @@ -1313,13 +1361,18 @@ public final class NfcAdapter { * to only register one at a time, and to do so in that activity's * {@link Activity#onCreate} * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public void setOnNdefPushCompleteCallback(OnNdefPushCompleteCallback callback, Activity activity, Activity ... activities) { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } int targetSdkVersion = getSdkVersion(); try { @@ -1524,12 +1577,17 @@ public final class NfcAdapter { * @param activity the current foreground Activity that has registered data to share * @return whether the Beam animation was successfully invoked * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated public boolean invokeBeam(Activity activity) { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return false; + } } if (activity == null) { throw new NullPointerException("activity may not be null."); @@ -1593,6 +1651,9 @@ public final class NfcAdapter { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } if (activity == null || message == null) { throw new NullPointerException(); @@ -1627,6 +1688,9 @@ public final class NfcAdapter { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return; + } } if (activity == null) { throw new NullPointerException(); @@ -1700,12 +1764,18 @@ public final class NfcAdapter { * @see android.provider.Settings#ACTION_NFCSHARING_SETTINGS * @return true if NDEF Push feature is enabled * @throws UnsupportedOperationException if FEATURE_NFC is unavailable. + * @deprecated this feature is deprecated. */ + @java.lang.Deprecated + public boolean isNdefPushEnabled() { synchronized (NfcAdapter.class) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); } + if (!sHasBeamFeature) { + return false; + } } try { return sService.isNdefPushEnabled(); |