mirror of
https://github.com/google/bumble.git
synced 2026-04-16 00:25:31 +00:00
fix byte order and packet accounting
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user