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

Commit c93419c7 authored by Chienyuan Huang's avatar Chienyuan Huang Committed by Gerrit Code Review
Browse files

Merge "Implement DistanceMeasurementManager in Bluetooth GD"

parents d1adae74 0911a598
Loading
Loading
Loading
Loading
+43 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth.gatt;

import android.bluetooth.BluetoothStatusCodes;

import com.android.internal.annotations.VisibleForTesting;

/**
@@ -29,6 +31,20 @@ public class DistanceMeasurementNativeInterface {
    private static final Object INSTANCE_LOCK = new Object();
    private DistanceMeasurementManager mDistanceMeasurementManager;

    /**
     * Do not modify without updating distance_measurement_manager.h
     * match up with DistanceMeasurementErrorCode enum of distance_measurement_manager.h
     */
    private static final int REASON_FEATURE_NOT_SUPPORTED_LOCAL = 0;
    private static final int REASON_FEATURE_NOT_SUPPORTED_REMOTE = 1;
    private static final int REASON_LOCAL_REQUEST = 2;
    private static final int REASON_REMOTE_REQUEST = 3;
    private static final int REASON_DURATION_TIMEOUT = 4;
    private static final int REASON_NO_LE_CONNECTION = 5;
    private static final int REASON_INVALID_PARAMETERS = 6;
    private static final int REASON_INTERNAL_ERROR = 7;


    private DistanceMeasurementNativeInterface() {}

    /**
@@ -67,11 +83,13 @@ public class DistanceMeasurementNativeInterface {
    }

    void onDistanceMeasurementStartFail(String address, int reason, int method) {
        mDistanceMeasurementManager.onDistanceMeasurementStartFail(address, reason, method);
        mDistanceMeasurementManager.onDistanceMeasurementStartFail(address,
                convertErrorCode(reason), method);
    }

    void onDistanceMeasurementStopped(String address, int reason, int method) {
        mDistanceMeasurementManager.onDistanceMeasurementStopped(address, reason, method);
        mDistanceMeasurementManager.onDistanceMeasurementStopped(address,
                convertErrorCode(reason), method);
    }

    void onDistanceMeasurementResult(String address, int centimeter, int errorCentimeter,
@@ -82,6 +100,29 @@ public class DistanceMeasurementNativeInterface {
                method);
    }

    private int convertErrorCode(int errorCode) {
        switch (errorCode) {
            case REASON_FEATURE_NOT_SUPPORTED_LOCAL:
                return BluetoothStatusCodes.FEATURE_NOT_SUPPORTED;
            case REASON_FEATURE_NOT_SUPPORTED_REMOTE:
                return BluetoothStatusCodes.ERROR_REMOTE_OPERATION_NOT_SUPPORTED;
            case REASON_LOCAL_REQUEST:
                return BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST;
            case REASON_REMOTE_REQUEST:
                return BluetoothStatusCodes.REASON_REMOTE_REQUEST;
            case REASON_DURATION_TIMEOUT:
                return BluetoothStatusCodes.ERROR_TIMEOUT;
            case REASON_NO_LE_CONNECTION:
                return BluetoothStatusCodes.ERROR_NO_LE_CONNECTION;
            case REASON_INVALID_PARAMETERS:
                return BluetoothStatusCodes.ERROR_BAD_PARAMETERS;
            case REASON_INTERNAL_ERROR:
                return BluetoothStatusCodes.DISTANCE_MEASUREMENT_ERROR_INTERNAL;
            default:
                return BluetoothStatusCodes.ERROR_UNKNOWN;
        }
    }

    static {
        classInitNative();
    }
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ filegroup {
        "acl_manager/acl_fragmenter.cc",
        "acl_manager.cc",
        "controller.cc",
        "distance_measurement_manager.cc",
        "hci_layer.cc",
        "hci_metrics_logging.cc",
        "le_address_manager.cc",
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ source_set("BluetoothHciSources") {
    "address.cc",
    "class_of_device.cc",
    "controller.cc",
    "distance_measurement_manager.cc",
    "hci_layer.cc",
    "hci_metrics_logging.cc",
    "le_address_manager.cc",
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "hci/acl_manager/le_connection_callbacks.h"
#include "hci/address.h"
#include "hci/address_with_type.h"
#include "hci/distance_measurement_manager.h"
#include "hci/hci_layer.h"
#include "hci/hci_packets.h"
#include "hci/le_address_manager.h"
@@ -56,6 +57,7 @@ class AclManager : public Module {
 friend void bluetooth::shim::L2CA_UseLegacySecurityModule();
 friend bool bluetooth::shim::L2CA_SetAclPriority(uint16_t, bool);
 friend class bluetooth::hci::LeScanningManager;
 friend class bluetooth::hci::DistanceMeasurementManager;

public:
 AclManager();
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ class Controller : public Module {
  static const ModuleFactory Factory;

  static constexpr uint64_t kDefaultEventMask = 0x3dbfffffffffffff;
  static constexpr uint64_t kDefaultLeEventMask = 0x000000044d02fe7f;
  static constexpr uint64_t kDefaultLeEventMask = 0x000000054d02fe7f;

  static constexpr uint64_t kLeEventMask53 = 0x00000007ffffffff;
  static constexpr uint64_t kLeEventMask52 = 0x00000003ffffffff;
Loading