mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "Bluetooth LMP Events: Interface for LMP events" into main
This commit is contained in:
33
bluetooth/lmp_event/aidl/Android.bp
Normal file
33
bluetooth/lmp_event/aidl/Android.bp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package {
|
||||||
|
// See: http://go/android-license-faq
|
||||||
|
// A large-scale-change added 'default_applicable_licenses' to import
|
||||||
|
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||||
|
// to get the below license kinds:
|
||||||
|
// SPDX-license-identifier-Apache-2.0
|
||||||
|
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||||
|
}
|
||||||
|
|
||||||
|
aidl_interface {
|
||||||
|
name: "android.hardware.bluetooth.lmp_event",
|
||||||
|
vendor_available: true,
|
||||||
|
host_supported: true,
|
||||||
|
srcs: ["android/hardware/bluetooth/lmp_event/*.aidl"],
|
||||||
|
stability: "vintf",
|
||||||
|
backend: {
|
||||||
|
java: {
|
||||||
|
enabled: true,
|
||||||
|
platform_apis: true,
|
||||||
|
},
|
||||||
|
cpp: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
ndk: {
|
||||||
|
enabled: true,
|
||||||
|
min_sdk_version: "33",
|
||||||
|
},
|
||||||
|
rust: {
|
||||||
|
enabled: true,
|
||||||
|
min_sdk_version: "33",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
@Backing(type="byte") @VintfStability
|
||||||
|
enum AddressType {
|
||||||
|
PUBLIC = 0x00,
|
||||||
|
RANDOM = 0x01,
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
@Backing(type="byte") @VintfStability
|
||||||
|
enum Direction {
|
||||||
|
TX = 0x00,
|
||||||
|
RX = 0x01,
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
@VintfStability
|
||||||
|
interface IBluetoothLmpEvent {
|
||||||
|
void registerForLmpEvents(in android.hardware.bluetooth.lmp_event.IBluetoothLmpEventCallback callback, in android.hardware.bluetooth.lmp_event.AddressType addressType, in byte[6] address, in android.hardware.bluetooth.lmp_event.LmpEventId[] lmpEventIds);
|
||||||
|
void unregisterLmpEvents(in android.hardware.bluetooth.lmp_event.AddressType addressType, in byte[6] address);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
@VintfStability
|
||||||
|
interface IBluetoothLmpEventCallback {
|
||||||
|
void onEventGenerated(in android.hardware.bluetooth.lmp_event.Timestamp timestamp, in android.hardware.bluetooth.lmp_event.AddressType addressType, in byte[6] address, in android.hardware.bluetooth.lmp_event.Direction direction, in android.hardware.bluetooth.lmp_event.LmpEventId lmpEventId, in char connEventCounter);
|
||||||
|
void onRegistered(in boolean status);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
@Backing(type="byte") @VintfStability
|
||||||
|
enum LmpEventId {
|
||||||
|
CONNECT_IND = 0x00,
|
||||||
|
LL_PHY_UPDATE_IND = 0x01,
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
@VintfStability
|
||||||
|
parcelable Timestamp {
|
||||||
|
long systemTimeUs;
|
||||||
|
long bluetoothTimeUs;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of Address
|
||||||
|
*/
|
||||||
|
@VintfStability
|
||||||
|
@Backing(type="byte")
|
||||||
|
enum AddressType {
|
||||||
|
PUBLIC = 0x00,
|
||||||
|
RANDOM = 0x01,
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direction of the LMP event
|
||||||
|
*/
|
||||||
|
@VintfStability
|
||||||
|
@Backing(type="byte")
|
||||||
|
enum Direction {
|
||||||
|
TX = 0x00,
|
||||||
|
RX = 0x01,
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
|
||||||
|
import android.hardware.bluetooth.lmp_event.IBluetoothLmpEventCallback;
|
||||||
|
import android.hardware.bluetooth.lmp_event.AddressType;
|
||||||
|
import android.hardware.bluetooth.lmp_event.LmpEventId;
|
||||||
|
|
||||||
|
@VintfStability
|
||||||
|
interface IBluetoothLmpEvent {
|
||||||
|
/**
|
||||||
|
* API to monitor specific LMP event timestamp for given Bluetooth device.
|
||||||
|
*
|
||||||
|
* @param callback An instance of the |IBluetoothLmpEventCallback| AIDL interface object.
|
||||||
|
* @param addressType Type of bluetooth address.
|
||||||
|
* @param address Bluetooth address to monitor.
|
||||||
|
* @param lmpEventIds LMP events to monitor.
|
||||||
|
*/
|
||||||
|
void registerForLmpEvents(in IBluetoothLmpEventCallback callback,
|
||||||
|
in AddressType addressType,
|
||||||
|
in byte[6] address,
|
||||||
|
in LmpEventId[] lmpEventIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API to stop monitoring a given Bluetooth device.
|
||||||
|
*
|
||||||
|
* @param addressType Type of Bluetooth address.
|
||||||
|
* @param address Bluetooth device to stop monitoring.
|
||||||
|
*/
|
||||||
|
void unregisterLmpEvents(in AddressType addressType, in byte[6] address);
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
|
||||||
|
import android.hardware.bluetooth.lmp_event.Direction;
|
||||||
|
import android.hardware.bluetooth.lmp_event.AddressType;
|
||||||
|
import android.hardware.bluetooth.lmp_event.LmpEventId;
|
||||||
|
import android.hardware.bluetooth.lmp_event.Timestamp;
|
||||||
|
|
||||||
|
@VintfStability
|
||||||
|
interface IBluetoothLmpEventCallback {
|
||||||
|
/**
|
||||||
|
* Callback when monitored LMP event invoked.
|
||||||
|
*
|
||||||
|
* @param timestamp Timestamp when the LMP event invoked
|
||||||
|
* @param addressType Type of Bluetooth address.
|
||||||
|
* @param address Remote bluetooth address that invoke LMP event
|
||||||
|
* @param direction Direction of the invoked LMP event
|
||||||
|
* @param lmpEventId LMP event id that bluetooth chip invoked
|
||||||
|
* @param connEventCounter counter incremented by one for each new connection event
|
||||||
|
*/
|
||||||
|
void onEventGenerated(in Timestamp timestamp,
|
||||||
|
in AddressType addressType,
|
||||||
|
in byte[6] address,
|
||||||
|
in Direction direction,
|
||||||
|
in LmpEventId lmpEventId,
|
||||||
|
in char connEventCounter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback when registration done.
|
||||||
|
*/
|
||||||
|
void onRegistered(in boolean status);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LMP event id to be monitored
|
||||||
|
* CONNECT_IND indicator for initiating connection
|
||||||
|
* LL_PHY_UPDATE_IND indicator for PHY update
|
||||||
|
*/
|
||||||
|
@VintfStability
|
||||||
|
@Backing(type="byte")
|
||||||
|
enum LmpEventId {
|
||||||
|
CONNECT_IND = 0x00,
|
||||||
|
LL_PHY_UPDATE_IND = 0x01,
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.bluetooth.lmp_event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic structure to return the timestamp
|
||||||
|
*/
|
||||||
|
@VintfStability
|
||||||
|
parcelable Timestamp {
|
||||||
|
/**
|
||||||
|
* Timestamp in microsecond since system boot.
|
||||||
|
* if systemTimeUs is set to 0, its value is to be ignored
|
||||||
|
*/
|
||||||
|
long systemTimeUs;
|
||||||
|
/**
|
||||||
|
* Timestamp in microsecond since Bluetooth controller power up.
|
||||||
|
*/
|
||||||
|
long bluetoothTimeUs;
|
||||||
|
}
|
||||||
28
bluetooth/lmp_event/aidl/default/Android.bp
Normal file
28
bluetooth/lmp_event/aidl/default/Android.bp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package {
|
||||||
|
// See: http://go/android-license-faq
|
||||||
|
// A large-scale-change added 'default_applicable_licenses' to import
|
||||||
|
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||||
|
// to get the below license kinds:
|
||||||
|
// SPDX-license-identifier-Apache-2.0
|
||||||
|
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_binary {
|
||||||
|
name: "android.hardware.bluetooth.lmp_event-service.default",
|
||||||
|
relative_install_path: "hw",
|
||||||
|
init_rc: ["lmp_event-default.rc"],
|
||||||
|
vintf_fragments: [":manifest_android.hardware.bluetooth.lmp_event-service.default.xml"],
|
||||||
|
vendor: true,
|
||||||
|
rustlibs: [
|
||||||
|
"liblogger",
|
||||||
|
"liblog_rust",
|
||||||
|
"libbinder_rs",
|
||||||
|
"android.hardware.bluetooth.lmp_event-V1-rust",
|
||||||
|
],
|
||||||
|
srcs: [ "src/main.rs" ],
|
||||||
|
}
|
||||||
|
|
||||||
|
filegroup {
|
||||||
|
name: "manifest_android.hardware.bluetooth.lmp_event-service.default.xml",
|
||||||
|
srcs: [ "lmp_event-default.xml" ],
|
||||||
|
}
|
||||||
6
bluetooth/lmp_event/aidl/default/lmp_event-default.rc
Normal file
6
bluetooth/lmp_event/aidl/default/lmp_event-default.rc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
service vendor.bluetooth.lmp_event-default /vendor/bin/hw/android.hardware.bluetooth.lmp_event-service.default
|
||||||
|
class hal
|
||||||
|
capabilities BLOCK_SUSPEND NET_ADMIN SYS_NICE
|
||||||
|
user bluetooth
|
||||||
|
group bluetooth
|
||||||
|
task_profiles HighPerformance
|
||||||
10
bluetooth/lmp_event/aidl/default/lmp_event-default.xml
Normal file
10
bluetooth/lmp_event/aidl/default/lmp_event-default.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<manifest version="1.0" type="device">
|
||||||
|
<hal format="aidl">
|
||||||
|
<name>android.hardware.bluetooth.lmp_event</name>
|
||||||
|
<version>1</version>
|
||||||
|
<interface>
|
||||||
|
<name>IBluetoothLmpEvent</name>
|
||||||
|
<instance>default</instance>
|
||||||
|
</interface>
|
||||||
|
</hal>
|
||||||
|
</manifest>
|
||||||
80
bluetooth/lmp_event/aidl/default/src/lmp_event.rs
Normal file
80
bluetooth/lmp_event/aidl/default/src/lmp_event.rs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
//! Implements LMP Event AIDL Interface.
|
||||||
|
|
||||||
|
use android_hardware_bluetooth_lmp_event::aidl::android::hardware::bluetooth::lmp_event::{
|
||||||
|
Direction::Direction, AddressType::AddressType, IBluetoothLmpEvent::IBluetoothLmpEvent,
|
||||||
|
IBluetoothLmpEventCallback::IBluetoothLmpEventCallback, LmpEventId::LmpEventId,
|
||||||
|
Timestamp::Timestamp,
|
||||||
|
};
|
||||||
|
|
||||||
|
use binder::{Interface, Result, Strong};
|
||||||
|
|
||||||
|
use log::info;
|
||||||
|
use std::thread;
|
||||||
|
use std::time;
|
||||||
|
|
||||||
|
|
||||||
|
pub struct LmpEvent;
|
||||||
|
|
||||||
|
impl LmpEvent {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Interface for LmpEvent {}
|
||||||
|
|
||||||
|
impl IBluetoothLmpEvent for LmpEvent {
|
||||||
|
fn registerForLmpEvents(&self,
|
||||||
|
callback: &Strong<dyn IBluetoothLmpEventCallback>,
|
||||||
|
address_type: AddressType,
|
||||||
|
address: &[u8; 6],
|
||||||
|
lmp_event_ids: &[LmpEventId]
|
||||||
|
) -> Result<()> {
|
||||||
|
info!("registerForLmpEvents");
|
||||||
|
|
||||||
|
let cb = callback.clone();
|
||||||
|
let addr_type = address_type;
|
||||||
|
let addr = address.clone();
|
||||||
|
let lmp_event = lmp_event_ids.to_vec();
|
||||||
|
|
||||||
|
let thread_handle = thread::spawn(move || {
|
||||||
|
let ts = Timestamp {
|
||||||
|
bluetoothTimeUs: 1000000,
|
||||||
|
systemTimeUs: 2000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
info!("sleep for 1000 ms");
|
||||||
|
thread::sleep(time::Duration::from_millis(1000));
|
||||||
|
|
||||||
|
info!("callback event");
|
||||||
|
cb.onEventGenerated(&ts, addr_type, &addr, Direction::RX, lmp_event[0], 1)
|
||||||
|
.expect("onEventGenerated failed");
|
||||||
|
});
|
||||||
|
|
||||||
|
info!("callback register");
|
||||||
|
callback.onRegistered(true)?;
|
||||||
|
|
||||||
|
thread_handle.join().expect("join failed");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn unregisterLmpEvents(&self, _address_type: AddressType, _address: &[u8; 6]) -> Result<()> {
|
||||||
|
info!("unregisterLmpEvents");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
50
bluetooth/lmp_event/aidl/default/src/main.rs
Normal file
50
bluetooth/lmp_event/aidl/default/src/main.rs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
//! Implements LMP Event Example Service.
|
||||||
|
|
||||||
|
|
||||||
|
use android_hardware_bluetooth_lmp_event::aidl::android::hardware::bluetooth::lmp_event::IBluetoothLmpEvent::{
|
||||||
|
IBluetoothLmpEvent, BnBluetoothLmpEvent
|
||||||
|
};
|
||||||
|
|
||||||
|
use binder::BinderFeatures;
|
||||||
|
use log::{info, Level};
|
||||||
|
|
||||||
|
mod lmp_event;
|
||||||
|
|
||||||
|
const LOG_TAG: &str = "lmp_event_service_example";
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
info!("{LOG_TAG}: starting service");
|
||||||
|
let logger_success = logger::init(
|
||||||
|
logger::Config::default().with_tag_on_device(LOG_TAG).with_min_level(Level::Trace)
|
||||||
|
);
|
||||||
|
if !logger_success {
|
||||||
|
panic!("{LOG_TAG}: Failed to start logger");
|
||||||
|
}
|
||||||
|
|
||||||
|
binder::ProcessState::set_thread_pool_max_thread_count(0);
|
||||||
|
|
||||||
|
let lmp_event_service = lmp_event::LmpEvent::new();
|
||||||
|
let lmp_event_service_binder = BnBluetoothLmpEvent::new_binder(lmp_event_service, BinderFeatures::default());
|
||||||
|
|
||||||
|
binder::add_service(
|
||||||
|
&format!("{}/default", lmp_event::LmpEvent::get_descriptor()),
|
||||||
|
lmp_event_service_binder.as_binder(),
|
||||||
|
).expect("Failed to register service");
|
||||||
|
|
||||||
|
binder::ProcessState::join_thread_pool()
|
||||||
|
}
|
||||||
20
bluetooth/lmp_event/aidl/vts/Android.bp
Normal file
20
bluetooth/lmp_event/aidl/vts/Android.bp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
cc_test {
|
||||||
|
name: "VtsHalLmpEventTargetTest",
|
||||||
|
defaults: [
|
||||||
|
"VtsHalTargetTestDefaults",
|
||||||
|
"use_libaidlvintf_gtest_helper_static",
|
||||||
|
],
|
||||||
|
srcs: ["VtsHalLmpEventTargetTest.cpp"],
|
||||||
|
shared_libs: [
|
||||||
|
"libbinder",
|
||||||
|
"libbinder_ndk"
|
||||||
|
],
|
||||||
|
static_libs: [
|
||||||
|
"android.hardware.bluetooth.lmp_event-V1-ndk",
|
||||||
|
],
|
||||||
|
test_suites: [
|
||||||
|
"general-tests",
|
||||||
|
"vts",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
176
bluetooth/lmp_event/aidl/vts/VtsHalLmpEventTargetTest.cpp
Normal file
176
bluetooth/lmp_event/aidl/vts/VtsHalLmpEventTargetTest.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the std::shared_ptrecific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOG_TAG "lmp_event_hal_test"
|
||||||
|
|
||||||
|
#include <aidl/Gtest.h>
|
||||||
|
#include <aidl/Vintf.h>
|
||||||
|
|
||||||
|
#include <aidl/android/hardware/bluetooth/lmp_event/BnBluetoothLmpEvent.h>
|
||||||
|
#include <aidl/android/hardware/bluetooth/lmp_event/BnBluetoothLmpEventCallback.h>
|
||||||
|
#include <aidl/android/hardware/bluetooth/lmp_event/Direction.h>
|
||||||
|
#include <aidl/android/hardware/bluetooth/lmp_event/AddressType.h>
|
||||||
|
#include <aidl/android/hardware/bluetooth/lmp_event/LmpEventId.h>
|
||||||
|
#include <aidl/android/hardware/bluetooth/lmp_event/Timestamp.h>
|
||||||
|
|
||||||
|
#include <android/binder_auto_utils.h>
|
||||||
|
#include <android/binder_manager.h>
|
||||||
|
#include <binder/IServiceManager.h>
|
||||||
|
#include <binder/ProcessState.h>
|
||||||
|
#include <log/log.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::BnBluetoothLmpEventCallback;
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::IBluetoothLmpEvent;
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::IBluetoothLmpEventCallback;
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::Direction;
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::AddressType;
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::LmpEventId;
|
||||||
|
using ::aidl::android::hardware::bluetooth::lmp_event::Timestamp;
|
||||||
|
|
||||||
|
using ::android::ProcessState;
|
||||||
|
using ::ndk::SpAIBinder;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static constexpr std::chrono::milliseconds kEventTimeoutMs(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
class BluetoothLmpEventTest : public testing::TestWithParam<std::string> {
|
||||||
|
public:
|
||||||
|
virtual void SetUp() override {
|
||||||
|
ALOGI("%s", __func__);
|
||||||
|
|
||||||
|
ibt_lmp_event_ = IBluetoothLmpEvent::fromBinder(SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
|
||||||
|
ASSERT_NE(ibt_lmp_event_, nullptr);
|
||||||
|
|
||||||
|
ibt_lmp_event_cb_ = ndk::SharedRefBase::make<BluetoothLmpEventCallback>(*this);
|
||||||
|
ASSERT_NE(ibt_lmp_event_cb_, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void TearDown() override {
|
||||||
|
ALOGI("%s", __func__);
|
||||||
|
ibt_lmp_event_->unregisterLmpEvents(address_type, address);
|
||||||
|
|
||||||
|
ibt_lmp_event_cb_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
class BluetoothLmpEventCallback : public BnBluetoothLmpEventCallback {
|
||||||
|
public:
|
||||||
|
BluetoothLmpEventTest& parent_;
|
||||||
|
BluetoothLmpEventCallback(BluetoothLmpEventTest& parent)
|
||||||
|
: parent_(parent) {}
|
||||||
|
~BluetoothLmpEventCallback() = default;
|
||||||
|
|
||||||
|
::ndk::ScopedAStatus onEventGenerated(const Timestamp& timestamp, AddressType address_type,
|
||||||
|
const std::array<uint8_t, 6>& address, Direction direction,
|
||||||
|
LmpEventId lmp_event_id, char16_t conn_event_counter) override {
|
||||||
|
for (auto t: address) {
|
||||||
|
ALOGD("%s: 0x%02x", __func__, t);
|
||||||
|
}
|
||||||
|
if (direction == Direction::TX) {
|
||||||
|
ALOGD("%s: Transmitting", __func__);
|
||||||
|
} else if (direction == Direction::RX) {
|
||||||
|
ALOGD("%s: Receiving", __func__);
|
||||||
|
}
|
||||||
|
if (address_type == AddressType::PUBLIC) {
|
||||||
|
ALOGD("%s: Public address", __func__);
|
||||||
|
} else if (address_type == AddressType::RANDOM) {
|
||||||
|
ALOGD("%s: Random address", __func__);
|
||||||
|
}
|
||||||
|
if (lmp_event_id == LmpEventId::CONNECT_IND) {
|
||||||
|
ALOGD("%s: initiating connection", __func__);
|
||||||
|
} else if (lmp_event_id == LmpEventId::LL_PHY_UPDATE_IND) {
|
||||||
|
ALOGD("%s: PHY update indication", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
ALOGD("%s: time: %" PRId64 "counter value: %x", __func__, timestamp.bluetoothTimeUs, conn_event_counter);
|
||||||
|
|
||||||
|
parent_.event_recv = true;
|
||||||
|
parent_.notify();
|
||||||
|
|
||||||
|
return ::ndk::ScopedAStatus::ok();
|
||||||
|
}
|
||||||
|
::ndk::ScopedAStatus onRegistered(bool status) override {
|
||||||
|
ALOGD("%s: status: %d", __func__, status);
|
||||||
|
parent_.status_recv = status;
|
||||||
|
parent_.notify();
|
||||||
|
return ::ndk::ScopedAStatus::ok();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void notify() {
|
||||||
|
std::unique_lock<std::mutex> lock(lmp_event_mtx);
|
||||||
|
lmp_event_cv.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void wait(bool is_register_event) {
|
||||||
|
std::unique_lock<std::mutex> lock(lmp_event_mtx);
|
||||||
|
|
||||||
|
|
||||||
|
if (is_register_event) {
|
||||||
|
lmp_event_cv.wait(lock, [&]() { return status_recv == true; });
|
||||||
|
} else {
|
||||||
|
lmp_event_cv.wait_for(lock, kEventTimeoutMs,
|
||||||
|
[&](){ return event_recv == true; });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IBluetoothLmpEvent> ibt_lmp_event_;
|
||||||
|
std::shared_ptr<IBluetoothLmpEventCallback> ibt_lmp_event_cb_;
|
||||||
|
|
||||||
|
AddressType address_type;
|
||||||
|
std::array<uint8_t, 6> address;
|
||||||
|
|
||||||
|
std::atomic<bool> event_recv;
|
||||||
|
bool status_recv;
|
||||||
|
|
||||||
|
std::mutex lmp_event_mtx;
|
||||||
|
std::condition_variable lmp_event_cv;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_P(BluetoothLmpEventTest, RegisterAndReceive) {
|
||||||
|
address = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
|
||||||
|
address_type = AddressType::RANDOM;
|
||||||
|
std::vector<LmpEventId> lmp_event_ids{LmpEventId::CONNECT_IND, LmpEventId::LL_PHY_UPDATE_IND};
|
||||||
|
|
||||||
|
ibt_lmp_event_->registerForLmpEvents(ibt_lmp_event_cb_, address_type, address, lmp_event_ids);
|
||||||
|
wait(true);
|
||||||
|
EXPECT_EQ(true, status_recv);
|
||||||
|
|
||||||
|
/* Wait for event generated here */
|
||||||
|
wait(false);
|
||||||
|
EXPECT_EQ(true, event_recv);
|
||||||
|
|
||||||
|
ibt_lmp_event_->unregisterLmpEvents(address_type, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BluetoothLmpEventTest);
|
||||||
|
INSTANTIATE_TEST_SUITE_P(BluetoothLmpEvent, BluetoothLmpEventTest,
|
||||||
|
testing::ValuesIn(android::getAidlHalInstanceNames(IBluetoothLmpEvent::descriptor)),
|
||||||
|
android::PrintInstanceNameToString);
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
ProcessState::self()->setThreadPoolMaxThreadCount(1);
|
||||||
|
ProcessState::self()->startThreadPool();
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -162,6 +162,14 @@
|
|||||||
<instance>default</instance>
|
<instance>default</instance>
|
||||||
</interface>
|
</interface>
|
||||||
</hal>
|
</hal>
|
||||||
|
<hal format="aidl" optional="true">
|
||||||
|
<name>android.hardware.bluetooth.lmp_event</name>
|
||||||
|
<version>1</version>
|
||||||
|
<interface>
|
||||||
|
<name>IBluetoothLmpEvent</name>
|
||||||
|
<instance>default</instance>
|
||||||
|
</interface>
|
||||||
|
</hal>
|
||||||
<hal format="aidl" optional="true">
|
<hal format="aidl" optional="true">
|
||||||
<name>android.hardware.boot</name>
|
<name>android.hardware.boot</name>
|
||||||
<interface>
|
<interface>
|
||||||
|
|||||||
Reference in New Issue
Block a user