Merge changes I3f440a75,I5566a1ef into main am: 9820d5d5ad am: 33e767ffea

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2763946

Change-Id: I61c8e311586dbeb6a395ca3db18a08895aaae4f3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Antoine Soulier
2023-12-05 20:56:21 +00:00
committed by Automerger Merge Worker
14 changed files with 489 additions and 6 deletions

View File

@@ -0,0 +1,50 @@
/*
* 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.audio;
@VintfStability
parcelable AudioContext {
int bitmask;
const int UNSPECIFIED = 0x0001;
const int CONVERSATIONAL = 0x0002;
const int MEDIA = 0x0004;
const int GAME = 0x0008;
const int INSTRUCTIONAL = 0x0010;
const int VOICE_ASSISTANTS = 0x0020;
const int LIVE_AUDIO = 0x0040;
const int SOUND_EFFECTS = 0x0080;
const int NOTIFICATIONS = 0x0100;
const int RINGTONE_ALERTS = 0x0200;
const int ALERTS = 0x0400;
const int EMERGENCY_ALARM = 0x0800;
}

View File

@@ -0,0 +1,53 @@
/*
* 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.audio;
@VintfStability
union CodecId {
android.hardware.bluetooth.audio.CodecId.A2dp a2dp = android.hardware.bluetooth.audio.CodecId.A2dp.SBC;
android.hardware.bluetooth.audio.CodecId.Core core;
android.hardware.bluetooth.audio.CodecId.Vendor vendor;
enum A2dp {
SBC = 0,
AAC = 2,
}
enum Core {
CVSD = 2,
MSBC = 5,
LC3 = 6,
}
parcelable Vendor {
int id;
int codecId;
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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.audio;
@VintfStability
parcelable CodecInfo {
android.hardware.bluetooth.audio.CodecId id;
String name;
android.hardware.bluetooth.audio.CodecInfo.Transport transport;
parcelable A2dp {
byte[] capabilities;
android.hardware.bluetooth.audio.ChannelMode[] channelMode;
int[] samplingFrequencyHz;
int[] bitdepth;
boolean lossless;
}
parcelable Hfp {
int inputDataPath = 1;
int outputDataPath = 1;
boolean useControllerCodec = true;
}
union Transport {
android.hardware.bluetooth.audio.CodecInfo.A2dp a2dp;
android.hardware.bluetooth.audio.CodecInfo.Hfp hfp;
}
}

View File

@@ -36,4 +36,10 @@ package android.hardware.bluetooth.audio;
interface IBluetoothAudioProviderFactory {
android.hardware.bluetooth.audio.AudioCapabilities[] getProviderCapabilities(in android.hardware.bluetooth.audio.SessionType sessionType);
android.hardware.bluetooth.audio.IBluetoothAudioProvider openProvider(in android.hardware.bluetooth.audio.SessionType sessionType);
@nullable android.hardware.bluetooth.audio.IBluetoothAudioProviderFactory.ProviderInfo getProviderInfo(in android.hardware.bluetooth.audio.SessionType sessionType);
@VintfStability
parcelable ProviderInfo {
String name;
android.hardware.bluetooth.audio.CodecInfo[] codecInfos;
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.audio;
/**
* Context of the audio configuration.
* Defined by PACS (Le Audio) and used either by A2DP or LE Audio.
* The `bitmask` is any combination of BT Sig standardized values
* [Assigned Numbers - 6.12.3], defined in this scope.
*/
@VintfStability
parcelable AudioContext {
const int UNSPECIFIED = 0x0001;
const int CONVERSATIONAL = 0x0002;
const int MEDIA = 0x0004;
const int GAME = 0x0008;
const int INSTRUCTIONAL = 0x0010;
const int VOICE_ASSISTANTS = 0x0020;
const int LIVE_AUDIO = 0x0040;
const int SOUND_EFFECTS = 0x0080;
const int NOTIFICATIONS = 0x0100;
const int RINGTONE_ALERTS = 0x0200;
const int ALERTS = 0x0400;
const int EMERGENCY_ALARM = 0x0800;
int bitmask;
}

View File

@@ -0,0 +1,49 @@
/*
* 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.audio;
@VintfStability
union CodecId {
/**
* Codec Identifier defined for A2DP
* The values are assigned by BT Sig [Assigned Numbers - 6.5.1]
*/
enum A2dp { SBC = 0, AAC = 2 }
/**
* Codec Identifier defined for the Bluetooth Core Specification
* The values are assigned by BT Sig [Assigned Numbers - 2.11]
*/
enum Core { CVSD = 2, MSBC = 5, LC3 = 6 }
/**
* Vendor Codec:
* id 16 bits - Assigned by BT Sig
* codecId 16 bits - Assigned by the vendor
*/
parcelable Vendor {
int id;
int codecId;
}
/**
* Standard (A2DP or Core numbering space) or vendor
*/
A2dp a2dp = A2dp.SBC;
Core core;
Vendor vendor;
}

View File

@@ -0,0 +1,99 @@
/*
* 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.audio;
import android.hardware.bluetooth.audio.ChannelMode;
import android.hardware.bluetooth.audio.CodecId;
/**
* General information about a Codec
*/
@VintfStability
parcelable CodecInfo {
/**
* Codec identifier and human readable name
*/
CodecId id;
String name;
/**
* A2DP Context
*/
parcelable A2dp {
/**
* The capabilities as defined by A2DP for codec interoperability
* requirements. With `id.a2dp`, the format is given by the `Codec
* Specific Information Elements` [A2DP - 4.3-6.2], and with `id.vendor`,
* by `Vendor Specific Value` [A2DP - 4.7.2].
*/
byte[] capabilities;
/**
* PCM characteristics:
* - Mono, Dual-Mono or Stereo
* - Supported sampling frequencies, in Hz.
* - Fixed point resolution, basically 16, 24 or 32 bits by samples.
* The value 32 should be used for floating point representation.
*
* When the bitdepth is not an encoding/decoding parameter (don't take part
* in the interoperability), the `bitdepth` list shall have a single element
* indicating the bitdepth selected for the platform.
*/
ChannelMode[] channelMode;
int[] samplingFrequencyHz;
int[] bitdepth;
/**
* Lossless capable characteristic
*/
boolean lossless;
}
/**
* HFP Context
*/
parcelable Hfp {
/**
* Vendor-specific identifiers of stream data paths, set in the
* HCI Command Enhanced Setup Synchronous Connection [Core - 4.E.7.1.45],
* in the command parameters respectively `Input_Data_Path` and
* `Output_Data_Path`. The value range from 0x01 to 0xFE.
* The stack operates as a pass-through; the client SHALL NOT
* interpret the values.
*/
int inputDataPath = 1;
int outputDataPath = 1;
/**
* Whether the audio stream is encoded and decoded in the controller or
* locally; enable the controller transparent mode when the audio
* stream is locally processed.
*/
boolean useControllerCodec = true;
}
/**
* Specific informations,
* depending on transport.
*/
union Transport {
A2dp a2dp;
Hfp hfp;
}
Transport transport;
}

View File

@@ -59,9 +59,8 @@ interface IBluetoothAudioProvider {
* audioConfig.pcmConfig parameter. Invalid if streaming is offloaded
* from/to hardware or on failure
*/
MQDescriptor<byte, SynchronizedReadWrite> startSession(
in IBluetoothAudioPort hostIf, in AudioConfiguration audioConfig,
in LatencyMode[] supportedLatencyModes);
MQDescriptor<byte, SynchronizedReadWrite> startSession(in IBluetoothAudioPort hostIf,
in AudioConfiguration audioConfig, in LatencyMode[] supportedLatencyModes);
/**
* Callback for IBluetoothAudioPort.startStream()
*

View File

@@ -17,8 +17,10 @@
package android.hardware.bluetooth.audio;
import android.hardware.bluetooth.audio.AudioCapabilities;
import android.hardware.bluetooth.audio.CodecInfo;
import android.hardware.bluetooth.audio.IBluetoothAudioProvider;
import android.hardware.bluetooth.audio.SessionType;
/**
* This factory allows a HAL implementation to be split into multiple
* independent providers.
@@ -62,4 +64,24 @@ interface IBluetoothAudioProviderFactory {
* @return provider The provider of the specified session type
*/
IBluetoothAudioProvider openProvider(in SessionType sessionType);
/**
* General information relative to a provider
* - An optional name
* - A list of codec information
*/
@VintfStability
parcelable ProviderInfo {
String name;
CodecInfo[] codecInfos;
}
/**
* Get general information relative to a provider.
*
* @param sessionType Hardware Offload provider (*_HARDWARE_OFFLOAD_*)
* @return General information relative to the provider.
* The `null` value can be returned when the provider is not available
*/
@nullable ProviderInfo getProviderInfo(in SessionType sessionType);
}

View File

@@ -168,4 +168,4 @@ ndk::ScopedAStatus BluetoothAudioProvider::setLowLatencyModeAllowed(
} // namespace bluetooth
} // namespace hardware
} // namespace android
} // namespace aidl
} // namespace aidl

View File

@@ -135,8 +135,17 @@ ndk::ScopedAStatus BluetoothAudioProviderFactory::getProviderCapabilities(
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus BluetoothAudioProviderFactory::getProviderInfo(
SessionType session_type, std::optional<ProviderInfo>* _aidl_return) {
*_aidl_return = std::nullopt;
(void)session_type;
return ndk::ScopedAStatus::ok();
}
} // namespace audio
} // namespace bluetooth
} // namespace hardware
} // namespace android
} // namespace aidl
} // namespace aidl

View File

@@ -35,6 +35,10 @@ class BluetoothAudioProviderFactory : public BnBluetoothAudioProviderFactory {
ndk::ScopedAStatus getProviderCapabilities(
const SessionType session_type,
std::vector<AudioCapabilities>* _aidl_return) override;
ndk::ScopedAStatus getProviderInfo(
SessionType in_sessionType,
std::optional<ProviderInfo>* _aidl_return) override;
};
} // namespace audio

View File

@@ -46,6 +46,8 @@ using aidl::android::hardware::bluetooth::audio::BroadcastCapability;
using aidl::android::hardware::bluetooth::audio::ChannelMode;
using aidl::android::hardware::bluetooth::audio::CodecCapabilities;
using aidl::android::hardware::bluetooth::audio::CodecConfiguration;
using aidl::android::hardware::bluetooth::audio::CodecId;
using aidl::android::hardware::bluetooth::audio::CodecInfo;
using aidl::android::hardware::bluetooth::audio::CodecType;
using aidl::android::hardware::bluetooth::audio::IBluetoothAudioPort;
using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider;
@@ -597,6 +599,99 @@ TEST_P(BluetoothAudioProviderFactoryAidl,
}
}
/**
* Test that getProviderInfo, when implemented,
* returns empty information for session types for
* software data paths.
*/
TEST_P(BluetoothAudioProviderFactoryAidl, getProviderInfo_invalidSessionTypes) {
static constexpr SessionType kInvalidSessionTypes[]{
SessionType::UNKNOWN,
SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH,
SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH,
SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH,
SessionType::A2DP_SOFTWARE_DECODING_DATAPATH,
};
for (auto session_type : kInvalidSessionTypes) {
std::optional<IBluetoothAudioProviderFactory::ProviderInfo> provider_info =
std::nullopt;
auto aidl_retval =
provider_factory_->getProviderInfo(session_type, &provider_info);
if (!aidl_retval.isOk()) {
continue;
}
// If getProviderInfo is supported, the provider info
// must be empty for software session types.
ASSERT_FALSE(provider_info.has_value());
}
}
/**
* Test that getProviderInfo, when implemented,
* returns valid information for session types for
* a2dp hardware data paths.
*/
TEST_P(BluetoothAudioProviderFactoryAidl, getProviderInfo_a2dpSessionTypes) {
static constexpr SessionType kA2dpSessionTypes[]{
SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH,
};
for (auto session_type : kA2dpSessionTypes) {
std::optional<IBluetoothAudioProviderFactory::ProviderInfo> provider_info =
std::nullopt;
auto aidl_retval =
provider_factory_->getProviderInfo(session_type, &provider_info);
if (!aidl_retval.isOk() || !provider_info.has_value()) {
continue;
}
for (auto const& codec_info : provider_info->codecInfos) {
// The codec id must not be core.
ASSERT_NE(codec_info.id.getTag(), CodecId::core);
// The codec info must contain the information
// for a2dp transport.
ASSERT_EQ(codec_info.transport.getTag(), CodecInfo::Transport::a2dp);
}
}
}
/**
* Test that getProviderInfo, when implemented,
* returns valid information for session types for
* le audio hardware data paths.
*/
TEST_P(BluetoothAudioProviderFactoryAidl, getProviderInfo_leAudioSessionTypes) {
static constexpr SessionType kLeAudioSessionTypes[]{
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH,
SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
};
for (auto session_type : kLeAudioSessionTypes) {
std::optional<IBluetoothAudioProviderFactory::ProviderInfo> provider_info =
std::nullopt;
auto aidl_retval =
provider_factory_->getProviderInfo(session_type, &provider_info);
if (!aidl_retval.isOk() || !provider_info.has_value()) {
continue;
}
for (auto const& codec_info : provider_info->codecInfos) {
// The codec id must not be a2dp.
ASSERT_NE(codec_info.id.getTag(), CodecId::a2dp);
// The codec info must contain the information
// for le audio transport.
// ASSERT_EQ(codec_info.transport.getTag(),
// CodecInfo::Transport::le_audio);
}
}
}
/**
* openProvider A2DP_SOFTWARE_ENCODING_DATAPATH
*/

View File

@@ -78,7 +78,7 @@ cc_test {
shared_libs: [
"libbase",
"libbinder_ndk",
"android.hardware.bluetooth.audio-V3-ndk",
"android.hardware.bluetooth.audio-V4-ndk",
"libxml2",
],
test_suites: [