Loading core/java/android/nfc/technology/BasicTagTechnology.java +17 −12 Original line number Diff line number Diff line Loading @@ -226,6 +226,22 @@ import android.util.Log; } } /** internal transceive */ /*package*/ byte[] transceive(byte[] data, boolean raw) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, raw); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } } /** * Send data to a tag and receive the response. * <p> Loading @@ -238,17 +254,6 @@ import android.util.Log; * @throws IOException if the target is lost or connection closed */ public byte[] transceive(byte[] data) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, true); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } return transceive(data, true); } } core/java/android/nfc/technology/MifareClassic.java +7 −34 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ public final class MifareClassic extends BasicTagTechnology { System.arraycopy(key, 0, cmd, 6, 6); try { if ((transceive(cmd) != null)) { if ((transceive(cmd, false) != null)) { return true; } } catch (IOException e) { Loading Loading @@ -308,7 +308,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] blockread_cmd = { 0x30, addr }; return transceive(blockread_cmd); return transceive(blockread_cmd, false); } /** Loading @@ -324,7 +324,7 @@ public final class MifareClassic extends BasicTagTechnology { blockwrite_cmd[1] = addr; System.arraycopy(data, 0, blockwrite_cmd, 2, data.length); transceive(blockwrite_cmd); transceive(blockwrite_cmd, false); } /** Loading @@ -345,7 +345,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] incr_cmd = { (byte) 0xC1, (byte) block }; transceive(incr_cmd); transceive(incr_cmd, false); } public void decrement(int block) throws IOException { Loading @@ -354,7 +354,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] decr_cmd = { (byte) 0xC0, (byte) block }; transceive(decr_cmd); transceive(decr_cmd, false); } public void transfer(int block) throws IOException { Loading @@ -363,7 +363,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] trans_cmd = { (byte) 0xB0, (byte) block }; transceive(trans_cmd); transceive(trans_cmd, false); } public void restore(int block) throws IOException { Loading @@ -372,33 +372,6 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] rest_cmd = { (byte) 0xC2, (byte) block }; transceive(rest_cmd); } /** * Send data to a tag and receive the response. * <p> * This method will block until the response is received. It can be canceled * with {@link #close}. * <p>Requires {@link android.Manifest.permission#NFC} permission. * * @param data bytes to send * @return bytes received in response * @throws IOException if the target is lost or connection closed */ @Override public byte[] transceive(byte[] data) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, false); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } transceive(rest_cmd, false); } } core/java/android/nfc/technology/MifareUltralight.java +3 −31 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public final class MifareUltralight extends BasicTagTechnology { checkConnected(); byte[] blockread_cmd = { 0x30, (byte)block }; // phHal_eMifareRead return transceive(blockread_cmd); return transceive(blockread_cmd, false); } /** Loading @@ -89,7 +89,7 @@ public final class MifareUltralight extends BasicTagTechnology { pagewrite_cmd[1] = (byte) block; System.arraycopy(data, 0, pagewrite_cmd, 2, data.length); transceive(pagewrite_cmd); transceive(pagewrite_cmd, false); } public void writeBlock(int block, byte[] data) throws IOException { Loading @@ -100,34 +100,6 @@ public final class MifareUltralight extends BasicTagTechnology { blockwrite_cmd[1] = (byte) block; System.arraycopy(data, 0, blockwrite_cmd, 2, data.length); transceive(blockwrite_cmd); transceive(blockwrite_cmd, false); } /** * Send data to a tag and receive the response. * <p> * This method will block until the response is received. It can be canceled * with {@link #close}. * <p>Requires {@link android.Manifest.permission#NFC} permission. * * @param data bytes to send * @return bytes received in response * @throws IOException if the target is lost or connection closed */ @Override public byte[] transceive(byte[] data) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, false); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } } } Loading
core/java/android/nfc/technology/BasicTagTechnology.java +17 −12 Original line number Diff line number Diff line Loading @@ -226,6 +226,22 @@ import android.util.Log; } } /** internal transceive */ /*package*/ byte[] transceive(byte[] data, boolean raw) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, raw); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } } /** * Send data to a tag and receive the response. * <p> Loading @@ -238,17 +254,6 @@ import android.util.Log; * @throws IOException if the target is lost or connection closed */ public byte[] transceive(byte[] data) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, true); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } return transceive(data, true); } }
core/java/android/nfc/technology/MifareClassic.java +7 −34 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ public final class MifareClassic extends BasicTagTechnology { System.arraycopy(key, 0, cmd, 6, 6); try { if ((transceive(cmd) != null)) { if ((transceive(cmd, false) != null)) { return true; } } catch (IOException e) { Loading Loading @@ -308,7 +308,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] blockread_cmd = { 0x30, addr }; return transceive(blockread_cmd); return transceive(blockread_cmd, false); } /** Loading @@ -324,7 +324,7 @@ public final class MifareClassic extends BasicTagTechnology { blockwrite_cmd[1] = addr; System.arraycopy(data, 0, blockwrite_cmd, 2, data.length); transceive(blockwrite_cmd); transceive(blockwrite_cmd, false); } /** Loading @@ -345,7 +345,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] incr_cmd = { (byte) 0xC1, (byte) block }; transceive(incr_cmd); transceive(incr_cmd, false); } public void decrement(int block) throws IOException { Loading @@ -354,7 +354,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] decr_cmd = { (byte) 0xC0, (byte) block }; transceive(decr_cmd); transceive(decr_cmd, false); } public void transfer(int block) throws IOException { Loading @@ -363,7 +363,7 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] trans_cmd = { (byte) 0xB0, (byte) block }; transceive(trans_cmd); transceive(trans_cmd, false); } public void restore(int block) throws IOException { Loading @@ -372,33 +372,6 @@ public final class MifareClassic extends BasicTagTechnology { byte addr = (byte) block; byte[] rest_cmd = { (byte) 0xC2, (byte) block }; transceive(rest_cmd); } /** * Send data to a tag and receive the response. * <p> * This method will block until the response is received. It can be canceled * with {@link #close}. * <p>Requires {@link android.Manifest.permission#NFC} permission. * * @param data bytes to send * @return bytes received in response * @throws IOException if the target is lost or connection closed */ @Override public byte[] transceive(byte[] data) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, false); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } transceive(rest_cmd, false); } }
core/java/android/nfc/technology/MifareUltralight.java +3 −31 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public final class MifareUltralight extends BasicTagTechnology { checkConnected(); byte[] blockread_cmd = { 0x30, (byte)block }; // phHal_eMifareRead return transceive(blockread_cmd); return transceive(blockread_cmd, false); } /** Loading @@ -89,7 +89,7 @@ public final class MifareUltralight extends BasicTagTechnology { pagewrite_cmd[1] = (byte) block; System.arraycopy(data, 0, pagewrite_cmd, 2, data.length); transceive(pagewrite_cmd); transceive(pagewrite_cmd, false); } public void writeBlock(int block, byte[] data) throws IOException { Loading @@ -100,34 +100,6 @@ public final class MifareUltralight extends BasicTagTechnology { blockwrite_cmd[1] = (byte) block; System.arraycopy(data, 0, blockwrite_cmd, 2, data.length); transceive(blockwrite_cmd); transceive(blockwrite_cmd, false); } /** * Send data to a tag and receive the response. * <p> * This method will block until the response is received. It can be canceled * with {@link #close}. * <p>Requires {@link android.Manifest.permission#NFC} permission. * * @param data bytes to send * @return bytes received in response * @throws IOException if the target is lost or connection closed */ @Override public byte[] transceive(byte[] data) throws IOException { checkConnected(); try { byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, false); if (response == null) { throw new IOException("transceive failed"); } return response; } catch (RemoteException e) { attemptDeadServiceRecovery(e); throw new IOException("NFC service died"); } } }