From 406da449098d5afb6812d600ba76ea2bb1c16ff9 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Mon, 16 May 2022 21:10:06 +0000 Subject: Delete HIDL 3.8 - HIDL camera device@3.8, metadata@3.8 were temporary interfaces Bug: 221108824 Test: GCA Test: Camera CTS Change-Id: I44cd1ac0e2f6647e3e9d5c60a535faf716d5ed93 Signed-off-by: Jayant Chowdhary --- camera/device/3.8/Android.bp | 39 - camera/device/3.8/ICameraDevice.hal | 122 -- camera/device/3.8/ICameraDeviceCallback.hal | 34 - camera/device/3.8/ICameraDeviceSession.hal | 98 -- camera/device/3.8/types.hal | 157 --- camera/metadata/3.8/Android.bp | 27 - camera/metadata/3.8/types.hal | 244 ---- camera/provider/2.4/vts/functional/Android.bp | 2 - .../VtsHalCameraProviderV2_4TargetTest.cpp | 1220 ++------------------ 9 files changed, 100 insertions(+), 1843 deletions(-) delete mode 100644 camera/device/3.8/Android.bp delete mode 100644 camera/device/3.8/ICameraDevice.hal delete mode 100644 camera/device/3.8/ICameraDeviceCallback.hal delete mode 100644 camera/device/3.8/ICameraDeviceSession.hal delete mode 100644 camera/device/3.8/types.hal delete mode 100644 camera/metadata/3.8/Android.bp delete mode 100644 camera/metadata/3.8/types.hal diff --git a/camera/device/3.8/Android.bp b/camera/device/3.8/Android.bp deleted file mode 100644 index c3c29416a9..0000000000 --- a/camera/device/3.8/Android.bp +++ /dev/null @@ -1,39 +0,0 @@ -// 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.camera.device@3.8", - root: "android.hardware", - srcs: [ - "types.hal", - "ICameraDevice.hal", - "ICameraDeviceCallback.hal", - "ICameraDeviceSession.hal", - ], - interfaces: [ - "android.hardware.camera.common@1.0", - "android.hardware.camera.device@3.2", - "android.hardware.camera.device@3.3", - "android.hardware.camera.device@3.4", - "android.hardware.camera.device@3.5", - "android.hardware.camera.device@3.6", - "android.hardware.camera.device@3.7", - "android.hardware.camera.metadata@3.2", - "android.hardware.camera.metadata@3.3", - "android.hardware.camera.metadata@3.4", - "android.hardware.camera.metadata@3.5", - "android.hardware.camera.metadata@3.6", - "android.hardware.camera.metadata@3.8", - "android.hardware.graphics.common@1.0", - "android.hidl.base@1.0", - ], - gen_java: false, -} diff --git a/camera/device/3.8/ICameraDevice.hal b/camera/device/3.8/ICameraDevice.hal deleted file mode 100644 index 09edb8ba20..0000000000 --- a/camera/device/3.8/ICameraDevice.hal +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2021 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.camera.device@3.8; - -import android.hardware.camera.common@1.0::Status; -import @3.7::ICameraDevice; - -/** - * Camera device interface - * - * Supports the android.hardware.Camera API, and the android.hardware.camera2 - * API at LIMITED or better hardware level. - * - * ICameraDevice.open() must return @3.2::ICameraDeviceSession, - * @3.5::ICameraDeviceSession, @3.6::ICameraDeviceSession, - * @3.7::ICameraDeviceSession, or @3.8::ICameraDeviceSession. - */ -interface ICameraDevice extends @3.7::ICameraDevice { - /** - * turnOnTorchWithStrengthLevel: - * - * Change the brightness level of the flash unit associated with this camera device - * and set it to value in torchStrength. This function also turns ON the torch - * with specified torchStrength if the torch is OFF. - * - * The torchStrength value must be within the valid range i.e. >=1 and - * <= FLASH_INFO_STRENGTH_MAXIMUM_LEVEL. Whenever the torch is turned OFF, - * the brightness level will reset to FLASH_INFO_STRENGTH_DEFAULT_LEVEL. - * When the client calls setTorchMode(ON) after turnOnTorchWithStrengthLevel(N), - * the flash unit will have brightness level equal to N. This level does not - * represent the real brightness units. It is linear in nature i.e. flashlight - * at level 10 is twice as bright as at level 5. - * - * @param torchStrength Brightness level to be set for the flashlight. - * - * @return status Status code for the operation, one of: - * OK: - * On a successful change to the torch strength level. - * INTERNAL_ERROR: - * The flash unit cannot be operated due to an unexpected internal - * error. - * CAMERA_IN_USE: - * This status code is returned when: - * - This camera device has been opened, so the torch cannot be - * controlled until it is closed. - * - Due to other camera devices being open, or due to other - * resource constraints, the torch cannot be controlled currently. - * ILLEGAL_ARGUMENT: - * If the torchStrength value is not within the range i.e. < 1 or - * > FLASH_INFO_STRENGTH_MAXIMUM_LEVEL. - * METHOD_NOT_SUPPORTED: - * This status code is returned when: - * - This camera device does not support direct operation of flashlight - * torch mode. The framework must open the camera device and turn - * the torch on through the device interface. - * - This camera device does not have a flash unit. - * - This camera device has flash unit but does not support torch - * strength control. - * CAMERA_DISCONNECTED: - * An external camera device has been disconnected, and is no longer - * available. This camera device interface is now stale, and a new - * instance must be acquired if the device is reconnected. All - * subsequent calls on this interface must return - * CAMERA_DISCONNECTED. - * - */ - turnOnTorchWithStrengthLevel(int32_t torchStrength) generates (Status status); - - /** - * getTorchStrengthLevel: - * - * Get current torch strength level. - * If the device supports torch strength control, when the torch is OFF the - * strength level will reset to default level, so the return - * value in this case will be equal to FLASH_INFO_STRENGTH_DEFAULT_LEVEL. - * - * @return status Status code for the operation, one of: - * OK: - * On success. - * INTERNAL_ERROR: - * An unexpected error occurred and the information is not - * available. - * METHOD_NOT_SUPPORTED: - * This status code is returned when: - * - This camera device does not support direct operation of flashlight - * torch mode. The framework must open the camera device and turn - * the torch on through the device interface. - * - This camera device does not have a flash unit. - * - This camera device has flash unit but does not support torch - * strength control. - * - * @return torchStrength Current torch strength level. - * - */ - getTorchStrengthLevel() generates (Status status, int32_t torchStrength); - - /** - * isStreamCombinationSupported_3_8: - * - * Identical to @3.7::ICameraDevice.isStreamCombinationSupported, except - * that it takes a @3.8::StreamConfiguration parameter, which could contain - * additional information about a specific 10-bit dynamic range profile or - * stream use case. - * - */ - isStreamCombinationSupported_3_8(StreamConfiguration streams) - generates (Status status, bool queryStatus); -}; diff --git a/camera/device/3.8/ICameraDeviceCallback.hal b/camera/device/3.8/ICameraDeviceCallback.hal deleted file mode 100644 index de0775d59f..0000000000 --- a/camera/device/3.8/ICameraDeviceCallback.hal +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2021 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.camera.device@3.8; - -import @3.5::ICameraDeviceCallback; - -/** - * Callback methods for the HAL to call into the framework. - */ -interface ICameraDeviceCallback extends @3.5::ICameraDeviceCallback { - /** - * Identical to @3.5::ICameraDeviceCallback.notify, except that it takes a - * list of @3.8::NotifyMsg which contain readout timestamp in addition - * to exposure start timestamp for shutter. - * - * The readout timestamp is used for the framework to re-time the viewfinder - * frames targeted for SurfaceView so that preview jitter can be reduced. - */ - notify_3_8(vec msgs); -}; diff --git a/camera/device/3.8/ICameraDeviceSession.hal b/camera/device/3.8/ICameraDeviceSession.hal deleted file mode 100644 index c3aa836ec1..0000000000 --- a/camera/device/3.8/ICameraDeviceSession.hal +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2021 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.camera.device@3.8; - -import android.hardware.camera.common@1.0::Status; -import @3.5::StreamConfiguration; -import @3.7::ICameraDeviceSession; -import @3.6::HalStreamConfiguration; - -/** - * Camera device active session interface. - * - * Obtained via ICameraDevice::open(), this interface contains the methods to - * configure and request captures from an active camera device. - */ -interface ICameraDeviceSession extends @3.7::ICameraDeviceSession { - /** - * configureStreams_3_8: - * - * Identical to @3.7::ICameraDeviceSession.configureStreams_3_7, except that: - * - * - The requestedConfiguration allows the camera framework to configure - * 10-bit dynamic range profile. - * - The requestedConfiguration allows the camera framework to configure - * stream use cases. - * - * @return status Status code for the operation, one of: - * OK: - * On successful stream configuration. - * INTERNAL_ERROR: - * If there has been a fatal error and the device is no longer - * operational. Only close() can be called successfully by the - * framework after this error is returned. - * ILLEGAL_ARGUMENT: - * If the requested stream configuration is invalid. Some examples - * of invalid stream configurations include: - * - Including more than 1 INPUT stream - * - Not including any OUTPUT streams - * - Including streams with unsupported formats, or an unsupported - * size for that format. - * - Including too many output streams of a certain format. - * - Unsupported rotation configuration - * - Stream sizes/formats don't satisfy the - * StreamConfigurationMode requirements - * for non-NORMAL mode, or the requested operation_mode is not - * supported by the HAL. - * - Unsupported usage flag - * - Unsupported stream groupIds, or unsupported multi-resolution - * input stream. - * - Invalid combination between a 10-bit dynamic range profile - * and none impl. defined 8-bit format for a particular stream. - * - Unsupported stream use case - * The camera service cannot filter out all possible illegal stream - * configurations, since some devices may support more simultaneous - * streams or larger stream resolutions than the minimum required - * for a given camera device hardware level. The HAL must return an - * ILLEGAL_ARGUMENT for any unsupported stream set, and then be - * ready to accept a future valid stream configuration in a later - * configureStreams call. - * @return halConfiguration The stream parameters desired by the HAL for - * each stream, including maximum buffers, the usage flags, and the - * override format and dataspace. - */ - configureStreams_3_8(StreamConfiguration requestedConfiguration) - generates (Status status, @3.6::HalStreamConfiguration halConfiguration); - - /** - * repeatingRequestEnd: - * - * Notification about the last frame number in a repeating request along with the - * ids of all streams included in the repeating request. - * - * This can be called at any point after 'processCaptureRequest' in response - * to camera clients disabling an active repeating request. - * - * Performance requirements: - * The call must not be blocked for extensive periods and should be extremely lightweight. There - * must be no frame rate degradation or frame jitter introduced. - * - * This method must always succeed, even if the device has encountered a - * serious error. - */ - repeatingRequestEnd(uint32_t frameNumber, vec streamIds); -}; diff --git a/camera/device/3.8/types.hal b/camera/device/3.8/types.hal deleted file mode 100644 index 04a245085b..0000000000 --- a/camera/device/3.8/types.hal +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2021 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.camera.device@3.8; - -import @3.2::ErrorMsg; -import @3.2::CameraMetadata; -import @3.2::MsgType; -import @3.2::ShutterMsg; -import @3.2::CameraMetadata; -import @3.2::StreamConfigurationMode; -import @3.7::Stream; - -import android.hardware.camera.metadata@3.8::CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap; -import android.hardware.camera.metadata@3.8::CameraMetadataEnumAndroidScalerAvailableStreamUseCases; - -/** - * ShutterMsg: - * - * Message contents for MsgType::SHUTTER - * - * This version extends the @3.2 ShutterMsg with the readout timestamp. - */ -struct ShutterMsg { - /** - * The definition of ShutterMsg from prior version. - */ - @3.2::ShutterMsg v3_2; - - /** - * Timestamp for the capture readout. This must be in the same time domain - * as v3_2.timestamp, and for a rolling shutter sensor, the value must be - * v3_2.timestamp + exposureTime + t_crop_top where t_crop_top is the exposure time - * skew of the cropped lines on the top. - */ - uint64_t readoutTimestamp; -}; - -/** - * NotifyMsg: - * - * The message structure sent to ICameraDevice3Callback::notify() - * - * This version extends the @3.2 NotifyMsg with the @3.8 version of ShutterMsg. - */ -struct NotifyMsg { - /** - * The message type. - */ - @3.2::MsgType type; - - union Message { - /** - * Error message contents. Valid if type is MsgType::ERROR - */ - @3.2::ErrorMsg error; - - /** - * Shutter message contents. Valid if type is MsgType::SHUTTER - */ - ShutterMsg shutter; - } msg; -}; - -/** - * Stream: - * - * A descriptor for a single camera input or output stream. A stream is defined - * by the framework by its buffer resolution and format, and additionally by the - * HAL with the gralloc usage flags and the maximum in-flight buffer count. - * - * This version extends the @3.7 Stream with the dynamic range profile and the - * stream use case field. - */ -struct Stream { - /** - * The definition of Stream from the prior version. - */ - @3.7::Stream v3_7; - - /** - * The dynamic range profile for this stream. - * - * This field is valid and must only be considered for streams with format - * android.hardware.graphics.common.PixelFormat.YCBCR_P010 or - * android.hardware.graphics.common.PixelFormat.IMPLEMENTATION_DEFINED on devices supporting the - * ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_10_BIT capability. - * - */ - CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap dynamicRangeProfile; - - /** - * The stream use case describing the stream's purpose - * - * This flag provides the camera device a hint on what user scenario this - * stream is intended for. With this flag, the camera device can optimize - * camera pipeline parameters, such as tuning, sensor mode, and ISP settings, - * for the intended use case. - * - * When this field is set to DEFAULT, the camera device should behave in - * the same way as in previous HAL versions, and optimize the camera pipeline - * based on stream format, data space, usage flag, and other stream properties. - * - * The HAL reports supported stream use cases in - * ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES. If the HAL doesn't support - * setting stream use cases, the camera framework leaves this field as - * DEFAULT. - */ - CameraMetadataEnumAndroidScalerAvailableStreamUseCases useCase; -}; - -/** - * StreamConfiguration: - * - * Identical to @3.7::StreamConfiguration, except that the streams - * vector contains @3.8::Stream. - */ -struct StreamConfiguration { - /** - * An array of camera stream pointers, defining the input/output - * configuration for the camera HAL device. - */ - vec streams; - - /** - * The definition of operation mode from prior version. - */ - @3.2::StreamConfigurationMode operationMode; - - /** - * The definition of session parameters from prior version. - */ - @3.2::CameraMetadata sessionParams; - - /** - * The definition of stream configuration counter from prior version. - */ - uint32_t streamConfigCounter; - - /** - * The definition of multi-resolution input image flag from prior version. - */ - bool multiResolutionInputImage; -}; diff --git a/camera/metadata/3.8/Android.bp b/camera/metadata/3.8/Android.bp deleted file mode 100644 index ead9543812..0000000000 --- a/camera/metadata/3.8/Android.bp +++ /dev/null @@ -1,27 +0,0 @@ -// 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.camera.metadata@3.8", - root: "android.hardware", - srcs: [ - "types.hal", - ], - interfaces: [ - "android.hardware.camera.metadata@3.2", - "android.hardware.camera.metadata@3.3", - "android.hardware.camera.metadata@3.4", - "android.hardware.camera.metadata@3.5", - "android.hardware.camera.metadata@3.6", - "android.hardware.camera.metadata@3.7", - ], - gen_java: true, -} diff --git a/camera/metadata/3.8/types.hal b/camera/metadata/3.8/types.hal deleted file mode 100644 index 8cc6646799..0000000000 --- a/camera/metadata/3.8/types.hal +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2021 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. - */ - -/* - * Autogenerated from camera metadata definitions in - * /system/media/camera/docs/metadata_definitions.xml - * *** DO NOT EDIT BY HAND *** - */ - -package android.hardware.camera.metadata@3.8; - -import android.hardware.camera.metadata@3.2; -import android.hardware.camera.metadata@3.3; -import android.hardware.camera.metadata@3.4; -import android.hardware.camera.metadata@3.5; -import android.hardware.camera.metadata@3.6; -import android.hardware.camera.metadata@3.7; - -/** - * Top level hierarchy definitions for camera metadata. *_INFO sections are for - * the static metadata that can be retrieved without opening the camera device. - */ -enum CameraMetadataSection : @3.4::CameraMetadataSection { - ANDROID_AUTOMOTIVE = - android.hardware.camera.metadata@3.4::CameraMetadataSection:ANDROID_SECTION_COUNT, - - ANDROID_AUTOMOTIVE_LENS, - - ANDROID_SECTION_COUNT_3_8, - - VENDOR_SECTION_3_8 = 0x8000, - -}; - -/** - * Hierarchy positions in enum space. All vendor extension sections must be - * defined with tag >= VENDOR_SECTION_START - */ -enum CameraMetadataSectionStart : android.hardware.camera.metadata@3.4::CameraMetadataSectionStart { - ANDROID_AUTOMOTIVE_START = CameraMetadataSection:ANDROID_AUTOMOTIVE << 16, - - ANDROID_AUTOMOTIVE_LENS_START = CameraMetadataSection:ANDROID_AUTOMOTIVE_LENS << 16, - - VENDOR_SECTION_START_3_8 = CameraMetadataSection:VENDOR_SECTION_3_8 << 16, - -}; - -/** - * Main enumeration for defining camera metadata tags added in this revision - * - *

Partial documentation is included for each tag; for complete documentation, reference - * '/system/media/camera/docs/docs.html' in the corresponding Android source tree.

- */ -enum CameraMetadataTag : @3.7::CameraMetadataTag { - /** android.flash.info.strengthMaximumLevel [static, int32, public] - * - *

Maximum flashlight brightness level.

- */ - ANDROID_FLASH_INFO_STRENGTH_MAXIMUM_LEVEL = android.hardware.camera.metadata@3.2::CameraMetadataTag:ANDROID_FLASH_INFO_END, - - /** android.flash.info.strengthDefaultLevel [static, int32, public] - * - *

Default flashlight brightness level to be set via - * {android.hardware.camera2.CameraManager#turnOnTorchWithStrengthLevel}.

- */ - ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL, - - ANDROID_FLASH_INFO_END_3_8, - - /** android.request.availableDynamicRangeProfilesMap [static, enum[], ndk_public] - * - *

A map of all available 10-bit dynamic range profiles along with their - * capture request constraints.

- */ - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP = android.hardware.camera.metadata@3.4::CameraMetadataTag:ANDROID_REQUEST_END_3_4, - - /** android.request.recommendedTenBitDynamicRangeProfile [static, int64, java_public] - * - *

Recommended 10-bit dynamic range profile.

- */ - ANDROID_REQUEST_RECOMMENDED_TEN_BIT_DYNAMIC_RANGE_PROFILE, - - ANDROID_REQUEST_END_3_8, - - /** android.scaler.availableStreamUseCases [static, enum[], public] - * - *

The stream use cases supported by this camera device.

- */ - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES = android.hardware.camera.metadata@3.6::CameraMetadataTag:ANDROID_SCALER_END_3_6, - - ANDROID_SCALER_END_3_8, - - /** android.automotive.location [static, enum, public] - * - *

Location of the cameras on the automotive devices.

- */ - ANDROID_AUTOMOTIVE_LOCATION = CameraMetadataSectionStart:ANDROID_AUTOMOTIVE_START, - - ANDROID_AUTOMOTIVE_END_3_8, - - /** android.automotive.lens.facing [static, enum[], public] - * - *

The direction of the camera faces relative to the vehicle body frame and the - * passenger seats.

- */ - ANDROID_AUTOMOTIVE_LENS_FACING = CameraMetadataSectionStart:ANDROID_AUTOMOTIVE_LENS_START, - - ANDROID_AUTOMOTIVE_LENS_END_3_8, - -}; - -/* - * Enumeration definitions for the various entries that need them - */ - -/** android.control.videoStabilizationMode enumeration values added since v3.2 - * @see ANDROID_CONTROL_VIDEO_STABILIZATION_MODE - */ -enum CameraMetadataEnumAndroidControlVideoStabilizationMode : - @3.2::CameraMetadataEnumAndroidControlVideoStabilizationMode { - ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION, -}; - -/** android.lens.poseReference enumeration values added since v3.5 - * @see ANDROID_LENS_POSE_REFERENCE - */ -enum CameraMetadataEnumAndroidLensPoseReference : - @3.5::CameraMetadataEnumAndroidLensPoseReference { - ANDROID_LENS_POSE_REFERENCE_AUTOMOTIVE, -}; - -/** android.request.availableCapabilities enumeration values added since v3.6 - * @see ANDROID_REQUEST_AVAILABLE_CAPABILITIES - */ -enum CameraMetadataEnumAndroidRequestAvailableCapabilities : - @3.6::CameraMetadataEnumAndroidRequestAvailableCapabilities { - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT, - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE, -}; - -/** android.request.availableDynamicRangeProfilesMap enumeration values - * @see ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP - */ -enum CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap : int64_t { - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD - = 0x1, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HLG10 = 0x2, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10 = 0x4, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10_PLUS - = 0x8, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF - = 0x10, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF_PO - = 0x20, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM - = 0x40, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM_PO - = 0x80, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF - = 0x100, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF_PO - = 0x200, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM - = 0x400, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM_PO - = 0x800, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_MAX = 0x1000, -}; - -/** android.scaler.availableRecommendedStreamConfigurations enumeration values added since v3.4 - * @see ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS - */ -enum CameraMetadataEnumAndroidScalerAvailableRecommendedStreamConfigurations : - @3.4::CameraMetadataEnumAndroidScalerAvailableRecommendedStreamConfigurations { - ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_10BIT_OUTPUT - = 0x8, - ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PUBLIC_END_3_8 - = 0x9, -}; - -/** android.scaler.availableStreamUseCases enumeration values - * @see ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES - */ -enum CameraMetadataEnumAndroidScalerAvailableStreamUseCases : int64_t { - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT = 0x0, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW = 0x1, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_STILL_CAPTURE = 0x2, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_RECORD = 0x3, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW_VIDEO_STILL - = 0x4, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_CALL = 0x5, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_VENDOR_START = 0x10000, -}; - -/** android.automotive.location enumeration values - * @see ANDROID_AUTOMOTIVE_LOCATION - */ -enum CameraMetadataEnumAndroidAutomotiveLocation : uint32_t { - ANDROID_AUTOMOTIVE_LOCATION_INTERIOR, - ANDROID_AUTOMOTIVE_LOCATION_EXTERIOR_OTHER, - ANDROID_AUTOMOTIVE_LOCATION_EXTERIOR_FRONT, - ANDROID_AUTOMOTIVE_LOCATION_EXTERIOR_REAR, - ANDROID_AUTOMOTIVE_LOCATION_EXTERIOR_LEFT, - ANDROID_AUTOMOTIVE_LOCATION_EXTERIOR_RIGHT, - ANDROID_AUTOMOTIVE_LOCATION_EXTRA_OTHER, - ANDROID_AUTOMOTIVE_LOCATION_EXTRA_FRONT, - ANDROID_AUTOMOTIVE_LOCATION_EXTRA_REAR, - ANDROID_AUTOMOTIVE_LOCATION_EXTRA_LEFT, - ANDROID_AUTOMOTIVE_LOCATION_EXTRA_RIGHT, -}; - -/** android.automotive.lens.facing enumeration values - * @see ANDROID_AUTOMOTIVE_LENS_FACING - */ -enum CameraMetadataEnumAndroidAutomotiveLensFacing : uint32_t { - ANDROID_AUTOMOTIVE_LENS_FACING_EXTERIOR_OTHER, - ANDROID_AUTOMOTIVE_LENS_FACING_EXTERIOR_FRONT, - ANDROID_AUTOMOTIVE_LENS_FACING_EXTERIOR_REAR, - ANDROID_AUTOMOTIVE_LENS_FACING_EXTERIOR_LEFT, - ANDROID_AUTOMOTIVE_LENS_FACING_EXTERIOR_RIGHT, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_OTHER, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_1_LEFT, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_1_CENTER, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_1_RIGHT, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_2_LEFT, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_2_CENTER, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_2_RIGHT, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_3_LEFT, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_3_CENTER, - ANDROID_AUTOMOTIVE_LENS_FACING_INTERIOR_SEAT_ROW_3_RIGHT, -}; diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp index 2f24dfd503..85e69eb866 100644 --- a/camera/provider/2.4/vts/functional/Android.bp +++ b/camera/provider/2.4/vts/functional/Android.bp @@ -50,9 +50,7 @@ cc_test { "android.hardware.camera.device@3.5", "android.hardware.camera.device@3.6", "android.hardware.camera.device@3.7", - "android.hardware.camera.device@3.8", "android.hardware.camera.metadata@3.4", - "android.hardware.camera.metadata@3.8", "android.hardware.camera.provider@2.4", "android.hardware.camera.provider@2.5", "android.hardware.camera.provider@2.6", diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index f89c71d241..6866776ba5 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -42,14 +42,9 @@ #include #include #include -#include #include -#include #include -#include -#include #include -#include #include #include #include @@ -134,10 +129,6 @@ using ::android::hardware::camera::metadata::V3_4:: CameraMetadataEnumAndroidSensorInfoColorFilterArrangement; using ::android::hardware::camera::metadata::V3_4::CameraMetadataTag; using ::android::hardware::camera::metadata::V3_6::CameraMetadataEnumAndroidSensorPixelMode; -using ::android::hardware::camera::metadata::V3_8:: - CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap; -using ::android::hardware::camera::metadata::V3_8:: - CameraMetadataEnumAndroidScalerAvailableStreamUseCases; using ::android::hardware::camera::provider::V2_4::ICameraProvider; using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback; using ::android::hardware::camera::provider::V2_6::CameraIdAndStreamCombination; @@ -233,8 +224,7 @@ const static std::vector kMandatoryUseCases = { namespace { // "device@/legacy/" - const char *kDeviceNameRE = "device@([0-9]+\\.[0-9]+)/%s/(.+)"; - const int CAMERA_DEVICE_API_VERSION_3_8 = 0x308; + const char* kDeviceNameRE = "device@([0-9]+\\.[0-9]+)/%s/(.+)"; const int CAMERA_DEVICE_API_VERSION_3_7 = 0x307; const int CAMERA_DEVICE_API_VERSION_3_6 = 0x306; const int CAMERA_DEVICE_API_VERSION_3_5 = 0x305; @@ -242,19 +232,16 @@ namespace { const int CAMERA_DEVICE_API_VERSION_3_3 = 0x303; const int CAMERA_DEVICE_API_VERSION_3_2 = 0x302; const int CAMERA_DEVICE_API_VERSION_1_0 = 0x100; - const char *kHAL3_8 = "3.8"; - const char *kHAL3_7 = "3.7"; - const char *kHAL3_6 = "3.6"; - const char *kHAL3_5 = "3.5"; - const char *kHAL3_4 = "3.4"; - const char *kHAL3_3 = "3.3"; - const char *kHAL3_2 = "3.2"; - const char *kHAL1_0 = "1.0"; - - bool matchDeviceName(const hidl_string& deviceName, - const hidl_string &providerType, - std::string* deviceVersion, - std::string* cameraId) { + const char* kHAL3_7 = "3.7"; + const char* kHAL3_6 = "3.6"; + const char* kHAL3_5 = "3.5"; + const char* kHAL3_4 = "3.4"; + const char* kHAL3_3 = "3.3"; + const char* kHAL3_2 = "3.2"; + const char* kHAL1_0 = "1.0"; + + bool matchDeviceName(const hidl_string& deviceName, const hidl_string& providerType, + std::string* deviceVersion, std::string* cameraId) { ::android::String8 pattern; pattern.appendFormat(kDeviceNameRE, providerType.c_str()); std::regex e(pattern.string()); @@ -280,9 +267,7 @@ namespace { return -1; } - if (version.compare(kHAL3_8) == 0) { - return CAMERA_DEVICE_API_VERSION_3_8; - } else if (version.compare(kHAL3_7) == 0) { + if (version.compare(kHAL3_7) == 0) { return CAMERA_DEVICE_API_VERSION_3_7; } else if (version.compare(kHAL3_6) == 0) { return CAMERA_DEVICE_API_VERSION_3_6; @@ -652,7 +637,8 @@ public: } virtual Return processCaptureResult_3_4( - const hidl_vec& /*results*/) override { + + const hidl_vec& /*results*/) override { ALOGI("processCaptureResult_3_4 callback"); ADD_FAILURE(); // Empty callback should not reach here return Void(); @@ -682,44 +668,41 @@ public: } }; - struct DeviceCb : public V3_8::ICameraDeviceCallback { - DeviceCb(CameraHidlTest *parent, int deviceVersion, const camera_metadata_t *staticMeta) : - mParent(parent), mDeviceVersion(deviceVersion) { + struct DeviceCb : public V3_5::ICameraDeviceCallback { + DeviceCb(CameraHidlTest* parent, int deviceVersion, const camera_metadata_t* staticMeta) + : mParent(parent), mDeviceVersion(deviceVersion) { mStaticMetadata = staticMeta; } - Return processCaptureResult_3_4( - const hidl_vec& results) override; + Return processCaptureResult_3_4(const hidl_vec& results) override; Return processCaptureResult(const hidl_vec& results) override; Return notify(const hidl_vec& msgs) override; - Return notify_3_8(const hidl_vec& msgs) override; - Return requestStreamBuffers( - const hidl_vec& bufReqs, - requestStreamBuffers_cb _hidl_cb) override; + Return requestStreamBuffers(const hidl_vec& bufReqs, + requestStreamBuffers_cb _hidl_cb) override; Return returnStreamBuffers(const hidl_vec& buffers) override; void setCurrentStreamConfig(const hidl_vec& streams, - const hidl_vec& halStreams); + const hidl_vec& halStreams); void waitForBuffersReturned(); private: bool processCaptureResultLocked(const CaptureResult& results, - hidl_vec physicalCameraMetadata); + hidl_vec physicalCameraMetadata); Return notifyHelper(const hidl_vec& msgs, - const std::vector>& readoutTimestamps); + const std::vector>& readoutTimestamps); - CameraHidlTest *mParent; // Parent object + CameraHidlTest* mParent; // Parent object int mDeviceVersion; android::hardware::camera::common::V1_0::helper::CameraMetadata mStaticMetadata; bool hasOutstandingBuffersLocked(); /* members for requestStreamBuffers() and returnStreamBuffers()*/ - std::mutex mLock; // protecting members below - bool mUseHalBufManager = false; - hidl_vec mStreams; + std::mutex mLock; // protecting members below + bool mUseHalBufManager = false; + hidl_vec mStreams; hidl_vec mHalStreams; uint64_t mNextBufferId = 1; using OutstandingBuffers = std::unordered_map; @@ -814,20 +797,18 @@ public: sp* provider2_5 /*out*/, sp* provider2_6 /*out*/, sp* provider2_7 /*out*/); - void castSession(const sp &session, int32_t deviceVersion, - sp *session3_3 /*out*/, - sp *session3_4 /*out*/, - sp *session3_5 /*out*/, - sp *session3_6 /*out*/, - sp *session3_7 /*out*/, - sp *session3_8 /*out*/); + void castSession(const sp& session, int32_t deviceVersion, + sp* session3_3 /*out*/, + sp* session3_4 /*out*/, + sp* session3_5 /*out*/, + sp* session3_6 /*out*/, + sp* session3_7 /*out*/); void castInjectionSession( const sp& session, sp* injectionSession3_7 /*out*/); void castDevice(const sp& device, int32_t deviceVersion, sp* device3_5 /*out*/, - sp* device3_7 /*out*/, - sp* device3_8 /*out*/); + sp* device3_7 /*out*/); void createStreamConfiguration( const ::android::hardware::hidl_vec& streams3_2, StreamConfigurationMode configMode, @@ -857,16 +838,6 @@ public: uint32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/, sp* outCb /*out*/, uint32_t streamConfigCounter, bool maxResolution); - void configureStreams3_8(const std::string& name, int32_t deviceVersion, - sp provider, PixelFormat format, - sp* session3_8 /*out*/, - V3_2::Stream* previewStream /*out*/, - device::V3_6::HalStreamConfiguration* halStreamConfig /*out*/, - bool* supportsPartialResults /*out*/, - uint32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/, - sp* outCb /*out*/, uint32_t streamConfigCounter, - bool maxResolution, - CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap prof); void configurePreviewStreams3_4(const std::string &name, int32_t deviceVersion, sp provider, @@ -947,9 +918,6 @@ public: static bool isDepthOnly(const camera_metadata_t* staticMeta); static bool isUltraHighResolution(const camera_metadata_t* staticMeta); - static void get10BitDynamicRangeProfiles(const camera_metadata_t* staticMeta, - std::vector *profiles); - static bool is10BitDynamicRangeCapable(const camera_metadata_t* staticMeta); static Status getAvailableOutputStreams(const camera_metadata_t* staticMeta, std::vector& outputStreams, @@ -1130,10 +1098,6 @@ protected: expectedPhysicalResults(extraPhysicalResult) {} }; - static void verify10BitMetadata(HandleImporter& importer, - const InFlightRequest& request, - CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap profile); - // Map from frame number to the in-flight request state typedef ::android::KeyedVector InFlightMap; @@ -1564,32 +1528,6 @@ void CameraHidlTest::DeviceCb::waitForBuffersReturned() { } } -Return CameraHidlTest::DeviceCb::notify_3_8( - const hidl_vec& msgs) { - hidl_vec msgs3_2; - std::vector> readoutTimestamps; - - nsecs_t count = msgs.size(); - msgs3_2.resize(count); - readoutTimestamps.resize(count); - - for (size_t i = 0; i < count; i++) { - msgs3_2[i].type = msgs[i].type; - switch (msgs[i].type) { - case MsgType::ERROR: - msgs3_2[i].msg.error = msgs[i].msg.error; - readoutTimestamps[i] = {false, 0}; - break; - case MsgType::SHUTTER: - msgs3_2[i].msg.shutter = msgs[i].msg.shutter.v3_2; - readoutTimestamps[i] = {true, msgs[i].msg.shutter.readoutTimestamp}; - break; - } - } - - return notifyHelper(msgs3_2, readoutTimestamps); -} - Return CameraHidlTest::DeviceCb::notify( const hidl_vec& messages) { std::vector> readoutTimestamps; @@ -2082,7 +2020,6 @@ TEST_P(CameraHidlTest, getCameraDeviceInterface) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -2127,7 +2064,6 @@ TEST_P(CameraHidlTest, getResourceCost) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -2869,7 +2805,6 @@ TEST_P(CameraHidlTest, systemCameraTest) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -2957,7 +2892,6 @@ TEST_P(CameraHidlTest, getCameraCharacteristics) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -3018,137 +2952,6 @@ TEST_P(CameraHidlTest, getCameraCharacteristics) { } } -// Verify that the torch strength level can be set and retrieved successfully. -TEST_P(CameraHidlTest, turnOnTorchWithStrengthLevel) { - hidl_vec cameraDeviceNames = getCameraDeviceNames(mProvider); - bool torchControlSupported = false; - bool torchStrengthControlSupported = false; - Return ret; - - ret = mProvider->isSetTorchModeSupported([&](auto status, bool support) { - ALOGI("isSetTorchModeSupported returns status:%d supported:%d", (int)status, support); - ASSERT_EQ(Status::OK, status); - torchControlSupported = support; - }); - - sp cb = new TorchProviderCb(this); - Return returnStatus = mProvider->setCallback(cb); - ASSERT_TRUE(returnStatus.isOk()); - ASSERT_EQ(Status::OK, returnStatus); - - for (const auto& name : cameraDeviceNames) { - int deviceVersion = getCameraDeviceVersion(name, mProviderType); - int32_t defaultLevel; - switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: { - ::android::sp<::android::hardware::camera::device::V3_8::ICameraDevice> device3_8; - ALOGI("%s: Testing camera device %s", __FUNCTION__, name.c_str()); - ret = mProvider->getCameraDeviceInterface_V3_x( - name, [&](auto status, const auto& device) { - ASSERT_EQ(Status::OK, status); - ASSERT_NE(device, nullptr); - auto castResult = device::V3_8::ICameraDevice::castFrom(device); - ASSERT_TRUE(castResult.isOk()); - device3_8 = castResult; - }); - ASSERT_TRUE(ret.isOk()); - - ret = device3_8->getCameraCharacteristics([&] (auto s, const auto& chars) { - ASSERT_EQ(Status::OK, s); - const camera_metadata_t* staticMeta = - reinterpret_cast(chars.data()); - ASSERT_NE(nullptr, staticMeta); - torchStrengthControlSupported = isTorchStrengthControlSupported(staticMeta); - camera_metadata_ro_entry entry; - int rc = find_camera_metadata_ro_entry(staticMeta, - ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL, &entry); - if (torchStrengthControlSupported) { - ASSERT_EQ(rc, 0); - ASSERT_GT(entry.count, 0); - defaultLevel = *entry.data.i32; - ALOGI("Default level is:%d", defaultLevel); - } - }); - ASSERT_TRUE(ret.isOk()); - // If torchStrengthControl is supported, torchControlSupported should be true. - if (torchStrengthControlSupported) { - ASSERT_TRUE(torchControlSupported); - } - mTorchStatus = TorchModeStatus::NOT_AVAILABLE; - returnStatus = device3_8->turnOnTorchWithStrengthLevel(2); - ASSERT_TRUE(returnStatus.isOk()); - // Method_not_supported check - if (!torchStrengthControlSupported) { - ALOGI("Torch strength control not supported."); - ASSERT_EQ(Status::METHOD_NOT_SUPPORTED, returnStatus); - } else { - ASSERT_EQ(Status::OK, returnStatus); - if (returnStatus == Status::OK) { - { - std::unique_lock l(mTorchLock); - while (TorchModeStatus::NOT_AVAILABLE == mTorchStatus) { - auto timeout = std::chrono::system_clock::now() + - std::chrono::seconds(kTorchTimeoutSec); - ASSERT_NE(std::cv_status::timeout, mTorchCond.wait_until(l, - timeout)); - } - ASSERT_EQ(TorchModeStatus::AVAILABLE_ON, mTorchStatus); - mTorchStatus = TorchModeStatus::NOT_AVAILABLE; - } - ALOGI("getTorchStrengthLevel: Testing"); - ret = device3_8->getTorchStrengthLevel([&] - (auto status, const auto& strengthLevel) { - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Status::OK, status); - ALOGI("Torch strength level is : %d", strengthLevel); - ASSERT_EQ(strengthLevel, 2); - }); - // Turn OFF the torch and verify torch strength level is reset to default level. - ALOGI("Testing torch strength level reset after turning the torch OFF."); - returnStatus = device3_8->setTorchMode(TorchMode::OFF); - ASSERT_TRUE(returnStatus.isOk()); - ASSERT_EQ(Status::OK, returnStatus); - { - std::unique_lock l(mTorchLock); - while (TorchModeStatus::NOT_AVAILABLE == mTorchStatus) { - auto timeout = std::chrono::system_clock::now() + - std::chrono::seconds(kTorchTimeoutSec); - ASSERT_NE(std::cv_status::timeout, mTorchCond.wait_until(l, - timeout)); - } - ASSERT_EQ(TorchModeStatus::AVAILABLE_OFF, mTorchStatus); - } - ret = device3_8->getTorchStrengthLevel([&] - (auto status, const auto& strengthLevel) { - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Status::OK, status); - ALOGI("Torch strength level after turning OFF torch is : %d", - strengthLevel); - ASSERT_EQ(strengthLevel, defaultLevel); - }); - } - } - } - break; - case CAMERA_DEVICE_API_VERSION_3_7: - case CAMERA_DEVICE_API_VERSION_3_6: - case CAMERA_DEVICE_API_VERSION_3_5: - case CAMERA_DEVICE_API_VERSION_3_4: - case CAMERA_DEVICE_API_VERSION_3_3: - case CAMERA_DEVICE_API_VERSION_3_2: - case CAMERA_DEVICE_API_VERSION_1_0: { - ALOGI("Torch strength control feature not supported."); - } - break; - default: { - ALOGI("Invalid device version."); - ADD_FAILURE(); - } - break; - } - } -} - //In case it is supported verify that torch can be enabled. //Check for corresponding toch callbacks as well. TEST_P(CameraHidlTest, setTorchMode) { @@ -3170,7 +2973,6 @@ TEST_P(CameraHidlTest, setTorchMode) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -3299,7 +3101,6 @@ TEST_P(CameraHidlTest, dumpState) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -3367,7 +3168,6 @@ TEST_P(CameraHidlTest, openClose) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -3401,13 +3201,10 @@ TEST_P(CameraHidlTest, openClose) { sp sessionV3_5; sp sessionV3_6; sp sessionV3_7; - sp sessionV3_8; - castSession(session, deviceVersion, &sessionV3_3, - &sessionV3_4, &sessionV3_5, &sessionV3_6, - &sessionV3_7, &sessionV3_8); - if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_8) { - ASSERT_TRUE(sessionV3_8.get() != nullptr); - } else if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_7) { + castSession(session, deviceVersion, &sessionV3_3, &sessionV3_4, &sessionV3_5, + &sessionV3_6, &sessionV3_7); + + if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_7) { ASSERT_TRUE(sessionV3_7.get() != nullptr); } else if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_6) { ASSERT_TRUE(sessionV3_6.get() != nullptr); @@ -3417,7 +3214,7 @@ TEST_P(CameraHidlTest, openClose) { ASSERT_TRUE(sessionV3_4.get() != nullptr); } else if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_3) { ASSERT_TRUE(sessionV3_3.get() != nullptr); - } else { //V3_2 + } else { // V3_2 ASSERT_TRUE(sessionV3_3.get() == nullptr); ASSERT_TRUE(sessionV3_4.get() == nullptr); ASSERT_TRUE(sessionV3_5.get() == nullptr); @@ -3473,7 +3270,6 @@ TEST_P(CameraHidlTest, constructDefaultRequestSettings) { for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: case CAMERA_DEVICE_API_VERSION_3_7: case CAMERA_DEVICE_API_VERSION_3_6: case CAMERA_DEVICE_API_VERSION_3_5: @@ -3575,17 +3371,14 @@ TEST_P(CameraHidlTest, configureStreamsAvailableOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); + castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); outputStreams.clear(); ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputStreams)); @@ -3681,11 +3474,9 @@ TEST_P(CameraHidlTest, configureConcurrentStreamsAvailableOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; ::android::hardware::camera::device::V3_7::StreamConfiguration config3_7; ::android::hardware::camera::device::V3_5::StreamConfiguration config3_5; ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4; @@ -3722,9 +3513,8 @@ TEST_P(CameraHidlTest, configureConcurrentStreamsAvailableOutputs) { openEmptyDeviceSession(name, mProvider2_6, &cti.session /*out*/, &cti.staticMeta /*out*/, &cti.cameraDevice /*out*/); castSession(cti.session, deviceVersion, &cti.session3_3, &cti.session3_4, - &cti.session3_5, &cti.session3_6, &cti.session3_7, &cti.session3_8); - castDevice(cti.cameraDevice, deviceVersion, &cti.cameraDevice3_5, &cti.cameraDevice3_7, - &cti.cameraDevice3_8); + &cti.session3_5, &cti.session3_6, &cti.session3_7); + castDevice(cti.cameraDevice, deviceVersion, &cti.cameraDevice3_5, &cti.cameraDevice3_7); outputStreams.clear(); ASSERT_EQ(Status::OK, getMandatoryConcurrentStreams(cti.staticMeta, &outputStreams)); @@ -3853,17 +3643,14 @@ TEST_P(CameraHidlTest, configureStreamsInvalidOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); + castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); outputStreams.clear(); ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputStreams)); @@ -4069,17 +3856,14 @@ TEST_P(CameraHidlTest, configureStreamsZSLInputOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); + castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); Status rc = isZSLModeAvailable(staticMeta); if (Status::METHOD_NOT_SUPPORTED == rc) { @@ -4258,10 +4042,9 @@ TEST_P(CameraHidlTest, configureStreamsWithSessionParameters) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMetaBuffer /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); if (deviceVersion == CAMERA_DEVICE_API_VERSION_3_4) { ASSERT_NE(session3_4, nullptr); } else { @@ -4400,17 +4183,14 @@ TEST_P(CameraHidlTest, configureStreamsPreviewStillOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); + castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); // Check if camera support depth only if (isDepthOnly(staticMeta)) { @@ -4537,17 +4317,14 @@ TEST_P(CameraHidlTest, configureStreamsConstrainedOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); + castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); Status rc = isConstrainedModeAvailable(staticMeta); if (Status::METHOD_NOT_SUPPORTED == rc) { @@ -4820,17 +4597,14 @@ TEST_P(CameraHidlTest, configureStreamsVideoStillOutputs) { sp session3_5; sp session3_6; sp session3_7; - sp session3_8; sp cameraDevice; sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); + castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); // Check if camera support depth only if (isDepthOnly(staticMeta)) { @@ -5069,28 +4843,6 @@ void CameraHidlTest::processCaptureRequestInternal(uint64_t bufferUsage, ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u); ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].buffer.streamId); - // For camera device 3.8 or newer, shutterReadoutTimestamp must be - // available, and it must be >= shutterTimestamp + exposureTime, and - // < shutterTimestamp + exposureTime + rollingShutterSkew / 2. - if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_8) { - ASSERT_TRUE(inflightReq.shutterReadoutTimestampValid); - ASSERT_FALSE(inflightReq.collectedResult.isEmpty()); - if (inflightReq.collectedResult.exists(ANDROID_SENSOR_EXPOSURE_TIME)) { - camera_metadata_entry_t exposureTimeResult = inflightReq.collectedResult.find( - ANDROID_SENSOR_EXPOSURE_TIME); - nsecs_t exposureToReadout = - inflightReq.shutterReadoutTimestamp - inflightReq.shutterTimestamp; - ASSERT_GE(exposureToReadout, exposureTimeResult.data.i64[0]); - if (inflightReq.collectedResult.exists(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW)) { - camera_metadata_entry_t rollingShutterSkew = - inflightReq.collectedResult.find( - ANDROID_SENSOR_ROLLING_SHUTTER_SKEW); - ASSERT_LT(exposureToReadout, exposureTimeResult.data.i64[0] + - rollingShutterSkew.data.i64[0] / 2); - } - } - } - request.frameNumber++; // Empty settings should be supported after the first call // for repeating requests. @@ -5114,20 +4866,6 @@ void CameraHidlTest::processCaptureRequestInternal(uint64_t bufferUsage, ASSERT_EQ(Status::OK, status); ASSERT_EQ(numRequestProcessed, 1u); - if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_8) { - sp session3_3; - sp session3_4; - sp session3_5; - sp session3_6; - sp session3_7; - sp session3_8; - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - ASSERT_TRUE(session3_8.get() != nullptr); - hidl_vec streamIds = { halStreamConfig.streams[0].id }; - session3_8->repeatingRequestEnd(request.frameNumber, streamIds); - } - { std::unique_lock l(mLock); while (!inflightReq.errorCodeValid && @@ -5153,196 +4891,6 @@ void CameraHidlTest::processCaptureRequestInternal(uint64_t bufferUsage, } } -TEST_P(CameraHidlTest, processCaptureRequestPreviewStabilization) { - std::unordered_map cameraDeviceToTimeLag; - processPreviewStabilizationCaptureRequestInternal(/*previewStabilizationOn*/ false, - cameraDeviceToTimeLag); - processPreviewStabilizationCaptureRequestInternal(/*previewStabilizationOn*/ true, - cameraDeviceToTimeLag); -} - -void CameraHidlTest::processPreviewStabilizationCaptureRequestInternal( - bool previewStabilizationOn, - // Used as output when preview stabilization is off, as output when its - // on. - std::unordered_map& cameraDeviceToTimeLag) { - hidl_vec cameraDeviceNames = getCameraDeviceNames(mProvider); - AvailableStream streamThreshold = {kMaxPreviewWidth, kMaxPreviewHeight, - static_cast(PixelFormat::IMPLEMENTATION_DEFINED)}; - uint64_t bufferId = 1; - uint32_t frameNumber = 1; - ::android::hardware::hidl_vec settings; - - for (const auto& name : cameraDeviceNames) { - int deviceVersion = getCameraDeviceVersion(name, mProviderType); - if (deviceVersion == CAMERA_DEVICE_API_VERSION_1_0) { - continue; - } else if (deviceVersion <= 0) { - ALOGE("%s: Unsupported device version %d", __func__, deviceVersion); - ADD_FAILURE(); - return; - } - - if (!supportsPreviewStabilization(name, mProvider)) { - ALOGI(" %s Camera device %s doesn't support preview stabilization, skipping", __func__, - name.c_str()); - continue; - } - - if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_8) { - ALOGE("%s: device version < 3.8 must not advertise preview stabilization," - " camera metadata validation will fail", - __func__); - ADD_FAILURE(); - } - - V3_2::Stream testStream; - HalStreamConfiguration halStreamConfig; - sp session; - sp cb; - bool supportsPartialResults = false; - bool useHalBufManager = false; - uint32_t partialResultCount = 0; - configureSingleStream(name, deviceVersion, mProvider, &streamThreshold, - GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, RequestTemplate::PREVIEW, - &session /*out*/, &testStream /*out*/, &halStreamConfig /*out*/, - &supportsPartialResults /*out*/, &partialResultCount /*out*/, - &useHalBufManager /*out*/, &cb /*out*/); - - std::shared_ptr resultQueue; - auto resultQueueRet = - session->getCaptureResultMetadataQueue([&resultQueue](const auto& descriptor) { - resultQueue = std::make_shared(descriptor); - if (!resultQueue->isValid() || resultQueue->availableToWrite() <= 0) { - ALOGE("%s: HAL returns empty result metadata fmq," - " not use it", - __func__); - resultQueue = nullptr; - // Don't use the queue onwards. - } - }); - ASSERT_TRUE(resultQueueRet.isOk()); - - InFlightRequest inflightReq = {1, false, supportsPartialResults, partialResultCount, - resultQueue}; - - Return ret; - android::hardware::camera::common::V1_0::helper::CameraMetadata defaultSettings; - ret = session->constructDefaultRequestSettings( - RequestTemplate::PREVIEW, [&](auto status, const auto& req) { - ASSERT_EQ(Status::OK, status); - const camera_metadata_t* metadata = - reinterpret_cast(req.data()); - defaultSettings = metadata; - settings = req; - }); - ASSERT_TRUE(ret.isOk()); - android::status_t metadataRet = ::android::OK; - uint8_t videoStabilizationMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF; - if (previewStabilizationOn) { - videoStabilizationMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION; - metadataRet = defaultSettings.update(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, - &videoStabilizationMode, 1); - } else { - metadataRet = defaultSettings.update(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, - &videoStabilizationMode, 1); - } - ASSERT_EQ(metadataRet, ::android::OK); - hidl_handle buffer_handle; - StreamBuffer outputBuffer; - if (useHalBufManager) { - outputBuffer = {halStreamConfig.streams[0].id, - /*bufferId*/ 0, - buffer_handle, - BufferStatus::OK, - nullptr, - nullptr}; - } else { - allocateGraphicBuffer( - testStream.width, testStream.height, - /* We don't look at halStreamConfig.streams[0].consumerUsage - * since that is 0 for output streams - */ - android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage, - GRALLOC1_CONSUMER_USAGE_HWCOMPOSER), - halStreamConfig.streams[0].overrideFormat, &buffer_handle); - outputBuffer = {halStreamConfig.streams[0].id, - bufferId, - buffer_handle, - BufferStatus::OK, - nullptr, - nullptr}; - } - ::android::hardware::hidl_vec outputBuffers = {outputBuffer}; - StreamBuffer emptyInputBuffer = {-1, 0, nullptr, BufferStatus::ERROR, nullptr, nullptr}; - CaptureRequest request = {frameNumber, 0 /* fmqSettingsSize */, settings, emptyInputBuffer, - outputBuffers}; - - { - std::unique_lock l(mLock); - mInflightMap.clear(); - mInflightMap.add(frameNumber, &inflightReq); - } - - Status status = Status::INTERNAL_ERROR; - uint32_t numRequestProcessed = 0; - hidl_vec cachesToRemove; - Return returnStatus = session->processCaptureRequest( - {request}, cachesToRemove, [&status, &numRequestProcessed](auto s, uint32_t n) { - status = s; - numRequestProcessed = n; - }); - ASSERT_TRUE(returnStatus.isOk()); - ASSERT_EQ(Status::OK, status); - ASSERT_EQ(numRequestProcessed, 1u); - - { - std::unique_lock l(mLock); - while (!inflightReq.errorCodeValid && - ((0 < inflightReq.numBuffersLeft) || (!inflightReq.haveResultMetadata))) { - auto timeout = std::chrono::system_clock::now() + - std::chrono::seconds(kStreamBufferTimeoutSec); - ASSERT_NE(std::cv_status::timeout, mResultCondition.wait_until(l, timeout)); - } - - ASSERT_FALSE(inflightReq.errorCodeValid); - ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u); - ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].buffer.streamId); - ASSERT_TRUE(inflightReq.shutterReadoutTimestampValid); - nsecs_t readoutTimestamp = inflightReq.shutterReadoutTimestamp; - - if (previewStabilizationOn) { - // Here we collect the time difference between the buffer ready - // timestamp - notify readout timestamp. - // timeLag = buffer ready timestamp - notify readout timestamp. - // timeLag(previewStabilization) must be <= - // timeLag(stabilization off) + 1 frame duration. - auto it = cameraDeviceToTimeLag.find(name.c_str()); - camera_metadata_entry e; - e = inflightReq.collectedResult.find(ANDROID_SENSOR_FRAME_DURATION); - ASSERT_TRUE(e.count > 0); - nsecs_t frameDuration = e.data.i64[0]; - ASSERT_TRUE(it != cameraDeviceToTimeLag.end()); - - nsecs_t previewStabOnLagTime = - inflightReq.resultOutputBuffers[0].timeStamp - readoutTimestamp; - ASSERT_TRUE(previewStabOnLagTime <= (it->second + frameDuration)); - } else { - // Fill in the buffer ready timestamp - notify timestamp; - cameraDeviceToTimeLag[std::string(name.c_str())] = - inflightReq.resultOutputBuffers[0].timeStamp - readoutTimestamp; - } - } - - if (useHalBufManager) { - verifyBuffersReturned(session, deviceVersion, testStream.id, cb); - } - - ret = session->close(); - ASSERT_TRUE(ret.isOk()); - } -} - // Generate and verify a multi-camera capture request TEST_P(CameraHidlTest, processMultiCaptureRequestPreview) { hidl_vec cameraDeviceNames = getCameraDeviceNames(mProvider); @@ -5771,226 +5319,44 @@ TEST_P(CameraHidlTest, processUltraHighResolutionRequest) { } } -// Generate and verify 10-bit dynamic range request -TEST_P(CameraHidlTest, process10BitDynamicRangeRequest) { +// Generate and verify a burst containing alternating sensor sensitivity values +TEST_P(CameraHidlTest, processCaptureRequestBurstISO) { hidl_vec cameraDeviceNames = getCameraDeviceNames(mProvider); + AvailableStream previewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight, + static_cast(PixelFormat::IMPLEMENTATION_DEFINED)}; uint64_t bufferId = 1; uint32_t frameNumber = 1; + float isoTol = .03f; ::android::hardware::hidl_vec settings; for (const auto& name : cameraDeviceNames) { int deviceVersion = getCameraDeviceVersion(name, mProviderType); - if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_8) { + if (deviceVersion == CAMERA_DEVICE_API_VERSION_1_0) { continue; + } else if (deviceVersion <= 0) { + ALOGE("%s: Unsupported device version %d", __func__, deviceVersion); + ADD_FAILURE(); + return; } - std::string version, deviceId; - ASSERT_TRUE(::matchDeviceName(name, mProviderType, &version, &deviceId)); - camera_metadata_t* staticMeta; + camera_metadata_t* staticMetaBuffer; Return ret; sp session; - openEmptyDeviceSession(name, mProvider, &session, &staticMeta); - if (!is10BitDynamicRangeCapable(staticMeta)) { - free_camera_metadata(staticMeta); + openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMetaBuffer /*out*/); + ::android::hardware::camera::common::V1_0::helper::CameraMetadata staticMeta( + staticMetaBuffer); + + camera_metadata_entry_t hwLevel = staticMeta.find(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL); + ASSERT_TRUE(0 < hwLevel.count); + if (ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED == hwLevel.data.u8[0] || + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL == hwLevel.data.u8[0]) { + // Limited/External devices can skip this test ret = session->close(); ASSERT_TRUE(ret.isOk()); continue; } - std::vector profileList; - get10BitDynamicRangeProfiles(staticMeta, &profileList); - ASSERT_FALSE(profileList.empty()); - android::hardware::camera::common::V1_0::helper::CameraMetadata defaultSettings; - ret = session->constructDefaultRequestSettings( - RequestTemplate::STILL_CAPTURE, - [&defaultSettings](auto status, const auto& req) mutable { - ASSERT_EQ(Status::OK, status); - - const camera_metadata_t* metadata = - reinterpret_cast(req.data()); - size_t expectedSize = req.size(); - int result = validate_camera_metadata_structure(metadata, &expectedSize); - ASSERT_TRUE((result == 0) || (result == CAMERA_METADATA_VALIDATION_SHIFTED)); - - size_t entryCount = get_camera_metadata_entry_count(metadata); - ASSERT_GT(entryCount, 0u); - defaultSettings = metadata; - }); - ASSERT_TRUE(ret.isOk()); - - const camera_metadata_t* settingsBuffer = defaultSettings.getAndLock(); - settings.setToExternal( - reinterpret_cast(const_cast(settingsBuffer)), - get_camera_metadata_size(settingsBuffer)); - overrideRotateAndCrop(&settings); - - free_camera_metadata(staticMeta); - ret = session->close(); - ASSERT_TRUE(ret.isOk()); - V3_6::HalStreamConfiguration halStreamConfig; - bool supportsPartialResults = false; - bool useHalBufManager = false; - uint32_t partialResultCount = 0; - V3_2::Stream previewStream; - sp session3_8; - sp cb; - for (const auto& profile : profileList) { - configureStreams3_8(name, deviceVersion, mProvider, PixelFormat::IMPLEMENTATION_DEFINED, - &session3_8, &previewStream, &halStreamConfig, - &supportsPartialResults, &partialResultCount, &useHalBufManager, - &cb, 0, /*maxResolution*/ false, profile); - ASSERT_NE(session3_8, nullptr); - - std::shared_ptr resultQueue; - auto resultQueueRet = session3_8->getCaptureResultMetadataQueue( - [&resultQueue](const auto& descriptor) { - resultQueue = std::make_shared(descriptor); - if (!resultQueue->isValid() || resultQueue->availableToWrite() <= 0) { - ALOGE("%s: HAL returns empty result metadata fmq," - " not use it", - __func__); - resultQueue = nullptr; - // Don't use the queue onwards. - } - }); - ASSERT_TRUE(resultQueueRet.isOk()); - - std::vector graphicBuffers; - graphicBuffers.reserve(halStreamConfig.streams.size()); - ::android::hardware::hidl_vec outputBuffers; - outputBuffers.resize(halStreamConfig.streams.size()); - InFlightRequest inflightReq = {static_cast(halStreamConfig.streams.size()), - false, - supportsPartialResults, - partialResultCount, - std::unordered_set(), - resultQueue}; - - size_t k = 0; - for (const auto& halStream : halStreamConfig.streams) { - hidl_handle buffer_handle; - if (useHalBufManager) { - outputBuffers[k] = {halStream.v3_4.v3_3.v3_2.id, - 0, - buffer_handle, - BufferStatus::OK, - nullptr, - nullptr}; - } else { - allocateGraphicBuffer( - previewStream.width, previewStream.height, - android_convertGralloc1To0Usage(halStream.v3_4.v3_3.v3_2.producerUsage, - halStream.v3_4.v3_3.v3_2.consumerUsage), - halStream.v3_4.v3_3.v3_2.overrideFormat, &buffer_handle); - - graphicBuffers.push_back(buffer_handle); - outputBuffers[k] = {halStream.v3_4.v3_3.v3_2.id, - bufferId, - buffer_handle, - BufferStatus::OK, - nullptr, - nullptr}; - bufferId++; - } - k++; - } - - StreamBuffer emptyInputBuffer = {-1, 0, nullptr, BufferStatus::ERROR, nullptr, nullptr}; - V3_4::CaptureRequest request3_4; - request3_4.v3_2.frameNumber = frameNumber; - request3_4.v3_2.fmqSettingsSize = 0; - request3_4.v3_2.settings = settings; - request3_4.v3_2.inputBuffer = emptyInputBuffer; - request3_4.v3_2.outputBuffers = outputBuffers; - V3_7::CaptureRequest request3_7; - request3_7.v3_4 = request3_4; - request3_7.inputWidth = 0; - request3_7.inputHeight = 0; - - { - std::unique_lock l(mLock); - mInflightMap.clear(); - mInflightMap.add(frameNumber, &inflightReq); - } - - Status stat = Status::INTERNAL_ERROR; - uint32_t numRequestProcessed = 0; - hidl_vec cachesToRemove; - Return returnStatus = session3_8->processCaptureRequest_3_7( - {request3_7}, cachesToRemove, - [&stat, &numRequestProcessed](auto s, uint32_t n) { - stat = s; - numRequestProcessed = n; - }); - ASSERT_TRUE(returnStatus.isOk()); - ASSERT_EQ(Status::OK, stat); - ASSERT_EQ(numRequestProcessed, 1u); - - { - std::unique_lock l(mLock); - while (!inflightReq.errorCodeValid && - ((0 < inflightReq.numBuffersLeft) || (!inflightReq.haveResultMetadata))) { - auto timeout = std::chrono::system_clock::now() + - std::chrono::seconds(kStreamBufferTimeoutSec); - ASSERT_NE(std::cv_status::timeout, mResultCondition.wait_until(l, timeout)); - } - - ASSERT_FALSE(inflightReq.errorCodeValid); - ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u); - verify10BitMetadata(mHandleImporter, inflightReq, profile); - } - if (useHalBufManager) { - hidl_vec streamIds(halStreamConfig.streams.size()); - for (size_t i = 0; i < streamIds.size(); i++) { - streamIds[i] = halStreamConfig.streams[i].v3_4.v3_3.v3_2.id; - } - session3_8->signalStreamFlush(streamIds, /*streamConfigCounter*/ 0); - cb->waitForBuffersReturned(); - } - - ret = session3_8->close(); - ASSERT_TRUE(ret.isOk()); - } - } -} - -// Generate and verify a burst containing alternating sensor sensitivity values -TEST_P(CameraHidlTest, processCaptureRequestBurstISO) { - hidl_vec cameraDeviceNames = getCameraDeviceNames(mProvider); - AvailableStream previewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight, - static_cast(PixelFormat::IMPLEMENTATION_DEFINED)}; - uint64_t bufferId = 1; - uint32_t frameNumber = 1; - float isoTol = .03f; - ::android::hardware::hidl_vec settings; - - for (const auto& name : cameraDeviceNames) { - int deviceVersion = getCameraDeviceVersion(name, mProviderType); - if (deviceVersion == CAMERA_DEVICE_API_VERSION_1_0) { - continue; - } else if (deviceVersion <= 0) { - ALOGE("%s: Unsupported device version %d", __func__, deviceVersion); - ADD_FAILURE(); - return; - } - camera_metadata_t* staticMetaBuffer; - Return ret; - sp session; - openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMetaBuffer /*out*/); - ::android::hardware::camera::common::V1_0::helper::CameraMetadata staticMeta( - staticMetaBuffer); - - camera_metadata_entry_t hwLevel = staticMeta.find(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL); - ASSERT_TRUE(0 < hwLevel.count); - if (ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED == hwLevel.data.u8[0] || - ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL == hwLevel.data.u8[0]) { - //Limited/External devices can skip this test - ret = session->close(); - ASSERT_TRUE(ret.isOk()); - continue; - } - - camera_metadata_entry_t isoRange = staticMeta.find(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE); - ASSERT_EQ(isoRange.count, 2u); + camera_metadata_entry_t isoRange = staticMeta.find(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE); + ASSERT_EQ(isoRange.count, 2u); ret = session->close(); ASSERT_TRUE(ret.isOk()); @@ -6946,134 +6312,6 @@ TEST_P(CameraHidlTest, configureInjectionStreamsWithSessionParameters) { } } -// Verify that valid stream use cases can be configured successfully, and invalid use cases -// fail stream configuration. -TEST_P(CameraHidlTest, configureStreamsUseCases) { - hidl_vec cameraDeviceNames = getCameraDeviceNames(mProvider); - - for (const auto& name : cameraDeviceNames) { - int deviceVersion = getCameraDeviceVersion(name, mProviderType); - if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_8) { - continue; - } - - camera_metadata_t* staticMeta; - Return ret; - sp session; - sp session3_3; - sp session3_4; - sp session3_5; - sp session3_6; - sp session3_7; - sp session3_8; - sp cameraDevice; - sp cameraDevice3_5; - sp cameraDevice3_7; - sp cameraDevice3_8; - openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/, - &cameraDevice /*out*/); - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); - ASSERT_NE(nullptr, session3_8); - castDevice(cameraDevice, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, - &cameraDevice3_8); - ASSERT_NE(nullptr, cameraDevice3_8); - - // Check if camera support depth only - if (isDepthOnly(staticMeta)) { - free_camera_metadata(staticMeta); - ret = session->close(); - ASSERT_TRUE(ret.isOk()); - continue; - } - - std::vector outputPreviewStreams; - AvailableStream previewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight, - static_cast(PixelFormat::YCBCR_420_888)}; - ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputPreviewStreams, - &previewThreshold)); - ASSERT_NE(0u, outputPreviewStreams.size()); - - // Combine valid and invalid stream use cases - std::vector useCases(kMandatoryUseCases); - useCases.push_back(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_CALL + 1); - - std::vector supportedUseCases; - camera_metadata_ro_entry entry; - auto retcode = find_camera_metadata_ro_entry(staticMeta, - ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES, &entry); - if ((0 == retcode) && (entry.count > 0)) { - supportedUseCases.insert(supportedUseCases.end(), entry.data.i64, - entry.data.i64 + entry.count); - } else { - supportedUseCases.push_back(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT); - } - free_camera_metadata(staticMeta); - - ::android::hardware::hidl_vec streams3_8(1); - streams3_8[0].v3_7.groupId = -1; - streams3_8[0].v3_7.sensorPixelModesUsed = { - CameraMetadataEnumAndroidSensorPixelMode::ANDROID_SENSOR_PIXEL_MODE_DEFAULT}; - streams3_8[0].v3_7.v3_4.bufferSize = 0; - streams3_8[0].v3_7.v3_4.v3_2.id = 0; - streams3_8[0].v3_7.v3_4.v3_2.streamType = StreamType::OUTPUT; - streams3_8[0].v3_7.v3_4.v3_2.width = static_cast(outputPreviewStreams[0].width); - streams3_8[0].v3_7.v3_4.v3_2.height = static_cast(outputPreviewStreams[0].height); - streams3_8[0].v3_7.v3_4.v3_2.format = - static_cast(outputPreviewStreams[0].format); - streams3_8[0].v3_7.v3_4.v3_2.usage = GRALLOC1_CONSUMER_USAGE_CPU_READ; - streams3_8[0].v3_7.v3_4.v3_2.dataSpace = 0; - streams3_8[0].v3_7.v3_4.v3_2.rotation = StreamRotation::ROTATION_0; - streams3_8[0].dynamicRangeProfile = - static_cast( - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD); - - uint32_t streamConfigCounter = 0; - ::android::hardware::camera::device::V3_8::StreamConfiguration config3_8; - RequestTemplate reqTemplate = RequestTemplate::STILL_CAPTURE; - ret = session3_8->constructDefaultRequestSettings(reqTemplate, - [&config3_8](auto status, const auto& req) { - ASSERT_EQ(Status::OK, status); - config3_8.sessionParams = req; - }); - ASSERT_TRUE(ret.isOk()); - - for (int64_t useCase : useCases) { - bool useCaseSupported = std::find(supportedUseCases.begin(), - supportedUseCases.end(), useCase) != supportedUseCases.end(); - - streams3_8[0].useCase = - static_cast(useCase); - config3_8.streams = streams3_8; - config3_8.operationMode = StreamConfigurationMode::NORMAL_MODE; - config3_8.streamConfigCounter = streamConfigCounter; - config3_8.multiResolutionInputImage = false; - ret = cameraDevice3_8->isStreamCombinationSupported_3_8( - config3_8, [&useCaseSupported](Status s, bool combStatus) { - ASSERT_TRUE((Status::OK == s) || (Status::METHOD_NOT_SUPPORTED == s)); - if (Status::OK == s) { - ASSERT_EQ(combStatus, useCaseSupported); - } - }); - ASSERT_TRUE(ret.isOk()); - - ret = session3_8->configureStreams_3_8( - config3_8, - [&](Status s, device::V3_6::HalStreamConfiguration halConfig) { - if (useCaseSupported) { - ASSERT_EQ(Status::OK, s); - ASSERT_EQ(1u, halConfig.streams.size()); - } else { - ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s); - } - }); - ASSERT_TRUE(ret.isOk()); - } - ret = session3_8->close(); - ASSERT_TRUE(ret.isOk()); - } -} - // Retrieve all valid output stream resolutions from the camera // static characteristics. Status CameraHidlTest::getAvailableOutputStreams(const camera_metadata_t* staticMeta, @@ -7736,9 +6974,8 @@ void CameraHidlTest::configureStreams3_7( sp session3_4; sp session3_5; sp session3_6; - sp session3_8; castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, - session3_7, &session3_8); + session3_7); ASSERT_NE(nullptr, (*session3_7).get()); *useHalBufManager = false; @@ -7786,8 +7023,7 @@ void CameraHidlTest::configureStreams3_7( ASSERT_TRUE(deviceVersion >= CAMERA_DEVICE_API_VERSION_3_7); sp cameraDevice3_5 = nullptr; sp cameraDevice3_7 = nullptr; - sp cameraDevice3_8 = nullptr; - castDevice(device3_x, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, &cameraDevice3_8); + castDevice(device3_x, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); ASSERT_NE(cameraDevice3_7, nullptr); bool supported = false; ret = cameraDevice3_7->isStreamCombinationSupported_3_7( @@ -7820,153 +7056,6 @@ void CameraHidlTest::configureStreams3_7( ASSERT_TRUE(ret.isOk()); } -// Configure streams -void CameraHidlTest::configureStreams3_8( - const std::string& name, int32_t deviceVersion, sp provider, - PixelFormat format, sp* session3_8 /*out*/, - V3_2::Stream* previewStream /*out*/, - device::V3_6::HalStreamConfiguration* halStreamConfig /*out*/, - bool* supportsPartialResults /*out*/, uint32_t* partialResultCount /*out*/, - bool* useHalBufManager /*out*/, sp* outCb /*out*/, uint32_t streamConfigCounter, - bool maxResolution, - CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap prof) { - ASSERT_NE(nullptr, session3_8); - ASSERT_NE(nullptr, halStreamConfig); - ASSERT_NE(nullptr, previewStream); - ASSERT_NE(nullptr, supportsPartialResults); - ASSERT_NE(nullptr, partialResultCount); - ASSERT_NE(nullptr, useHalBufManager); - ASSERT_NE(nullptr, outCb); - ASSERT_TRUE(deviceVersion >= CAMERA_DEVICE_API_VERSION_3_8); - - std::vector outputStreams; - ::android::sp device3_x; - ALOGI("configureStreams: Testing camera device %s", name.c_str()); - Return ret; - ret = provider->getCameraDeviceInterface_V3_x(name, [&](auto status, const auto& device) { - ALOGI("getCameraDeviceInterface_V3_x returns status:%d", (int)status); - ASSERT_EQ(Status::OK, status); - ASSERT_NE(device, nullptr); - device3_x = device; - }); - ASSERT_TRUE(ret.isOk()); - - camera_metadata_t* staticMeta; - ret = device3_x->getCameraCharacteristics([&](Status s, CameraMetadata metadata) { - ASSERT_EQ(Status::OK, s); - staticMeta = - clone_camera_metadata(reinterpret_cast(metadata.data())); - ASSERT_NE(nullptr, staticMeta); - }); - ASSERT_TRUE(ret.isOk()); - - camera_metadata_ro_entry entry; - auto status = - find_camera_metadata_ro_entry(staticMeta, ANDROID_REQUEST_PARTIAL_RESULT_COUNT, &entry); - if ((0 == status) && (entry.count > 0)) { - *partialResultCount = entry.data.i32[0]; - *supportsPartialResults = (*partialResultCount > 1); - } - - sp cb = new DeviceCb(this, deviceVersion, staticMeta); - sp session; - ret = device3_x->open(cb, [&session](auto status, const auto& newSession) { - ALOGI("device::open returns status:%d", (int)status); - ASSERT_EQ(Status::OK, status); - ASSERT_NE(newSession, nullptr); - session = newSession; - }); - ASSERT_TRUE(ret.isOk()); - *outCb = cb; - - sp session3_3; - sp session3_4; - sp session3_5; - sp session3_6; - sp session3_7; - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, - &session3_7, session3_8); - ASSERT_NE(nullptr, (*session3_8).get()); - - *useHalBufManager = false; - status = find_camera_metadata_ro_entry( - staticMeta, ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry); - if ((0 == status) && (entry.count == 1)) { - *useHalBufManager = (entry.data.u8[0] == - ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5); - } - - outputStreams.clear(); - Size maxSize; - auto rc = getMaxOutputSizeForFormat(staticMeta, format, &maxSize, maxResolution); - ASSERT_EQ(Status::OK, rc); - free_camera_metadata(staticMeta); - - ::android::hardware::hidl_vec streams3_8(1); - streams3_8[0].v3_7.groupId = -1; - streams3_8[0].v3_7.sensorPixelModesUsed = { - CameraMetadataEnumAndroidSensorPixelMode::ANDROID_SENSOR_PIXEL_MODE_DEFAULT}; - streams3_8[0].v3_7.v3_4.bufferSize = 0; - streams3_8[0].v3_7.v3_4.v3_2.id = 0; - streams3_8[0].v3_7.v3_4.v3_2.streamType = StreamType::OUTPUT; - streams3_8[0].v3_7.v3_4.v3_2.width = static_cast(maxSize.width); - streams3_8[0].v3_7.v3_4.v3_2.height = static_cast(maxSize.height); - streams3_8[0].v3_7.v3_4.v3_2.format = static_cast(format); - streams3_8[0].v3_7.v3_4.v3_2.usage = GRALLOC1_CONSUMER_USAGE_CPU_READ; - streams3_8[0].v3_7.v3_4.v3_2.dataSpace = 0; - streams3_8[0].v3_7.v3_4.v3_2.rotation = StreamRotation::ROTATION_0; - streams3_8[0].dynamicRangeProfile = prof; - - ::android::hardware::camera::device::V3_8::StreamConfiguration config3_8; - config3_8.streams = streams3_8; - config3_8.operationMode = StreamConfigurationMode::NORMAL_MODE; - config3_8.streamConfigCounter = streamConfigCounter; - config3_8.multiResolutionInputImage = false; - RequestTemplate reqTemplate = RequestTemplate::STILL_CAPTURE; - ret = (*session3_8) - ->constructDefaultRequestSettings(reqTemplate, - [&config3_8](auto status, const auto& req) { - ASSERT_EQ(Status::OK, status); - config3_8.sessionParams = req; - }); - ASSERT_TRUE(ret.isOk()); - - sp cameraDevice3_5 = nullptr; - sp cameraDevice3_7 = nullptr; - sp cameraDevice3_8 = nullptr; - castDevice(device3_x, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, &cameraDevice3_8); - ASSERT_NE(cameraDevice3_8, nullptr); - bool supported = false; - ret = cameraDevice3_8->isStreamCombinationSupported_3_8( - config3_8, [&supported](Status s, bool combStatus) { - ASSERT_TRUE((Status::OK == s) || (Status::METHOD_NOT_SUPPORTED == s)); - if (Status::OK == s) { - supported = combStatus; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(supported, true); - - if (*session3_8 != nullptr) { - ret = (*session3_8) - ->configureStreams_3_8( - config3_8, - [&](Status s, device::V3_6::HalStreamConfiguration halConfig) { - ASSERT_EQ(Status::OK, s); - *halStreamConfig = halConfig; - if (*useHalBufManager) { - hidl_vec streams(1); - hidl_vec halStreams(1); - streams[0] = streams3_8[0].v3_7.v3_4; - halStreams[0] = halConfig.streams[0].v3_4.v3_3.v3_2; - cb->setCurrentStreamConfig(streams, halStreams); - } - }); - } - *previewStream = streams3_8[0].v3_7.v3_4.v3_2; - ASSERT_TRUE(ret.isOk()); -} - // Configure multiple preview streams using different physical ids. void CameraHidlTest::configurePreviewStreams3_4(const std::string &name, int32_t deviceVersion, sp provider, @@ -8041,9 +7130,8 @@ void CameraHidlTest::configurePreviewStreams3_4(const std::string &name, int32_t sp session3_3; sp session3_6; sp session3_7; - sp session3_8; - castSession(session, deviceVersion, &session3_3, session3_4, session3_5, - &session3_6, &session3_7, &session3_8); + castSession(session, deviceVersion, &session3_3, session3_4, session3_5, &session3_6, + &session3_7); ASSERT_NE(nullptr, (*session3_4).get()); *useHalBufManager = false; @@ -8088,8 +7176,7 @@ void CameraHidlTest::configurePreviewStreams3_4(const std::string &name, int32_t if (allowUnsupport) { sp cameraDevice3_5; sp cameraDevice3_7; - sp cameraDevice3_8; - castDevice(device3_x, deviceVersion, &cameraDevice3_5, &cameraDevice3_7, &cameraDevice3_8); + castDevice(device3_x, deviceVersion, &cameraDevice3_5, &cameraDevice3_7); bool supported = false; ret = cameraDevice3_5->isStreamCombinationSupported(config3_4, @@ -8282,95 +7369,6 @@ bool CameraHidlTest::isUltraHighResolution(const camera_metadata_t* staticMeta) return false; } -void CameraHidlTest::get10BitDynamicRangeProfiles(const camera_metadata_t* staticMeta, - std::vector *profiles) { - ASSERT_NE(nullptr, staticMeta); - ASSERT_NE(nullptr, profiles); - camera_metadata_ro_entry entry; - std::unordered_set entries; - int rc = find_camera_metadata_ro_entry(staticMeta, - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP, &entry); - ASSERT_EQ(rc, 0); - ASSERT_TRUE(entry.count > 0); - ASSERT_EQ(entry.count % 3, 0); - - for (uint32_t i = 0; i < entry.count; i += 3) { - ASSERT_NE(entry.data.i64[i], - ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD); - ASSERT_EQ(entries.find(entry.data.i64[i]), entries.end()); - entries.insert(entry.data.i64[i]); - profiles->emplace_back( - static_cast - (entry.data.i64[i])); - } - - if (!entries.empty()) { - ASSERT_NE(entries.find(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HLG10), - entries.end()); - } -} - -bool CameraHidlTest::is10BitDynamicRangeCapable(const camera_metadata_t* staticMeta) { - camera_metadata_ro_entry scalarEntry; - int rc = find_camera_metadata_ro_entry(staticMeta, ANDROID_REQUEST_AVAILABLE_CAPABILITIES, - &scalarEntry); - if (rc == 0) { - for (uint32_t i = 0; i < scalarEntry.count; i++) { - if (scalarEntry.data.u8[i] == - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT) { - return true; - } - } - } - return false; -} - -void CameraHidlTest::verify10BitMetadata(HandleImporter& importer, - const InFlightRequest& request, - CameraMetadataEnumAndroidRequestAvailableDynamicRangeProfilesMap profile) { - for (const auto& b : request.resultOutputBuffers) { - bool smpte2086Present = importer.isSmpte2086Present(b.buffer.buffer.getNativeHandle()); - bool smpte2094_10Present = importer.isSmpte2094_10Present( - b.buffer.buffer.getNativeHandle()); - bool smpte2094_40Present = importer.isSmpte2094_40Present( - b.buffer.buffer.getNativeHandle()); - - switch (static_cast(profile)) { - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HLG10: - ASSERT_FALSE(smpte2086Present); - ASSERT_FALSE(smpte2094_10Present); - ASSERT_FALSE(smpte2094_40Present); - break; - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10: - ASSERT_TRUE(smpte2086Present); - ASSERT_FALSE(smpte2094_10Present); - ASSERT_FALSE(smpte2094_40Present); - break; - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10_PLUS: - ASSERT_FALSE(smpte2086Present); - ASSERT_FALSE(smpte2094_10Present); - ASSERT_TRUE(smpte2094_40Present); - break; - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF_PO: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM_PO: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF_PO: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM: - case ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM_PO: - ASSERT_FALSE(smpte2086Present); - ASSERT_TRUE(smpte2094_10Present); - ASSERT_FALSE(smpte2094_40Present); - break; - default: - ALOGE("%s: Unexpected 10-bit dynamic range profile: %" PRId64, - __FUNCTION__, profile); - ADD_FAILURE(); - } - } -} - bool CameraHidlTest::isDepthOnly(const camera_metadata_t* staticMeta) { camera_metadata_ro_entry scalarEntry; camera_metadata_ro_entry depthEntry; @@ -8534,9 +7532,8 @@ void CameraHidlTest::configureSingleStream( sp session3_5; sp session3_6; sp session3_7; - sp session3_8; - castSession(*session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); + castSession(*session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); *useHalBufManager = false; status = find_camera_metadata_ro_entry(staticMeta, @@ -8667,19 +7664,11 @@ void CameraHidlTest::configureSingleStream( void CameraHidlTest::castDevice(const sp& device, int32_t deviceVersion, sp* device3_5 /*out*/, - sp* device3_7 /*out*/, - sp* device3_8 /*out*/) { + sp* device3_7 /*out*/) { ASSERT_NE(nullptr, device3_5); ASSERT_NE(nullptr, device3_7); - ASSERT_NE(nullptr, device3_8); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: { - auto castResult = device::V3_8::ICameraDevice::castFrom(device); - ASSERT_TRUE(castResult.isOk()); - *device3_8 = castResult; - } - [[fallthrough]]; case CAMERA_DEVICE_API_VERSION_3_7: { auto castResult = device::V3_7::ICameraDevice::castFrom(device); ASSERT_TRUE(castResult.isOk()); @@ -8723,27 +7712,19 @@ void CameraHidlTest::castProvider(const sp& provider, } //Cast camera device session to corresponding version -void CameraHidlTest::castSession(const sp &session, int32_t deviceVersion, - sp *session3_3 /*out*/, - sp *session3_4 /*out*/, - sp *session3_5 /*out*/, - sp *session3_6 /*out*/, - sp *session3_7 /*out*/, - sp *session3_8 /*out*/) { +void CameraHidlTest::castSession(const sp& session, int32_t deviceVersion, + sp* session3_3 /*out*/, + sp* session3_4 /*out*/, + sp* session3_5 /*out*/, + sp* session3_6 /*out*/, + sp* session3_7 /*out*/) { ASSERT_NE(nullptr, session3_3); ASSERT_NE(nullptr, session3_4); ASSERT_NE(nullptr, session3_5); ASSERT_NE(nullptr, session3_6); ASSERT_NE(nullptr, session3_7); - ASSERT_NE(nullptr, session3_8); switch (deviceVersion) { - case CAMERA_DEVICE_API_VERSION_3_8: { - auto castResult = device::V3_8::ICameraDeviceSession::castFrom(session); - ASSERT_TRUE(castResult.isOk()); - *session3_8 = castResult; - } - [[fallthrough]]; case CAMERA_DEVICE_API_VERSION_3_7: { auto castResult = device::V3_7::ICameraDeviceSession::castFrom(session); ASSERT_TRUE(castResult.isOk()); @@ -9661,9 +8642,8 @@ void CameraHidlTest::verifyBuffersReturned( sp session3_5; sp session3_6; sp session3_7; - sp session3_8; - castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, - &session3_6, &session3_7, &session3_8); + castSession(session, deviceVersion, &session3_3, &session3_4, &session3_5, &session3_6, + &session3_7); ASSERT_NE(nullptr, session3_5.get()); hidl_vec streamIds(1); @@ -9905,7 +8885,7 @@ void CameraHidlTest::verifyRecommendedConfigs(const CameraMetadata& chars) { size_t CONFIG_ENTRY_TYPE_OFFSET = 3; size_t CONFIG_ENTRY_BITFIELD_OFFSET = 4; uint32_t maxPublicUsecase = - ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PUBLIC_END_3_8; + ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PUBLIC_END; uint32_t vendorUsecaseStart = ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VENDOR_START; uint32_t usecaseMask = (1 << vendorUsecaseStart) - 1; -- cgit v1.2.3 From 608655b45078e310fdc233b7dab325ac5abb9aae Mon Sep 17 00:00:00 2001 From: Simon Bowden Date: Wed, 1 Jun 2022 12:09:41 +0000 Subject: Use a shared ref for Vibrator when passed to a worker thread. To try to protect against this easy mistake, I removed the implicit capture from thread lambdas. Bug: 228523213 Test: atest Change-Id: I8fa37dacb4acf89848a8b17db8db317a988809d4 --- vibrator/aidl/default/Vibrator.cpp | 14 +++++++++----- vibrator/aidl/default/VibratorManager.cpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vibrator/aidl/default/Vibrator.cpp b/vibrator/aidl/default/Vibrator.cpp index ddc6ee0d02..01602abffb 100644 --- a/vibrator/aidl/default/Vibrator.cpp +++ b/vibrator/aidl/default/Vibrator.cpp @@ -59,7 +59,10 @@ ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr& callback) { LOG(VERBOSE) << "Vibrator on for timeoutMs: " << timeoutMs; if (callback != nullptr) { - std::thread([=] { + // Note that thread lambdas aren't using implicit capture [=], to avoid capturing "this", + // which may be asynchronously destructed. + // If "this" is needed, use [sharedThis = this->ref()]. + std::thread([timeoutMs, callback] { LOG(VERBOSE) << "Starting on on another thread"; usleep(timeoutMs * 1000); LOG(VERBOSE) << "Notifying on complete"; @@ -87,7 +90,7 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, constexpr size_t kEffectMillis = 100; if (callback != nullptr) { - std::thread([=] { + std::thread([callback] { LOG(VERBOSE) << "Starting perform on another thread"; usleep(kEffectMillis * 1000); LOG(VERBOSE) << "Notifying perform complete"; @@ -174,7 +177,8 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector& composi } } - std::thread([=] { + // The thread may theoretically outlive the vibrator, so take a proper reference to it. + std::thread([sharedThis = this->ref(), composite, callback] { LOG(VERBOSE) << "Starting compose on another thread"; for (auto& e : composite) { @@ -185,7 +189,7 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector& composi << e.scale; int32_t durationMs; - getPrimitiveDuration(e.primitive, &durationMs); + sharedThis->getPrimitiveDuration(e.primitive, &durationMs); usleep(durationMs * 1000); } @@ -396,7 +400,7 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector &compo } } - std::thread([=] { + std::thread([totalDuration, callback] { LOG(VERBOSE) << "Starting composePwle on another thread"; usleep(totalDuration * 1000); if (callback != nullptr) { diff --git a/vibrator/aidl/default/VibratorManager.cpp b/vibrator/aidl/default/VibratorManager.cpp index 7cf9e6a5d8..26edf5a805 100644 --- a/vibrator/aidl/default/VibratorManager.cpp +++ b/vibrator/aidl/default/VibratorManager.cpp @@ -66,7 +66,7 @@ ndk::ScopedAStatus VibratorManager::prepareSynced(const std::vector& vi ndk::ScopedAStatus VibratorManager::triggerSynced( const std::shared_ptr& callback) { LOG(INFO) << "Vibrator Manager trigger synced"; - std::thread([=] { + std::thread([callback] { if (callback != nullptr) { LOG(INFO) << "Notifying perform complete"; callback->onComplete(); -- cgit v1.2.3 From 7d55d4269d5ec7247c00f9f1a84c33a6d6f53a00 Mon Sep 17 00:00:00 2001 From: Midas Chien Date: Tue, 7 Jun 2022 02:32:28 +0800 Subject: composer: vts: configure layer for DisplayDecoration Some HW may not support crop function for decoration and current API can't query this capability. Configure decoration layer to full screen to avoid this limitation. Bug: 225765061 Test: VtsHalGraphicsComposer3_TargetTest --gtest_filter=*DisplayDecoration* Change-Id: If47154adf9d48f9c1b8390b4bee090d8bf40ff3b --- graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index 759bfecca3..047109e35f 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -1719,10 +1719,10 @@ TEST_P(GraphicsComposerAidlCommandTest, DisplayDecoration) { } } + configureLayer(display, layer, Composition::DISPLAY_DECORATION, display.getFrameRect(), + display.getCrop()); mWriter.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, decorBuffer->handle, /*acquireFence*/ -1); - mWriter.setLayerCompositionType(display.getDisplayId(), layer, - Composition::DISPLAY_DECORATION); mWriter.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (support) { -- cgit v1.2.3 From 551bc88864bb4cefb3b79f8fbce7eeed05c5c01f Mon Sep 17 00:00:00 2001 From: seanhong Date: Thu, 9 Jun 2022 00:10:15 +0000 Subject: Add ENGINE_COOLANT_TEMP property for the emulator Test: atest CarPropertyManagerTest Bug: 231209215 Change-Id: Ic80ced50e9a59041d60da1968564a59ce5a2115f --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index e00f775a04..ff480e9bc2 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -713,6 +713,16 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {toInt(VehicleIgnitionState::ON)}}}, + {.config = + { + .prop = toInt(VehicleProperty::ENGINE_COOLANT_TEMP), + .access = VehiclePropertyAccess::READ, + .changeMode = VehiclePropertyChangeMode::CONTINUOUS, + .minSampleRate = 1.0f, + .maxSampleRate = 10.0f, + }, + .initialValue = {.floatValues = {75.0f}}}, + {.config = { .prop = toInt(VehicleProperty::ENGINE_OIL_LEVEL), -- cgit v1.2.3 From 308f4ac90690febbac077c297302890772ada495 Mon Sep 17 00:00:00 2001 From: Midas Chien Date: Tue, 7 Jun 2022 02:32:28 +0800 Subject: composer: vts: configure layer for DisplayDecoration Some HW may not support crop function for decoration and current API can't query this capability. Configure decoration layer to full screen to avoid this limitation. Bug: 225765061 Test: VtsHalGraphicsComposer3_TargetTest --gtest_filter=*DisplayDecoration* Change-Id: If47154adf9d48f9c1b8390b4bee090d8bf40ff3b (cherry picked from commit 7d55d4269d5ec7247c00f9f1a84c33a6d6f53a00) Merged-In: If47154adf9d48f9c1b8390b4bee090d8bf40ff3b --- graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index 759bfecca3..047109e35f 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -1719,10 +1719,10 @@ TEST_P(GraphicsComposerAidlCommandTest, DisplayDecoration) { } } + configureLayer(display, layer, Composition::DISPLAY_DECORATION, display.getFrameRect(), + display.getCrop()); mWriter.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, decorBuffer->handle, /*acquireFence*/ -1); - mWriter.setLayerCompositionType(display.getDisplayId(), layer, - Composition::DISPLAY_DECORATION); mWriter.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (support) { -- cgit v1.2.3 From 6a553afeecd2625d09ef401005c860f32ae367a1 Mon Sep 17 00:00:00 2001 From: Yu Shan Date: Wed, 15 Jun 2022 20:54:17 +0000 Subject: Add support for GSR property in HIDL ref VHAL. Test: Presubmit Bug: 236135569 Merged-In: I3788b66aa409304927e8f5af371c049cb1bcd58e (cherry-picked from I3788b66aa409304927e8f5af371c049cb1bcd58e) Change-Id: I3788b66aa409304927e8f5af371c049cb1bcd58e --- .../vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h | 13 +++++++++++++ .../default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h index cfbbbd3224..e276a39314 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h @@ -1109,6 +1109,19 @@ const ConfigDeclaration kVehicleProperties[]{ }, .initialValue = {.stringValue = {"Test"}}, }, + // This property is later defined in the AIDL VHAL interface. However, HIDL VHAL might + // require support for this property to meet EU regulation. + { + .config = + { + // GENERAL_SAFETY_REGULATION_COMPLIANCE_REQUIREMENT + .prop = 0x11400F47, + .access = VehiclePropertyAccess::READ, + .changeMode = VehiclePropertyChangeMode::STATIC, + }, + // GsrComplianceRequirementType::GSR_COMPLIANCE_REQUIRED_V1 + .initialValue = {.int32Values = {1}}, + }, #ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING // Vendor propetry for E2E ClusterHomeService testing. { diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp index e3c8dd6c79..d35792d4b2 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp @@ -141,7 +141,7 @@ class DefaultVhalImplTest : public ::testing::Test { TEST_F(DefaultVhalImplTest, testListProperties) { std::vector configs = mHal->listProperties(); - EXPECT_EQ((size_t)121, configs.size()); + EXPECT_EQ((size_t)122, configs.size()); } TEST_F(DefaultVhalImplTest, testGetDefaultPropertyFloat) { -- cgit v1.2.3 From 073e68f29ff3522d820dc1bc3c720324555410bd Mon Sep 17 00:00:00 2001 From: Tyler Trephan Date: Wed, 15 Jun 2022 01:06:09 +0000 Subject: Implemented EV_BATTERY_DISPLAY_UNITS Test: atest CarPropertyManagerTest Bug: 232859264 Change-Id: I8a3663f345a08b88e0047cd1211eb99978e4ded9 --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index ff480e9bc2..3319f724d6 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -171,6 +171,17 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {toInt(VehicleUnit::KILOMETERS_PER_HOUR)}}}, + {.config = + { + .prop = toInt(VehicleProperty::EV_BATTERY_DISPLAY_UNITS), + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + .configArray = {toInt(VehicleUnit::WATT_HOUR), + toInt(VehicleUnit::AMPERE_HOURS), + toInt(VehicleUnit::KILOWATT_HOUR)}, + }, + .initialValue = {.int32Values = {toInt(VehicleUnit::KILOWATT_HOUR)}}}, + {.config = { .prop = toInt(VehicleProperty::SEAT_OCCUPANCY), -- cgit v1.2.3 From f234fe48bf06c81eb1560568845b9c3f14ff9756 Mon Sep 17 00:00:00 2001 From: Nishtha Ahuja Date: Thu, 24 Mar 2022 02:42:47 +0000 Subject: Add value for FUEL_VOLUME_DISPLAY_UNITS in default config. Bug: 232859264 Fix: 221916124 Test: Tested manually in KitchenSink app Change-Id: I8c0bf768210037f655d76848d8b4aadf047838f3 (cherry picked from commit fccd300be6370ebcf07bb6457e8f97161cc56096) --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index ff480e9bc2..109626d4d8 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -458,6 +458,15 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {0}}}, + {.config = + { + .prop = toInt(VehicleProperty::FUEL_VOLUME_DISPLAY_UNITS), + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + .configArray = {(int)VehicleUnit::LITER, (int)VehicleUnit::US_GALLON}, + }, + .initialValue = {.int32Values = {(int)VehicleUnit::LITER}}}, + {.config = { .prop = toInt(VehicleProperty::HW_KEY_INPUT), -- cgit v1.2.3 From 6973e79b917ff1b7b0febddee69dd245f4222b22 Mon Sep 17 00:00:00 2001 From: Arun Johnson Date: Fri, 24 Jun 2022 18:17:00 +0000 Subject: Allowing OMX.google* codecs for Devices launching with S S AOSP did not remove the OMX.google* codecs, so this cannot be enforced for devices launching with S bug: 230582620 Change-Id: I25e8f827645db8e83c8c3142f5e76a912fdf7b22 --- .../functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp b/media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp index 2ae9c2b001..00e9837710 100755 --- a/media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp +++ b/media/omx/1.0/vts/functional/store/VtsHalMediaOmxV1_0TargetStoreTest.cpp @@ -400,9 +400,18 @@ TEST_P(StoreHidlTest, OmxCodecAllowedTest) { << " Component: " << info.mName.c_str() << " Role: " << role.c_str() << " not allowed for devices launching with Android T and above"; } else { - ASSERT_LT(getFirstApiLevel(), __ANDROID_API_S__) + std::string codecName = info.mName; + bool isAndroidCodec = (codecName.rfind("OMX.google", 0) != std::string::npos); + if (isAndroidCodec && (getFirstApiLevel() <= __ANDROID_API_S__)) { + // refer b/230582620 + // S AOSP build did not remove the OMX.google video codecs + // so it is infeasible to require no OMX.google.* video codecs + // on S launching devices + } else { + ASSERT_LT(getFirstApiLevel(), __ANDROID_API_S__) << " Component: " << info.mName.c_str() << " Role: " << role.c_str() << " not allowed for devices launching with Android S and above"; + } } } if (role.find("audio_decoder") != std::string::npos || -- cgit v1.2.3 From 14b6d3acf9556e6253d03e1e3edc858f636f474b Mon Sep 17 00:00:00 2001 From: seanhong Date: Mon, 27 Jun 2022 21:58:28 +0000 Subject: Remove FOG_LIGHTS_STATE from the emulator for the CTS test FOG_LIGHTS_STATE should not be implemented when FRONT_FOG_LIGHTS_STATE or REAR_FOG_LIGHTS_STATE is implemented. Test: atest CarPropertyManagerTest Bug: 233789475 Change-Id: I396ad9410265df4003fddcc244605519f6f5e88a --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index ff480e9bc2..83d148ac0f 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -892,14 +892,6 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {LIGHT_STATE_ON}}}, - {.config = - { - .prop = toInt(VehicleProperty::FOG_LIGHTS_STATE), - .access = VehiclePropertyAccess::READ, - .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - }, - .initialValue = {.int32Values = {LIGHT_STATE_ON}}}, - {.config = { .prop = toInt(VehicleProperty::FRONT_FOG_LIGHTS_STATE), -- cgit v1.2.3 From c33f1282d8fa899ebd944008db1f92976174e92d Mon Sep 17 00:00:00 2001 From: Gabriel Biren Date: Tue, 14 Jun 2022 18:58:46 +0000 Subject: In supplicant VTS test setup, make sure that the wifi hal is stopped before starting wifi. Bug: 234853504 Test: atest VtsHalWifiSupplicantV1_0TargetTest # HIDL service Change-Id: I413c3803a6607a72cc3aa8a5fa208551be1b1032 (cherry picked from commit bfe60cda4d9400f4f370b46e26cac97db3207917) Merged-In: I413c3803a6607a72cc3aa8a5fa208551be1b1032 --- .../1.0/vts/functional/supplicant_hidl_test.cpp | 7 ++--- .../vts/functional/supplicant_hidl_test_utils.cpp | 30 +++++++++++++++++----- .../vts/functional/supplicant_hidl_test_utils.h | 13 +++++----- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp index eabbf1b141..da3ff3a29b 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp @@ -38,11 +38,12 @@ class SupplicantHidlTest : public ::testing::TestWithParam> { public: virtual void SetUp() override { - // Stop Wi-Fi - ASSERT_TRUE(stopWifiFramework()); // stop & wait for wifi to shutdown. - wifi_instance_name_ = std::get<0>(GetParam()); supplicant_instance_name_ = std::get<1>(GetParam()); + + // Stop & wait for wifi to shutdown. + ASSERT_TRUE(stopWifiFramework(wifi_instance_name_)); + std::system("/system/bin/start"); ASSERT_TRUE(waitForFrameworkReady()); isP2pOn_ = diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp index 086166a5de..6760663d77 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp @@ -28,26 +28,42 @@ using ::android::sp; using ::android::hardware::configureRpcThreadpool; -using ::android::hardware::joinRpcThreadpool; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; +using ::android::hardware::joinRpcThreadpool; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::wifi::V1_0::ChipModeId; -using ::android::hardware::wifi::V1_0::IWifiChip; +using ::android::hardware::wifi::supplicant::V1_0::IfaceType; using ::android::hardware::wifi::supplicant::V1_0::ISupplicant; using ::android::hardware::wifi::supplicant::V1_0::ISupplicantIface; using ::android::hardware::wifi::supplicant::V1_0::ISupplicantNetwork; +using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface; using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface; using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork; -using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface; -using ::android::hardware::wifi::supplicant::V1_0::IfaceType; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode; +using ::android::hardware::wifi::V1_0::ChipModeId; +using ::android::hardware::wifi::V1_0::IWifi; +using ::android::hardware::wifi::V1_0::IWifiChip; using ::android::wifi_system::InterfaceTool; using ::android::wifi_system::SupplicantManager; namespace { + +bool waitForWifiHalStop(const std::string& wifi_instance_name) { + sp wifi = getWifi(wifi_instance_name); + int count = 50; /* wait at most 5 seconds for completion */ + while (count-- > 0) { + if (wifi != nullptr && !wifi->isStarted()) { + return true; + } + usleep(100000); + wifi = getWifi(wifi_instance_name); + } + LOG(ERROR) << "Wifi HAL was not stopped"; + return false; +} + bool waitForSupplicantState(bool is_running) { SupplicantManager supplicant_manager; int count = 50; /* wait at most 5 seconds for completion */ @@ -113,10 +129,10 @@ bool startWifiFramework() { return waitForSupplicantStart(); // wait for wifi to start. } -bool stopWifiFramework() { +bool stopWifiFramework(const std::string& wifi_instance_name) { std::system("svc wifi disable"); std::system("cmd wifi set-scan-always-available disabled"); - return waitForSupplicantStop(); // wait for wifi to shutdown. + return waitForSupplicantStop() && waitForWifiHalStop(wifi_instance_name); } void stopSupplicant() { stopSupplicant(""); } diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h index 72286231b4..2198d7cbf8 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h @@ -33,7 +33,7 @@ bool startWifiFramework(); // Used to stop the android wifi framework before every test. -bool stopWifiFramework(); +bool stopWifiFramework(const std::string& wifi_instance_name); void stopSupplicant(const std::string& wifi_instance_name); // Used to configure the chip, driver and start wpa_supplicant before every @@ -77,12 +77,13 @@ class SupplicantHidlTestBase : public ::testing::TestWithParam> { public: virtual void SetUp() override { - // Stop Wi-Fi - ASSERT_TRUE(stopWifiFramework()); // stop & wait for wifi to shutdown. - - // should always be v1.0 wifi - wifi_v1_0_instance_name_ = std::get<0>(GetParam()); + wifi_v1_0_instance_name_ = + std::get<0>(GetParam()); // should always be v1.0 wifi supplicant_instance_name_ = std::get<1>(GetParam()); + + // Stop & wait for wifi to shutdown. + ASSERT_TRUE(stopWifiFramework(wifi_v1_0_instance_name_)); + std::system("/system/bin/start"); ASSERT_TRUE(waitForFrameworkReady()); isP2pOn_ = -- cgit v1.2.3 From 4be58ff1de78c99dd01c036732b9eb4814c7d84a Mon Sep 17 00:00:00 2001 From: Yu Shan Date: Mon, 27 Jun 2022 21:59:48 +0000 Subject: Add EventMode to VehiclePropertyStore writeValue. Add an option to specify whether to trigger onpropertychange callback when VehiclePropertyStore.writeValue is called. Test: atest VehiclePropertyStoreTest Bug: 237318964 Change-Id: Iefd572c96f67dab2ecd5de56acf2e0d1c9b58939 --- .../fake_impl/hardware/src/FakeVehicleHardware.cpp | 23 ++++---- .../utils/common/include/VehiclePropertyStore.h | 31 ++++++++++- .../impl/utils/common/src/VehiclePropertyStore.cpp | 10 +++- .../utils/common/test/VehiclePropertyStoreTest.cpp | 61 ++++++++++++++++++++++ 4 files changed, 110 insertions(+), 15 deletions(-) diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp index b64c1a65cc..20c34aa12e 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp @@ -217,17 +217,16 @@ VhalResult FakeVehicleHardware::setApPowerStateReport(const VehiclePropVal [[fallthrough]]; case toInt(VehicleApPowerStateReport::WAIT_FOR_VHAL): // CPMS is in WAIT_FOR_VHAL state, simply move to ON and send back to HAL. - // Must erase existing state because in the case when Car Service crashes, the power - // state would already be ON when we receive WAIT_FOR_VHAL and thus new property change - // event would be generated. However, Car Service always expect a property change event - // even though there is not actual state change. - mServerSidePropStore->removeValuesForProperty( - toInt(VehicleProperty::AP_POWER_STATE_REQ)); prop = createApPowerStateReq(VehicleApPowerStateReq::ON); - // ALWAYS update status for generated property value + // ALWAYS update status for generated property value, and force a property update event + // because in the case when Car Service crashes, the power state would already be ON + // when we receive WAIT_FOR_VHAL and thus new property change event would be generated. + // However, Car Service always expect a property change event even though there is no + // actual state change. if (auto writeResult = - mServerSidePropStore->writeValue(std::move(prop), /*updateStatus=*/true); + mServerSidePropStore->writeValue(std::move(prop), /*updateStatus=*/true, + VehiclePropertyStore::EventMode::ALWAYS); !writeResult.ok()) { return StatusError(getErrorCode(writeResult)) << "failed to write AP_POWER_STATE_REQ into property store, error: " @@ -894,10 +893,10 @@ StatusCode FakeVehicleHardware::updateSampleRate(int32_t propId, int32_t areaId, return; } result.value()->timestamp = elapsedRealtimeNano(); - // Must remove the value before writing, otherwise, we would generate no update event since - // the value is the same. - mServerSidePropStore->removeValue(*result.value()); - mServerSidePropStore->writeValue(std::move(result.value())); + // For continuous properties, we must generate a new onPropertyChange event periodically + // according to the sample rate. + mServerSidePropStore->writeValue(std::move(result.value()), /*updateStatus=*/true, + VehiclePropertyStore::EventMode::ALWAYS); }); mRecurrentTimer->registerTimerCallback(interval, action); mRecurrentActions[propIdAreaId] = action; diff --git a/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h b/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h index ddc4f684aa..3d25cd3a41 100644 --- a/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h +++ b/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h @@ -46,6 +46,33 @@ class VehiclePropertyStore final { using ValueResultType = VhalResult; using ValuesResultType = VhalResult>; + enum class EventMode : uint8_t { + /** + * Only invoke OnValueChangeCallback if the new property value (ignoring timestamp) is + * different than the existing value. + * + * This should be used for regular cases. + */ + ON_VALUE_CHANGE, + /** + * Always invoke OnValueChangeCallback. + * + * This should be used for the special properties that are used for delivering event, e.g. + * HW_KEY_INPUT. + */ + ALWAYS, + /** + * Never invoke OnValueChangeCallback. + * + * This should be used for continuous property subscription when the sample rate for the + * subscription is smaller than the refresh rate for the property. E.g., the vehicle speed + * is refreshed at 20hz, but we are only subscribing at 10hz. In this case, we want to + * generate the property change event at 10hz, not 20hz, but we still want to refresh the + * timestamp (via writeValue) at 20hz. + */ + NEVER, + }; + explicit VehiclePropertyStore(std::shared_ptr valuePool) : mValuePool(valuePool) {} @@ -72,8 +99,10 @@ class VehiclePropertyStore final { // 'status' would be initialized to {@code VehiclePropertyStatus::AVAILABLE}, if this is to // override an existing value, the status for the existing value would be used for the // overridden value. + // 'EventMode' controls whether the 'OnValueChangeCallback' will be called for this operation. VhalResult writeValue(VehiclePropValuePool::RecyclableType propValue, - bool updateStatus = false); + bool updateStatus = false, + EventMode mode = EventMode::ON_VALUE_CHANGE); // Remove a given property value from the property store. The 'propValue' would be used to // generate the key for the value to remove. diff --git a/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp b/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp index c8fb994684..646dc0e618 100644 --- a/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp +++ b/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp @@ -106,7 +106,8 @@ void VehiclePropertyStore::registerProperty(const VehiclePropConfig& config, } VhalResult VehiclePropertyStore::writeValue(VehiclePropValuePool::RecyclableType propValue, - bool updateStatus) { + bool updateStatus, + VehiclePropertyStore::EventMode eventMode) { std::scoped_lock g(mLock); int32_t propId = propValue->prop; @@ -145,7 +146,12 @@ VhalResult VehiclePropertyStore::writeValue(VehiclePropValuePool::Recyclab } record->values[recId] = std::move(propValue); - if (valueUpdated && mOnValueChangeCallback != nullptr) { + + if (eventMode == EventMode::NEVER) { + return {}; + } + + if ((eventMode == EventMode::ALWAYS || valueUpdated) && mOnValueChangeCallback != nullptr) { mOnValueChangeCallback(*(record->values[recId])); } return {}; diff --git a/automotive/vehicle/aidl/impl/utils/common/test/VehiclePropertyStoreTest.cpp b/automotive/vehicle/aidl/impl/utils/common/test/VehiclePropertyStoreTest.cpp index 4d6f811795..fea5034db9 100644 --- a/automotive/vehicle/aidl/impl/utils/common/test/VehiclePropertyStoreTest.cpp +++ b/automotive/vehicle/aidl/impl/utils/common/test/VehiclePropertyStoreTest.cpp @@ -448,6 +448,67 @@ TEST_F(VehiclePropertyStoreTest, testPropertyChangeCallbackNoUpdate) { ASSERT_EQ(updatedValue.prop, INVALID_PROP_ID); } +TEST_F(VehiclePropertyStoreTest, testPropertyChangeCallbackNoUpdateForTimestampChange) { + VehiclePropValue updatedValue{ + .prop = INVALID_PROP_ID, + }; + VehiclePropValue fuelCapacity = { + .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY), + .value = {.floatValues = {1.0}}, + }; + ASSERT_RESULT_OK(mStore->writeValue(mValuePool->obtain(fuelCapacity))); + + mStore->setOnValueChangeCallback( + [&updatedValue](const VehiclePropValue& value) { updatedValue = value; }); + + // Write the same value with different timestamp should succeed but should not trigger callback. + fuelCapacity.timestamp = 1; + ASSERT_RESULT_OK(mStore->writeValue(mValuePool->obtain(fuelCapacity))); + + ASSERT_EQ(updatedValue.prop, INVALID_PROP_ID); +} + +TEST_F(VehiclePropertyStoreTest, testPropertyChangeCallbackForceUpdate) { + VehiclePropValue updatedValue{ + .prop = INVALID_PROP_ID, + }; + VehiclePropValue fuelCapacity = { + .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY), + .value = {.floatValues = {1.0}}, + }; + ASSERT_RESULT_OK(mStore->writeValue(mValuePool->obtain(fuelCapacity))); + + mStore->setOnValueChangeCallback( + [&updatedValue](const VehiclePropValue& value) { updatedValue = value; }); + + fuelCapacity.timestamp = 1; + ASSERT_RESULT_OK(mStore->writeValue(mValuePool->obtain(fuelCapacity), /*updateStatus=*/false, + VehiclePropertyStore::EventMode::ALWAYS)); + + ASSERT_EQ(updatedValue, fuelCapacity); +} + +TEST_F(VehiclePropertyStoreTest, testPropertyChangeCallbackForceNoUpdate) { + VehiclePropValue updatedValue{ + .prop = INVALID_PROP_ID, + }; + VehiclePropValue fuelCapacity = { + .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY), + .value = {.floatValues = {1.0}}, + }; + ASSERT_RESULT_OK(mStore->writeValue(mValuePool->obtain(fuelCapacity))); + + mStore->setOnValueChangeCallback( + [&updatedValue](const VehiclePropValue& value) { updatedValue = value; }); + fuelCapacity.value.floatValues[0] = 2.0; + fuelCapacity.timestamp = 1; + + ASSERT_RESULT_OK(mStore->writeValue(mValuePool->obtain(fuelCapacity), /*updateStatus=*/false, + VehiclePropertyStore::EventMode::NEVER)); + + ASSERT_EQ(updatedValue.prop, INVALID_PROP_ID); +} + } // namespace vehicle } // namespace automotive } // namespace hardware -- cgit v1.2.3 From 912469a468bd7a092eedf4d4ff2abe3bc123216f Mon Sep 17 00:00:00 2001 From: Les Lee Date: Tue, 7 Jun 2022 10:02:16 +0800 Subject: wifi: create interface before running hostapd vts Adding to support creating interface in hostapd vts. cp from aosp/2116501 Bug: 230008250 Test: 1. setprop ro.vendor.wifi.sap.interface swlan0 2. vts-tradefed run commandAndExit vts --skip-all-system-status-check --primary-abi-only --skip-preconditions --module VtsHalWifiHostapdV1_2Target -l INFO Change-Id: I483671cb01b68bc6f5ac4840c61b10f4c31f10e4 Merged-In: I483671cb01b68bc6f5ac4840c61b10f4c31f10e4 --- wifi/1.4/vts/functional/Android.bp | 21 ++++ .../vts/functional/wifi_hidl_test_utils_1_4.cpp | 54 ++++++++ wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h | 33 +++++ wifi/hostapd/1.2/vts/functional/Android.bp | 5 + .../1.2/vts/functional/hostapd_hidl_test.cpp | 139 +++++++++++---------- 5 files changed, 187 insertions(+), 65 deletions(-) create mode 100644 wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp create mode 100644 wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h diff --git a/wifi/1.4/vts/functional/Android.bp b/wifi/1.4/vts/functional/Android.bp index f86869bf61..cac8c0b2f8 100644 --- a/wifi/1.4/vts/functional/Android.bp +++ b/wifi/1.4/vts/functional/Android.bp @@ -44,6 +44,27 @@ cc_test { ], } +cc_library_static { + name: "VtsHalWifiV1_4TargetTestUtil", + defaults: ["VtsHalTargetTestDefaults"], + srcs: [ + "wifi_hidl_test_utils_1_4.cpp", + ], + export_include_dirs: [ + ".", + ], + shared_libs: [ + "libnativehelper", + ], + static_libs: [ + "VtsHalWifiV1_0TargetTestUtil", + "android.hardware.wifi@1.0", + "android.hardware.wifi@1.3", + "android.hardware.wifi@1.4", + "libwifi-system-iface", + ], +} + // SoftAP-specific tests, similar to VtsHalWifiApV1_0TargetTest. cc_test { name: "VtsHalWifiApV1_4TargetTest", diff --git a/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp new file mode 100644 index 0000000000..02e8320954 --- /dev/null +++ b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#include +#include + +#undef NAN // NAN is defined in bionic/libc/include/math.h:38 + +#include +#include +#include +#include +#include +#include + +#include "wifi_hidl_call_util.h" +#include "wifi_hidl_test_utils.h" + +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::wifi::V1_0::ChipModeId; +using ::android::hardware::wifi::V1_0::IfaceType; +using ::android::hardware::wifi::V1_4::IWifiApIface; +using ::android::hardware::wifi::V1_4::IWifiChip; + +sp getWifiChip_1_4(const std::string& instance_name) { + return IWifiChip::castFrom(getWifiChip(instance_name)); +} + +sp getWifiApIface_1_4(const std::string& instance_name) { + LOG(INFO) << "getWifiApIface_1_4"; + ChipModeId mode_id; + sp wifi_chip_ = getWifiChip_1_4(instance_name); + configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id); + const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface); + LOG(INFO) << "getWifiApIface_1_4 done to status_and_iface"; + return IWifiApIface::castFrom(status_and_iface.second); +} diff --git a/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h new file mode 100644 index 0000000000..a2c58154a1 --- /dev/null +++ b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +#include + +#include +// Helper functions to obtain references to the various HIDL interface objects. +// Note: We only have a single instance of each of these objects currently. +// These helper functions should be modified to return vectors if we support +// multiple instances. +android::sp getWifiChip_1_4( + const std::string& instance_name); +android::sp getWifiApIface_1_4( + const std::string& instance_name); diff --git a/wifi/hostapd/1.2/vts/functional/Android.bp b/wifi/hostapd/1.2/vts/functional/Android.bp index 9609da5d41..26edab576b 100644 --- a/wifi/hostapd/1.2/vts/functional/Android.bp +++ b/wifi/hostapd/1.2/vts/functional/Android.bp @@ -31,12 +31,17 @@ cc_test { ], static_libs: [ "VtsHalWifiV1_0TargetTestUtil", + "VtsHalWifiV1_4TargetTestUtil", "VtsHalWifiHostapdV1_0TargetTestUtil", "android.hardware.wifi.hostapd@1.0", "android.hardware.wifi.hostapd@1.1", "android.hardware.wifi.hostapd@1.2", "android.hardware.wifi.hostapd@1.3", "android.hardware.wifi@1.0", + "android.hardware.wifi@1.1", + "android.hardware.wifi@1.2", + "android.hardware.wifi@1.3", + "android.hardware.wifi@1.4", "libgmock", "libwifi-system", "libwifi-system-iface", diff --git a/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp index c40c582406..2fade4dc6b 100644 --- a/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp +++ b/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp @@ -29,6 +29,7 @@ #include "hostapd_hidl_call_util.h" #include "hostapd_hidl_test_utils.h" +#include "wifi_hidl_test_utils_1_4.h" using ::android::sp; using ::android::hardware::hidl_string; @@ -39,6 +40,9 @@ using ::android::hardware::wifi::hostapd::V1_2::HostapdStatusCode; using ::android::hardware::wifi::hostapd::V1_2::Ieee80211ReasonCode; using ::android::hardware::wifi::hostapd::V1_2::IHostapd; using ::android::hardware::wifi::V1_0::IWifi; +using ::android::hardware::wifi::V1_0::WifiStatusCode; +using ::android::hardware::wifi::V1_4::IWifiApIface; +using ::android::hardware::wifi::V1_4::IWifiChip; namespace { constexpr unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1', @@ -81,23 +85,25 @@ class HostapdHidlTest protected: bool isWpa3SaeSupport_ = false; bool isAcsSupport_ = false; - std::string getPrimaryWlanIfaceName() { - std::array buffer; - auto res = property_get("ro.vendor.wifi.sap.interface", buffer.data(), - nullptr); - if (res > 0) return buffer.data(); - property_get("wifi.interface", buffer.data(), "wlan0"); - return buffer.data(); + + std::string setupApIfaceIfNeededAndGetName() { + sp wifi_ap_iface; + wifi_ap_iface = getWifiApIface_1_4(wifi_instance_name_); + EXPECT_NE(nullptr, wifi_ap_iface.get()); + + const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName); + EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_name.first.code); + return status_and_name.second; } - IHostapd::IfaceParams getIfaceParamsWithoutAcs() { + IHostapd::IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) { ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams iface_params; ::android::hardware::wifi::hostapd::V1_1::IHostapd::IfaceParams iface_params_1_1; IHostapd::IfaceParams iface_params_1_2; - iface_params.ifaceName = getPrimaryWlanIfaceName(); + iface_params.ifaceName = iface_name; iface_params.hwModeParams.enable80211N = true; iface_params.hwModeParams.enable80211AC = false; iface_params.channelParams.enableAcs = false; @@ -114,9 +120,9 @@ class HostapdHidlTest return iface_params_1_2; } - IHostapd::IfaceParams getIfaceParamsWithAcs() { + IHostapd::IfaceParams getIfaceParamsWithAcs(std::string iface_name) { // First get the settings for WithoutAcs and then make changes - IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs(); + IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs(iface_name); iface_params_1_2.V1_1.V1_0.channelParams.enableAcs = true; iface_params_1_2.V1_1.V1_0.channelParams.acsShouldExcludeDfs = true; iface_params_1_2.V1_1.V1_0.channelParams.channel = 0; @@ -126,8 +132,8 @@ class HostapdHidlTest return iface_params_1_2; } - IHostapd::IfaceParams getIfaceParamsWithAcsAndFreqRange() { - IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithAcs(); + IHostapd::IfaceParams getIfaceParamsWithAcsAndFreqRange(std::string iface_name) { + IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithAcs(iface_name); ::android::hardware::wifi::hostapd::V1_2::IHostapd::AcsFrequencyRange acsFrequencyRange; acsFrequencyRange.start = 2412; @@ -141,9 +147,8 @@ class HostapdHidlTest return iface_params_1_2; } - IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidFreqRange() { - IHostapd::IfaceParams iface_params_1_2 = - getIfaceParamsWithAcsAndFreqRange(); + IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidFreqRange(std::string iface_name) { + IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithAcsAndFreqRange(iface_name); iface_params_1_2.channelParams.acsChannelFreqRangesMhz[0].start = 222; iface_params_1_2.channelParams.acsChannelFreqRangesMhz[0].end = 999; return iface_params_1_2; @@ -205,8 +210,8 @@ class HostapdHidlTest return nw_params_1_2; } - IHostapd::IfaceParams getIfaceParamsWithInvalidChannel() { - IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs(); + IHostapd::IfaceParams getIfaceParamsWithInvalidChannel(std::string iface_name) { + IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs(iface_name); iface_params_1_2.V1_1.V1_0.channelParams.channel = kIfaceInvalidChannel; return iface_params_1_2; } @@ -231,8 +236,9 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithAcs) { if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithAcs(), getPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname), + getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -244,9 +250,9 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndFreqRange) { if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithAcsAndFreqRange(), getPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, + getIfaceParamsWithAcsAndFreqRange(ifname), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -258,9 +264,9 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndInvalidFreqRange) { if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; + std::string ifname = setupApIfaceIfNeededAndGetName(); auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithAcsAndInvalidFreqRange(), - getPskNwParams()); + getIfaceParamsWithAcsAndInvalidFreqRange(ifname), getPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } @@ -272,8 +278,9 @@ TEST_P(HostapdHidlTest, AddOpenAccessPointWithAcs) { if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithAcs(), getOpenNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname), + getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -284,8 +291,9 @@ TEST_P(HostapdHidlTest, AddOpenAccessPointWithAcs) { TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcs) { if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithoutAcs(), getPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -296,8 +304,9 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcs) { TEST_P(HostapdHidlTest, AddOpenAccessPointWithoutAcs) { if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithoutAcs(), getOpenNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -309,9 +318,9 @@ TEST_P(HostapdHidlTest, AddSaeTransitionAccessPointWithoutAcs) { if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(), - getSaeTransitionNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getSaeTransitionNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -323,8 +332,9 @@ TEST_P(HostapdHidlTest, AddSAEAccessPointWithoutAcs) { if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithoutAcs(), getSaeNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getSaeNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } @@ -336,11 +346,11 @@ TEST_P(HostapdHidlTest, RemoveAccessPointWithAcs) { if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithAcs(), getPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname), + getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code); - auto status = - HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); + auto status = HIDL_INVOKE(hostapd_, removeAccessPoint, ifname); EXPECT_EQ( android::hardware::wifi::hostapd::V1_0::HostapdStatusCode::SUCCESS, status.code); @@ -353,11 +363,11 @@ TEST_P(HostapdHidlTest, RemoveAccessPointWithAcs) { TEST_P(HostapdHidlTest, RemoveAccessPointWithoutAcs) { if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithoutAcs(), getPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code); - auto status = - HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); + auto status = HIDL_INVOKE(hostapd_, removeAccessPoint, ifname); EXPECT_EQ( android::hardware::wifi::hostapd::V1_0::HostapdStatusCode::SUCCESS, status.code); @@ -370,9 +380,9 @@ TEST_P(HostapdHidlTest, RemoveAccessPointWithoutAcs) { TEST_P(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) { if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, - getIfaceParamsWithInvalidChannel(), getPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, + getIfaceParamsWithInvalidChannel(ifname), getPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } @@ -383,9 +393,9 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) { TEST_P(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) { if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(), - getInvalidPskNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getInvalidPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } @@ -397,9 +407,9 @@ TEST_P(HostapdHidlTest, AddInvalidSaeTransitionAccessPointWithoutAcs) { if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(), - getInvalidSaeTransitionNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getInvalidSaeTransitionNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } @@ -411,9 +421,9 @@ TEST_P(HostapdHidlTest, AddInvalidSaeAccessPointWithoutAcs) { if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support"; if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(), - getInvalidSaeNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getInvalidSaeNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } @@ -422,9 +432,9 @@ TEST_P(HostapdHidlTest, AddInvalidSaeAccessPointWithoutAcs) { * when hotspot interface doesn't init.. */ TEST_P(HostapdHidlTest, DisconnectClientWhenIfaceNotAvailable) { - auto status = - HIDL_INVOKE(hostapd_, forceClientDisconnect, getPrimaryWlanIfaceName(), - kTestZeroMacAddr, kTestDisconnectReasonCode); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status = HIDL_INVOKE(hostapd_, forceClientDisconnect, ifname, kTestZeroMacAddr, + kTestDisconnectReasonCode); EXPECT_EQ(HostapdStatusCode::FAILURE_IFACE_UNKNOWN, status.code); } @@ -435,14 +445,13 @@ TEST_P(HostapdHidlTest, DisconnectClientWhenIfaceNotAvailable) { TEST_P(HostapdHidlTest, DisconnectClientWhenIfacAvailable) { if (is_1_3(hostapd_)) GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3"; - auto status_1_2 = - HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(), - getOpenNwParams()); + std::string ifname = setupApIfaceIfNeededAndGetName(); + auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname), + getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code); - status_1_2 = - HIDL_INVOKE(hostapd_, forceClientDisconnect, getPrimaryWlanIfaceName(), - kTestZeroMacAddr, kTestDisconnectReasonCode); + status_1_2 = HIDL_INVOKE(hostapd_, forceClientDisconnect, ifname, kTestZeroMacAddr, + kTestDisconnectReasonCode); EXPECT_EQ(HostapdStatusCode::FAILURE_CLIENT_UNKNOWN, status_1_2.code); } -- cgit v1.2.3 From dd789ad9dc1c4c20f0f8671ae4f323d1a83fda09 Mon Sep 17 00:00:00 2001 From: Gabriel Biren Date: Wed, 15 Jun 2022 00:04:50 +0000 Subject: Update supplicant AIDL VTS tests to use the new version of stopWifiFramework(). Bug: 234853504 Test: atest VtsHalWifiSupplicantStaIfaceTargetTest \ VtsHalWifiSupplicantStaNetworkTargetTest \ VtsHalWifiSupplicantP2pIfaceTargetTest # AIDL service Change-Id: I9e06f025a5b6b44d6a6caf8362c64bd5a546e1ac (cherry picked from commit 99bb1485108ae2da16045cc845e7e7b43126441d) Merged-In: I9e06f025a5b6b44d6a6caf8362c64bd5a546e1ac --- wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h b/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h index 17e0394892..31042a2b7c 100644 --- a/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h +++ b/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h @@ -78,7 +78,7 @@ void startSupplicant() { void stopSupplicantService() { stopSupplicant(getWifiInstanceName()); } void initializeService() { - ASSERT_TRUE(stopWifiFramework()); + ASSERT_TRUE(stopWifiFramework(getWifiInstanceName())); std::system("/system/bin/start"); ASSERT_TRUE(waitForFrameworkReady()); stopSupplicantService(); -- cgit v1.2.3 From f16c6d3a5741768356159f099d04bfe2219c81fe Mon Sep 17 00:00:00 2001 From: jiabin Date: Thu, 7 Jul 2022 18:13:45 +0000 Subject: Fix array out of bound in audioTransportToHal. The number of audio profile and extra audio descriptor must not be greater than the maximum value. Bug: 237288416 Bug: 237717857 Test: repo step in bug Test: atest android.hardware.audio.common@7.0-util_tests Change-Id: I1fcfa29d7841a1cb73bafb1ea92f3b1630992ae9 Merged-In: I1fcfa29d7841a1cb73bafb1ea92f3b1630992ae9 (cherry picked from commit 0ee75ca925f6334741d3e34c5e1d1b0efae5943b) --- .../common/all-versions/default/7.0/HidlUtils.cpp | 5 +-- .../all-versions/default/tests/hidlutils_tests.cpp | 42 +++++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/audio/common/all-versions/default/7.0/HidlUtils.cpp b/audio/common/all-versions/default/7.0/HidlUtils.cpp index 5a5b5d276a..af29da61f3 100644 --- a/audio/common/all-versions/default/7.0/HidlUtils.cpp +++ b/audio/common/all-versions/default/7.0/HidlUtils.cpp @@ -894,7 +894,7 @@ status_t HidlUtils::audioTransportsToHal(const hidl_vec& transpo for (const auto& transport : transports) { switch (transport.audioCapability.getDiscriminator()) { case AudioTransport::AudioCapability::hidl_discriminator::profile: - if (halPort->num_audio_profiles > AUDIO_PORT_MAX_AUDIO_PROFILES) { + if (halPort->num_audio_profiles >= AUDIO_PORT_MAX_AUDIO_PROFILES) { ALOGE("%s, too many audio profiles", __func__); result = BAD_VALUE; break; @@ -910,7 +910,8 @@ status_t HidlUtils::audioTransportsToHal(const hidl_vec& transpo result); break; case AudioTransport::AudioCapability::hidl_discriminator::edid: - if (halPort->num_extra_audio_descriptors > AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS) { + if (halPort->num_extra_audio_descriptors >= + AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS) { ALOGE("%s, too many extra audio descriptors", __func__); result = BAD_VALUE; break; diff --git a/audio/common/all-versions/default/tests/hidlutils_tests.cpp b/audio/common/all-versions/default/tests/hidlutils_tests.cpp index c9e6fac7b2..33ed3b99bb 100644 --- a/audio/common/all-versions/default/tests/hidlutils_tests.cpp +++ b/audio/common/all-versions/default/tests/hidlutils_tests.cpp @@ -954,6 +954,18 @@ TEST(HidlUtils, ConvertAudioPortConfig) { EXPECT_TRUE(audio_port_configs_are_equal(&halConfig, &halConfigBack)); } +static AudioProfile generateValidAudioProfile() { + AudioProfile profile; + profile.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT); + profile.sampleRates.resize(2); + profile.sampleRates[0] = 44100; + profile.sampleRates[1] = 48000; + profile.channelMasks.resize(2); + profile.channelMasks[0] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_MONO); + profile.channelMasks[1] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO); + return profile; +} + TEST(HidlUtils, ConvertInvalidAudioTransports) { hidl_vec invalid; struct audio_port_v7 halInvalid = {}; @@ -973,20 +985,32 @@ TEST(HidlUtils, ConvertInvalidAudioTransports) { invalid[0].audioCapability.edid(hidl_vec(EXTRA_AUDIO_DESCRIPTOR_SIZE + 1)); invalid[1].encapsulationType = "random string"; EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid)); + + // The size of audio profile must not be greater than the maximum value. + invalid.resize(0); + invalid.resize(AUDIO_PORT_MAX_AUDIO_PROFILES + 1); + for (size_t i = 0; i < invalid.size(); ++i) { + invalid[i].audioCapability.profile(generateValidAudioProfile()); + invalid[i].encapsulationType = + toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_NONE); + } + EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid)); + + // The size of extra audio descriptors must not be greater than the maximum value. + invalid.resize(0); + invalid.resize(AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS + 1); + for (size_t i = 0; i < invalid.size(); ++i) { + invalid[i].audioCapability.edid({0x11, 0x06, 0x01}); + invalid[i].encapsulationType = + toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_IEC61937); + } + EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid)); } TEST(HidlUtils, ConvertAudioTransports) { hidl_vec transports; transports.resize(2); - AudioProfile profile; - profile.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT); - profile.sampleRates.resize(2); - profile.sampleRates[0] = 44100; - profile.sampleRates[1] = 48000; - profile.channelMasks.resize(2); - profile.channelMasks[0] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_MONO); - profile.channelMasks[1] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO); - transports[0].audioCapability.profile(profile); + transports[0].audioCapability.profile(generateValidAudioProfile()); hidl_vec shortAudioDescriptor({0x11, 0x06, 0x01}); transports[0].encapsulationType = toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_NONE); -- cgit v1.2.3 From a2bdec821d7d5c86471cd4801892467cc284ca39 Mon Sep 17 00:00:00 2001 From: Tyler Trephan Date: Thu, 7 Jul 2022 23:43:05 +0000 Subject: Added FUEL_CONSUMPTION_UNITS_DISTANCE_OVER_VOLUME Test: atest CarPropertyManagerTest Bug: 238367528 Change-Id: If9f4fab38ce47d6e2d463cca3e5eeb909866bf89 --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index fc9ed47be3..4e284e8bd0 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -478,6 +478,15 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {(int)VehicleUnit::LITER}}}, + {.config = + { + .prop = toInt( + VehicleProperty::FUEL_CONSUMPTION_UNITS_DISTANCE_OVER_VOLUME), + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + }, + .initialValue = {.int32Values = {1}}}, + {.config = { .prop = toInt(VehicleProperty::HW_KEY_INPUT), -- cgit v1.2.3 From 4f110343d667159f85df5c2b787a9e9a5349bcbe Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Thu, 7 Jul 2022 20:37:42 +0000 Subject: audio: Add checks to HIDL -> effect_param_t conversion By convention, the size of the resulting effect_param_t can not exceed EFFECT_PARAM_SIZE_MAX. This checks needs to be enforced when converting from HIDL arguments into legacy C API structures. Bug: 237291425 Test: atest VtsHalAudioEffectV7_0TargetTest Change-Id: Ie92f62b002dc622fa8246139c3d956909670fdb6 --- audio/effect/all-versions/default/Effect.cpp | 43 ++++++++++++++++------ audio/effect/all-versions/default/Effect.h | 4 +- .../vts/functional/VtsHalAudioEffectTargetTest.cpp | 17 +++++++++ 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/audio/effect/all-versions/default/Effect.cpp b/audio/effect/all-versions/default/Effect.cpp index 3baafc9343..def3a3f3fb 100644 --- a/audio/effect/all-versions/default/Effect.cpp +++ b/audio/effect/all-versions/default/Effect.cpp @@ -238,12 +238,27 @@ void Effect::effectOffloadParamToHal(const EffectOffloadParameter& offload, } // static -std::vector Effect::parameterToHal(uint32_t paramSize, const void* paramData, - uint32_t valueSize, const void** valueData) { +bool Effect::parameterToHal(uint32_t paramSize, const void* paramData, uint32_t valueSize, + const void** valueData, std::vector* halParamBuffer) { + constexpr size_t kMaxSize = EFFECT_PARAM_SIZE_MAX - sizeof(effect_param_t); + if (paramSize > kMaxSize) { + ALOGE("%s: Parameter size is too big: %" PRIu32, __func__, paramSize); + return false; + } size_t valueOffsetFromData = alignedSizeIn(paramSize) * sizeof(uint32_t); + if (valueOffsetFromData > kMaxSize) { + ALOGE("%s: Aligned parameter size is too big: %zu", __func__, valueOffsetFromData); + return false; + } + if (valueSize > kMaxSize - valueOffsetFromData) { + ALOGE("%s: Value size is too big: %" PRIu32 ", max size is %zu", __func__, valueSize, + kMaxSize - valueOffsetFromData); + android_errorWriteLog(0x534e4554, "237291425"); + return false; + } size_t halParamBufferSize = sizeof(effect_param_t) + valueOffsetFromData + valueSize; - std::vector halParamBuffer(halParamBufferSize, 0); - effect_param_t* halParam = reinterpret_cast(&halParamBuffer[0]); + halParamBuffer->resize(halParamBufferSize, 0); + effect_param_t* halParam = reinterpret_cast(halParamBuffer->data()); halParam->psize = paramSize; halParam->vsize = valueSize; memcpy(halParam->data, paramData, paramSize); @@ -256,7 +271,7 @@ std::vector Effect::parameterToHal(uint32_t paramSize, const void* para *valueData = halParam->data + valueOffsetFromData; } } - return halParamBuffer; + return true; } Result Effect::analyzeCommandStatus(const char* commandName, const char* context, status_t status) { @@ -314,11 +329,15 @@ Result Effect::getParameterImpl(uint32_t paramSize, const void* paramData, GetParameterSuccessCallback onSuccess) { // As it is unknown what method HAL uses for copying the provided parameter data, // it is safer to make sure that input and output buffers do not overlap. - std::vector halCmdBuffer = - parameterToHal(paramSize, paramData, requestValueSize, nullptr); + std::vector halCmdBuffer; + if (!parameterToHal(paramSize, paramData, requestValueSize, nullptr, &halCmdBuffer)) { + return Result::INVALID_ARGUMENTS; + } const void* valueData = nullptr; - std::vector halParamBuffer = - parameterToHal(paramSize, paramData, replyValueSize, &valueData); + std::vector halParamBuffer; + if (!parameterToHal(paramSize, paramData, replyValueSize, &valueData, &halParamBuffer)) { + return Result::INVALID_ARGUMENTS; + } uint32_t halParamBufferSize = halParamBuffer.size(); return sendCommandReturningStatusAndData( @@ -472,8 +491,10 @@ Result Effect::setConfigImpl(int commandCode, const char* commandName, const Eff Result Effect::setParameterImpl(uint32_t paramSize, const void* paramData, uint32_t valueSize, const void* valueData) { - std::vector halParamBuffer = - parameterToHal(paramSize, paramData, valueSize, &valueData); + std::vector halParamBuffer; + if (!parameterToHal(paramSize, paramData, valueSize, &valueData, &halParamBuffer)) { + return Result::INVALID_ARGUMENTS; + } return sendCommandReturningStatus(EFFECT_CMD_SET_PARAM, "SET_PARAM", halParamBuffer.size(), &halParamBuffer[0]); } diff --git a/audio/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h index 011544d760..f0b65df0b9 100644 --- a/audio/effect/all-versions/default/Effect.h +++ b/audio/effect/all-versions/default/Effect.h @@ -211,8 +211,8 @@ struct Effect : public IEffect { channel_config_t* halConfig); static void effectOffloadParamToHal(const EffectOffloadParameter& offload, effect_offload_param_t* halOffload); - static std::vector parameterToHal(uint32_t paramSize, const void* paramData, - uint32_t valueSize, const void** valueData); + static bool parameterToHal(uint32_t paramSize, const void* paramData, uint32_t valueSize, + const void** valueData, std::vector* halParamBuffer); Result analyzeCommandStatus(const char* commandName, const char* context, status_t status); void getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb); diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp index e59423fa98..ffa4c56e7a 100644 --- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp +++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp @@ -623,6 +623,23 @@ TEST_P(AudioEffectHidlTest, GetParameter) { EXPECT_TRUE(ret.isOk()); } +TEST_P(AudioEffectHidlTest, GetParameterInvalidMaxReplySize) { + description("Verify that GetParameter caps the maximum reply size"); + // Use a non-empty parameter to avoid being rejected by any earlier checks. + hidl_vec parameter; + parameter.resize(16); + // Use very large size to ensure that the service does not crash. Since parameters + // are specific to each effect, and some effects may not have parameters at all, + // simply checking the return value would not reveal an issue of using an uncapped value. + const uint32_t veryLargeReplySize = std::numeric_limits::max() - 100; + Result retval = Result::OK; + Return ret = + effect->getParameter(parameter, veryLargeReplySize, + [&](Result r, const hidl_vec&) { retval = r; }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::INVALID_ARGUMENTS, retval); +} + TEST_P(AudioEffectHidlTest, GetSupportedConfigsForFeature) { description("Verify that GetSupportedConfigsForFeature does not crash"); Return ret = effect->getSupportedConfigsForFeature( -- cgit v1.2.3 From cdc036a685bc467562ad8b2472d5336e4714c23b Mon Sep 17 00:00:00 2001 From: Tyler Trephan Date: Mon, 11 Jul 2022 23:57:51 +0000 Subject: Fixed VEHICLE_CURB_WEIGHT property Test: atest CarPropertyManagerTest Bug: 238677365 Change-Id: Iccea9313ec4654652be65e115ecebdcf7f68652f --- automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index fc9ed47be3..d29813df03 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -363,8 +363,9 @@ const std::vector kVehicleProperties = { .prop = toInt(VehicleProperty::VEHICLE_CURB_WEIGHT), .access = VehiclePropertyAccess::READ, .changeMode = VehiclePropertyChangeMode::STATIC, + .configArray = {/*gross weight kg=*/2948}, }, - .initialValue = {.int32Values = {30}}}, + .initialValue = {.int32Values = {2211 /*kg*/}}}, {.config = { -- cgit v1.2.3 From bd915c129c110de3b015059f51222315cea101cc Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Sun, 10 Jul 2022 23:59:18 +0800 Subject: Bluetooth audio hal check broadcast configuraiton for the broadcast offload The patch contains the following changes 1. Check the broadcast audio configuration as starting broadcast offload session 2. Update audio configuration checker for broadcast offload 3. Remove the IsOffloadLeAudioConfigurationValid function that the audio configuraiton is invalid as session started, so we don't need to check it at that time Bug: 210987580 Test: start the offload broadcast stream, and check the session status Change-Id: I60b1b506051873f6d942f2febace6562634fc12a Merged-In: I60b1b506051873f6d942f2febace6562634fc12a (cherry picked from commit ee398a93f564e515051932dfd3801081426b1ae8) --- .../aidl/default/LeAudioOffloadAudioProvider.cpp | 19 +++++++++---------- .../audio/utils/aidl_session/BluetoothAudioCodecs.cpp | 13 ------------- .../audio/utils/aidl_session/BluetoothAudioCodecs.h | 3 --- .../utils/aidl_session/BluetoothAudioSession.cpp | 15 +++++++++++---- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp index 0e22e44490..7f610ef3d0 100644 --- a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp +++ b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp @@ -55,21 +55,20 @@ ndk::ScopedAStatus LeAudioOffloadAudioProvider::startSession( const std::shared_ptr& host_if, const AudioConfiguration& audio_config, const std::vector& latency_modes, DataMQDesc* _aidl_return) { - if (audio_config.getTag() != AudioConfiguration::leAudioConfig) { + if (session_type_ == + SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { + if (audio_config.getTag() != AudioConfiguration::leAudioBroadcastConfig) { + LOG(WARNING) << __func__ << " - Invalid Audio Configuration=" + << audio_config.toString(); + *_aidl_return = DataMQDesc(); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + } else if (audio_config.getTag() != AudioConfiguration::leAudioConfig) { LOG(WARNING) << __func__ << " - Invalid Audio Configuration=" << audio_config.toString(); *_aidl_return = DataMQDesc(); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } - const auto& le_audio_config = - audio_config.get(); - if (!BluetoothAudioCodecs::IsOffloadLeAudioConfigurationValid( - session_type_, le_audio_config)) { - LOG(WARNING) << __func__ << " - Unsupported LC3 Offloaded Configuration=" - << le_audio_config.toString(); - *_aidl_return = DataMQDesc(); - return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); - } return BluetoothAudioProvider::startSession( host_if, audio_config, latency_modes, _aidl_return); diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp index b858f504ed..d5e85b8e93 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp @@ -321,19 +321,6 @@ bool BluetoothAudioCodecs::IsOffloadOpusConfigurationValid( return false; } -bool BluetoothAudioCodecs::IsOffloadLeAudioConfigurationValid( - const SessionType& session_type, const LeAudioConfiguration&) { - if (session_type != - SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH && - session_type != - SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH && - session_type != - SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { - return false; - } - return true; -} - std::vector BluetoothAudioCodecs::GetSoftwarePcmCapabilities() { return {kDefaultSoftwarePcmCapabilities}; diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h index ed0598b975..e3d657b497 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h @@ -44,9 +44,6 @@ class BluetoothAudioCodecs { static bool IsOffloadCodecConfigurationValid( const SessionType& session_type, const CodecConfiguration& codec_config); - static bool IsOffloadLeAudioConfigurationValid( - const SessionType& session_type, const LeAudioConfiguration&); - static std::vector GetLeAudioOffloadCodecCapabilities(const SessionType& session_type); diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp index 3214bf2228..1dd7887a0a 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp @@ -274,11 +274,14 @@ bool BluetoothAudioSession::UpdateAudioConfig( bool is_offload_a2dp_session = (session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH || session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH); - bool is_offload_le_audio_session = + bool is_offload_le_audio_unicast_session = (session_type_ == SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || session_type_ == SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH); + bool is_offload_le_audio_broadcast_session = + (session_type_ == + SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH); auto audio_config_tag = audio_config.getTag(); bool is_software_audio_config = (is_software_session && @@ -286,11 +289,15 @@ bool BluetoothAudioSession::UpdateAudioConfig( bool is_a2dp_offload_audio_config = (is_offload_a2dp_session && audio_config_tag == AudioConfiguration::a2dpConfig); - bool is_le_audio_offload_audio_config = - (is_offload_le_audio_session && + bool is_le_audio_offload_unicast_audio_config = + (is_offload_le_audio_unicast_session && audio_config_tag == AudioConfiguration::leAudioConfig); + bool is_le_audio_offload_broadcast_audio_config = + (is_offload_le_audio_broadcast_session && + audio_config_tag == AudioConfiguration::leAudioBroadcastConfig); if (!is_software_audio_config && !is_a2dp_offload_audio_config && - !is_le_audio_offload_audio_config) { + !is_le_audio_offload_unicast_audio_config && + !is_le_audio_offload_broadcast_audio_config) { return false; } audio_config_ = std::make_unique(audio_config); -- cgit v1.2.3 From 6fefa59d939e37215febbd6877551923c84daa4c Mon Sep 17 00:00:00 2001 From: seanhong Date: Mon, 11 Jul 2022 21:16:22 +0000 Subject: Remove FOG_LIGHTS_SWITCH from the emulator for the CTS test FOG_LIGHTS_SWITCH should not be implemented when FRONT_FOG_LIGHTS_SWITCH or REAR_FOG_LIGHTS_SWITCH is implemented. Test: atest CarPropertyManagerTest Bug: 237691268 Change-Id: I5d1fc669a038c50e3262b5b057c45300e48848b6 --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index fc9ed47be3..46f6df5fc3 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -952,14 +952,7 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {LIGHT_SWITCH_AUTO}}}, - {.config = - { - .prop = toInt(VehicleProperty::FOG_LIGHTS_SWITCH), - .access = VehiclePropertyAccess::READ_WRITE, - .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - }, - .initialValue = {.int32Values = {LIGHT_SWITCH_AUTO}}}, - + // FOG_LIGHTS_SWITCH must not be implemented when FRONT_FOG_LIGHTS_SWITCH is implemented {.config = { .prop = toInt(VehicleProperty::FRONT_FOG_LIGHTS_SWITCH), @@ -968,6 +961,7 @@ const std::vector kVehicleProperties = { }, .initialValue = {.int32Values = {LIGHT_SWITCH_AUTO}}}, + // FOG_LIGHTS_SWITCH must not be implemented when REAR_FOG_LIGHTS_SWITCH is implemented {.config = { .prop = toInt(VehicleProperty::REAR_FOG_LIGHTS_SWITCH), -- cgit v1.2.3 From 53c6e83534dbb9618dc79ba9eb1ad3752383f90d Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Fri, 8 Jul 2022 00:32:04 +0800 Subject: Supoort audio configuration update to audio HAL for broadcast offload Bug: 210987580 Test: start the broadcast offload, check log Change-Id: Iadae625d10ad179089b952ac94ff66ae90a6236e Merged-In: Iadae625d10ad179089b952ac94ff66ae90a6236e (cherry picked from commit 36a879796bb046a5261d9862a69776f2bba94466) --- bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp index 1dd7887a0a..292d352b9c 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp @@ -111,7 +111,9 @@ void BluetoothAudioSession::ReportAudioConfigChanged( if (session_type_ != SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH && session_type_ != - SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) { + SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH && + session_type_ != + SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { return; } std::lock_guard guard(mutex_); -- cgit v1.2.3 From 1e703f182e2fcbb9123bf661d81d22a04d0e1f8d Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Tue, 28 Jun 2022 01:46:21 +0000 Subject: audio VTS: Refactor test parameter generation for I/O streams Two changes that are necessary to test offloaded output: 1. Pass all mix port flags specified in the config to HAL when opening an output stream. Previously the generator was omitting the 'NON_BLOCKING' flag, however it is necessary for offloaded output to work. This also now passes the 'GAPLESS_OFFLOAD' flag to the stream opening call site. 2. Provide the DeviceAddress of the attached source/sink device to tests that use mix ports. Some tests were looking up the device address anyway. Also, HAL implementations seem to prefer to have the actual output device instead of 'DEFAULT' when opening offload streams. Bug: 219767875 Test: atest VtsHalAudioV7_0TargetTest Test: atest VtsHalAudioV7_1TargetTest Test: atest HalAudioV7_0GeneratorTest Change-Id: I0482376ecc7d6964f45f508a80716ffab18044b4 Merged-In: I0482376ecc7d6964f45f508a80716ffab18044b4 (cherry picked from commit 713d2c55908aa6bd22481163509c4543a9c6d1bf) --- .../vts/functional/7.0/AudioPrimaryHidlHalTest.cpp | 50 +++------------ .../all-versions/vts/functional/7.0/Generators.cpp | 71 ++++++++++++---------- .../all-versions/vts/functional/7.0/PolicyConfig.h | 14 ++++- .../vts/functional/AudioPrimaryHidlHalTest.h | 17 +++--- .../vts/functional/AudioTestDefinitions.h | 3 +- 5 files changed, 68 insertions(+), 87 deletions(-) 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 dfc238623c..be90b2180c 100644 --- a/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp @@ -517,20 +517,10 @@ class PcmOnlyConfigOutputStreamTest : public OutputStreamTest { } bool canQueryPresentationPosition() const { - auto maybeSinkAddress = - getCachedPolicyConfig().getSinkDeviceForMixPort(getDeviceName(), getMixPortName()); - // Returning 'true' when no sink is found so the test can fail later with a more clear - // problem description. - return !maybeSinkAddress.has_value() || - !xsd::isTelephonyDevice(maybeSinkAddress.value().deviceType); + return !xsd::isTelephonyDevice(address.deviceType); } void createPatchIfNeeded() { - auto maybeSinkAddress = - getCachedPolicyConfig().getSinkDeviceForMixPort(getDeviceName(), getMixPortName()); - ASSERT_TRUE(maybeSinkAddress.has_value()) - << "No sink device found for mix port " << getMixPortName() << " (module " - << getDeviceName() << ")"; if (areAudioPatchesSupported()) { AudioPortConfig source; source.base.format.value(getConfig().base.format); @@ -540,13 +530,13 @@ class PcmOnlyConfigOutputStreamTest : public OutputStreamTest { source.ext.mix().ioHandle = helper.getIoHandle(); source.ext.mix().useCase.stream({}); AudioPortConfig sink; - sink.ext.device(maybeSinkAddress.value()); + sink.ext.device(address); EXPECT_OK(getDevice()->createAudioPatch(hidl_vec{source}, hidl_vec{sink}, returnIn(res, mPatchHandle))); mHasPatch = res == Result::OK; } else { - EXPECT_OK(stream->setDevices({maybeSinkAddress.value()})); + EXPECT_OK(stream->setDevices({address})); } } @@ -556,10 +546,6 @@ class PcmOnlyConfigOutputStreamTest : public OutputStreamTest { EXPECT_OK(getDevice()->releaseAudioPatch(mPatchHandle)); mHasPatch = false; } - } else { - if (stream) { - EXPECT_OK(stream->setDevices({address})); - } } } @@ -691,24 +677,12 @@ class PcmOnlyConfigInputStreamTest : public InputStreamTest { InputStreamTest::TearDown(); } - bool canQueryCapturePosition() const { - auto maybeSourceAddress = getCachedPolicyConfig().getSourceDeviceForMixPort( - getDeviceName(), getMixPortName()); - // Returning 'true' when no source is found so the test can fail later with a more clear - // problem description. - return !maybeSourceAddress.has_value() || - !xsd::isTelephonyDevice(maybeSourceAddress.value().deviceType); - } + bool canQueryCapturePosition() const { return !xsd::isTelephonyDevice(address.deviceType); } void createPatchIfNeeded() { - auto maybeSourceAddress = getCachedPolicyConfig().getSourceDeviceForMixPort( - getDeviceName(), getMixPortName()); - ASSERT_TRUE(maybeSourceAddress.has_value()) - << "No source device found for mix port " << getMixPortName() << " (module " - << getDeviceName() << ")"; if (areAudioPatchesSupported()) { AudioPortConfig source; - source.ext.device(maybeSourceAddress.value()); + source.ext.device(address); AudioPortConfig sink; sink.base.format.value(getConfig().base.format); sink.base.sampleRateHz.value(getConfig().base.sampleRateHz); @@ -721,7 +695,7 @@ class PcmOnlyConfigInputStreamTest : public InputStreamTest { returnIn(res, mPatchHandle))); mHasPatch = res == Result::OK; } else { - EXPECT_OK(stream->setDevices({maybeSourceAddress.value()})); + EXPECT_OK(stream->setDevices({address})); } } @@ -731,10 +705,6 @@ class PcmOnlyConfigInputStreamTest : public InputStreamTest { EXPECT_OK(getDevice()->releaseAudioPatch(mPatchHandle)); mHasPatch = false; } - } else { - if (stream) { - EXPECT_OK(stream->setDevices({address})); - } } } @@ -864,14 +834,8 @@ TEST_P(MicrophoneInfoInputStreamTest, GetActiveMicrophones) { } ASSERT_OK(res); - auto maybeSourceAddress = - getCachedPolicyConfig().getSourceDeviceForMixPort(getDeviceName(), getMixPortName()); - ASSERT_TRUE(maybeSourceAddress.has_value()) - << "No source device found for mix port " << getMixPortName() << " (module " - << getDeviceName() << ")"; - for (auto microphone : microphones) { - if (microphone.deviceAddress == maybeSourceAddress.value()) { + if (microphone.deviceAddress == address) { StreamReader reader(stream.get(), stream->getBufferSize()); ASSERT_TRUE(reader.start()); reader.pause(); // This ensures that at least one read has happened. 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 f936d0afbf..cd84c41308 100644 --- a/audio/core/all-versions/vts/functional/7.0/Generators.cpp +++ b/audio/core/all-versions/vts/functional/7.0/Generators.cpp @@ -57,9 +57,6 @@ static std::vector combineAudioConfig(std::vector, bool> generateOutFlags( const xsd::MixPorts::MixPort& mixPort) { - static const std::vector offloadFlags = { - toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD), - toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_DIRECT)}; std::vector flags; bool isOffload = false; if (mixPort.hasFlags()) { @@ -67,14 +64,10 @@ static std::tuple, bool> generateOutFlags( isOffload = std::find(xsdFlags.begin(), xsdFlags.end(), xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != xsdFlags.end(); - if (!isOffload) { - for (auto flag : xsdFlags) { - if (flag != xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_PRIMARY) { - flags.push_back(toString(flag)); - } + for (auto flag : xsdFlags) { + if (flag != xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_PRIMARY) { + flags.push_back(toString(flag)); } - } else { - flags = offloadFlags; } } return {flags, isOffload}; @@ -100,11 +93,10 @@ std::vector generateOutputDeviceConfigParameters(bool one if (!module || !module->getFirstMixPorts()) break; for (const auto& mixPort : module->getFirstMixPorts()->getMixPort()) { if (mixPort.getRole() != xsd::Role::source) continue; // not an output profile - if (getCachedPolicyConfig() - .getAttachedSinkDeviceForMixPort(moduleName, mixPort.getName()) - .empty()) { - continue; // no attached device - } + const auto attachedDeviceAddress = + getCachedPolicyConfig().getDeviceAddressOfSinkDeviceAttachedToMixPort( + moduleName, mixPort.getName()); + if (!attachedDeviceAddress.has_value()) continue; auto [flags, isOffload] = generateOutFlags(mixPort); for (const auto& profile : mixPort.getProfile()) { if (!profile.hasFormat() || !profile.hasSamplingRates() || @@ -118,7 +110,8 @@ std::vector generateOutputDeviceConfigParameters(bool one if (isOffload) { config.offloadInfo.info(generateOffloadInfo(config.base)); } - result.emplace_back(device, mixPort.getName(), config, flags); + result.emplace_back(device, mixPort.getName(), attachedDeviceAddress.value(), + config, flags); if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; @@ -162,13 +155,16 @@ const std::vector& getOutputDeviceInvalidConfigParameters profile.getFormat(), static_cast(profile.getSamplingRates()[0]), toString(profile.getChannelMasks()[0])}; + DeviceAddress defaultDevice = { + toString(xsd::AudioDevice::AUDIO_DEVICE_OUT_DEFAULT), {}}; { AudioConfig config{.base = validBase}; config.base.channelMask = "random_string"; if (isOffload) { config.offloadInfo.info(generateOffloadInfo(validBase)); } - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } { AudioConfig config{.base = validBase}; @@ -176,7 +172,8 @@ const std::vector& getOutputDeviceInvalidConfigParameters if (isOffload) { config.offloadInfo.info(generateOffloadInfo(validBase)); } - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } if (generateInvalidFlags) { AudioConfig config{.base = validBase}; @@ -184,32 +181,37 @@ const std::vector& getOutputDeviceInvalidConfigParameters config.offloadInfo.info(generateOffloadInfo(validBase)); } std::vector flags = {"random_string", ""}; - result.emplace_back(device, mixPort.getName(), config, flags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + flags); } if (isOffload) { { AudioConfig config{.base = validBase}; config.offloadInfo.info(generateOffloadInfo(validBase)); config.offloadInfo.info().base.channelMask = "random_string"; - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } { AudioConfig config{.base = validBase}; config.offloadInfo.info(generateOffloadInfo(validBase)); config.offloadInfo.info().base.format = "random_string"; - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } { AudioConfig config{.base = validBase}; config.offloadInfo.info(generateOffloadInfo(validBase)); config.offloadInfo.info().streamType = "random_string"; - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } { AudioConfig config{.base = validBase}; config.offloadInfo.info(generateOffloadInfo(validBase)); config.offloadInfo.info().usage = "random_string"; - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } hasOffloadConfig = true; } else { @@ -233,11 +235,10 @@ std::vector generateInputDeviceConfigParameters(bool oneP if (!module || !module->getFirstMixPorts()) break; for (const auto& mixPort : module->getFirstMixPorts()->getMixPort()) { if (mixPort.getRole() != xsd::Role::sink) continue; // not an input profile - if (getCachedPolicyConfig() - .getAttachedSourceDeviceForMixPort(moduleName, mixPort.getName()) - .empty()) { - continue; // no attached device - } + const auto attachedDeviceAddress = + getCachedPolicyConfig().getDeviceAddressOfSourceDeviceAttachedToMixPort( + moduleName, mixPort.getName()); + if (!attachedDeviceAddress.has_value()) continue; std::vector flags; if (mixPort.hasFlags()) { std::transform(mixPort.getFlags().begin(), mixPort.getFlags().end(), @@ -250,7 +251,8 @@ std::vector generateInputDeviceConfigParameters(bool oneP auto configs = combineAudioConfig(profile.getChannelMasks(), profile.getSamplingRates(), profile.getFormat()); for (const auto& config : configs) { - result.emplace_back(device, mixPort.getName(), config, flags); + result.emplace_back(device, mixPort.getName(), attachedDeviceAddress.value(), + config, flags); if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; @@ -298,20 +300,25 @@ const std::vector& getInputDeviceInvalidConfigParameters( profile.getFormat(), static_cast(profile.getSamplingRates()[0]), toString(profile.getChannelMasks()[0])}; + DeviceAddress defaultDevice = { + toString(xsd::AudioDevice::AUDIO_DEVICE_IN_DEFAULT), {}}; { AudioConfig config{.base = validBase}; config.base.channelMask = "random_string"; - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } { AudioConfig config{.base = validBase}; config.base.format = "random_string"; - result.emplace_back(device, mixPort.getName(), config, validFlags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + validFlags); } if (generateInvalidFlags) { AudioConfig config{.base = validBase}; std::vector flags = {"random_string", ""}; - result.emplace_back(device, mixPort.getName(), config, flags); + result.emplace_back(device, mixPort.getName(), defaultDevice, config, + flags); } hasConfig = true; break; 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 4aea503938..c1d5669775 100644 --- a/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h +++ b/audio/core/all-versions/vts/functional/7.0/PolicyConfig.h @@ -61,6 +61,18 @@ class PolicyConfig { const std::set& getModulesWithDevicesNames() const { return mModulesWithDevicesNames; } + std::optional getDeviceAddressOfSinkDeviceAttachedToMixPort( + const std::string& moduleName, const std::string& mixPortName) const { + const auto attachedDevicePort = getAttachedSinkDeviceForMixPort(moduleName, mixPortName); + if (attachedDevicePort.empty()) return {}; + return getDeviceAddressOfDevicePort(moduleName, attachedDevicePort); + } + std::optional getDeviceAddressOfSourceDeviceAttachedToMixPort( + const std::string& moduleName, const std::string& mixPortName) const { + const auto attachedDevicePort = getAttachedSourceDeviceForMixPort(moduleName, mixPortName); + if (attachedDevicePort.empty()) return {}; + return getDeviceAddressOfDevicePort(moduleName, attachedDevicePort); + } std::string getAttachedSinkDeviceForMixPort(const std::string& moduleName, const std::string& mixPortName) const { return findAttachedDevice(getAttachedDevices(moduleName), @@ -84,8 +96,6 @@ class PolicyConfig { const std::vector& getAttachedDevices(const std::string& moduleName) const; std::optional getDeviceAddressOfDevicePort( const std::string& moduleName, const std::string& devicePortName) const; - std::string getDevicePortTagNameFromType(const std::string& moduleName, - const AudioDevice& deviceType) const; std::set getSinkDevicesForMixPort(const std::string& moduleName, const std::string& mixPortName) const; std::set getSourceDevicesForMixPort(const std::string& moduleName, diff --git a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h index 38e9e5f467..afc25f0a1e 100644 --- a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h +++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h @@ -617,7 +617,8 @@ static std::string DeviceConfigParameterToString( std::get(info.param))); #elif MAJOR_VERSION >= 7 const auto configPart = - std::to_string(config.base.sampleRateHz) + "_" + + ::testing::PrintToString(std::get(info.param).deviceType) + + "_" + std::to_string(config.base.sampleRateHz) + "_" + // The channel masks and flags are vectors of strings, just need to sanitize them. SanitizeStringForGTestName(::testing::PrintToString(config.base.channelMask)) + "_" + SanitizeStringForGTestName(::testing::PrintToString(std::get(info.param))); @@ -658,6 +659,9 @@ class AudioHidlTestWithDeviceConfigParameter std::get(std::get(GetParam()))); } #elif MAJOR_VERSION >= 7 + DeviceAddress getAttachedDeviceAddress() const { + return std::get(GetParam()); + } hidl_vec getInputFlags() const { return std::get(GetParam()); } hidl_vec getOutputFlags() const { return std::get(GetParam()); } #endif @@ -1047,7 +1051,7 @@ class OutputStreamTest #if MAJOR_VERSION <= 6 address.device = AudioDevice::OUT_DEFAULT; #elif MAJOR_VERSION >= 7 - address.deviceType = toString(xsd::AudioDevice::AUDIO_DEVICE_OUT_DEFAULT); + address = getAttachedDeviceAddress(); #endif const AudioConfig& config = getConfig(); auto flags = getOutputFlags(); @@ -1243,16 +1247,11 @@ class InputStreamTest #if MAJOR_VERSION <= 6 address.device = AudioDevice::IN_DEFAULT; #elif MAJOR_VERSION >= 7 - auto maybeSourceAddress = getCachedPolicyConfig().getSourceDeviceForMixPort( - getDeviceName(), getMixPortName()); + address = getAttachedDeviceAddress(); auto& metadata = initMetadata.tracks[0]; - if (maybeSourceAddress.has_value() && - !xsd::isTelephonyDevice(maybeSourceAddress.value().deviceType)) { - address = maybeSourceAddress.value(); + if (!xsd::isTelephonyDevice(address.deviceType)) { metadata.source = toString(xsd::AudioSource::AUDIO_SOURCE_UNPROCESSED); metadata.channelMask = getConfig().base.channelMask; - } else { - address.deviceType = toString(xsd::AudioDevice::AUDIO_DEVICE_IN_DEFAULT); } #if MAJOR_VERSION == 7 && MINOR_VERSION >= 1 auto flagsIt = std::find(flags.begin(), flags.end(), diff --git a/audio/core/all-versions/vts/functional/AudioTestDefinitions.h b/audio/core/all-versions/vts/functional/AudioTestDefinitions.h index 802b87bc36..3de06c35ac 100644 --- a/audio/core/all-versions/vts/functional/AudioTestDefinitions.h +++ b/audio/core/all-versions/vts/functional/AudioTestDefinitions.h @@ -39,9 +39,10 @@ using DeviceConfigParameter = std::tuple< std::variant>; #elif MAJOR_VERSION >= 7 -enum { PARAM_DEVICE, PARAM_PORT_NAME, PARAM_CONFIG, PARAM_FLAGS }; +enum { PARAM_DEVICE, PARAM_PORT_NAME, PARAM_ATTACHED_DEV_ADDR, PARAM_CONFIG, PARAM_FLAGS }; using DeviceConfigParameter = std::tuple>; #endif -- cgit v1.2.3 From 56f1666febb747d67f2a6d9749eb3351e720307b Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Mon, 27 Jun 2022 21:34:09 +0000 Subject: audio VTS: add CompressedOffloadOutputStream test CompressedOffloadOutputStreamTest#Mp3FormatGaplessOffload verifies that gapless offload is supported by compressed offload mix ports. Bug: 219767875 Test: atest VtsHalAudioV7_0TargetTest Test: atest VtsHalAudioV7_1TargetTest Change-Id: I7d42f8a714da2923b8775445ba301938ca90b885 Merged-In: I7d42f8a714da2923b8775445ba301938ca90b885 (cherry picked from commit 158a2ddb2fafa01e2e52a4c9033b81c29d05dfdd) --- .../vts/functional/7.0/AudioPrimaryHidlHalTest.cpp | 126 +++++++++++++++++++-- .../all-versions/vts/functional/7.0/Generators.cpp | 4 +- audio/core/all-versions/vts/functional/Android.bp | 2 + .../vts/functional/AudioPrimaryHidlHalTest.h | 17 ++- .../vts/functional/VtsHalAudioV7_0TargetTest.xml | 1 + .../vts/functional/VtsHalAudioV7_1TargetTest.xml | 2 + .../vts/functional/data/sine882hz3s.mp3 | Bin 0 -> 19117 bytes 7 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 audio/core/all-versions/vts/functional/data/sine882hz3s.mp3 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 be90b2180c..37992ae720 100644 --- a/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +#include +#include + #include #include "Generators.h" @@ -561,16 +564,22 @@ class PcmOnlyConfigOutputStreamTest : public OutputStreamTest { // Sometimes HAL doesn't have enough information until the audio data actually gets // consumed by the hardware. bool timedOut = false; - res = Result::INVALID_STATE; - for (android::base::Timer elapsed; - res != Result::OK && !writer.hasError() && - !(timedOut = (elapsed.duration() >= kPositionChangeTimeout));) { - usleep(kWriteDurationUs); - ASSERT_OK(stream->getPresentationPosition(returnIn(res, framesInitial, ts))); - ASSERT_RESULT(okOrInvalidState, res); + if (!firstPosition || *firstPosition == std::numeric_limits::max()) { + res = Result::INVALID_STATE; + for (android::base::Timer elapsed; + res != Result::OK && !writer.hasError() && + !(timedOut = (elapsed.duration() >= kPositionChangeTimeout));) { + usleep(kWriteDurationUs); + ASSERT_OK(stream->getPresentationPosition(returnIn(res, framesInitial, ts))); + ASSERT_RESULT(okOrInvalidState, res); + } + ASSERT_FALSE(writer.hasError()); + ASSERT_FALSE(timedOut); + } else { + // Use `firstPosition` instead of querying it from the HAL. This is used when + // `waitForPresentationPositionAdvance` is called in a loop. + framesInitial = *firstPosition; } - ASSERT_FALSE(writer.hasError()); - ASSERT_FALSE(timedOut); uint64_t frames = framesInitial; for (android::base::Timer elapsed; @@ -632,7 +641,7 @@ TEST_P(PcmOnlyConfigOutputStreamTest, PresentationPositionPreservedOnStandby) { ASSERT_OK(stream->standby()); writer.resume(); - uint64_t frames; + uint64_t frames = std::numeric_limits::max(); ASSERT_NO_FATAL_FAILURE(waitForPresentationPositionAdvance(writer, &frames)); EXPECT_GT(frames, framesInitial); @@ -853,3 +862,100 @@ INSTANTIATE_TEST_CASE_P(MicrophoneInfoInputStream, MicrophoneInfoInputStreamTest ::testing::ValuesIn(getBuiltinMicConfigParameters()), &DeviceConfigParameterToString); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MicrophoneInfoInputStreamTest); + +static const std::vector& getOutputDeviceCompressedConfigParameters( + const AudioConfigBase& configToMatch) { + static const std::vector parameters = [&] { + auto allParams = getOutputDeviceConfigParameters(); + std::vector compressedParams; + std::copy_if(allParams.begin(), allParams.end(), std::back_inserter(compressedParams), + [&](auto cfg) { + if (std::get(cfg).base != configToMatch) return false; + const auto& flags = std::get(cfg); + return std::find_if(flags.begin(), flags.end(), [](const auto& flag) { + return flag == + toString(xsd::AudioInOutFlag:: + AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD); + }) != flags.end(); + }); + return compressedParams; + }(); + return parameters; +} + +class CompressedOffloadOutputStreamTest : public PcmOnlyConfigOutputStreamTest { + public: + void loadData(const std::string& fileName, std::vector* data) { + std::ifstream is(fileName, std::ios::in | std::ios::binary); + ASSERT_TRUE(is.good()) << "Failed to open file " << fileName; + is.seekg(0, is.end); + data->reserve(data->size() + is.tellg()); + is.seekg(0, is.beg); + data->insert(data->end(), std::istreambuf_iterator(is), + std::istreambuf_iterator()); + ASSERT_TRUE(!is.fail()) << "Failed to read from file " << fileName; + } +}; + +TEST_P(CompressedOffloadOutputStreamTest, Mp3FormatGaplessOffload) { + doc::test("Check that compressed offload mix ports for MP3 implement gapless offload"); + const auto& flags = getOutputFlags(); + if (std::find_if(flags.begin(), flags.end(), [](const auto& flag) { + return flag == toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD); + }) == flags.end()) { + GTEST_SKIP() << "Compressed offload mix port does not support gapless offload"; + } + // FIXME: The presentation position is not updated if there is no zero padding in data. + std::vector offloadData(stream->getBufferSize()); + ASSERT_NO_FATAL_FAILURE(loadData("/data/local/tmp/sine882hz3s.mp3", &offloadData)); + ASSERT_FALSE(offloadData.empty()); + ASSERT_NO_FATAL_FAILURE(createPatchIfNeeded()); + const int presentationeEndPrecisionMs = 1000; + const int sampleRate = 44100; + const int significantSampleNumber = (presentationeEndPrecisionMs * sampleRate) / 1000; + const int delay = 576 + 1000; + const int padding = 756 + 1000; + const int durationMs = 3000 - 44; + // StreamWriter plays 'offloadData' in a loop, possibly using multiple calls to 'write', + // this depends on the relative sizes of 'offloadData' and the HAL buffer. Writer calls + // 'onDataWrap' callback each time it wraps around the buffer. + StreamWriter writer( + stream.get(), stream->getBufferSize(), std::move(offloadData), [&]() /* onDataWrap */ { + Parameters::set(stream, + {{AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES, std::to_string(delay)}, + {AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES, std::to_string(padding)}}); + stream->drain(AudioDrain::EARLY_NOTIFY); + }); + ASSERT_TRUE(writer.start()); + ASSERT_TRUE(writer.waitForAtLeastOneCycle()); + // Decrease the volume since the test plays a loud sine wave. + ASSERT_OK(stream->setVolume(0.1, 0.1)); + // How many times to loop the track so that the sum of gapless delay and padding from + // the first presentation end to the last is at least 'presentationeEndPrecisionMs'. + const int playbackNumber = (int)(significantSampleNumber / ((float)delay + padding) + 1); + std::vector presentationEndTimes; + uint64_t previousPosition = std::numeric_limits::max(); + for (int i = 0; i < playbackNumber; ++i) { + const auto start = std::chrono::steady_clock::now(); + ASSERT_NO_FATAL_FAILURE( + waitForPresentationPositionAdvance(writer, &previousPosition, &previousPosition)); + presentationEndTimes.push_back(std::chrono::duration_cast( + std::chrono::steady_clock::now() - start) + .count()); + } + const float avgDuration = + std::accumulate(presentationEndTimes.begin(), presentationEndTimes.end(), 0.0) / + presentationEndTimes.size(); + EXPECT_NEAR(durationMs, avgDuration, presentationeEndPrecisionMs * 0.1); + writer.stop(); + releasePatchIfNeeded(); +} + +INSTANTIATE_TEST_CASE_P( + CompressedOffloadOutputStream, CompressedOffloadOutputStreamTest, + ::testing::ValuesIn(getOutputDeviceCompressedConfigParameters(AudioConfigBase{ + .format = xsd::toString(xsd::AudioFormat::AUDIO_FORMAT_MP3), + .sampleRateHz = 44100, + .channelMask = xsd::toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO)})), + &DeviceConfigParameterToString); +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CompressedOffloadOutputStreamTest); 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 cd84c41308..8b955b6c84 100644 --- a/audio/core/all-versions/vts/functional/7.0/Generators.cpp +++ b/audio/core/all-versions/vts/functional/7.0/Generators.cpp @@ -78,10 +78,10 @@ static AudioOffloadInfo generateOffloadInfo(const AudioConfigBase& base) { .base = base, .streamType = toString(xsd::AudioStreamType::AUDIO_STREAM_MUSIC), .usage = toString(xsd::AudioUsage::AUDIO_USAGE_MEDIA), - .bitRatePerSecond = 320, + .bitRatePerSecond = 192, // as in sine882hz3s.mp3 .durationMicroseconds = -1, .bitWidth = 16, - .bufferSize = 256 // arbitrary value + .bufferSize = 72000 // 3 seconds at 192 kbps, as in sine882hz3s.mp3 }; } diff --git a/audio/core/all-versions/vts/functional/Android.bp b/audio/core/all-versions/vts/functional/Android.bp index c757032e0f..5b0a7f28f9 100644 --- a/audio/core/all-versions/vts/functional/Android.bp +++ b/audio/core/all-versions/vts/functional/Android.bp @@ -190,6 +190,7 @@ cc_test { ], data: [ ":audio_policy_configuration_V7_0", + "data/sine882hz3s.mp3", ], // Use test_config for vts suite. // TODO(b/146104851): Add auto-gen rules and remove it. @@ -223,6 +224,7 @@ cc_test { ], data: [ ":audio_policy_configuration_V7_1", + "data/sine882hz3s.mp3", ], // Use test_config for vts suite. // TODO(b/146104851): Add auto-gen rules and remove it. diff --git a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h index afc25f0a1e..6c5584d427 100644 --- a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h +++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h @@ -937,6 +937,14 @@ class StreamWriter : public StreamWorker { StreamWriter(IStreamOut* stream, size_t bufferSize) : mStream(stream), mBufferSize(bufferSize), mData(mBufferSize) {} + StreamWriter(IStreamOut* stream, size_t bufferSize, std::vector&& data, + std::function onDataWrap) + : mStream(stream), + mBufferSize(bufferSize), + mData(std::move(data)), + mOnDataWrap(onDataWrap) { + ALOGW("StreamWriter data size: %d", (int)mData.size()); + } ~StreamWriter() { stop(); if (mEfGroup) { @@ -1002,9 +1010,11 @@ class StreamWriter : public StreamWorker { ALOGE("command message queue write failed"); return false; } - const size_t dataSize = std::min(mData.size(), mDataMQ->availableToWrite()); - bool success = mDataMQ->write(mData.data(), dataSize); + const size_t dataSize = std::min(mData.size() - mDataPosition, mDataMQ->availableToWrite()); + bool success = mDataMQ->write(mData.data() + mDataPosition, dataSize); ALOGE_IF(!success, "data message queue write failed"); + mDataPosition += dataSize; + if (mDataPosition >= mData.size()) mDataPosition = 0; mEfGroup->wake(static_cast(MessageQueueFlagBits::NOT_EMPTY)); uint32_t efState = 0; @@ -1030,6 +1040,7 @@ class StreamWriter : public StreamWorker { ALOGE("bad wait status: %d", ret); success = false; } + if (success && mDataPosition == 0) mOnDataWrap(); return success; } @@ -1037,6 +1048,8 @@ class StreamWriter : public StreamWorker { IStreamOut* const mStream; const size_t mBufferSize; std::vector mData; + std::function mOnDataWrap = []() {}; + size_t mDataPosition = 0; std::unique_ptr mCommandMQ; std::unique_ptr mDataMQ; std::unique_ptr mStatusMQ; diff --git a/audio/core/all-versions/vts/functional/VtsHalAudioV7_0TargetTest.xml b/audio/core/all-versions/vts/functional/VtsHalAudioV7_0TargetTest.xml index f0e26958b9..8da5744089 100644 --- a/audio/core/all-versions/vts/functional/VtsHalAudioV7_0TargetTest.xml +++ b/audio/core/all-versions/vts/functional/VtsHalAudioV7_0TargetTest.xml @@ -29,6 +29,7 @@