diff --git a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciHal.java b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciHal.java index bac35ea8..fd819218 100644 --- a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciHal.java +++ b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciHal.java @@ -156,7 +156,7 @@ class HciAidlHal extends android.hardware.bluetooth.IBluetoothHciCallbacks.Stub private static final String TAG = "HciAidlHal"; private final android.hardware.bluetooth.IBluetoothHci mHciService; private final HciHalCallback mHciCallbacks; - private int mInitializationStatus = android.hardware.bluetooth.Status.SUCCESS; //-1; + private int mInitializationStatus = android.hardware.bluetooth.Status.SUCCESS; public static HciAidlHal create(HciHalCallback hciCallbacks) { IBinder binder = ServiceManager.getService("android.hardware.bluetooth.IBluetoothHci/default"); @@ -233,7 +233,7 @@ class HciAidlHal extends android.hardware.bluetooth.IBluetoothHciCallbacks.Stub // IBluetoothHciCallbacks methods. @Override - public /* synchronized */ void initializationComplete(int status) throws RemoteException { + public synchronized void initializationComplete(int status) throws RemoteException { mInitializationStatus = status; notifyAll(); } diff --git a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciParser.java b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciParser.java index 0a3513ca..8647468c 100644 --- a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciParser.java +++ b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciParser.java @@ -4,22 +4,10 @@ import static java.lang.Integer.min; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; +import java.nio.ByteOrder; class HciParser { - enum State { - NEED_TYPE, - NEED_LENGTH, - NEED_BODY - } - - interface Sink { - void onPacket(HciPacket.Type type, byte[] packet); - } - - static class InvalidFormatException extends RuntimeException { - } - Sink sink; State state; int bytesNeeded; @@ -51,7 +39,9 @@ class HciParser { bytesNeeded = packetType.lengthOffset + packetType.lengthSize; state = State.NEED_LENGTH; } else if (state == State.NEED_LENGTH) { - ByteBuffer lengthBuffer = ByteBuffer.wrap(packet.toByteArray()); + ByteBuffer lengthBuffer = + ByteBuffer.wrap(packet.toByteArray()) + .order(ByteOrder.LITTLE_ENDIAN); bytesNeeded = packetType.lengthSize == 1 ? lengthBuffer.get(packetType.lengthOffset) & 0xFF : lengthBuffer.getShort(packetType.lengthOffset) & 0xFFFF; @@ -79,4 +69,15 @@ class HciParser { packet.reset(); packetType = null; } + + enum State { + NEED_TYPE, NEED_LENGTH, NEED_BODY + } + + interface Sink { + void onPacket(HciPacket.Type type, byte[] packet); + } + + static class InvalidFormatException extends RuntimeException { + } } \ No newline at end of file diff --git a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciProxy.java b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciProxy.java index 7ded1578..1949a636 100644 --- a/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciProxy.java +++ b/extras/android/RemoteHCI/app/src/main/java/com/github/google/bumble/remotehci/HciProxy.java @@ -24,6 +24,21 @@ public class HciProxy { @Override public void onPacket(HciPacket.Type type, byte[] packet) { mServer.sendPacket(type, packet); + + switch (type) { + case EVENT: + mEventPacketsSent += 1; + break; + + case ACL_DATA: + mAclPacketsSent += 1; + break; + + case SCO_DATA: + mScoPacketsSent += 1; + break; + } + updateHciPacketCount(); } }); if (hciHal == null) {