Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9f72a10 authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge changes from topic "AndroidHeadtrackerService" into main

* changes:
  Map headtracking service characteristics to HOGP report characteristics
  bta_hh_le minor refactor
  Use LE transport when Headtracker service is available
  Add Android Headtracker Service UUIDs
  Add support for Android Headtracker Service in HidHostService
parents 7ea6ca88 843330f9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1633,7 +1633,10 @@ public class AdapterService extends Service {
        }
        if (profile == BluetoothProfile.HID_HOST) {
            return Utils.arrayContains(remoteDeviceUuids, BluetoothUuid.HID)
                    || Utils.arrayContains(remoteDeviceUuids, BluetoothUuid.HOGP);
                    || Utils.arrayContains(remoteDeviceUuids, BluetoothUuid.HOGP)
                    || (Flags.androidHeadtrackerService()
                            && Utils.arrayContains(
                                    remoteDeviceUuids, HidHostService.ANDROID_HEADTRACKER_UUID));
        }
        if (profile == BluetoothProfile.HID_DEVICE) {
            return mHidDeviceService.getConnectionState(device)
+4 −1
Original line number Diff line number Diff line
@@ -331,7 +331,10 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback {
        // This avoids needless auto-connect attempts to profiles non-existent on the remote device
        if ((hidService != null)
                && (Utils.arrayContains(uuids, BluetoothUuid.HID)
                        || Utils.arrayContains(uuids, BluetoothUuid.HOGP))
                        || Utils.arrayContains(uuids, BluetoothUuid.HOGP)
                        || (Flags.androidHeadtrackerService()
                                && Utils.arrayContains(
                                        uuids, HidHostService.ANDROID_HEADTRACKER_UUID)))
                && (hidService.getConnectionPolicy(device)
                        == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            if (mAutoConnectProfilesSupported) {
+25 −5
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.ParcelUuid;
import android.os.UserHandle;
import android.sysprop.BluetoothProperties;
import android.util.Log;
@@ -63,6 +64,12 @@ import java.util.stream.Collectors;
public class HidHostService extends ProfileService {
    private static final String TAG = "BluetoothHidHostService";

    public static final String ANDROID_HEADTRACKER_UUID_STR =
            "109b862f-50e3-45cc-8ea1-ac62de4846d1";

    public static final ParcelUuid ANDROID_HEADTRACKER_UUID =
            ParcelUuid.fromString(ANDROID_HEADTRACKER_UUID_STR);

    private static class InputDevice {
        int mSelectedTransport = BluetoothDevice.TRANSPORT_AUTO;
        int mHidState = BluetoothProfile.STATE_DISCONNECTED;
@@ -201,8 +208,15 @@ public class HidHostService extends ProfileService {
    }

    private byte[] getByteAddress(BluetoothDevice device, int transport) {
        ParcelUuid[] uuids = device.getUuids();

        if (!Flags.allowSwitchingHidAndHogp()) {
            if (Utils.arrayContains(device.getUuids(), BluetoothUuid.HOGP)) {
            boolean hogpSupported = Utils.arrayContains(uuids, BluetoothUuid.HOGP);
            boolean headtrackerSupported =
                    Flags.androidHeadtrackerService()
                            && Utils.arrayContains(uuids, HidHostService.ANDROID_HEADTRACKER_UUID);

            if (hogpSupported || headtrackerSupported) {
                // Use pseudo address when HOGP is available
                return Utils.getByteAddress(device);
            } else {
@@ -218,8 +232,9 @@ public class HidHostService extends ProfileService {
            // Use identity address if HID is to be used
            return getIdentityAddress(device);
        } else { // BluetoothDevice.TRANSPORT_AUTO
            boolean hidSupported = Utils.arrayContains(uuids, BluetoothUuid.HID);
            // Prefer HID over HOGP
            if (Utils.arrayContains(device.getUuids(), BluetoothUuid.HID)) {
            if (hidSupported) {
                // Use identity address if HID is available
                return getIdentityAddress(device);
            } else {
@@ -1128,12 +1143,17 @@ public class HidHostService extends ProfileService {
            return false;
        }

        boolean hidSupported = Utils.arrayContains(device.getUuids(), BluetoothUuid.HID);
        boolean hogpSupported = Utils.arrayContains(device.getUuids(), BluetoothUuid.HOGP);
        ParcelUuid[] uuids = device.getUuids();
        boolean hidSupported = Utils.arrayContains(uuids, BluetoothUuid.HID);
        boolean hogpSupported = Utils.arrayContains(uuids, BluetoothUuid.HOGP);
        boolean headtrackerSupported =
                Flags.androidHeadtrackerService()
                        && Utils.arrayContains(uuids, HidHostService.ANDROID_HEADTRACKER_UUID);
        if (transport == BluetoothDevice.TRANSPORT_BREDR && !hidSupported) {
            Log.w(TAG, "HID not supported: " + device);
            return false;
        } else if (transport == BluetoothDevice.TRANSPORT_LE && !hogpSupported) {
        } else if (transport == BluetoothDevice.TRANSPORT_LE
                && !(hogpSupported || headtrackerSupported)) {
            Log.w(TAG, "HOGP not supported: " + device);
            return false;
        }
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ cc_library_static {
        "hh/bta_hh_act.cc",
        "hh/bta_hh_api.cc",
        "hh/bta_hh_cfg.cc",
        "hh/bta_hh_headtracker.cc",
        "hh/bta_hh_le.cc",
        "hh/bta_hh_main.cc",
        "hh/bta_hh_utils.cc",
@@ -1290,6 +1291,7 @@ cc_test {
        "hh/bta_hh_act.cc",
        "hh/bta_hh_api.cc",
        "hh/bta_hh_cfg.cc",
        "hh/bta_hh_headtracker.cc",
        "hh/bta_hh_le.cc",
        "hh/bta_hh_main.cc",
        "hh/bta_hh_utils.cc",
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ static_library("bta") {
    "hh/bta_hh_act.cc",
    "hh/bta_hh_api.cc",
    "hh/bta_hh_cfg.cc",
    "hh/bta_hh_headtracker.cc",
    "hh/bta_hh_le.cc",
    "hh/bta_hh_main.cc",
    "hh/bta_hh_utils.cc",
Loading