Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted behavior when using CompanionDeviceManager #32

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
public void run() {
// this calls onCharacteristicRead after completed
gatt.readCharacteristic(manufacturerCharacteristic);
if (gattRequestQueue.size() > 0) {
gattRequestQueue.remove(0).run();
}
}
});
}
Expand All @@ -152,6 +155,9 @@ public void run() {
public void run() {
// this calls onCharacteristicRead after completed
gatt.readCharacteristic(modelCharacteristic);
if (gattRequestQueue.size() > 0) {
gattRequestQueue.remove(0).run();
}
}
});
}
Expand All @@ -161,7 +167,9 @@ public void run() {
gattRequestQueue.add(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
// if the app is running on Meta/Oculus, don't set the mtu
boolean isOculusDevices = "miramar".equals(Build.DEVICE) || "hollywood".equals(Build.DEVICE) || "eureka".equals(Build.DEVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE || isOculusDevices) {
// Android 14: the default MTU size set to 517
// https://developer.android.com/about/versions/14/behavior-changes-all#mtu-set-to-517
final int mtu = 517;
Expand All @@ -180,6 +188,7 @@ public void run() {
} else {
// request maximum MTU size
// this calls onMtuChanged after completed
// NOTE: Some devices already have MTU set to 517, so the `onMtuChanged` method is not called.
boolean result = gatt.requestMtu(517); // GATT_MAX_MTU_SIZE defined at `stack/include/gatt_api.h`
Log.d(Constants.TAG, "Central requestMtu address: " + gatt.getDevice().getAddress() + ", succeed: " + result);
}
Expand Down
Loading