Loading api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -17664,7 +17664,7 @@ package android.nfc { method public boolean invokeBeam(android.app.Activity); method public boolean isEnabled(); method public boolean isNdefPushEnabled(); method public boolean registerLockscreenDispatch(android.nfc.NfcAdapter.NfcLockscreenDispatch, int[]); method public boolean registerLockscreenDispatch(android.nfc.NfcAdapter.NfcLockscreenDispatch, java.lang.String[]); 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...); core/java/android/nfc/NfcAdapter.java +5 −2 Original line number Diff line number Diff line Loading @@ -1428,17 +1428,20 @@ public final class NfcAdapter { } public boolean registerLockscreenDispatch(final NfcLockscreenDispatch lockscreenDispatch, int[] techList) { String[] techList) { try { sService.registerLockscreenDispatch(new INfcLockscreenDispatch.Stub() { @Override public boolean onTagDetected(Tag tag) throws RemoteException { return lockscreenDispatch.onTagDetected(tag); } }, techList); }, Tag.techListFromStrings(techList)); } catch (RemoteException e) { attemptDeadServiceRecovery(e); return false; } catch (IllegalArgumentException e) { Log.e(TAG, "Unable to register LockscreenDispatch", e); return false; } return true; Loading core/java/android/nfc/Tag.java +36 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.os.RemoteException; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; /** * Represents an NFC tag that has been discovered. Loading Loading @@ -195,6 +196,41 @@ public final class Tag implements Parcelable { return strings; } static int[] techListFromStrings(String[] techStringList) throws IllegalArgumentException { if (techStringList == null) { throw new IllegalArgumentException("List cannot be null"); } int[] techIntList = new int[techStringList.length]; HashMap<String, Integer> stringToCodeMap = getTechStringToCodeMap(); for (int i = 0; i < techStringList.length; i++) { Integer code = stringToCodeMap.get(techStringList[i]); if (code == null) { throw new IllegalArgumentException("Unknown tech type " + techStringList[i]); } techIntList[i] = code.intValue(); } return techIntList; } private static HashMap<String, Integer> getTechStringToCodeMap() { HashMap<String, Integer> techStringToCodeMap = new HashMap<String, Integer>(); techStringToCodeMap.put(IsoDep.class.getName(), TagTechnology.ISO_DEP); techStringToCodeMap.put(MifareClassic.class.getName(), TagTechnology.MIFARE_CLASSIC); techStringToCodeMap.put(MifareUltralight.class.getName(), TagTechnology.MIFARE_ULTRALIGHT); techStringToCodeMap.put(Ndef.class.getName(), TagTechnology.NDEF); techStringToCodeMap.put(NdefFormatable.class.getName(), TagTechnology.NDEF_FORMATABLE); techStringToCodeMap.put(NfcA.class.getName(), TagTechnology.NFC_A); techStringToCodeMap.put(NfcB.class.getName(), TagTechnology.NFC_B); techStringToCodeMap.put(NfcF.class.getName(), TagTechnology.NFC_F); techStringToCodeMap.put(NfcV.class.getName(), TagTechnology.NFC_V); techStringToCodeMap.put(NfcBarcode.class.getName(), TagTechnology.NFC_BARCODE); return techStringToCodeMap; } /** * For use by NfcService only. * @hide Loading Loading
api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -17664,7 +17664,7 @@ package android.nfc { method public boolean invokeBeam(android.app.Activity); method public boolean isEnabled(); method public boolean isNdefPushEnabled(); method public boolean registerLockscreenDispatch(android.nfc.NfcAdapter.NfcLockscreenDispatch, int[]); method public boolean registerLockscreenDispatch(android.nfc.NfcAdapter.NfcLockscreenDispatch, java.lang.String[]); 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...);
core/java/android/nfc/NfcAdapter.java +5 −2 Original line number Diff line number Diff line Loading @@ -1428,17 +1428,20 @@ public final class NfcAdapter { } public boolean registerLockscreenDispatch(final NfcLockscreenDispatch lockscreenDispatch, int[] techList) { String[] techList) { try { sService.registerLockscreenDispatch(new INfcLockscreenDispatch.Stub() { @Override public boolean onTagDetected(Tag tag) throws RemoteException { return lockscreenDispatch.onTagDetected(tag); } }, techList); }, Tag.techListFromStrings(techList)); } catch (RemoteException e) { attemptDeadServiceRecovery(e); return false; } catch (IllegalArgumentException e) { Log.e(TAG, "Unable to register LockscreenDispatch", e); return false; } return true; Loading
core/java/android/nfc/Tag.java +36 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.os.RemoteException; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; /** * Represents an NFC tag that has been discovered. Loading Loading @@ -195,6 +196,41 @@ public final class Tag implements Parcelable { return strings; } static int[] techListFromStrings(String[] techStringList) throws IllegalArgumentException { if (techStringList == null) { throw new IllegalArgumentException("List cannot be null"); } int[] techIntList = new int[techStringList.length]; HashMap<String, Integer> stringToCodeMap = getTechStringToCodeMap(); for (int i = 0; i < techStringList.length; i++) { Integer code = stringToCodeMap.get(techStringList[i]); if (code == null) { throw new IllegalArgumentException("Unknown tech type " + techStringList[i]); } techIntList[i] = code.intValue(); } return techIntList; } private static HashMap<String, Integer> getTechStringToCodeMap() { HashMap<String, Integer> techStringToCodeMap = new HashMap<String, Integer>(); techStringToCodeMap.put(IsoDep.class.getName(), TagTechnology.ISO_DEP); techStringToCodeMap.put(MifareClassic.class.getName(), TagTechnology.MIFARE_CLASSIC); techStringToCodeMap.put(MifareUltralight.class.getName(), TagTechnology.MIFARE_ULTRALIGHT); techStringToCodeMap.put(Ndef.class.getName(), TagTechnology.NDEF); techStringToCodeMap.put(NdefFormatable.class.getName(), TagTechnology.NDEF_FORMATABLE); techStringToCodeMap.put(NfcA.class.getName(), TagTechnology.NFC_A); techStringToCodeMap.put(NfcB.class.getName(), TagTechnology.NFC_B); techStringToCodeMap.put(NfcF.class.getName(), TagTechnology.NFC_F); techStringToCodeMap.put(NfcV.class.getName(), TagTechnology.NFC_V); techStringToCodeMap.put(NfcBarcode.class.getName(), TagTechnology.NFC_BARCODE); return techStringToCodeMap; } /** * For use by NfcService only. * @hide Loading