diff --git a/audio/7.1/Android.bp b/audio/7.1/Android.bp new file mode 100644 index 0000000000..d0d96b6cf6 --- /dev/null +++ b/audio/7.1/Android.bp @@ -0,0 +1,30 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +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"], +} + +hidl_interface { + name: "android.hardware.audio@7.1", + root: "android.hardware", + srcs: [ + "IDevice.hal", + "IDevicesFactory.hal", + "IPrimaryDevice.hal", + "IStreamIn.hal", + "IStreamOut.hal", + ], + interfaces: [ + "android.hardware.audio@7.0", + "android.hardware.audio.common@7.0", + "android.hidl.base@1.0", + "android.hidl.safe_union@1.0", + ], + gen_java: false, + gen_java_constants: false, +} diff --git a/audio/7.1/IDevice.hal b/audio/7.1/IDevice.hal new file mode 100644 index 0000000000..373d17f4f9 --- /dev/null +++ b/audio/7.1/IDevice.hal @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +import android.hardware.audio.common@7.0; +import @7.0::AudioInOutFlag; +import @7.0::IDevice; +import @7.0::Result; +import IStreamIn; +import IStreamOut; + +interface IDevice extends @7.0::IDevice { + /** + * This method creates and opens the audio hardware output stream. + * If the stream can not be opened with the proposed audio config, + * HAL must provide suggested values for the audio config. + * + * Note: INVALID_ARGUMENTS is returned both in the case when the + * HAL can not use the provided config and in the case when + * the value of any argument is invalid. In the latter case the + * HAL must provide a default initialized suggested config. + * + * @param ioHandle handle assigned by AudioFlinger. + * @param device device type and (if needed) address. + * @param config stream configuration. + * @param flags additional flags. + * @param sourceMetadata Description of the audio that will be played. + May be used by implementations to configure hardware effects. + * @return retval operation completion status. + * @return outStream created output stream. + * @return suggestedConfig in the case of rejection of the proposed config, + * a config suggested by the HAL. + */ + openOutputStream_7_1( + AudioIoHandle ioHandle, + DeviceAddress device, + AudioConfig config, + vec flags, + SourceMetadata sourceMetadata) generates ( + Result retval, + IStreamOut outStream, + AudioConfig suggestedConfig); + + /** + * This method creates and opens the audio hardware input stream. + * If the stream can not be opened with the proposed audio config, + * HAL must provide suggested values for the audio config. + * + * Note: INVALID_ARGUMENTS is returned both in the case when the + * HAL can not use the provided config and in the case when + * the value of any argument is invalid. In the latter case the + * HAL must provide a default initialized suggested config. + * + * @param ioHandle handle assigned by AudioFlinger. + * @param device device type and (if needed) address. + * @param config stream configuration. + * @param flags additional flags. + * @param sinkMetadata Description of the audio that is suggested by the client. + * May be used by implementations to configure processing effects. + * @return retval operation completion status. + * @return inStream in case of success, created input stream. + * @return suggestedConfig in the case of rejection of the proposed config, + * a config suggested by the HAL. + */ + openInputStream_7_1( + AudioIoHandle ioHandle, + DeviceAddress device, + AudioConfig config, + vec flags, + SinkMetadata sinkMetadata) generates ( + Result retval, + IStreamIn inStream, + AudioConfig suggestedConfig); +}; diff --git a/audio/7.1/IDevicesFactory.hal b/audio/7.1/IDevicesFactory.hal new file mode 100644 index 0000000000..7669614e59 --- /dev/null +++ b/audio/7.1/IDevicesFactory.hal @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +import @7.0::IDevicesFactory; +import @7.0::Result; +import IDevice; +import IPrimaryDevice; + +/** + * This factory allows a HAL implementation to be split in multiple independent + * devices (called module in the pre-treble API). Note that this division is + * arbitrary and implementation are free to only have a Primary. The framework + * will query the devices according to audio_policy_configuration.xml + * + * Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml + * and only used to identify a device in this factory. + * The framework must not interpret the name, treating it as a vendor opaque data + * with the following exception: + * - the "r_submix" device that must be present to support policyMixes (Eg: Android projected). + * Note that this Device is included by default in a build derived from AOSP. + */ +interface IDevicesFactory extends @7.0::IDevicesFactory { + + /** + * Opens an audio device. To close the device, it is necessary to call + * 'close' method on the returned device object. + * + * Important note: due to rules of HIDL, @7.1::IPrimaryDevice extends + * @7.0::IPrimaryDevice, rather than @7.1::IDevice. Thus the returned + * IDevice interface can not be up-casted to @7.1::IPrimaryDevice for the + * primary device. The client needs to use IPrimaryDevice instead of this + * method if it needs full functionality of the IPrimaryDevice interface. + * + * @param device device name. + * @return retval operation completion status. Returns INVALID_ARGUMENTS + * if there is no corresponding hardware module found, + * NOT_INITIALIZED if an error occurred while opening the hardware + * module. + * @return result the interface for the created device. + */ + openDevice_7_1(string device) generates (Result retval, IDevice result); + + /** + * Opens the Primary audio device that must be present. + * This function is not optional and must return successfully the primary device. + * + * This device must have the name "primary". + * + * The telephony stack uses this device to control the audio during a voice call. + * + * @return retval operation completion status. Must be SUCCESS. + * For debugging, return INVALID_ARGUMENTS if there is no corresponding + * hardware module found, NOT_INITIALIZED if an error occurred + * while opening the hardware module. + * @return result the interface for the created device. + */ + openPrimaryDevice_7_1() generates (Result retval, IPrimaryDevice result); +}; diff --git a/audio/7.1/IPrimaryDevice.hal b/audio/7.1/IPrimaryDevice.hal new file mode 100644 index 0000000000..16596716f5 --- /dev/null +++ b/audio/7.1/IPrimaryDevice.hal @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +import android.hardware.audio.common@7.0; +import @7.0::IPrimaryDevice; +import IDevice; + +interface IPrimaryDevice extends @7.0::IPrimaryDevice { + /** + * Retrieve the generic @7.1::IDevice interface. + * + * Since @7.1::IPrimaryDevice extends @7.0::IPrimaryDevice, the interface + * reference can not be downcasted to @7.1::IDevice using standard methods. + * For this reason a dedicated interface method is provided. + * + * @return result the generic part of the interface. + */ + getDevice() generates (IDevice result); +}; diff --git a/audio/7.1/IStreamIn.hal b/audio/7.1/IStreamIn.hal new file mode 100644 index 0000000000..abebe6a062 --- /dev/null +++ b/audio/7.1/IStreamIn.hal @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +import @7.0::IStreamIn; + +interface IStreamIn extends @7.0::IStreamIn { +}; diff --git a/audio/7.1/IStreamOut.hal b/audio/7.1/IStreamOut.hal new file mode 100644 index 0000000000..092a9a0f40 --- /dev/null +++ b/audio/7.1/IStreamOut.hal @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +import @7.0::IStreamOut; + +interface IStreamOut extends @7.0::IStreamOut { +}; diff --git a/audio/7.1/config/Android.bp b/audio/7.1/config/Android.bp new file mode 100644 index 0000000000..70c8fd4a77 --- /dev/null +++ b/audio/7.1/config/Android.bp @@ -0,0 +1,31 @@ +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"], +} + +xsd_config { + name: "audio_policy_configuration_V7_1", + srcs: ["audio_policy_configuration.xsd"], + package_name: "android.audio.policy.configuration.V7_1", + nullability: true, +} + +xsd_config { + name: "audio_policy_configuration_V7_1_enums", + srcs: ["audio_policy_configuration.xsd"], + package_name: "android.audio.policy.configuration.V7_1", + nullability: true, + enums_only: true, +} + +xsd_config { + name: "audio_policy_configuration_V7_1_parser", + srcs: ["audio_policy_configuration.xsd"], + package_name: "android.audio.policy.configuration.V7_1", + nullability: true, + parser_only: true, +} diff --git a/audio/7.1/config/api/current.txt b/audio/7.1/config/api/current.txt new file mode 100644 index 0000000000..01c2e4bbd5 --- /dev/null +++ b/audio/7.1/config/api/current.txt @@ -0,0 +1,592 @@ +// Signature format: 2.0 +package android.audio.policy.configuration.V7_1 { + + public class AttachedDevices { + ctor public AttachedDevices(); + method @Nullable public java.util.List getItem(); + } + + public enum AudioChannelMask { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_10; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_11; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_12; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_13; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_14; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_15; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_16; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_17; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_18; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_19; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_20; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_21; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_22; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_23; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_24; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_5; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_6; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_7; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_8; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_9; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_2POINT0POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_2POINT1POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_3POINT0POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_3POINT1POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_5POINT1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_6; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_FRONT_BACK; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_MONO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_STEREO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_VOICE_CALL_MONO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_NONE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_13POINT_360RA; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_22POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_2POINT0POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_2POINT1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_2POINT1POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_3POINT0POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_3POINT1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_3POINT1POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1POINT4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1_BACK; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1_SIDE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_6POINT1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1POINT2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1POINT4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_HAPTIC_AB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_MONO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_MONO_HAPTIC_A; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_MONO_HAPTIC_AB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_PENTA; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_QUAD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_QUAD_BACK; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_QUAD_SIDE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_STEREO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_STEREO_HAPTIC_AB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_SURROUND; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_TRI; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_TRI_BACK; + } + + public enum AudioContentType { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioContentType AUDIO_CONTENT_TYPE_MOVIE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioContentType AUDIO_CONTENT_TYPE_MUSIC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioContentType AUDIO_CONTENT_TYPE_SONIFICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioContentType AUDIO_CONTENT_TYPE_SPEECH; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioContentType AUDIO_CONTENT_TYPE_UNKNOWN; + } + + public enum AudioDevice { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_AMBIENT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_AUX_DIGITAL; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BACK_MIC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BLE_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BLUETOOTH_A2DP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BLUETOOTH_BLE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BUILTIN_MIC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_BUS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_COMMUNICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_DEFAULT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_ECHO_REFERENCE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_FM_TUNER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_HDMI; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_HDMI_ARC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_HDMI_EARC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_IP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_LINE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_LOOPBACK; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_PROXY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_REMOTE_SUBMIX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_SPDIF; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_STUB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_TELEPHONY_RX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_TV_TUNER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_USB_ACCESSORY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_USB_DEVICE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_USB_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_VOICE_CALL; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_IN_WIRED_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_NONE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_AUX_DIGITAL; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_AUX_LINE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLE_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLE_SPEAKER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_SCO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BUS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_DEFAULT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_EARPIECE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_ECHO_CANCELLER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_FM; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_HDMI; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_HDMI_ARC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_HDMI_EARC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_HEARING_AID; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_IP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_LINE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_PROXY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_REMOTE_SUBMIX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_SPDIF; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_SPEAKER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_SPEAKER_SAFE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_STUB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_TELEPHONY_TX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_USB_ACCESSORY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_USB_DEVICE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_USB_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_WIRED_HEADPHONE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_WIRED_HEADSET; + } + + public enum AudioEncapsulationType { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioEncapsulationType AUDIO_ENCAPSULATION_TYPE_IEC61937; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioEncapsulationType AUDIO_ENCAPSULATION_TYPE_NONE; + } + + public enum AudioFormat { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADIF; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_ELD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_ERLC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_HE_V1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_HE_V2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_LC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_LD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_LTP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_MAIN; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_SCALABLE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_SSR; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ADTS_XHE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ELD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_ERLC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_HE_V1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_HE_V2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LATM; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LATM_HE_V1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LATM_HE_V2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LATM_LC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_LTP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_MAIN; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_SCALABLE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_SSR; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AAC_XHE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AC3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AC4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_ALAC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AMR_NB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AMR_WB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_AMR_WB_PLUS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_APE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_APTX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_APTX_ADAPTIVE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_APTX_HD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_APTX_TWSP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_CELT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DEFAULT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DOLBY_TRUEHD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DRA; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DSD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DTS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DTS_HD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_DTS_UHD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_EVRC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_EVRCB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_EVRCNW; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_EVRCWB; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_E_AC3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_E_AC3_JOC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_FLAC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_HE_AAC_V1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_HE_AAC_V2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_IEC60958; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_IEC61937; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_LC3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_LDAC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_LHDC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_LHDC_LL; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MAT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MAT_1_0; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MAT_2_0; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MAT_2_1; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MP2; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MP3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MPEGH_BL_L3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MPEGH_BL_L4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MPEGH_LC_L3; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_MPEGH_LC_L4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_OPUS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_PCM_16_BIT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_PCM_24_BIT_PACKED; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_PCM_32_BIT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_PCM_8_24_BIT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_PCM_8_BIT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_PCM_FLOAT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_QCELP; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_SBC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_VORBIS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_WMA; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioFormat AUDIO_FORMAT_WMA_PRO; + } + + public enum AudioGainMode { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioGainMode AUDIO_GAIN_MODE_CHANNELS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioGainMode AUDIO_GAIN_MODE_JOINT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioGainMode AUDIO_GAIN_MODE_RAMP; + } + + public enum AudioInOutFlag { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_DIRECT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_FAST; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_HW_AV_SYNC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_HW_HOTWORD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_MMAP_NOIRQ; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_RAW; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_SYNC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_INPUT_FLAG_VOIP_TX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_DEEP_BUFFER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_DIRECT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_DIRECT_PCM; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_FAST; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_HW_AV_SYNC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_INCALL_MUSIC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_MMAP_NOIRQ; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_NON_BLOCKING; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_PRIMARY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_RAW; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_SYNC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_TTS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_VOIP_RX; + } + + public class AudioPolicyConfiguration { + ctor public AudioPolicyConfiguration(); + method @Nullable public android.audio.policy.configuration.V7_1.GlobalConfiguration getGlobalConfiguration(); + method @Nullable public java.util.List getModules(); + method @Nullable public android.audio.policy.configuration.V7_1.SurroundSound getSurroundSound(); + method @Nullable public android.audio.policy.configuration.V7_1.Version getVersion(); + method @Nullable public java.util.List getVolumes(); + method public void setGlobalConfiguration(@Nullable android.audio.policy.configuration.V7_1.GlobalConfiguration); + method public void setSurroundSound(@Nullable android.audio.policy.configuration.V7_1.SurroundSound); + method public void setVersion(@Nullable android.audio.policy.configuration.V7_1.Version); + } + + public enum AudioSource { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_CAMCORDER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_DEFAULT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_ECHO_REFERENCE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_FM_TUNER; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_HOTWORD; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_MIC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_REMOTE_SUBMIX; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_UNPROCESSED; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_VOICE_CALL; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_VOICE_COMMUNICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_VOICE_DOWNLINK; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_VOICE_PERFORMANCE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_VOICE_RECOGNITION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioSource AUDIO_SOURCE_VOICE_UPLINK; + } + + public enum AudioStreamType { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_ACCESSIBILITY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_ALARM; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_ASSISTANT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_BLUETOOTH_SCO; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_CALL_ASSISTANT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_DTMF; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_ENFORCED_AUDIBLE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_MUSIC; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_NOTIFICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_PATCH; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_REROUTING; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_RING; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_SYSTEM; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_TTS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioStreamType AUDIO_STREAM_VOICE_CALL; + } + + public enum AudioUsage { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_ALARM; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_ANNOUNCEMENT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_ASSISTANCE_SONIFICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_ASSISTANT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_CALL_ASSISTANT; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_EMERGENCY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_GAME; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_MEDIA; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_NOTIFICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_SAFETY; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_UNKNOWN; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_VEHICLE_STATUS; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_VIRTUAL_SOURCE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_VOICE_COMMUNICATION; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioUsage AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING; + } + + public enum DeviceCategory { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.DeviceCategory DEVICE_CATEGORY_EARPIECE; + enum_constant public static final android.audio.policy.configuration.V7_1.DeviceCategory DEVICE_CATEGORY_EXT_MEDIA; + enum_constant public static final android.audio.policy.configuration.V7_1.DeviceCategory DEVICE_CATEGORY_HEADSET; + enum_constant public static final android.audio.policy.configuration.V7_1.DeviceCategory DEVICE_CATEGORY_HEARING_AID; + enum_constant public static final android.audio.policy.configuration.V7_1.DeviceCategory DEVICE_CATEGORY_SPEAKER; + } + + public class DevicePorts { + ctor public DevicePorts(); + method @Nullable public java.util.List getDevicePort(); + } + + public static class DevicePorts.DevicePort { + ctor public DevicePorts.DevicePort(); + method @Nullable public String getAddress(); + method @Nullable public java.util.List getEncodedFormats(); + method @Nullable public android.audio.policy.configuration.V7_1.Gains getGains(); + method @Nullable public java.util.List getProfile(); + method @Nullable public android.audio.policy.configuration.V7_1.Role getRole(); + method @Nullable public String getTagName(); + method @Nullable public String getType(); + method @Nullable public boolean get_default(); + method public void setAddress(@Nullable String); + method public void setEncodedFormats(@Nullable java.util.List); + method public void setGains(@Nullable android.audio.policy.configuration.V7_1.Gains); + method public void setRole(@Nullable android.audio.policy.configuration.V7_1.Role); + method public void setTagName(@Nullable String); + method public void setType(@Nullable String); + method public void set_default(@Nullable boolean); + } + + public enum EngineSuffix { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.EngineSuffix _default; + enum_constant public static final android.audio.policy.configuration.V7_1.EngineSuffix configurable; + } + + public class Gains { + ctor public Gains(); + method @Nullable public java.util.List getGain(); + } + + public static class Gains.Gain { + ctor public Gains.Gain(); + method @Nullable public android.audio.policy.configuration.V7_1.AudioChannelMask getChannel_mask(); + method @Nullable public int getDefaultValueMB(); + method @Nullable public int getMaxRampMs(); + method @Nullable public int getMaxValueMB(); + method @Nullable public int getMinRampMs(); + method @Nullable public int getMinValueMB(); + method @Nullable public java.util.List getMode(); + method @Nullable public String getName(); + method @Nullable public int getStepValueMB(); + method @Nullable public boolean getUseForVolume(); + method public void setChannel_mask(@Nullable android.audio.policy.configuration.V7_1.AudioChannelMask); + method public void setDefaultValueMB(@Nullable int); + method public void setMaxRampMs(@Nullable int); + method public void setMaxValueMB(@Nullable int); + method public void setMinRampMs(@Nullable int); + method public void setMinValueMB(@Nullable int); + method public void setMode(@Nullable java.util.List); + method public void setName(@Nullable String); + method public void setStepValueMB(@Nullable int); + method public void setUseForVolume(@Nullable boolean); + } + + public class GlobalConfiguration { + ctor public GlobalConfiguration(); + method @Nullable public boolean getCall_screen_mode_supported(); + method @Nullable public android.audio.policy.configuration.V7_1.EngineSuffix getEngine_library(); + method @Nullable public boolean getSpeaker_drc_enabled(); + method public void setCall_screen_mode_supported(@Nullable boolean); + method public void setEngine_library(@Nullable android.audio.policy.configuration.V7_1.EngineSuffix); + method public void setSpeaker_drc_enabled(@Nullable boolean); + } + + public enum HalVersion { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.HalVersion _2_0; + enum_constant public static final android.audio.policy.configuration.V7_1.HalVersion _3_0; + } + + public class MixPorts { + ctor public MixPorts(); + method @Nullable public java.util.List getMixPort(); + } + + public static class MixPorts.MixPort { + ctor public MixPorts.MixPort(); + method @Nullable public java.util.List getFlags(); + method @Nullable public android.audio.policy.configuration.V7_1.Gains getGains(); + method @Nullable public long getMaxActiveCount(); + method @Nullable public long getMaxOpenCount(); + method @Nullable public String getName(); + method @Nullable public java.util.List getPreferredUsage(); + method @Nullable public java.util.List getProfile(); + method @Nullable public android.audio.policy.configuration.V7_1.Role getRole(); + method public void setFlags(@Nullable java.util.List); + method public void setGains(@Nullable android.audio.policy.configuration.V7_1.Gains); + method public void setMaxActiveCount(@Nullable long); + method public void setMaxOpenCount(@Nullable long); + method public void setName(@Nullable String); + method public void setPreferredUsage(@Nullable java.util.List); + method public void setRole(@Nullable android.audio.policy.configuration.V7_1.Role); + } + + public enum MixType { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.MixType mix; + enum_constant public static final android.audio.policy.configuration.V7_1.MixType mux; + } + + public class Modules { + ctor public Modules(); + method @Nullable public java.util.List getModule(); + } + + public static class Modules.Module { + ctor public Modules.Module(); + method @Nullable public android.audio.policy.configuration.V7_1.AttachedDevices getAttachedDevices(); + method @Nullable public String getDefaultOutputDevice(); + method @Nullable public android.audio.policy.configuration.V7_1.DevicePorts getDevicePorts(); + method @Nullable public android.audio.policy.configuration.V7_1.HalVersion getHalVersion(); + method @Nullable public android.audio.policy.configuration.V7_1.MixPorts getMixPorts(); + method @Nullable public String getName(); + method @Nullable public android.audio.policy.configuration.V7_1.Routes getRoutes(); + method public void setAttachedDevices(@Nullable android.audio.policy.configuration.V7_1.AttachedDevices); + method public void setDefaultOutputDevice(@Nullable String); + method public void setDevicePorts(@Nullable android.audio.policy.configuration.V7_1.DevicePorts); + method public void setHalVersion(@Nullable android.audio.policy.configuration.V7_1.HalVersion); + method public void setMixPorts(@Nullable android.audio.policy.configuration.V7_1.MixPorts); + method public void setName(@Nullable String); + method public void setRoutes(@Nullable android.audio.policy.configuration.V7_1.Routes); + } + + public class Profile { + ctor public Profile(); + method @Nullable public java.util.List getChannelMasks(); + method @Nullable public android.audio.policy.configuration.V7_1.AudioEncapsulationType getEncapsulationType(); + method @Nullable public String getFormat(); + method @Nullable public String getName(); + method @Nullable public java.util.List getSamplingRates(); + method public void setChannelMasks(@Nullable java.util.List); + method public void setEncapsulationType(@Nullable android.audio.policy.configuration.V7_1.AudioEncapsulationType); + method public void setFormat(@Nullable String); + method public void setName(@Nullable String); + method public void setSamplingRates(@Nullable java.util.List); + } + + public class Reference { + ctor public Reference(); + method @Nullable public String getName(); + method @Nullable public java.util.List getPoint(); + method public void setName(@Nullable String); + } + + public enum Role { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.Role sink; + enum_constant public static final android.audio.policy.configuration.V7_1.Role source; + } + + public class Routes { + ctor public Routes(); + method @Nullable public java.util.List getRoute(); + } + + public static class Routes.Route { + ctor public Routes.Route(); + method @Nullable public String getSink(); + method @Nullable public String getSources(); + method @Nullable public android.audio.policy.configuration.V7_1.MixType getType(); + method public void setSink(@Nullable String); + method public void setSources(@Nullable String); + method public void setType(@Nullable android.audio.policy.configuration.V7_1.MixType); + } + + public class SurroundFormats { + ctor public SurroundFormats(); + method @Nullable public java.util.List getFormat(); + } + + public static class SurroundFormats.Format { + ctor public SurroundFormats.Format(); + method @Nullable public String getName(); + method @Nullable public java.util.List getSubformats(); + method public void setName(@Nullable String); + method public void setSubformats(@Nullable java.util.List); + } + + public class SurroundSound { + ctor public SurroundSound(); + method @Nullable public android.audio.policy.configuration.V7_1.SurroundFormats getFormats(); + method public void setFormats(@Nullable android.audio.policy.configuration.V7_1.SurroundFormats); + } + + public enum Version { + method @NonNull public String getRawName(); + enum_constant public static final android.audio.policy.configuration.V7_1.Version _7_0; + enum_constant public static final android.audio.policy.configuration.V7_1.Version _7_1; + } + + public class Volume { + ctor public Volume(); + method @Nullable public android.audio.policy.configuration.V7_1.DeviceCategory getDeviceCategory(); + method @Nullable public java.util.List getPoint(); + method @Nullable public String getRef(); + method @Nullable public android.audio.policy.configuration.V7_1.AudioStreamType getStream(); + method public void setDeviceCategory(@Nullable android.audio.policy.configuration.V7_1.DeviceCategory); + method public void setRef(@Nullable String); + method public void setStream(@Nullable android.audio.policy.configuration.V7_1.AudioStreamType); + } + + public class Volumes { + ctor public Volumes(); + method @Nullable public java.util.List getReference(); + method @Nullable public java.util.List getVolume(); + } + + public class XmlParser { + ctor public XmlParser(); + method @Nullable public static android.audio.policy.configuration.V7_1.AudioPolicyConfiguration read(@NonNull java.io.InputStream) throws javax.xml.datatype.DatatypeConfigurationException, java.io.IOException, org.xmlpull.v1.XmlPullParserException; + method @Nullable public static String readText(@NonNull org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException; + method public static void skip(@NonNull org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException; + } + +} + diff --git a/audio/7.1/config/api/last_current.txt b/audio/7.1/config/api/last_current.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/audio/7.1/config/api/last_removed.txt b/audio/7.1/config/api/last_removed.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/audio/7.1/config/api/removed.txt b/audio/7.1/config/api/removed.txt new file mode 100644 index 0000000000..d802177e24 --- /dev/null +++ b/audio/7.1/config/api/removed.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/audio/7.1/config/audio_policy_configuration.xsd b/audio/7.1/config/audio_policy_configuration.xsd new file mode 100644 index 0000000000..731bb7c75f --- /dev/null +++ b/audio/7.1/config/audio_policy_configuration.xsd @@ -0,0 +1,815 @@ + + + + + + + + + + + + + + Version of the interface the hal implements. Note that this + relates to legacy HAL API versions since HIDL APIs are versioned + using other mechanisms. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + There should be one section per audio HW module present on the platform. + Each contains two mandatory tags: “halVersion” and “name”. + The module "name" is the same as in previous .conf file. + Each module must contain the following sections: + - : a list of device descriptors for all + input and output devices accessible via this module. + This contains both permanently attached devices and removable devices. + - : listing all output and input streams exposed by the audio HAL + - : list of possible connections between input + and output devices or between stream and devices. + A is defined by a set of 3 attributes: + -"type": mux|mix means all sources are mutual exclusive (mux) or can be mixed (mix) + -"sink": the sink involved in this route + -"sources": all the sources than can be connected to the sink via this route + - : permanently attached devices. + The attachedDevices section is a list of devices names. + Their names correspond to device names defined in "devicePorts" section. + - is the device to be used when no policy rule applies + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The flags indicate suggested stream attributes supported by the profile. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + When choosing the mixPort of an audio track, the audioPolicy + first considers the mixPorts with a preferredUsage including + the track AudioUsage preferred . + If non support the track format, the other mixPorts are considered. + Eg: a will receive + the audio of all apps playing with a MEDIA usage. + It may receive audio from ALARM if there are no audio compatible + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Audio usage specifies the intended use case for the sound being played. + Please consult frameworks/base/media/java/android/media/AudioAttributes.java + for the description of each value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Audio content type expresses the general category of the content. + Please consult frameworks/base/media/java/android/media/AudioAttributes.java + for the description of each value. + + + + + + + + + + + + + + + + + Audio channel mask specifies presence of particular channels. + There are two representations: + - representation position (traditional discrete channel specification, + e.g. "left", "right"); + - indexed (this is similar to "tracks" in audio mixing, channels + are represented using numbers). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The default device will be used if multiple have the same type + and no explicit route request exists for a specific device of + that type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + List all available sources for a given sink. + + + + + + + + + + + + + + + + + + + + + + Comma separated pair of number. + The fist one is the framework level (between 0 and 100). + The second one is the volume to send to the HAL. + The framework will interpolate volumes not specified. + Their MUST be at least 2 points specified. + + + + + + + + + + Audio stream type describing the intended use case of a stream. + Please consult frameworks/base/media/java/android/media/AudioSystem.java + for the description of each value. + + + + + + + + + + + + + + + + + + + + + + + + An audio source defines the intended use case for the sound being recorded. + Please consult frameworks/base/media/java/android/media/MediaRecorder.java + for the description of each value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Volume section defines a volume curve for a given use case and device category. + It contains a list of points of this curve expressing the attenuation in Millibels + for a given volume index from 0 to 100. + + 0,-9600 + 100,0 + + + It may also reference a reference/@name to avoid duplicating curves. + + + 0,-9600 + 100,0 + + + + + + + + + + + + + + + + + + + + Surround Sound section provides configuration related to handling of + multi-channel formats. + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/common/7.1/Android.bp b/audio/common/7.1/Android.bp new file mode 100644 index 0000000000..a2575104e6 --- /dev/null +++ b/audio/common/7.1/Android.bp @@ -0,0 +1,23 @@ +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"], +} + +cc_library { + name: "android.hardware.audio.common@7.1-enums", + vendor_available: true, + generated_headers: ["audio_policy_configuration_V7_1_enums"], + generated_sources: ["audio_policy_configuration_V7_1_enums"], + header_libs: ["libxsdc-utils"], + export_generated_headers: ["audio_policy_configuration_V7_1_enums"], + export_header_lib_headers: ["libxsdc-utils"], + export_include_dirs: ["enums/include"], + shared_libs: [ + "libbase", + "liblog", + ], +} diff --git a/audio/common/7.1/enums/OWNERS b/audio/common/7.1/enums/OWNERS new file mode 100644 index 0000000000..24071af220 --- /dev/null +++ b/audio/common/7.1/enums/OWNERS @@ -0,0 +1,2 @@ +elaurent@google.com +mnaganov@google.com diff --git a/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h b/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h new file mode 100644 index 0000000000..815f869e93 --- /dev/null +++ b/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2022 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. + */ + +#ifndef ANDROID_AUDIO_POLICY_CONFIGURATION_V7_1__ENUMS_H +#define ANDROID_AUDIO_POLICY_CONFIGURATION_V7_1__ENUMS_H + +#include +#include +#include + +#include + +namespace android::audio::policy::configuration::V7_1 { + +static inline size_t getChannelCount(AudioChannelMask mask) { + switch (mask) { + case AudioChannelMask::AUDIO_CHANNEL_NONE: + return 0; + case AudioChannelMask::AUDIO_CHANNEL_OUT_MONO: + case AudioChannelMask::AUDIO_CHANNEL_IN_MONO: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_1: + return 1; + case AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO: + case AudioChannelMask::AUDIO_CHANNEL_OUT_MONO_HAPTIC_A: + case AudioChannelMask::AUDIO_CHANNEL_OUT_HAPTIC_AB: + case AudioChannelMask::AUDIO_CHANNEL_IN_STEREO: + case AudioChannelMask::AUDIO_CHANNEL_IN_FRONT_BACK: + case AudioChannelMask::AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO: + case AudioChannelMask::AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO: + case AudioChannelMask::AUDIO_CHANNEL_IN_VOICE_CALL_MONO: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_2: + return 2; + case AudioChannelMask::AUDIO_CHANNEL_OUT_2POINT1: + case AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A: + case AudioChannelMask::AUDIO_CHANNEL_OUT_MONO_HAPTIC_AB: + case AudioChannelMask::AUDIO_CHANNEL_OUT_TRI: + case AudioChannelMask::AUDIO_CHANNEL_OUT_TRI_BACK: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_3: + return 3; + case AudioChannelMask::AUDIO_CHANNEL_OUT_2POINT0POINT2: + case AudioChannelMask::AUDIO_CHANNEL_OUT_3POINT1: + case AudioChannelMask::AUDIO_CHANNEL_OUT_QUAD: + case AudioChannelMask::AUDIO_CHANNEL_OUT_QUAD_BACK: + case AudioChannelMask::AUDIO_CHANNEL_OUT_QUAD_SIDE: + case AudioChannelMask::AUDIO_CHANNEL_OUT_SURROUND: + case AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO_HAPTIC_AB: + case AudioChannelMask::AUDIO_CHANNEL_IN_2POINT0POINT2: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_4: + return 4; + case AudioChannelMask::AUDIO_CHANNEL_OUT_2POINT1POINT2: + case AudioChannelMask::AUDIO_CHANNEL_OUT_3POINT0POINT2: + case AudioChannelMask::AUDIO_CHANNEL_OUT_PENTA: + case AudioChannelMask::AUDIO_CHANNEL_IN_2POINT1POINT2: + case AudioChannelMask::AUDIO_CHANNEL_IN_3POINT0POINT2: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_5: + return 5; + case AudioChannelMask::AUDIO_CHANNEL_OUT_3POINT1POINT2: + case AudioChannelMask::AUDIO_CHANNEL_OUT_5POINT1: + case AudioChannelMask::AUDIO_CHANNEL_OUT_5POINT1_BACK: + case AudioChannelMask::AUDIO_CHANNEL_OUT_5POINT1_SIDE: + case AudioChannelMask::AUDIO_CHANNEL_IN_6: + case AudioChannelMask::AUDIO_CHANNEL_IN_3POINT1POINT2: + case AudioChannelMask::AUDIO_CHANNEL_IN_5POINT1: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_6: + return 6; + case AudioChannelMask::AUDIO_CHANNEL_OUT_6POINT1: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_7: + return 7; + case AudioChannelMask::AUDIO_CHANNEL_OUT_5POINT1POINT2: + case AudioChannelMask::AUDIO_CHANNEL_OUT_7POINT1: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_8: + return 8; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_9: + return 9; + case AudioChannelMask::AUDIO_CHANNEL_OUT_5POINT1POINT4: + case AudioChannelMask::AUDIO_CHANNEL_OUT_7POINT1POINT2: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_10: + return 10; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_11: + return 11; + case AudioChannelMask::AUDIO_CHANNEL_OUT_7POINT1POINT4: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_12: + return 12; + case AudioChannelMask::AUDIO_CHANNEL_OUT_13POINT_360RA: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_13: + return 13; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_14: + return 14; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_15: + return 15; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_16: + return 16; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_17: + return 17; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_18: + return 18; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_19: + return 19; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_20: + return 20; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_21: + return 21; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_22: + return 22; + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_23: + return 23; + case AudioChannelMask::AUDIO_CHANNEL_OUT_22POINT2: + case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_24: + return 24; + case AudioChannelMask::UNKNOWN: + return 0; + // No default to make sure all cases are covered. + } + // This is to avoid undefined behavior if 'mask' isn't a valid enum value. + return 0; +} + +static inline ssize_t getChannelCount(const std::string& mask) { + return getChannelCount(stringToAudioChannelMask(mask)); +} + +static inline bool isOutputDevice(AudioDevice device) { + switch (device) { + case AudioDevice::UNKNOWN: + case AudioDevice::AUDIO_DEVICE_NONE: + return false; + case AudioDevice::AUDIO_DEVICE_OUT_EARPIECE: + case AudioDevice::AUDIO_DEVICE_OUT_SPEAKER: + case AudioDevice::AUDIO_DEVICE_OUT_WIRED_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_WIRED_HEADPHONE: + case AudioDevice::AUDIO_DEVICE_OUT_BLUETOOTH_SCO: + case AudioDevice::AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT: + case AudioDevice::AUDIO_DEVICE_OUT_BLUETOOTH_A2DP: + case AudioDevice::AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: + case AudioDevice::AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER: + case AudioDevice::AUDIO_DEVICE_OUT_AUX_DIGITAL: + case AudioDevice::AUDIO_DEVICE_OUT_HDMI: + case AudioDevice::AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_USB_ACCESSORY: + case AudioDevice::AUDIO_DEVICE_OUT_USB_DEVICE: + case AudioDevice::AUDIO_DEVICE_OUT_REMOTE_SUBMIX: + case AudioDevice::AUDIO_DEVICE_OUT_TELEPHONY_TX: + case AudioDevice::AUDIO_DEVICE_OUT_LINE: + case AudioDevice::AUDIO_DEVICE_OUT_HDMI_ARC: + case AudioDevice::AUDIO_DEVICE_OUT_HDMI_EARC: + case AudioDevice::AUDIO_DEVICE_OUT_SPDIF: + case AudioDevice::AUDIO_DEVICE_OUT_FM: + case AudioDevice::AUDIO_DEVICE_OUT_AUX_LINE: + case AudioDevice::AUDIO_DEVICE_OUT_SPEAKER_SAFE: + case AudioDevice::AUDIO_DEVICE_OUT_IP: + case AudioDevice::AUDIO_DEVICE_OUT_BUS: + case AudioDevice::AUDIO_DEVICE_OUT_PROXY: + case AudioDevice::AUDIO_DEVICE_OUT_USB_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_HEARING_AID: + case AudioDevice::AUDIO_DEVICE_OUT_ECHO_CANCELLER: + case AudioDevice::AUDIO_DEVICE_OUT_BLE_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_BLE_SPEAKER: + case AudioDevice::AUDIO_DEVICE_OUT_DEFAULT: + case AudioDevice::AUDIO_DEVICE_OUT_STUB: + return true; + case AudioDevice::AUDIO_DEVICE_IN_COMMUNICATION: + case AudioDevice::AUDIO_DEVICE_IN_AMBIENT: + case AudioDevice::AUDIO_DEVICE_IN_BUILTIN_MIC: + case AudioDevice::AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET: + case AudioDevice::AUDIO_DEVICE_IN_WIRED_HEADSET: + case AudioDevice::AUDIO_DEVICE_IN_AUX_DIGITAL: + case AudioDevice::AUDIO_DEVICE_IN_HDMI: + case AudioDevice::AUDIO_DEVICE_IN_VOICE_CALL: + case AudioDevice::AUDIO_DEVICE_IN_TELEPHONY_RX: + case AudioDevice::AUDIO_DEVICE_IN_BACK_MIC: + case AudioDevice::AUDIO_DEVICE_IN_REMOTE_SUBMIX: + case AudioDevice::AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET: + case AudioDevice::AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET: + case AudioDevice::AUDIO_DEVICE_IN_USB_ACCESSORY: + case AudioDevice::AUDIO_DEVICE_IN_USB_DEVICE: + case AudioDevice::AUDIO_DEVICE_IN_FM_TUNER: + case AudioDevice::AUDIO_DEVICE_IN_TV_TUNER: + case AudioDevice::AUDIO_DEVICE_IN_LINE: + case AudioDevice::AUDIO_DEVICE_IN_SPDIF: + case AudioDevice::AUDIO_DEVICE_IN_BLUETOOTH_A2DP: + case AudioDevice::AUDIO_DEVICE_IN_LOOPBACK: + case AudioDevice::AUDIO_DEVICE_IN_IP: + case AudioDevice::AUDIO_DEVICE_IN_BUS: + case AudioDevice::AUDIO_DEVICE_IN_PROXY: + case AudioDevice::AUDIO_DEVICE_IN_USB_HEADSET: + case AudioDevice::AUDIO_DEVICE_IN_BLUETOOTH_BLE: + case AudioDevice::AUDIO_DEVICE_IN_HDMI_ARC: + case AudioDevice::AUDIO_DEVICE_IN_HDMI_EARC: + case AudioDevice::AUDIO_DEVICE_IN_ECHO_REFERENCE: + case AudioDevice::AUDIO_DEVICE_IN_BLE_HEADSET: + case AudioDevice::AUDIO_DEVICE_IN_DEFAULT: + case AudioDevice::AUDIO_DEVICE_IN_STUB: + return false; + // No default to make sure all cases are covered. + } + // This is to avoid undefined behavior if 'device' isn't a valid enum value. + return false; +} + +static inline bool isOutputDevice(const std::string& device) { + return isOutputDevice(stringToAudioDevice(device)); +} + +static inline bool isTelephonyDevice(AudioDevice device) { + return device == AudioDevice::AUDIO_DEVICE_OUT_TELEPHONY_TX || + device == AudioDevice::AUDIO_DEVICE_IN_TELEPHONY_RX; +} + +static inline bool isTelephonyDevice(const std::string& device) { + return isTelephonyDevice(stringToAudioDevice(device)); +} + +static inline bool maybeVendorExtension(const std::string& s) { + // Only checks whether the string starts with the "vendor prefix". + static const std::string vendorPrefix = "VX_"; + return s.size() > vendorPrefix.size() && s.substr(0, vendorPrefix.size()) == vendorPrefix; +} + +static inline bool isVendorExtension(const std::string& s) { + // Must be the same as the "vendorExtension" rule from the XSD file. + static const std::regex vendorExtension("VX_[A-Z0-9]{3,}_[_A-Z0-9]+"); + return std::regex_match(s.begin(), s.end(), vendorExtension); +} + +static inline bool isUnknownAudioChannelMask(const std::string& mask) { + return stringToAudioChannelMask(mask) == AudioChannelMask::UNKNOWN; +} + +static inline bool isUnknownAudioContentType(const std::string& contentType) { + return stringToAudioContentType(contentType) == AudioContentType::UNKNOWN; +} + +static inline bool isUnknownAudioDevice(const std::string& device) { + return stringToAudioDevice(device) == AudioDevice::UNKNOWN && !isVendorExtension(device); +} + +static inline bool isUnknownAudioFormat(const std::string& format) { + return stringToAudioFormat(format) == AudioFormat::UNKNOWN && !isVendorExtension(format); +} + +static inline bool isUnknownAudioGainMode(const std::string& mode) { + return stringToAudioGainMode(mode) == AudioGainMode::UNKNOWN; +} + +static inline bool isUnknownAudioInOutFlag(const std::string& flag) { + return stringToAudioInOutFlag(flag) == AudioInOutFlag::UNKNOWN; +} + +static inline bool isUnknownAudioSource(const std::string& source) { + return stringToAudioSource(source) == AudioSource::UNKNOWN; +} + +static inline bool isUnknownAudioStreamType(const std::string& streamType) { + return stringToAudioStreamType(streamType) == AudioStreamType::UNKNOWN; +} + +static inline bool isUnknownAudioUsage(const std::string& usage) { + return stringToAudioUsage(usage) == AudioUsage::UNKNOWN; +} + +static inline bool isLinearPcm(AudioFormat format) { + switch (format) { + case AudioFormat::AUDIO_FORMAT_PCM_16_BIT: + case AudioFormat::AUDIO_FORMAT_PCM_8_BIT: + case AudioFormat::AUDIO_FORMAT_PCM_32_BIT: + case AudioFormat::AUDIO_FORMAT_PCM_8_24_BIT: + case AudioFormat::AUDIO_FORMAT_PCM_FLOAT: + case AudioFormat::AUDIO_FORMAT_PCM_24_BIT_PACKED: + return true; + default: + return false; + } +} + +static inline bool isLinearPcm(const std::string& format) { + return isLinearPcm(stringToAudioFormat(format)); +} + +static inline bool isUnknownAudioEncapsulationType(const std::string& encapsulationType) { + return stringToAudioEncapsulationType(encapsulationType) == AudioEncapsulationType::UNKNOWN; +} + +} // namespace android::audio::policy::configuration::V7_1 + +#endif // ANDROID_AUDIO_POLICY_CONFIGURATION_V7_1__ENUMS_H diff --git a/audio/common/all-versions/default/7.0/HidlUtils.cpp b/audio/common/all-versions/default/7.0/HidlUtils.cpp index 5a5b5d276a..218d7c06b7 100644 --- a/audio/common/all-versions/default/7.0/HidlUtils.cpp +++ b/audio/common/all-versions/default/7.0/HidlUtils.cpp @@ -21,7 +21,7 @@ #define LOG_TAG "HidlUtils" #include -#include +#include PATH(APM_XSD_ENUMS_H_FILENAME) #include #include @@ -31,11 +31,11 @@ namespace android { namespace hardware { namespace audio { namespace common { -namespace CPP_VERSION { +namespace COMMON_TYPES_CPP_VERSION { namespace implementation { namespace xsd { -using namespace ::android::audio::policy::configuration::V7_0; +using namespace ::android::audio::policy::configuration::CPP_VERSION; } #define CONVERT_CHECKED(expr, result) \ @@ -1151,7 +1151,7 @@ status_t HidlUtils::deviceAddressToHal(const DeviceAddress& device, audio_device } } // namespace implementation -} // namespace CPP_VERSION +} // namespace COMMON_TYPES_CPP_VERSION } // namespace common } // namespace audio } // namespace hardware diff --git a/audio/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h index 98ecc0754e..ad9dee22c1 100644 --- a/audio/common/all-versions/default/HidlUtils.h +++ b/audio/common/all-versions/default/HidlUtils.h @@ -17,7 +17,9 @@ #ifndef android_hardware_audio_Hidl_Utils_H_ #define android_hardware_audio_Hidl_Utils_H_ -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +// clang-format off +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) +// clang-format on #include #include @@ -29,11 +31,11 @@ namespace android { namespace hardware { namespace audio { namespace common { -namespace CPP_VERSION { +namespace COMMON_TYPES_CPP_VERSION { namespace implementation { using ::android::hardware::hidl_vec; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; struct HidlUtils { static status_t audioConfigFromHal(const audio_config_t& halConfig, bool isInput, @@ -267,7 +269,7 @@ status_t HidlUtils::deviceAddressFromHalImpl(audio_devices_t halDeviceType, #endif // MAJOR_VERSION <= 6 } // namespace implementation -} // namespace CPP_VERSION +} // namespace COMMON_TYPES_CPP_VERSION } // namespace common } // namespace audio } // namespace hardware diff --git a/audio/common/all-versions/default/UuidUtils.h b/audio/common/all-versions/default/UuidUtils.h index cd04fb039a..4a64f0a570 100644 --- a/audio/common/all-versions/default/UuidUtils.h +++ b/audio/common/all-versions/default/UuidUtils.h @@ -20,7 +20,7 @@ #include // clang-format off -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on #include @@ -32,7 +32,7 @@ namespace common { namespace CPP_VERSION { namespace implementation { -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; class UuidUtils { public: diff --git a/audio/common/all-versions/default/VersionUtils.h b/audio/common/all-versions/default/VersionUtils.h index 9bfca0cdcc..9771374c33 100644 --- a/audio/common/all-versions/default/VersionUtils.h +++ b/audio/common/all-versions/default/VersionUtils.h @@ -17,7 +17,30 @@ #ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H #define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +// A workaround for b/216149583 (vendor code having its own copy of VersionMacro.h) +#ifndef COMMON_TYPES_MINOR_VERSION +#define COMMON_TYPES_MINOR_VERSION MINOR_VERSION +#endif +#ifndef CORE_TYPES_MINOR_VERSION +#define CORE_TYPES_MINOR_VERSION MINOR_VERSION +#endif +#ifndef COMMON_TYPES_FILE_VERSION +#define COMMON_TYPES_FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., COMMON_TYPES_MINOR_VERSION) +#endif +#ifndef CORE_TYPES_FILE_VERSION +#define CORE_TYPES_FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., CORE_TYPES_MINOR_VERSION) +#endif +#ifndef COMMON_TYPES_CPP_VERSION +#define COMMON_TYPES_CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, COMMON_TYPES_MINOR_VERSION) +#endif +#ifndef CORE_TYPES_CPP_VERSION +#define CORE_TYPES_CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, CORE_TYPES_MINOR_VERSION) +#endif +// End of workaround + +// clang-format off +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) +// clang-format on namespace android { namespace hardware { diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp index 89585b0620..e26369fd70 100644 --- a/audio/common/all-versions/default/service/service.cpp +++ b/audio/common/all-versions/default/service/service.cpp @@ -66,6 +66,7 @@ int main(int /* argc */, char* /* argv */ []) { const std::vector mandatoryInterfaces = { { "Audio Core API", + "android.hardware.audio@7.1::IDevicesFactory", "android.hardware.audio@7.0::IDevicesFactory", "android.hardware.audio@6.0::IDevicesFactory", "android.hardware.audio@5.0::IDevicesFactory", diff --git a/audio/common/all-versions/default/tests/hidlutils6_tests.cpp b/audio/common/all-versions/default/tests/hidlutils6_tests.cpp index 3a24e752bc..ca59b9de6c 100644 --- a/audio/common/all-versions/default/tests/hidlutils6_tests.cpp +++ b/audio/common/all-versions/default/tests/hidlutils6_tests.cpp @@ -23,14 +23,14 @@ #include using namespace android; -using namespace ::android::hardware::audio::common::CPP_VERSION; -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; // Not generated automatically because DeviceAddress contains // an union. // // operator== must be defined in the same namespace as the data type. -namespace android::hardware::audio::common::CPP_VERSION { +namespace android::hardware::audio::common::COMMON_TYPES_CPP_VERSION { inline bool operator==(const DeviceAddress& lhs, const DeviceAddress& rhs) { if (lhs.device != rhs.device) return false; @@ -49,7 +49,7 @@ inline bool operator==(const DeviceAddress& lhs, const DeviceAddress& rhs) { return lhs.busAddress == rhs.busAddress; } -} // namespace android::hardware::audio::common::CPP_VERSION +} // namespace android::hardware::audio::common::COMMON_TYPES_CPP_VERSION static void ConvertDeviceAddress(const DeviceAddress& device) { audio_devices_t halDeviceType; diff --git a/audio/common/all-versions/default/tests/hidlutils_tests.cpp b/audio/common/all-versions/default/tests/hidlutils_tests.cpp index c9e6fac7b2..2749cce748 100644 --- a/audio/common/all-versions/default/tests/hidlutils_tests.cpp +++ b/audio/common/all-versions/default/tests/hidlutils_tests.cpp @@ -29,8 +29,8 @@ using namespace android; using ::android::hardware::hidl_vec; -using namespace ::android::hardware::audio::common::CPP_VERSION; -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; namespace xsd { using namespace ::android::audio::policy::configuration::V7_0; } diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h b/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h index dc54cee206..875e167f38 100644 --- a/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h +++ b/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h @@ -21,6 +21,14 @@ #error "MAJOR_VERSION and MINOR_VERSION must be defined" #endif +#ifndef COMMON_TYPES_MINOR_VERSION +#define COMMON_TYPES_MINOR_VERSION MINOR_VERSION +#endif + +#ifndef CORE_TYPES_MINOR_VERSION +#define CORE_TYPES_MINOR_VERSION MINOR_VERSION +#endif + /** Allows macro expansion for x and add surrounding `<>`. * Is intended to be used for version dependant includes as * `#include` do not macro expand if starting with < or " @@ -34,10 +42,30 @@ #define EXPAND_CONCAT_3(a, b, c) CONCAT_3(a, b, c) /** The directory name of the version: . */ #define FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., MINOR_VERSION) +#define COMMON_TYPES_FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., COMMON_TYPES_MINOR_VERSION) +#define CORE_TYPES_FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., CORE_TYPES_MINOR_VERSION) #define CONCAT_4(a, b, c, d) a##b##c##d #define EXPAND_CONCAT_4(a, b, c, d) CONCAT_4(a, b, c, d) /** The c++ namespace of the version: V_ */ #define CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, MINOR_VERSION) +#define COMMON_TYPES_CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, COMMON_TYPES_MINOR_VERSION) +#define CORE_TYPES_CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, CORE_TYPES_MINOR_VERSION) + +/* Gluing these file names from macros is non-trivial due to "illegal tokens" + occurring during expansion. The XSD and enums always use the minor version. */ +// clang-format off +#if MAJOR_VERSION >= 7 +#if MINOR_VERSION == 0 +#define APM_XSD_H_FILENAME android_audio_policy_configuration_V7_0.h +#define APM_XSD_ENUMS_H_FILENAME android_audio_policy_configuration_V7_0-enums.h +#elif MINOR_VERSION == 1 +#define APM_XSD_H_FILENAME android_audio_policy_configuration_V7_1.h +#define APM_XSD_ENUMS_H_FILENAME android_audio_policy_configuration_V7_1-enums.h +#else +#error "Unsupported minor version" +#endif +#endif +// clang-format on #endif // ANDROID_HARDWARE_VERSION_MACRO_H diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp index 6a0d0a08cd..df688fd909 100644 --- a/audio/core/all-versions/default/Android.bp +++ b/audio/core/all-versions/default/Android.bp @@ -161,3 +161,29 @@ cc_library_shared { name: "android.hardware.audio@7.0-impl", defaults: ["android.hardware.audio@7.0-impl_default"], } + +cc_defaults { + name: "android.hardware.audio@7.1-impl_default", + defaults: ["android.hardware.audio-impl_default"], + shared_libs: [ + "android.hardware.audio@7.0", + "android.hardware.audio@7.1", + "android.hardware.audio@7.0-util", + "android.hardware.audio.common@7.0", + "android.hardware.audio.common@7.1-enums", + "android.hardware.audio.common@7.0-util", + "libbase", + ], + cflags: [ + "-DMAJOR_VERSION=7", + "-DMINOR_VERSION=1", + "-DCOMMON_TYPES_MINOR_VERSION=0", + "-DCORE_TYPES_MINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ], +} + +cc_library_shared { + name: "android.hardware.audio@7.1-impl", + defaults: ["android.hardware.audio@7.1-impl_default"], +} diff --git a/audio/core/all-versions/default/Device.cpp b/audio/core/all-versions/default/Device.cpp index c33e6f30fa..ac5a3ba8ef 100644 --- a/audio/core/all-versions/default/Device.cpp +++ b/audio/core/all-versions/default/Device.cpp @@ -41,7 +41,10 @@ namespace audio { namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; +namespace util { +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::util; +} Device::Device(audio_hw_device_t* device) : mIsClosed(false), mDevice(device) {} @@ -84,7 +87,7 @@ Return Device::setMasterVolume(float volume) { if (mDevice->set_master_volume == NULL) { return Result::NOT_SUPPORTED; } - if (!isGainNormalized(volume)) { + if (!util::isGainNormalized(volume)) { ALOGW("Can not set a master volume (%f) outside [0,1]", volume); return Result::INVALID_ARGUMENTS; } @@ -150,7 +153,7 @@ Return Device::getInputBufferSize(const AudioConfig& config, getInputBuffe return Void(); } -std::tuple> Device::openOutputStreamImpl(int32_t ioHandle, +std::tuple> Device::openOutputStreamCore(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, const AudioOutputFlags& flags, @@ -187,7 +190,7 @@ std::tuple> Device::openOutputStreamImpl(int32_t ioHandle return {analyzeStatus("open_output_stream", status, {EINVAL} /*ignore*/), streamOut}; } -std::tuple> Device::openInputStreamImpl( +std::tuple> Device::openInputStreamCore( int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, const AudioInputFlags& flags, AudioSource source, AudioConfig* suggestedConfig) { audio_config_t halConfig; @@ -230,7 +233,7 @@ Return Device::openOutputStream(int32_t ioHandle, const DeviceAddress& dev openOutputStream_cb _hidl_cb) { AudioConfig suggestedConfig; auto [result, streamOut] = - openOutputStreamImpl(ioHandle, device, config, flags, &suggestedConfig); + openOutputStreamCore(ioHandle, device, config, flags, &suggestedConfig); _hidl_cb(result, streamOut, suggestedConfig); return Void(); } @@ -240,12 +243,36 @@ Return Device::openInputStream(int32_t ioHandle, const DeviceAddress& devi AudioSource source, openInputStream_cb _hidl_cb) { AudioConfig suggestedConfig; auto [result, streamIn] = - openInputStreamImpl(ioHandle, device, config, flags, source, &suggestedConfig); + openInputStreamCore(ioHandle, device, config, flags, source, &suggestedConfig); _hidl_cb(result, streamIn, suggestedConfig); return Void(); } #elif MAJOR_VERSION >= 4 +std::tuple, AudioConfig> Device::openOutputStreamImpl( + int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, + const SourceMetadata& sourceMetadata, +#if MAJOR_VERSION <= 6 + AudioOutputFlags flags) { + if (status_t status = CoreUtils::sourceMetadataToHal(sourceMetadata, nullptr); + status != NO_ERROR) { +#else + const AudioOutputFlags& flags) { + if (status_t status = CoreUtils::sourceMetadataToHalV7(sourceMetadata, + false /*ignoreNonVendorTags*/, nullptr); + status != NO_ERROR) { +#endif + return {analyzeStatus("sourceMetadataToHal", status), nullptr, {}}; + } + AudioConfig suggestedConfig; + auto [result, streamOut] = + openOutputStreamCore(ioHandle, device, config, flags, &suggestedConfig); + if (streamOut) { + streamOut->updateSourceMetadata(sourceMetadata); + } + return {result, streamOut, suggestedConfig}; +} + Return Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, #if MAJOR_VERSION <= 6 @@ -255,27 +282,46 @@ Return Device::openOutputStream(int32_t ioHandle, const DeviceAddress& dev #endif const SourceMetadata& sourceMetadata, openOutputStream_cb _hidl_cb) { -#if MAJOR_VERSION <= 6 - if (status_t status = CoreUtils::sourceMetadataToHal(sourceMetadata, nullptr); - status != NO_ERROR) { -#else - if (status_t status = CoreUtils::sourceMetadataToHalV7(sourceMetadata, - false /*ignoreNonVendorTags*/, nullptr); - status != NO_ERROR) { -#endif - _hidl_cb(analyzeStatus("sourceMetadataToHal", status), nullptr, AudioConfig{}); - return Void(); - } - AudioConfig suggestedConfig; - auto [result, streamOut] = - openOutputStreamImpl(ioHandle, device, config, flags, &suggestedConfig); - if (streamOut) { - streamOut->updateSourceMetadata(sourceMetadata); - } + auto [result, streamOut, suggestedConfig] = + openOutputStreamImpl(ioHandle, device, config, sourceMetadata, flags); _hidl_cb(result, streamOut, suggestedConfig); return Void(); } +std::tuple, AudioConfig> Device::openInputStreamImpl( + int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, +#if MAJOR_VERSION <= 6 + AudioInputFlags flags, +#else + const AudioInputFlags& flags, +#endif + const SinkMetadata& sinkMetadata) { + if (sinkMetadata.tracks.size() == 0) { + // This should never happen, the framework must not create as stream + // if there is no client + ALOGE("openInputStream called without tracks connected"); + return {Result::INVALID_ARGUMENTS, nullptr, AudioConfig{}}; + } +#if MAJOR_VERSION <= 6 + if (status_t status = CoreUtils::sinkMetadataToHal(sinkMetadata, nullptr); status != NO_ERROR) { +#else + if (status_t status = CoreUtils::sinkMetadataToHalV7(sinkMetadata, + false /*ignoreNonVendorTags*/, nullptr); + status != NO_ERROR) { +#endif + return {analyzeStatus("sinkMetadataToHal", status), nullptr, AudioConfig{}}; + } + // Pick the first one as the main. + AudioSource source = sinkMetadata.tracks[0].source; + AudioConfig suggestedConfig; + auto [result, streamIn] = + openInputStreamCore(ioHandle, device, config, flags, source, &suggestedConfig); + if (streamIn) { + streamIn->updateSinkMetadata(sinkMetadata); + } + return {result, streamIn, suggestedConfig}; +} + Return Device::openInputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, #if MAJOR_VERSION <= 6 @@ -285,36 +331,35 @@ Return Device::openInputStream(int32_t ioHandle, const DeviceAddress& devi #endif const SinkMetadata& sinkMetadata, openInputStream_cb _hidl_cb) { - if (sinkMetadata.tracks.size() == 0) { - // This should never happen, the framework must not create as stream - // if there is no client - ALOGE("openInputStream called without tracks connected"); - _hidl_cb(Result::INVALID_ARGUMENTS, nullptr, AudioConfig{}); - return Void(); - } -#if MAJOR_VERSION <= 6 - if (status_t status = CoreUtils::sinkMetadataToHal(sinkMetadata, nullptr); status != NO_ERROR) { -#else - if (status_t status = CoreUtils::sinkMetadataToHalV7(sinkMetadata, - false /*ignoreNonVendorTags*/, nullptr); - status != NO_ERROR) { -#endif - _hidl_cb(analyzeStatus("sinkMetadataToHal", status), nullptr, AudioConfig{}); - return Void(); - } - // Pick the first one as the main. - AudioSource source = sinkMetadata.tracks[0].source; - AudioConfig suggestedConfig; - auto [result, streamIn] = - openInputStreamImpl(ioHandle, device, config, flags, source, &suggestedConfig); - if (streamIn) { - streamIn->updateSinkMetadata(sinkMetadata); - } + auto [result, streamIn, suggestedConfig] = + openInputStreamImpl(ioHandle, device, config, flags, sinkMetadata); _hidl_cb(result, streamIn, suggestedConfig); return Void(); } #endif /* MAJOR_VERSION */ +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 +Return Device::openOutputStream_7_1(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, const AudioOutputFlags& flags, + const SourceMetadata& sourceMetadata, + openOutputStream_7_1_cb _hidl_cb) { + auto [result, streamOut, suggestedConfig] = + openOutputStreamImpl(ioHandle, device, config, sourceMetadata, flags); + _hidl_cb(result, streamOut, suggestedConfig); + return Void(); +} + +Return Device::openInputStream_7_1(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, const AudioInputFlags& flags, + const SinkMetadata& sinkMetadata, + openInputStream_7_1_cb _hidl_cb) { + auto [result, streamIn, suggestedConfig] = + openInputStreamImpl(ioHandle, device, config, flags, sinkMetadata); + _hidl_cb(result, streamIn, suggestedConfig); + return Void(); +} +#endif // V7.1 + Return Device::supportsAudioPatches() { return version() >= AUDIO_DEVICE_API_VERSION_3_0; } diff --git a/audio/core/all-versions/default/DevicesFactory.cpp b/audio/core/all-versions/default/DevicesFactory.cpp index 729f18cf91..f44daf0b0e 100644 --- a/audio/core/all-versions/default/DevicesFactory.cpp +++ b/audio/core/all-versions/default/DevicesFactory.cpp @@ -47,22 +47,54 @@ Return DevicesFactory::openDevice(IDevicesFactory::Device device, openDevi _hidl_cb(Result::INVALID_ARGUMENTS, nullptr); return Void(); } + +Return DevicesFactory::openDevice(const char* moduleName, openDevice_cb _hidl_cb) { + return openDevice(moduleName, _hidl_cb); +} #elif MAJOR_VERSION >= 4 Return DevicesFactory::openDevice(const hidl_string& moduleName, openDevice_cb _hidl_cb) { if (moduleName == AUDIO_HARDWARE_MODULE_ID_PRIMARY) { return openDevice(moduleName.c_str(), _hidl_cb); } - return openDevice(moduleName.c_str(), _hidl_cb); + return openDevice(moduleName.c_str(), _hidl_cb); } Return DevicesFactory::openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) { return openDevice(AUDIO_HARDWARE_MODULE_ID_PRIMARY, _hidl_cb); } #endif -Return DevicesFactory::openDevice(const char* moduleName, openDevice_cb _hidl_cb) { - return openDevice(moduleName, _hidl_cb); +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 +Return DevicesFactory::openDevice_7_1(const hidl_string& moduleName, + openDevice_7_1_cb _hidl_cb) { + if (moduleName == AUDIO_HARDWARE_MODULE_ID_PRIMARY) { + Result result; + sp primary; + auto ret = openDevice( + AUDIO_HARDWARE_MODULE_ID_PRIMARY, + [&result, &primary](Result r, const sp& p) { + result = r; + primary = p; + }); + if (ret.isOk() && result == Result::OK && primary != nullptr) { + auto getDeviceRet = primary->getDevice(); + if (getDeviceRet.isOk()) { + _hidl_cb(result, getDeviceRet); + } else { + _hidl_cb(Result::NOT_INITIALIZED, nullptr); + } + } else { + _hidl_cb(result, nullptr); + } + return Void(); + } + return openDevice(moduleName.c_str(), _hidl_cb); } +Return DevicesFactory::openPrimaryDevice_7_1(openPrimaryDevice_7_1_cb _hidl_cb) { + return openDevice(AUDIO_HARDWARE_MODULE_ID_PRIMARY, _hidl_cb); +} +#endif // V7.1 + template Return DevicesFactory::openDevice(const char* moduleName, Callback _hidl_cb) { audio_hw_device_t* halDevice; diff --git a/audio/core/all-versions/default/ParametersUtil.cpp b/audio/core/all-versions/default/ParametersUtil.cpp index 4d536455d4..e21eff2845 100644 --- a/audio/core/all-versions/default/ParametersUtil.cpp +++ b/audio/core/all-versions/default/ParametersUtil.cpp @@ -24,7 +24,7 @@ namespace android { namespace hardware { namespace audio { -namespace CPP_VERSION { +namespace CORE_TYPES_CPP_VERSION { namespace implementation { /** Converts a status_t in Result according to the rules of AudioParameter::get* @@ -168,7 +168,7 @@ Result ParametersUtil::setParams(const AudioParameter& param) { } } // namespace implementation -} // namespace CPP_VERSION +} // namespace CORE_TYPES_CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/PrimaryDevice.cpp b/audio/core/all-versions/default/PrimaryDevice.cpp index fe56177975..cf162f1463 100644 --- a/audio/core/all-versions/default/PrimaryDevice.cpp +++ b/audio/core/all-versions/default/PrimaryDevice.cpp @@ -29,6 +29,10 @@ namespace audio { namespace CPP_VERSION { namespace implementation { +namespace util { +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::util; +} + PrimaryDevice::PrimaryDevice(audio_hw_device_t* device) : mDevice(new Device(device)) {} PrimaryDevice::~PrimaryDevice() { @@ -195,7 +199,7 @@ Return PrimaryDevice::updateAudioPatch(int32_t previousPatch, // Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow. Return PrimaryDevice::setVoiceVolume(float volume) { - if (!isGainNormalized(volume)) { + if (!util::isGainNormalized(volume)) { ALOGW("Can not set a voice volume (%f) outside [0,1]", volume); return Result::INVALID_ARGUMENTS; } @@ -326,7 +330,7 @@ Return PrimaryDevice::setBtHfpSampleRate(uint32_t sampleRateHz) { return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE, int(sampleRateHz)); } Return PrimaryDevice::setBtHfpVolume(float volume) { - if (!isGainNormalized(volume)) { + if (!util::isGainNormalized(volume)) { ALOGW("Can not set BT HFP volume (%f) outside [0,1]", volume); return Result::INVALID_ARGUMENTS; } diff --git a/audio/core/all-versions/default/Stream.cpp b/audio/core/all-versions/default/Stream.cpp index 7e3257399c..8e85a8b255 100644 --- a/audio/core/all-versions/default/Stream.cpp +++ b/audio/core/all-versions/default/Stream.cpp @@ -37,8 +37,12 @@ namespace audio { namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; using ::android::hardware::audio::common::utils::splitString; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::CoreUtils; +namespace util { +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::util; +} Stream::Stream(bool isInput, audio_stream_t* stream) : mIsInput(isInput), mStream(stream) { (void)mIsInput; // prevent 'unused field' warnings in pre-V7 versions. diff --git a/audio/core/all-versions/default/StreamIn.cpp b/audio/core/all-versions/default/StreamIn.cpp index 2aeee43c59..2bea425f26 100644 --- a/audio/core/all-versions/default/StreamIn.cpp +++ b/audio/core/all-versions/default/StreamIn.cpp @@ -37,7 +37,11 @@ namespace audio { namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::CoreUtils; +namespace util { +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::util; +} namespace { @@ -348,7 +352,7 @@ Return StreamIn::getAudioSource(getAudioSource_cb _hidl_cb) { } Return StreamIn::setGain(float gain) { - if (!isGainNormalized(gain)) { + if (!util::isGainNormalized(gain)) { ALOGW("Can not set a stream input gain (%f) outside [0,1]", gain); return Result::INVALID_ARGUMENTS; } diff --git a/audio/core/all-versions/default/StreamOut.cpp b/audio/core/all-versions/default/StreamOut.cpp index d027231f11..d4a89d7bf9 100644 --- a/audio/core/all-versions/default/StreamOut.cpp +++ b/audio/core/all-versions/default/StreamOut.cpp @@ -39,7 +39,11 @@ namespace audio { namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::CoreUtils; +namespace util { +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::util; +} namespace { @@ -334,7 +338,7 @@ Return StreamOut::setVolume(float left, float right) { if (mStream->set_volume == NULL) { return Result::NOT_SUPPORTED; } - if (!isGainNormalized(left)) { + if (!util::isGainNormalized(left)) { ALOGW("Can not set a stream output volume {%f, %f} outside [0,1]", left, right); return Result::INVALID_ARGUMENTS; } diff --git a/audio/core/all-versions/default/include/core/default/Device.h b/audio/core/all-versions/default/include/core/default/Device.h index 94cad53581..0aeb6b32cb 100644 --- a/audio/core/all-versions/default/include/core/default/Device.h +++ b/audio/core/all-versions/default/include/core/default/Device.h @@ -44,7 +44,10 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::CoreUtils; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::ParametersUtil; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; using AudioInputFlags = CoreUtils::AudioInputFlags; using AudioOutputFlags = CoreUtils::AudioOutputFlags; @@ -63,14 +66,32 @@ struct Device : public IDevice, public ParametersUtil { Return getInputBufferSize(const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override; - std::tuple> openOutputStreamImpl(int32_t ioHandle, + std::tuple> openOutputStreamCore(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, const AudioOutputFlags& flags, AudioConfig* suggestedConfig); - std::tuple> openInputStreamImpl( + std::tuple> openInputStreamCore( int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, const AudioInputFlags& flags, AudioSource source, AudioConfig* suggestedConfig); +#if MAJOR_VERSION >= 4 + std::tuple, AudioConfig> openOutputStreamImpl( + int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, + const SourceMetadata& sourceMetadata, +#if MAJOR_VERSION <= 6 + AudioOutputFlags flags); +#else + const AudioOutputFlags& flags); +#endif + std::tuple, AudioConfig> openInputStreamImpl( + int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, +#if MAJOR_VERSION <= 6 + AudioInputFlags flags, +#else + const AudioInputFlags& flags, +#endif + const SinkMetadata& sinkMetadata); +#endif // MAJOR_VERSION >= 4 Return openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, @@ -97,6 +118,17 @@ struct Device : public IDevice, public ParametersUtil { #endif openInputStream_cb _hidl_cb) override; +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 + Return openOutputStream_7_1(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, const AudioOutputFlags& flags, + const SourceMetadata& sourceMetadata, + openOutputStream_7_1_cb _hidl_cb) override; + Return openInputStream_7_1(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, const AudioInputFlags& flags, + const SinkMetadata& sinkMetadata, + openInputStream_7_1_cb _hidl_cb) override; +#endif + Return supportsAudioPatches() override; Return createAudioPatch(const hidl_vec& sources, const hidl_vec& sinks, diff --git a/audio/core/all-versions/default/include/core/default/DevicesFactory.h b/audio/core/all-versions/default/include/core/default/DevicesFactory.h index 9f93a38a0e..566bc8ad79 100644 --- a/audio/core/all-versions/default/include/core/default/DevicesFactory.h +++ b/audio/core/all-versions/default/include/core/default/DevicesFactory.h @@ -44,11 +44,17 @@ struct DevicesFactory : public IDevicesFactory { Return openDevice(const hidl_string& device, openDevice_cb _hidl_cb) override; Return openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override; #endif +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 + Return openDevice_7_1(const hidl_string& device, openDevice_7_1_cb _hidl_cb) override; + Return openPrimaryDevice_7_1(openPrimaryDevice_7_1_cb _hidl_cb) override; +#endif - private: + private: template Return openDevice(const char* moduleName, Callback _hidl_cb); +#if MAJOR_VERSION == 2 Return openDevice(const char* moduleName, openDevice_cb _hidl_cb); +#endif static int loadAudioInterface(const char* if_name, audio_hw_device_t** dev); }; diff --git a/audio/core/all-versions/default/include/core/default/ParametersUtil.h b/audio/core/all-versions/default/include/core/default/ParametersUtil.h index 45d9b2140d..25c193aedd 100644 --- a/audio/core/all-versions/default/include/core/default/ParametersUtil.h +++ b/audio/core/all-versions/default/include/core/default/ParametersUtil.h @@ -17,7 +17,10 @@ #ifndef ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_ #define ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_ -#include PATH(android/hardware/audio/FILE_VERSION/types.h) +// clang-format off +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +// clang-format on #include #include @@ -28,13 +31,13 @@ namespace android { namespace hardware { namespace audio { -namespace CPP_VERSION { +namespace CORE_TYPES_CPP_VERSION { namespace implementation { using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; -using namespace ::android::hardware::audio::common::CPP_VERSION; -using namespace ::android::hardware::audio::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; class ParametersUtil { public: @@ -62,7 +65,7 @@ class ParametersUtil { }; } // namespace implementation -} // namespace CPP_VERSION +} // namespace CORE_TYPES_CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/default/PrimaryDevice.h b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h index 5f65acfcf1..8b37e014b5 100644 --- a/audio/core/all-versions/default/include/core/default/PrimaryDevice.h +++ b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h @@ -36,7 +36,8 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; struct PrimaryDevice : public IPrimaryDevice { @@ -135,8 +136,10 @@ struct PrimaryDevice : public IPrimaryDevice { Return setBtHfpVolume(float volume) override; Return updateRotation(IPrimaryDevice::Rotation rotation) override; #endif - - private: +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 + Return> getDevice() override { return mDevice; } +#endif + private: sp mDevice; virtual ~PrimaryDevice(); diff --git a/audio/core/all-versions/default/include/core/default/Stream.h b/audio/core/all-versions/default/include/core/default/Stream.h index 66d60e3aa7..4e7988401e 100644 --- a/audio/core/all-versions/default/include/core/default/Stream.h +++ b/audio/core/all-versions/default/include/core/default/Stream.h @@ -17,7 +17,9 @@ #ifndef ANDROID_HARDWARE_AUDIO_STREAM_H #define ANDROID_HARDWARE_AUDIO_STREAM_H -#include PATH(android/hardware/audio/FILE_VERSION/IStream.h) +// clang-format off +#include PATH(android/hardware/audio/COMMON_TYPES_FILE_VERSION/IStream.h) +// clang-format on #include "ParametersUtil.h" @@ -41,10 +43,13 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::implementation::ParametersUtil; #if MAJOR_VERSION <= 6 -using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation:: + AudioChannelBitfield; #endif -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; struct Stream : public IStream, public ParametersUtil { diff --git a/audio/core/all-versions/default/include/core/default/StreamIn.h b/audio/core/all-versions/default/include/core/default/StreamIn.h index a980f3f999..a6346e5db4 100644 --- a/audio/core/all-versions/default/include/core/default/StreamIn.h +++ b/audio/core/all-versions/default/include/core/default/StreamIn.h @@ -42,7 +42,8 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; struct StreamIn : public IStreamIn { diff --git a/audio/core/all-versions/default/include/core/default/StreamOut.h b/audio/core/all-versions/default/include/core/default/StreamOut.h index 0b07972810..60ad5d5ea1 100644 --- a/audio/core/all-versions/default/include/core/default/StreamOut.h +++ b/audio/core/all-versions/default/include/core/default/StreamOut.h @@ -43,7 +43,8 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; struct StreamOut : public IStreamOut { diff --git a/audio/core/all-versions/default/include/core/default/Util.h b/audio/core/all-versions/default/include/core/default/Util.h index 78ae03eab2..abf531732a 100644 --- a/audio/core/all-versions/default/include/core/default/Util.h +++ b/audio/core/all-versions/default/include/core/default/Util.h @@ -17,7 +17,9 @@ #ifndef ANDROID_HARDWARE_AUDIO_UTIL_H #define ANDROID_HARDWARE_AUDIO_UTIL_H -#include PATH(android/hardware/audio/FILE_VERSION/types.h) +// clang-format off +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +// clang-format on #include #include @@ -27,19 +29,19 @@ namespace android { namespace hardware { namespace audio { -namespace CPP_VERSION { +namespace CORE_TYPES_CPP_VERSION { namespace implementation { -using namespace ::android::hardware::audio::common::CPP_VERSION; -using namespace ::android::hardware::audio::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; + +namespace util { /** @return true if gain is between 0 and 1 included. */ constexpr bool isGainNormalized(float gain) { return gain >= 0.0 && gain <= 1.0; } -namespace util { - template inline bool element_in(T e, const std::vector& v) { return std::find(v.begin(), v.end(), e) != v.end(); @@ -72,7 +74,7 @@ static inline Result analyzeStatus(const char* className, const char* funcName, } // namespace util } // namespace implementation -} // namespace CPP_VERSION +} // namespace CORE_TYPES_CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/util/CoreUtils.cpp b/audio/core/all-versions/default/util/CoreUtils.cpp index 773be21962..8e83ea1fbc 100644 --- a/audio/core/all-versions/default/util/CoreUtils.cpp +++ b/audio/core/all-versions/default/util/CoreUtils.cpp @@ -15,24 +15,24 @@ */ #if MAJOR_VERSION >= 7 -#include +#include PATH(APM_XSD_ENUMS_H_FILENAME) #endif #include #include #include "util/CoreUtils.h" -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; #if MAJOR_VERSION >= 7 namespace xsd { -using namespace ::android::audio::policy::configuration::V7_0; +using namespace ::android::audio::policy::configuration::CPP_VERSION; } #endif namespace android { namespace hardware { namespace audio { -namespace CPP_VERSION { +namespace CORE_TYPES_CPP_VERSION { namespace implementation { #define CONVERT_CHECKED(expr, result) \ @@ -389,7 +389,7 @@ status_t CoreUtils::sourceMetadataToHalV7(const SourceMetadata& sourceMetadata, #if MAJOR_VERSION >= 7 namespace xsd { -using namespace ::android::audio::policy::configuration::V7_0; +using namespace ::android::audio::policy::configuration::CPP_VERSION; } status_t CoreUtils::audioInputFlagsFromHal(audio_input_flags_t halFlagMask, @@ -470,7 +470,7 @@ status_t CoreUtils::audioOutputFlagsToHal(const AudioOutputFlags& flags, #endif } // namespace implementation -} // namespace CPP_VERSION +} // namespace CORE_TYPES_CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/util/include/util/CoreUtils.h b/audio/core/all-versions/default/util/include/util/CoreUtils.h index 1e5272a479..dc35772882 100644 --- a/audio/core/all-versions/default/util/include/util/CoreUtils.h +++ b/audio/core/all-versions/default/util/include/util/CoreUtils.h @@ -17,7 +17,7 @@ #pragma once // clang-format off -#include PATH(android/hardware/audio/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) // clang-format off #include @@ -30,13 +30,13 @@ namespace android { namespace hardware { namespace audio { -namespace CPP_VERSION { +namespace CORE_TYPES_CPP_VERSION { namespace implementation { using ::android::hardware::audio::common::utils::EnumBitfield; using ::android::hardware::hidl_vec; -using namespace ::android::hardware::audio::common::CPP_VERSION; -using namespace ::android::hardware::audio::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; struct CoreUtils { // Note: the converters for DeviceAddress have to be in CoreUtils for HAL V4 @@ -93,8 +93,8 @@ struct CoreUtils { return NO_ERROR; } #else - using AudioInputFlags = hidl_vec<::android::hardware::audio::CPP_VERSION::AudioInOutFlag>; - using AudioOutputFlags = hidl_vec<::android::hardware::audio::CPP_VERSION::AudioInOutFlag>; + using AudioInputFlags = hidl_vec<::android::hardware::audio::CORE_TYPES_CPP_VERSION::AudioInOutFlag>; + using AudioOutputFlags = hidl_vec<::android::hardware::audio::CORE_TYPES_CPP_VERSION::AudioInOutFlag>; static status_t audioInputFlagsFromHal(audio_input_flags_t halFlagMask, AudioInputFlags* flags); static status_t audioInputFlagsToHal(const AudioInputFlags& flags, audio_input_flags_t* halFlagMask); static status_t audioOutputFlagsFromHal(audio_output_flags_t halFlagMask, AudioOutputFlags* flags); diff --git a/audio/core/all-versions/default/util/tests/coreutils_tests.cpp b/audio/core/all-versions/default/util/tests/coreutils_tests.cpp index 0c18482632..3976b088e4 100644 --- a/audio/core/all-versions/default/util/tests/coreutils_tests.cpp +++ b/audio/core/all-versions/default/util/tests/coreutils_tests.cpp @@ -28,7 +28,7 @@ #include using namespace android; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; using ::android::hardware::hidl_vec; using ::android::hardware::audio::CPP_VERSION::implementation::CoreUtils; diff --git a/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h index 1cffd41831..dd80dd6fbc 100644 --- a/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h +++ b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h @@ -14,16 +14,18 @@ * limitations under the License. */ +// clang-format off #include PATH(android/hardware/audio/FILE_VERSION/IStream.h) -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) +// clang-format on #include using ::android::hardware::hidl_handle; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; -using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioFormat; using ::android::hardware::audio::CPP_VERSION::IStream; using ::android::hardware::audio::CPP_VERSION::ParameterValue; using ::android::hardware::audio::CPP_VERSION::Result; diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp index 787654bdd3..a9797bbfbd 100644 --- a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp @@ -17,7 +17,7 @@ #include "AudioPrimaryHidlHalTest.h" #if MAJOR_VERSION >= 7 -#include +#include PATH(APM_XSD_H_FILENAME) #include using android::xsdc_enum_range; @@ -28,17 +28,37 @@ TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { if (getDeviceName() != DeviceManager::kPrimaryDevice) { GTEST_SKIP() << "No primary device on this factory"; // returns } - - { // Scope for device SPs - sp baseDevice = - DeviceManager::getInstance().get(getFactoryName(), DeviceManager::kPrimaryDevice); - ASSERT_TRUE(baseDevice != nullptr); - Return> primaryDevice = IPrimaryDevice::castFrom(baseDevice); - EXPECT_TRUE(primaryDevice.isOk()); - EXPECT_TRUE(sp(primaryDevice) != nullptr); - } EXPECT_TRUE( DeviceManager::getInstance().reset(getFactoryName(), DeviceManager::kPrimaryDevice)); + + // Must use IDevicesFactory directly because DeviceManager always uses + // the latest interfaces version and corresponding methods for opening + // them. However, in minor package uprevs IPrimaryDevice does not inherit + // IDevice from the same package and thus IDevice can not be upcasted + // (see the interfaces in V7.1). + auto factory = DevicesFactoryManager::getInstance().get(getFactoryName()); + ASSERT_TRUE(factory != nullptr); + sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IDevice> baseDevice; + Result result; + auto ret = factory->openDevice(DeviceManager::kPrimaryDevice, returnIn(result, baseDevice)); + ASSERT_TRUE(ret.isOk()) << ret.description(); + ASSERT_EQ(Result::OK, result); + ASSERT_TRUE(baseDevice != nullptr); + { + Return> + primaryDevice = ::android::hardware::audio::CORE_TYPES_CPP_VERSION::IPrimaryDevice:: + castFrom(baseDevice); + EXPECT_TRUE(primaryDevice.isOk()); + EXPECT_TRUE(sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IPrimaryDevice>( + primaryDevice) != nullptr); + } +#if MAJOR_VERSION < 6 + baseDevice.clear(); + DeviceManager::waitForInstanceDestruction(); +#else + auto closeRet = baseDevice->close(); + EXPECT_TRUE(closeRet.isOk()); +#endif } ////////////////////////////////////////////////////////////////////////////// @@ -183,7 +203,7 @@ TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") : testSetDevices(stream.get(), address)) -static void checkGetHwAVSync(IDevice* device) { +static void checkGetHwAVSync(::android::hardware::audio::CPP_VERSION::IDevice* device) { Result res; AudioHwSync sync; ASSERT_OK(device->getHwAvSync(returnIn(res, sync))); @@ -215,7 +235,7 @@ TEST_P(InputStreamTest, updateSinkMetadata) { ASSERT_OK(stream->updateSinkMetadata(initMetadata)); #elif MAJOR_VERSION >= 7 - xsdc_enum_range range; + xsdc_enum_range range; // Test all possible track configuration for (auto source : range) { for (float volume : {0.0, 0.5, 1.0}) { @@ -272,8 +292,9 @@ TEST_P(OutputStreamTest, updateSourceMetadata) { // Restore initial ASSERT_OK(stream->updateSourceMetadata(initMetadata)); #elif MAJOR_VERSION >= 7 - xsdc_enum_range usageRange; - xsdc_enum_range contentRange; + xsdc_enum_range usageRange; + xsdc_enum_range + contentRange; // Test all possible track configuration for (auto usage : usageRange) { for (auto content : contentRange) { diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h index 81a1f7b4b7..a567cf90e2 100644 --- a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h @@ -14,33 +14,36 @@ * limitations under the License. */ -#include PATH(android/hardware/audio/FILE_VERSION/IStream.h) -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +// clang-format off +#include PATH(android/hardware/audio/FILE_VERSION/IStreamIn.h) +#include PATH(android/hardware/audio/FILE_VERSION/IStreamOut.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) +// clang-format on #include using ::android::hardware::hidl_bitfield; using ::android::hardware::hidl_handle; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; -using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; -using ::android::hardware::audio::CPP_VERSION::IStream; -using ::android::hardware::audio::CPP_VERSION::ParameterValue; -using ::android::hardware::audio::CPP_VERSION::Result; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioFormat; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::IStream; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::Result; using namespace ::android::hardware::audio::common::test::utility; -using Rotation = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice::Rotation; -using ::android::hardware::audio::common::CPP_VERSION::AudioContentType; -using ::android::hardware::audio::common::CPP_VERSION::AudioUsage; -using ::android::hardware::audio::CPP_VERSION::MicrophoneInfo; +using Rotation = ::android::hardware::audio::CORE_TYPES_CPP_VERSION::IPrimaryDevice::Rotation; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioContentType; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioUsage; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::MicrophoneInfo; #if MAJOR_VERSION < 5 using ::android::hardware::audio::CPP_VERSION::SinkMetadata; using ::android::hardware::audio::CPP_VERSION::SourceMetadata; #else -using ::android::hardware::audio::common::CPP_VERSION::SinkMetadata; -using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::SinkMetadata; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::SourceMetadata; #endif struct Parameters { diff --git a/audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp index 8af4c7855a..aef94da6eb 100644 --- a/audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp @@ -59,7 +59,8 @@ TEST_P(DualMonoModeAccessorHidlTest, DualMonoModeTest) { testAccessors(&OutputStreamTest::getStream, "dual mono mode", Initial{DualMonoMode::OFF}, {DualMonoMode::LR, DualMonoMode::LL, DualMonoMode::RR}, - &IStreamOut::setDualMonoMode, &IStreamOut::getDualMonoMode); + &::android::hardware::audio::CPP_VERSION::IStreamOut::setDualMonoMode, + &::android::hardware::audio::CPP_VERSION::IStreamOut::getDualMonoMode); } GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DualMonoModeAccessorHidlTest); @@ -73,7 +74,8 @@ TEST_P(AudioDescriptionMixLevelHidlTest, AudioDescriptionMixLevelTest) { testAccessors( &OutputStreamTest::getStream, "audio description mix level", Initial{-std::numeric_limits::infinity()}, {-48.0f, -1.0f, 0.0f, 1.0f, 48.0f}, - &IStreamOut::setAudioDescriptionMixLevel, &IStreamOut::getAudioDescriptionMixLevel, + &::android::hardware::audio::CPP_VERSION::IStreamOut::setAudioDescriptionMixLevel, + &::android::hardware::audio::CPP_VERSION::IStreamOut::getAudioDescriptionMixLevel, {48.5f, 1000.0f, std::numeric_limits::infinity()}); } @@ -105,7 +107,8 @@ TEST_P(PlaybackRateParametersHidlTest, PlaybackRateParametersTest) { PlaybackRate{0.5f, 0.5f, TimestretchMode::VOICE, TimestretchFallbackMode::MUTE}, PlaybackRate{1000.0f, 1000.0f, TimestretchMode::VOICE, TimestretchFallbackMode::MUTE}, PlaybackRate{1.0f, 1.0f, TimestretchMode::VOICE, TimestretchFallbackMode::FAIL}}, - &IStreamOut::setPlaybackRateParameters, &IStreamOut::getPlaybackRateParameters, + &::android::hardware::audio::CPP_VERSION::IStreamOut::setPlaybackRateParameters, + &::android::hardware::audio::CPP_VERSION::IStreamOut::getPlaybackRateParameters, {PlaybackRate{1000.0f, 1000.0f, TimestretchMode::DEFAULT, TimestretchFallbackMode::FAIL}, PlaybackRate{1000.0f, 1000.0f, TimestretchMode::VOICE, diff --git a/audio/core/all-versions/vts/functional/6.0/Generators.cpp b/audio/core/all-versions/vts/functional/6.0/Generators.cpp index e3b98c909f..dafd32697b 100644 --- a/audio/core/all-versions/vts/functional/6.0/Generators.cpp +++ b/audio/core/all-versions/vts/functional/6.0/Generators.cpp @@ -21,8 +21,8 @@ #include "PolicyConfig.h" // clang-format off -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on // Forward declaration for functions that are substituted @@ -30,7 +30,7 @@ const PolicyConfig& getCachedPolicyConfig(); const std::vector& getDeviceParameters(); -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION; std::vector generateOutputDeviceConfigParameters(bool oneProfilePerDevice) { diff --git a/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp index 222fad7769..f25c391ba9 100644 --- a/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp @@ -381,13 +381,13 @@ TEST_P(StreamOpenTest, OpenInputOrOutputStreamTest) { "IDevice::open{Input|Output}Stream method."); AudioConfig suggestedConfig{}; if (isParamForInputStream()) { - sp stream; + sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IStreamIn> stream; ASSERT_OK(getDevice()->openInputStream(AudioIoHandle{}, getDeviceAddress(), getConfig(), getFlags(), getSinkMetadata(), returnIn(res, stream, suggestedConfig))); ASSERT_TRUE(stream == nullptr); } else { - sp stream; + sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IStreamOut> stream; ASSERT_OK(getDevice()->openOutputStream(AudioIoHandle{}, getDeviceAddress(), getConfig(), getFlags(), getSourceMetadata(), returnIn(res, stream, suggestedConfig))); @@ -551,13 +551,15 @@ class PcmOnlyConfigOutputStreamTest : public OutputStreamTest { } void releasePatchIfNeeded() { - if (areAudioPatchesSupported()) { - if (mHasPatch) { + if (getDevice()) { + if (areAudioPatchesSupported() && mHasPatch) { EXPECT_OK(getDevice()->releaseAudioPatch(mPatchHandle)); mHasPatch = false; } } else { - EXPECT_OK(stream->setDevices({address})); + if (stream) { + EXPECT_OK(stream->setDevices({address})); + } } } @@ -724,13 +726,15 @@ class PcmOnlyConfigInputStreamTest : public InputStreamTest { } void releasePatchIfNeeded() { - if (areAudioPatchesSupported()) { - if (mHasPatch) { + if (getDevice()) { + if (areAudioPatchesSupported() && mHasPatch) { EXPECT_OK(getDevice()->releaseAudioPatch(mPatchHandle)); mHasPatch = false; } } else { - EXPECT_OK(stream->setDevices({address})); + if (stream) { + EXPECT_OK(stream->setDevices({address})); + } } } diff --git a/audio/core/all-versions/vts/functional/7.0/Generators.cpp b/audio/core/all-versions/vts/functional/7.0/Generators.cpp index 42bf1d341d..f936d0afbf 100644 --- a/audio/core/all-versions/vts/functional/7.0/Generators.cpp +++ b/audio/core/all-versions/vts/functional/7.0/Generators.cpp @@ -20,20 +20,20 @@ #include "7.0/PolicyConfig.h" // clang-format off -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on -#include -#include +#include PATH(APM_XSD_ENUMS_H_FILENAME) +#include PATH(APM_XSD_H_FILENAME) // Forward declaration for functions that are substituted // in generator unit tests. const PolicyConfig& getCachedPolicyConfig(); const std::vector& getDeviceParameters(); -using namespace ::android::hardware::audio::common::CPP_VERSION; -using namespace ::android::hardware::audio::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; namespace xsd { using namespace ::android::audio::policy::configuration::CPP_VERSION; } diff --git a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.cpp b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.cpp index 29882077d1..d674403a2c 100644 --- a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.cpp +++ b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.cpp @@ -30,9 +30,9 @@ using ::android::NO_ERROR; using ::android::OK; -using namespace ::android::hardware::audio::common::CPP_VERSION; -using namespace ::android::hardware::audio::CPP_VERSION; -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; using ::android::hardware::audio::common::utils::splitString; namespace xsd { using namespace ::android::audio::policy::configuration::CPP_VERSION; diff --git a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h index f798839cb8..4aea503938 100644 --- a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h +++ b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h @@ -25,15 +25,15 @@ #include // clang-format off -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on -#include -#include +#include PATH(APM_XSD_ENUMS_H_FILENAME) +#include PATH(APM_XSD_H_FILENAME) -using namespace ::android::hardware::audio::common::CPP_VERSION; -using namespace ::android::hardware::audio::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; +using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION; namespace xsd { using namespace ::android::audio::policy::configuration::CPP_VERSION; using Module = Modules::Module; diff --git a/audio/core/all-versions/vts/functional/7.1/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/7.1/AudioPrimaryHidlHalTest.cpp new file mode 100644 index 0000000000..b750f56ca2 --- /dev/null +++ b/audio/core/all-versions/vts/functional/7.1/AudioPrimaryHidlHalTest.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2022 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. + */ + +// pull in all the <= 7.0 tests +#include "7.0/AudioPrimaryHidlHalTest.cpp" diff --git a/audio/core/all-versions/vts/functional/Android.bp b/audio/core/all-versions/vts/functional/Android.bp index b280d7c3ae..61ab1bbb6d 100644 --- a/audio/core/all-versions/vts/functional/Android.bp +++ b/audio/core/all-versions/vts/functional/Android.bp @@ -184,6 +184,39 @@ cc_test { test_config: "VtsHalAudioV7_0TargetTest.xml", } +cc_test { + name: "VtsHalAudioV7_1TargetTest", + defaults: ["VtsHalAudioTargetTest_defaults"], + srcs: [ + "7.1/AudioPrimaryHidlHalTest.cpp", + "7.0/Generators.cpp", + "7.0/PolicyConfig.cpp", + ], + generated_headers: ["audio_policy_configuration_V7_1_parser"], + generated_sources: ["audio_policy_configuration_V7_1_parser"], + static_libs: [ + "android.hardware.audio@7.0", + "android.hardware.audio@7.1", + "android.hardware.audio.common@7.0", + "android.hardware.audio.common@7.0-enums", + "android.hardware.audio.common@7.1-enums", + "android.hardware.audio.common@7.0-util", + ], + cflags: [ + "-DMAJOR_VERSION=7", + "-DMINOR_VERSION=1", + "-DCOMMON_TYPES_MINOR_VERSION=0", + "-DCORE_TYPES_MINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ], + data: [ + ":audio_policy_configuration_V7_1", + ], + // Use test_config for vts suite. + // TODO(b/146104851): Add auto-gen rules and remove it. + test_config: "VtsHalAudioV7_1TargetTest.xml", +} + // Note: the following aren't VTS tests, but rather unit tests // to verify correctness of test utilities. cc_test { diff --git a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h index 340903a4ea..404532a6fa 100644 --- a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h +++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h @@ -37,15 +37,17 @@ #include #include +// clang-format off #include PATH(android/hardware/audio/FILE_VERSION/IDevice.h) #include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h) #include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h) -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) #if MAJOR_VERSION >= 7 -#include -#include +#include PATH(APM_XSD_ENUMS_H_FILENAME) +#include PATH(APM_XSD_H_FILENAME) #endif +// clang-format on #include #include @@ -86,7 +88,7 @@ using ::android::hardware::audio::common::utils::EnumBitfield; using ::android::hardware::audio::common::utils::mkEnumBitfield; using ::android::hardware::details::toHexString; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::common::test::utility; using namespace ::android::hardware::audio::CPP_VERSION; using ReadParameters = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadParameters; @@ -124,6 +126,9 @@ static auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUP class HidlTest : public ::testing::Test { public: + using IDevice = ::android::hardware::audio::CPP_VERSION::IDevice; + using IDevicesFactory = ::android::hardware::audio::CPP_VERSION::IDevicesFactory; + virtual ~HidlTest() = default; // public access to avoid annoyances when using this method in template classes // derived from test classes @@ -168,7 +173,8 @@ const PolicyConfig& getCachedPolicyConfig() { } TEST(CheckConfig, audioPolicyConfigurationValidation) { - const auto factories = ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); + const auto factories = ::android::hardware::getAllHalInstanceNames( + ::android::hardware::audio::CPP_VERSION::IDevicesFactory::descriptor); if (factories.size() == 0) { GTEST_SKIP() << "Skipping audioPolicyConfigurationValidation because no factory instances " "are found."; @@ -198,8 +204,8 @@ static inline std::string DeviceParameterToString( const std::vector& getDeviceParameters() { static std::vector parameters = [] { std::vector result; - const auto factories = - ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); + const auto factories = ::android::hardware::getAllHalInstanceNames( + ::android::hardware::audio::CPP_VERSION::IDevicesFactory::descriptor); const auto devices = getCachedPolicyConfig().getModulesWithDevicesNames(); result.reserve(devices.size()); for (const auto& factoryName : factories) { @@ -217,8 +223,8 @@ const std::vector& getDeviceParameters() { const std::vector& getDeviceParametersForFactoryTests() { static std::vector parameters = [] { std::vector result; - const auto factories = - ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); + const auto factories = ::android::hardware::getAllHalInstanceNames( + ::android::hardware::audio::CPP_VERSION::IDevicesFactory::descriptor); for (const auto& factoryName : factories) { result.emplace_back(factoryName, DeviceManager::getInstance().getPrimary(factoryName) != nullptr @@ -288,6 +294,8 @@ GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioPolicyConfigTest); // Test audio devices factory class AudioHidlTest : public AudioHidlTestWithDeviceParameter { public: + using IPrimaryDevice = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice; + void SetUp() override { ASSERT_NO_FATAL_FAILURE(AudioHidlTestWithDeviceParameter::SetUp()); // setup base ASSERT_TRUE(getDevicesFactory() != nullptr); @@ -301,7 +309,7 @@ TEST_P(AudioHidlTest, GetAudioDevicesFactoryService) { TEST_P(AudioHidlTest, OpenDeviceInvalidParameter) { doc::test("Test passing an invalid parameter to openDevice"); Result result; - sp device; + sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IDevice> device; #if MAJOR_VERSION == 2 auto invalidDevice = IDevicesFactory::Device(-1); #elif MAJOR_VERSION >= 4 @@ -572,8 +580,8 @@ static std::string DeviceConfigParameterToString( [](auto&& arg) -> std::string { using T = std::decay_t; // Need to use FQN of toString to avoid confusing the compiler - return ::android::hardware::audio::common::CPP_VERSION::toString( - hidl_bitfield(arg)); + return ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION:: + toString(hidl_bitfield(arg)); }, std::get(info.param))); #elif MAJOR_VERSION >= 7 @@ -890,6 +898,8 @@ class OpenStreamTest : public AudioHidlTestWithDeviceConfigParameter { class StreamWriter : public StreamWorker { public: + using IStreamOut = ::android::hardware::audio::CPP_VERSION::IStreamOut; + StreamWriter(IStreamOut* stream, size_t bufferSize) : mStream(stream), mBufferSize(bufferSize), mData(mBufferSize) {} ~StreamWriter() { @@ -998,7 +1008,8 @@ class StreamWriter : public StreamWorker { EventFlag* mEfGroup = nullptr; }; -class OutputStreamTest : public OpenStreamTest { +class OutputStreamTest + : public OpenStreamTest<::android::hardware::audio::CPP_VERSION::IStreamOut> { void SetUp() override { ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base #if MAJOR_VERSION <= 6 @@ -1012,9 +1023,12 @@ class OutputStreamTest : public OpenStreamTest { [&](AudioIoHandle handle, AudioConfig config, auto cb) { #if MAJOR_VERSION == 2 return getDevice()->openOutputStream(handle, address, config, flags, cb); -#elif MAJOR_VERSION >= 4 +#elif MAJOR_VERSION >= 4 && (MAJOR_VERSION < 7 || (MAJOR_VERSION == 7 && MINOR_VERSION == 0)) return getDevice()->openOutputStream(handle, address, config, flags, initMetadata, cb); +#elif MAJOR_VERSION == 7 && MINOR_VERSION == 1 + return getDevice()->openOutputStream_7_1(handle, address, config, flags, + initMetadata, cb); #endif }, config); @@ -1075,6 +1089,8 @@ GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(OutputStreamTest); class StreamReader : public StreamWorker { public: + using IStreamIn = ::android::hardware::audio::CPP_VERSION::IStreamIn; + StreamReader(IStreamIn* stream, size_t bufferSize) : mStream(stream), mBufferSize(bufferSize), mData(mBufferSize) {} ~StreamReader() { @@ -1188,7 +1204,7 @@ class StreamReader : public StreamWorker { EventFlag* mEfGroup = nullptr; }; -class InputStreamTest : public OpenStreamTest { +class InputStreamTest : public OpenStreamTest<::android::hardware::audio::CPP_VERSION::IStreamIn> { void SetUp() override { ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base #if MAJOR_VERSION <= 6 @@ -1210,8 +1226,13 @@ class InputStreamTest : public OpenStreamTest { auto flags = getInputFlags(); testOpen( [&](AudioIoHandle handle, AudioConfig config, auto cb) { +#if MAJOR_VERSION < 7 || (MAJOR_VERSION == 7 && MINOR_VERSION == 0) return getDevice()->openInputStream(handle, address, config, flags, initMetadata, cb); +#elif MAJOR_VERSION == 7 && MINOR_VERSION == 1 + return getDevice()->openInputStream_7_1(handle, address, config, flags, + initMetadata, cb); +#endif }, config); } @@ -1584,7 +1605,8 @@ TEST_P(InputStreamTest, SetGain) { "InputStream::setGain"); } -static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount) { +static void testPrepareForReading(::android::hardware::audio::CPP_VERSION::IStreamIn* stream, + uint32_t frameSize, uint32_t framesCount) { Result res; // Ignore output parameters as the call should fail ASSERT_OK(stream->prepareForReading(frameSize, framesCount, @@ -1655,7 +1677,8 @@ TEST_P(OutputStreamTest, setVolume) { "setVolume"); } -static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount) { +static void testPrepareForWriting(::android::hardware::audio::CPP_VERSION::IStreamOut* stream, + uint32_t frameSize, uint32_t framesCount) { Result res; // Ignore output parameters as the call should fail ASSERT_OK(stream->prepareForWriting(frameSize, framesCount, @@ -1682,6 +1705,8 @@ TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) { } struct Capability { + using IStreamOut = ::android::hardware::audio::CPP_VERSION::IStreamOut; + Capability(IStreamOut* stream) { EXPECT_OK(stream->supportsPauseAndResume(returnIn(pause, resume))); drain = extract(stream->supportsDrain()); @@ -1725,7 +1750,7 @@ class MockOutCallbacks : public IStreamOutCallback { Return onError() override { return {}; } }; -static bool isAsyncModeSupported(IStreamOut* stream) { +static bool isAsyncModeSupported(::android::hardware::audio::CPP_VERSION::IStreamOut* stream) { auto res = stream->setCallback(new MockOutCallbacks); stream->clearCallback(); // try to restore the no callback state, ignore // any error @@ -1780,7 +1805,8 @@ TEST_P(OutputStreamTest, Pause) { ASSERT_RESULT(Result::INVALID_STATE, stream->pause()); } -static void testDrain(IStreamOut* stream, AudioDrain type) { +static void testDrain(::android::hardware::audio::CPP_VERSION::IStreamOut* stream, + AudioDrain type) { if (!Capability(stream).drain) { doc::partialTest("The output stream does not support drain"); return; @@ -1866,7 +1892,8 @@ TEST_P(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) { } using TtyModeAccessorPrimaryHidlTest = - AccessorHidlTest; + AccessorHidlTest<::android::hardware::audio::CPP_VERSION::IPrimaryDevice::TtyMode, + AudioPrimaryHidlTest>; TEST_P(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) { doc::test("Query and set the TTY mode state"); testAccessors( diff --git a/audio/core/all-versions/vts/functional/AudioTestDefinitions.h b/audio/core/all-versions/vts/functional/AudioTestDefinitions.h index aa676308cb..802b87bc36 100644 --- a/audio/core/all-versions/vts/functional/AudioTestDefinitions.h +++ b/audio/core/all-versions/vts/functional/AudioTestDefinitions.h @@ -22,8 +22,8 @@ #include // clang-format off -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on enum { PARAM_FACTORY_NAME, PARAM_DEVICE_NAME }; @@ -34,14 +34,14 @@ using DeviceParameter = std::tuple; #if MAJOR_VERSION <= 6 enum { PARAM_DEVICE, PARAM_CONFIG, PARAM_FLAGS }; enum { INDEX_INPUT, INDEX_OUTPUT }; -using DeviceConfigParameter = - std::tuple>; +using DeviceConfigParameter = std::tuple< + DeviceParameter, android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioConfig, + std::variant>; #elif MAJOR_VERSION >= 7 enum { PARAM_DEVICE, PARAM_PORT_NAME, PARAM_CONFIG, PARAM_FLAGS }; using DeviceConfigParameter = std::tuple>; + android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioConfig, + std::vector>; #endif diff --git a/audio/core/all-versions/vts/functional/ConfigHelper.h b/audio/core/all-versions/vts/functional/ConfigHelper.h index a2bb1eecf0..e4008cf046 100644 --- a/audio/core/all-versions/vts/functional/ConfigHelper.h +++ b/audio/core/all-versions/vts/functional/ConfigHelper.h @@ -21,8 +21,8 @@ #include "PolicyConfig.h" // clang-format off -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on using ::android::hardware::audio::common::utils::EnumBitfield; diff --git a/audio/core/all-versions/vts/functional/DeviceManager.h b/audio/core/all-versions/vts/functional/DeviceManager.h index 6db78a77d6..c8e016731d 100644 --- a/audio/core/all-versions/vts/functional/DeviceManager.h +++ b/audio/core/all-versions/vts/functional/DeviceManager.h @@ -22,19 +22,21 @@ #include #include +#include // clang-format off #include PATH(android/hardware/audio/FILE_VERSION/IDevice.h) #include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h) #include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h) -#include PATH(android/hardware/audio/FILE_VERSION/types.h) -#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h) // clang-format on #include "utility/ReturnIn.h" using ::android::sp; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::Result; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::common::test::utility; using namespace ::android::hardware::audio::CPP_VERSION; @@ -104,21 +106,30 @@ class DeviceManager : public InterfaceManager createInterfaceInstance(const FactoryAndDevice& factoryAndDevice) { auto [factoryName, name] = factoryAndDevice; sp factory = DevicesFactoryManager::getInstance().get(factoryName); - return name == kPrimaryDevice ? openPrimaryDevice(factory) : openDevice(factory, name); + return openDevice(factory, name); } using InterfaceManager::reset; static constexpr const char* kPrimaryDevice = "primary"; sp get(const std::string& factoryName, const std::string& name) { + if (name == kPrimaryDevice) { + (void)getPrimary(factoryName); // for initializing primaryDevice if needed. + } return InterfaceManager::get(std::make_tuple(factoryName, name)); } sp getPrimary(const std::string& factoryName) { - sp device = get(factoryName, kPrimaryDevice); - return device != nullptr ? IPrimaryDevice::castFrom(device) : nullptr; + if (primaryDevice == nullptr) { + sp factory = DevicesFactoryManager::getInstance().get(factoryName); + primaryDevice = openPrimaryDevice(factory); + } + return primaryDevice; } bool reset(const std::string& factoryName, const std::string& name) __attribute__((warn_unused_result)) { + if (name == kPrimaryDevice) { + primaryDevice.clear(); + } #if MAJOR_VERSION <= 5 return InterfaceManager::reset(std::make_tuple(factoryName, name), true); #elif MAJOR_VERSION >= 6 @@ -140,35 +151,75 @@ class DeviceManager : public InterfaceManager openDevice(const sp& factory, const std::string& name) { if (factory == nullptr) return nullptr; - sp device; -#if MAJOR_VERSION >= 4 Result result; + sp device; +#if MAJOR_VERSION == 2 + IDevicesFactory::Device dev = IDevicesFactory::IDevicesFactory::Device(-1); + if (name == AUDIO_HARDWARE_MODULE_ID_PRIMARY) { + dev = IDevicesFactory::Device::PRIMARY; + } else if (name == AUDIO_HARDWARE_MODULE_ID_A2DP) { + dev = IDevicesFactory::Device::A2DP; + } else if (name == AUDIO_HARDWARE_MODULE_ID_USB) { + dev = IDevicesFactory::Device::USB; + } else if (name == AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX) { + dev = IDevicesFactory::Device::R_SUBMIX; + } else if (name == AUDIO_HARDWARE_MODULE_ID_STUB) { + dev = IDevicesFactory::Device::STUB; + } + auto ret = factory->openDevice(dev, returnIn(result, device)); +#elif MAJOR_VERSION >= 4 && (MAJOR_VERSION < 7 || (MAJOR_VERSION == 7 && MINOR_VERSION == 0)) auto ret = factory->openDevice(name, returnIn(result, device)); +#elif MAJOR_VERSION == 7 && MINOR_VERSION == 1 + auto ret = factory->openDevice_7_1(name, returnIn(result, device)); +#endif if (!ret.isOk() || result != Result::OK || device == nullptr) { ALOGW("Device %s can not be opened, transaction: %s, result %d, device %p", name.c_str(), ret.description().c_str(), result, device.get()); return nullptr; } -#else - (void)name; -#endif return device; } - static sp openPrimaryDevice(const sp& factory) { - if (factory == nullptr) return nullptr; + static sp openPrimaryDevice(const sp& factory) { + if (factory == nullptr) return {}; Result result; sp device; + sp primaryDevice; #if MAJOR_VERSION == 2 auto ret = factory->openDevice(IDevicesFactory::Device::PRIMARY, returnIn(result, device)); -#elif MAJOR_VERSION >= 4 + if (ret.isOk() && result == Result::OK && device != nullptr) { + primaryDevice = IPrimaryDevice::castFrom(device); + } +#elif MAJOR_VERSION >= 4 && (MAJOR_VERSION < 7 || (MAJOR_VERSION == 7 && MINOR_VERSION == 0)) auto ret = factory->openPrimaryDevice(returnIn(result, device)); + if (ret.isOk() && result == Result::OK && device != nullptr) { + primaryDevice = IPrimaryDevice::castFrom(device); + } +#elif MAJOR_VERSION == 7 && MINOR_VERSION == 1 + auto ret = factory->openPrimaryDevice_7_1(returnIn(result, primaryDevice)); + if (ret.isOk() && result == Result::OK && primaryDevice != nullptr) { + auto getDeviceRet = primaryDevice->getDevice(); + if (getDeviceRet.isOk()) { + device = getDeviceRet; + } else { + primaryDevice.clear(); + ALOGW("Primary device can not downcast, transaction: %s, primary %p", + getDeviceRet.description().c_str(), primaryDevice.get()); + return {}; + } + } #endif if (!ret.isOk() || result != Result::OK || device == nullptr) { ALOGW("Primary device can not be opened, transaction: %s, result %d, device %p", ret.description().c_str(), result, device.get()); - return nullptr; + return {}; } - return device; + return primaryDevice; } + + private: + // There can only be one primary device across all HAL modules. + // A reference to a complete interface is used because in V7.1 IDevice can not + // be upcasted to IPrimaryDevice. + sp primaryDevice; }; diff --git a/audio/core/all-versions/vts/functional/VtsHalAudioV7_1TargetTest.xml b/audio/core/all-versions/vts/functional/VtsHalAudioV7_1TargetTest.xml new file mode 100644 index 0000000000..7b33a8f340 --- /dev/null +++ b/audio/core/all-versions/vts/functional/VtsHalAudioV7_1TargetTest.xml @@ -0,0 +1,39 @@ + + + + diff --git a/audio/core/all-versions/vts/functional/tests/generators_tests.cpp b/audio/core/all-versions/vts/functional/tests/generators_tests.cpp index 3fdd8e6086..76bf93e2d7 100644 --- a/audio/core/all-versions/vts/functional/tests/generators_tests.cpp +++ b/audio/core/all-versions/vts/functional/tests/generators_tests.cpp @@ -33,7 +33,7 @@ #endif using namespace android; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; #if MAJOR_VERSION == 7 namespace xsd { using namespace ::android::audio::policy::configuration::CPP_VERSION; diff --git a/audio/effect/all-versions/default/Effect.cpp b/audio/effect/all-versions/default/Effect.cpp index ccfc6b22c9..49f6bf2ece 100644 --- a/audio/effect/all-versions/default/Effect.cpp +++ b/audio/effect/all-versions/default/Effect.cpp @@ -42,9 +42,10 @@ namespace CPP_VERSION { namespace implementation { #if MAJOR_VERSION <= 6 -using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation:: + AudioChannelBitfield; #endif -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; namespace { diff --git a/audio/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h index d5218f7240..f9a6796e8f 100644 --- a/audio/effect/all-versions/default/Effect.h +++ b/audio/effect/all-versions/default/Effect.h @@ -48,9 +48,10 @@ using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; #if MAJOR_VERSION <= 6 -using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioDeviceBitfield; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation:: + AudioDeviceBitfield; #endif -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct Effect : public IEffect { diff --git a/audio/effect/all-versions/default/EffectsFactory.cpp b/audio/effect/all-versions/default/EffectsFactory.cpp index eb1cb4971c..e93ad893a8 100644 --- a/audio/effect/all-versions/default/EffectsFactory.cpp +++ b/audio/effect/all-versions/default/EffectsFactory.cpp @@ -53,7 +53,7 @@ namespace effect { namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::CPP_VERSION::implementation::UuidUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::UuidUtils; // static sp EffectsFactory::dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor, diff --git a/audio/effect/all-versions/default/EffectsFactory.h b/audio/effect/all-versions/default/EffectsFactory.h index 0b86836e4b..da16923b1e 100644 --- a/audio/effect/all-versions/default/EffectsFactory.h +++ b/audio/effect/all-versions/default/EffectsFactory.h @@ -41,7 +41,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct EffectsFactory : public IEffectsFactory { diff --git a/audio/effect/all-versions/default/EnvironmentalReverbEffect.h b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h index 9694b5d8c1..001774d7fe 100644 --- a/audio/effect/all-versions/default/EnvironmentalReverbEffect.h +++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h @@ -43,7 +43,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect { diff --git a/audio/effect/all-versions/default/EqualizerEffect.h b/audio/effect/all-versions/default/EqualizerEffect.h index 7a6bc0a8b0..c4d76c1c18 100644 --- a/audio/effect/all-versions/default/EqualizerEffect.h +++ b/audio/effect/all-versions/default/EqualizerEffect.h @@ -43,7 +43,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct EqualizerEffect : public IEqualizerEffect { diff --git a/audio/effect/all-versions/default/LoudnessEnhancerEffect.h b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h index 6d80207dc3..122ec364c9 100644 --- a/audio/effect/all-versions/default/LoudnessEnhancerEffect.h +++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h @@ -39,7 +39,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect { diff --git a/audio/effect/all-versions/default/NoiseSuppressionEffect.h b/audio/effect/all-versions/default/NoiseSuppressionEffect.h index 6cc45b983c..96b9ecfd62 100644 --- a/audio/effect/all-versions/default/NoiseSuppressionEffect.h +++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.h @@ -41,7 +41,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct NoiseSuppressionEffect : public INoiseSuppressionEffect { diff --git a/audio/effect/all-versions/default/PresetReverbEffect.h b/audio/effect/all-versions/default/PresetReverbEffect.h index eb55e20fe2..9d82c08abd 100644 --- a/audio/effect/all-versions/default/PresetReverbEffect.h +++ b/audio/effect/all-versions/default/PresetReverbEffect.h @@ -39,7 +39,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct PresetReverbEffect : public IPresetReverbEffect { diff --git a/audio/effect/all-versions/default/VirtualizerEffect.cpp b/audio/effect/all-versions/default/VirtualizerEffect.cpp index 1dce1810ea..6efc4eaa12 100644 --- a/audio/effect/all-versions/default/VirtualizerEffect.cpp +++ b/audio/effect/all-versions/default/VirtualizerEffect.cpp @@ -34,7 +34,7 @@ namespace effect { namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; VirtualizerEffect::VirtualizerEffect(effect_handle_t handle) : mEffect(new Effect(false /*isInput*/, handle)) {} diff --git a/audio/effect/all-versions/default/VirtualizerEffect.h b/audio/effect/all-versions/default/VirtualizerEffect.h index 3ed06d147f..f26e4fa215 100644 --- a/audio/effect/all-versions/default/VirtualizerEffect.h +++ b/audio/effect/all-versions/default/VirtualizerEffect.h @@ -40,9 +40,10 @@ using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; #if MAJOR_VERSION <= 6 -using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation:: + AudioChannelBitfield; #endif -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct VirtualizerEffect : public IVirtualizerEffect { diff --git a/audio/effect/all-versions/default/VisualizerEffect.h b/audio/effect/all-versions/default/VisualizerEffect.h index 3ae4b08193..b8424c418d 100644 --- a/audio/effect/all-versions/default/VisualizerEffect.h +++ b/audio/effect/all-versions/default/VisualizerEffect.h @@ -39,7 +39,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; struct VisualizerEffect : public IVisualizerEffect { diff --git a/audio/effect/all-versions/default/util/EffectUtils.cpp b/audio/effect/all-versions/default/util/EffectUtils.cpp index 1156d211a1..296f84d2db 100644 --- a/audio/effect/all-versions/default/util/EffectUtils.cpp +++ b/audio/effect/all-versions/default/util/EffectUtils.cpp @@ -25,8 +25,8 @@ #include "util/EffectUtils.h" -using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; -using ::android::hardware::audio::common::CPP_VERSION::implementation::UuidUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils; +using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::UuidUtils; using ::android::hardware::audio::common::utils::EnumBitfield; namespace android { @@ -36,7 +36,7 @@ namespace effect { namespace CPP_VERSION { namespace implementation { -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; #define CONVERT_CHECKED(expr, result) \ if (status_t status = (expr); status != NO_ERROR) { \ diff --git a/audio/effect/all-versions/default/util/tests/effectutils_tests.cpp b/audio/effect/all-versions/default/util/tests/effectutils_tests.cpp index d021fa0b92..adfa167e46 100644 --- a/audio/effect/all-versions/default/util/tests/effectutils_tests.cpp +++ b/audio/effect/all-versions/default/util/tests/effectutils_tests.cpp @@ -27,7 +27,7 @@ #include using namespace android; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; using ::android::hardware::audio::effect::CPP_VERSION::implementation::EffectUtils; namespace xsd { diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp index 23e77867a5..e59423fa98 100644 --- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp +++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp @@ -50,7 +50,7 @@ using ::android::hardware::Void; using ::android::hardware::audio::common::utils::mkEnumBitfield; using ::android::hidl::allocator::V1_0::IAllocator; using ::android::hidl::memory::V1_0::IMemory; -using namespace ::android::hardware::audio::common::CPP_VERSION; +using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION; using namespace ::android::hardware::audio::effect::CPP_VERSION; #if MAJOR_VERSION >= 7 // Make an alias for enumerations generated from the APM config XSD. diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index e6dd1bf638..dc716bbdc0 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -10,7 +10,7 @@ android.hardware.audio 6.0 - 7.0 + 7.0-1 IDevicesFactory default