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

Commit 2fb0dc36 authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Automerger Merge Worker
Browse files

Merge changes from topic "AndroidHeadtrackerService" into main am: d9f72a10

parents 40571296 d9f72a10
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