From df9ea6e6792ded9d909fe16cc2acb33d2064890e Mon Sep 17 00:00:00 2001 From: Ravneet Dhanjal Date: Wed, 4 Jan 2023 21:06:52 +0000 Subject: [PATCH 01/10] Validate request metadata before coverting to camera metadata - Backport similar fix from AIDL to HIDL to protect from malformed metadata Bug: 256166626 Test: CTS test Change-Id: If8f83520144824e38ed102b7468d6d5ee2e6d963 --- camera/device/3.2/default/convert.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/camera/device/3.2/default/convert.cpp b/camera/device/3.2/default/convert.cpp index 06ad7e963c..207560783f 100644 --- a/camera/device/3.2/default/convert.cpp +++ b/camera/device/3.2/default/convert.cpp @@ -16,6 +16,7 @@ #define LOG_TAG "android.hardware.camera.device@3.2-convert-impl" #include +#include #include "include/convert.h" @@ -43,6 +44,13 @@ bool convertFromHidl(const CameraMetadata &src, const camera_metadata_t** dst) { ALOGE("%s: input CameraMetadata is corrupt!", __FUNCTION__); return false; } + + if (validate_camera_metadata_structure((camera_metadata_t*)data, /*expected_size=*/NULL) != + OK) { + ALOGE("%s: Failed to validate the metadata structure", __FUNCTION__); + return false; + } + *dst = (camera_metadata_t*) data; return true; } From cbde2d0940cda564092538ec8d3703776bef032f Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 11 Jan 2023 12:08:43 -0800 Subject: [PATCH 02/10] Effect: Move thread priority updates from threadLoop Now updated in prepareForProcessing(), which avoids race with close(). Test: atest AudioEffectTest Test: Run spatial audio Test: adb shell 'uclampset -a -p $(pgrep -of android.hardware.audio.service)' Bug: 265055114 Change-Id: I31de38d54aa42d7ae3cc87d0afc4a410fc3336ad --- audio/effect/all-versions/default/Effect.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/audio/effect/all-versions/default/Effect.cpp b/audio/effect/all-versions/default/Effect.cpp index 87e1ab7a7d..5aecd324eb 100644 --- a/audio/effect/all-versions/default/Effect.cpp +++ b/audio/effect/all-versions/default/Effect.cpp @@ -240,16 +240,6 @@ class ProcessThread : public Thread { }; bool ProcessThread::threadLoop() { - // For a spatializer effect, we perform scheduler adjustments to reduce glitches and power. - { - effect_descriptor_t halDescriptor{}; - if ((*mEffect)->get_descriptor(mEffect, &halDescriptor) == NO_ERROR && - memcmp(&halDescriptor.type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0) { - const status_t status = scheduler::updateSpatializerPriority(gettid()); - ALOGW_IF(status != OK, "Failed to update Spatializer priority"); - } - } - // This implementation doesn't return control back to the Thread until it decides to stop, // as the Thread uses mutexes, and this can lead to priority inversion. while (!std::atomic_load_explicit(mStop, std::memory_order_acquire)) { @@ -570,6 +560,15 @@ Return Effect::prepareForProcessing(prepareForProcessing_cb _hidl_cb) { return Void(); } + // For a spatializer effect, we perform scheduler adjustments to reduce glitches and power. + // We do it here instead of the ProcessThread::threadLoop to ensure that mHandle is valid. + if (effect_descriptor_t halDescriptor{}; + (*mHandle)->get_descriptor(mHandle, &halDescriptor) == NO_ERROR && + memcmp(&halDescriptor.type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0) { + const status_t status = scheduler::updateSpatializerPriority(mProcessThread->getTid()); + ALOGW_IF(status != OK, "Failed to update Spatializer priority"); + } + mStatusMQ = std::move(tempStatusMQ); _hidl_cb(Result::OK, *mStatusMQ->getDesc()); return Void(); From f331f1202f4eb6602b0836b79505df453d7ca222 Mon Sep 17 00:00:00 2001 From: shrikar Date: Thu, 22 Dec 2022 17:06:49 +0000 Subject: [PATCH 03/10] Change default units to be consistent in tm-qpr-dev/DefaultConfig.h Bug: 259879204 Test: atest CarPropertyManagerTest Change-Id: I6060ffbce028dc95091e2b002b594a5b6a5eed48 Merged-In: Ib159f781f61de8a7cd1498ad2a07e5dbd0eca734 --- .../vehicle/aidl/impl/default_config/include/DefaultConfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h index 622846a301..5ce98bd954 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -177,7 +177,7 @@ const std::vector kVehicleProperties = { toInt(VehicleUnit::MILES_PER_HOUR), toInt(VehicleUnit::KILOMETERS_PER_HOUR)}, }, - .initialValue = {.int32Values = {toInt(VehicleUnit::KILOMETERS_PER_HOUR)}}}, + .initialValue = {.int32Values = {toInt(VehicleUnit::MILES_PER_HOUR)}}}, {.config = { @@ -1025,7 +1025,7 @@ const std::vector kVehicleProperties = { .changeMode = VehiclePropertyChangeMode::ON_CHANGE, .configArray = {(int)VehicleUnit::LITER, (int)VehicleUnit::US_GALLON}, }, - .initialValue = {.int32Values = {(int)VehicleUnit::LITER}}}, + .initialValue = {.int32Values = {(int)VehicleUnit::US_GALLON}}}, {.config = { From 042995281706b8acfc8d2cc18358b143886aa794 Mon Sep 17 00:00:00 2001 From: Rongxuan Liu Date: Thu, 26 Jan 2023 17:14:54 +0000 Subject: [PATCH 04/10] Add new field 'pcmStreamId' in LeAudioBroadcastConfiguration This field is used to indicate the PCM stream source for given stream handle Tag: #feature Bug: 264692800 Test: m android.hardware.bluetooth.audio-update-api Change-Id: I3df9066e98ca552329bb58ae5fbc5346d1021b10 Merged-In: I3df9066e98ca552329bb58ae5fbc5346d1021b10 --- .../bluetooth/audio/LeAudioBroadcastConfiguration.aidl | 1 + .../bluetooth/audio/LeAudioBroadcastConfiguration.aidl | 4 ++++ bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl index 7d53b0ca8e..2945710c26 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl @@ -41,5 +41,6 @@ parcelable LeAudioBroadcastConfiguration { char streamHandle; int audioChannelAllocation; android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig; + char pcmStreamId; } } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl index e9a1a0c6e9..16503fb36a 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl @@ -35,6 +35,10 @@ parcelable LeAudioBroadcastConfiguration { */ int audioChannelAllocation; LeAudioCodecConfiguration leAudioCodecConfig; + /* + * Pcm stream id to identify the source for given streamHandle. + */ + char pcmStreamId; } CodecType codecType; BroadcastStreamMap[] streamMap; diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp index 128ef61403..6a913f7b1e 100644 --- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp +++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp @@ -1570,6 +1570,10 @@ TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl, le_audio_broadcast_config.streamMap[0] .leAudioCodecConfig.set( lc3_config); + le_audio_broadcast_config.streamMap[0].streamHandle = 0x0; + le_audio_broadcast_config.streamMap[0].pcmStreamId = 0x0; + le_audio_broadcast_config.streamMap[0].audioChannelAllocation = 0x1 << 0; + DataMQDesc mq_desc; auto aidl_retval = audio_provider_->startSession( audio_port_, AudioConfiguration(le_audio_broadcast_config), From 0ec2eb8ca4f297fcea50d75e5700673213662c4c Mon Sep 17 00:00:00 2001 From: Rongxuan Liu Date: Thu, 26 Jan 2023 17:16:20 +0000 Subject: [PATCH 05/10] Update android.hardware.bluetooth.audio to V3 Tag: #feature Bug: 266740545 Test: m android.hardware.bluetooth.audio-update-api && atest VtsHalBluetoothAudioTargetTest Change-Id: Ia92043aeedf12a8c68d7f4ee18a1dd52ac5a252f Merged-In: Ia92043aeedf12a8c68d7f4ee18a1dd52ac5a252f (cherry picked from commit dfd6fb219f5e7db430d9fab2a8727713c4353615) --- bluetooth/audio/aidl/default/Android.bp | 2 +- bluetooth/audio/aidl/default/bluetooth_audio.xml | 2 +- bluetooth/audio/aidl/vts/Android.bp | 2 +- bluetooth/audio/utils/Android.bp | 4 ++-- compatibility_matrices/compatibility_matrix.8.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bluetooth/audio/aidl/default/Android.bp b/bluetooth/audio/aidl/default/Android.bp index cbf23dce46..e4c2844ca0 100644 --- a/bluetooth/audio/aidl/default/Android.bp +++ b/bluetooth/audio/aidl/default/Android.bp @@ -29,7 +29,7 @@ cc_library_shared { "libcutils", "libfmq", "liblog", - "android.hardware.bluetooth.audio-V2-ndk", + "android.hardware.bluetooth.audio-V3-ndk", "libbluetooth_audio_session_aidl", ], } diff --git a/bluetooth/audio/aidl/default/bluetooth_audio.xml b/bluetooth/audio/aidl/default/bluetooth_audio.xml index c4b1872333..c0bc55e2f7 100644 --- a/bluetooth/audio/aidl/default/bluetooth_audio.xml +++ b/bluetooth/audio/aidl/default/bluetooth_audio.xml @@ -1,7 +1,7 @@ android.hardware.bluetooth.audio - 2 + 3 IBluetoothAudioProviderFactory/default diff --git a/bluetooth/audio/aidl/vts/Android.bp b/bluetooth/audio/aidl/vts/Android.bp index 3aed1b38ff..e03fb5873d 100644 --- a/bluetooth/audio/aidl/vts/Android.bp +++ b/bluetooth/audio/aidl/vts/Android.bp @@ -17,7 +17,7 @@ cc_test { srcs: ["VtsHalBluetoothAudioTargetTest.cpp"], shared_libs: [ "android.hardware.audio.common-V1-ndk", - "android.hardware.bluetooth.audio-V2-ndk", + "android.hardware.bluetooth.audio-V3-ndk", "android.hardware.common-V2-ndk", "android.hardware.common.fmq-V1-ndk", "libbase", diff --git a/bluetooth/audio/utils/Android.bp b/bluetooth/audio/utils/Android.bp index 70797a7aaf..914d2b2fd3 100644 --- a/bluetooth/audio/utils/Android.bp +++ b/bluetooth/audio/utils/Android.bp @@ -55,7 +55,7 @@ cc_library_shared { "libbinder_ndk", "libfmq", "liblog", - "android.hardware.bluetooth.audio-V2-ndk", + "android.hardware.bluetooth.audio-V3-ndk", "libhidlbase", "libxml2", ], @@ -75,7 +75,7 @@ cc_test { shared_libs: [ "libbase", "libbinder_ndk", - "android.hardware.bluetooth.audio-V2-ndk", + "android.hardware.bluetooth.audio-V3-ndk", "libxml2", ], test_suites: [ diff --git a/compatibility_matrices/compatibility_matrix.8.xml b/compatibility_matrices/compatibility_matrix.8.xml index eb649bf1bd..c7b05e8028 100644 --- a/compatibility_matrices/compatibility_matrix.8.xml +++ b/compatibility_matrices/compatibility_matrix.8.xml @@ -167,7 +167,7 @@ android.hardware.bluetooth.audio - 2 + 3 IBluetoothAudioProviderFactory default From c36d6be8ff89e4c022dcf6d480b5921f13328d9b Mon Sep 17 00:00:00 2001 From: Jusik Chung Date: Fri, 17 Feb 2023 15:13:12 +0900 Subject: [PATCH 06/10] VHAL for PERF_VEHICLE_SPEED_DISPLAY. Bug: 261934875 Bug: 261943854 Test: adb shell cmd car_service get-property-value 0x11600208 Change-Id: I0390189129ebd41a913f5fc0f903a0ee22b226d7 Merged-In: Ifdd41da591e8c352326a247f65a59cda36b76981 --- .../aidl/impl/default_config/include/DefaultConfig.h | 10 +++++++++- 1 file changed, 9 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 5ce98bd954..f023fd2063 100644 --- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h +++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h @@ -167,7 +167,15 @@ const std::vector kVehicleProperties = { .maxSampleRate = 10.0f, }, .initialValue = {.floatValues = {0.0f}}}, - + {.config = + { + .prop = toInt(VehicleProperty::PERF_VEHICLE_SPEED_DISPLAY), + .access = VehiclePropertyAccess::READ, + .changeMode = VehiclePropertyChangeMode::CONTINUOUS, + .minSampleRate = 1.0f, + .maxSampleRate = 10.0f, + }, + .initialValue = {.floatValues = {0.0f}}}, {.config = { .prop = toInt(VehicleProperty::VEHICLE_SPEED_DISPLAY_UNITS), From 6dddd6f43a328eac0c236553be2c1da071832a0a Mon Sep 17 00:00:00 2001 From: Yuchen He Date: Thu, 2 Mar 2023 00:02:13 +0000 Subject: [PATCH 07/10] Fix epoll leaks: clean up file descriptor and epoll instance properly Bug: 262762412 Test: manual test Change-Id: Ia587f8ba0ce44234a7c00cd820db73258dba19b0 (cherry picked from commit 9af806fe06a92e67a86ede4b134ca1fec8abe0c6) --- .../common/utils/default/DeviceFileReader.cpp | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/gnss/common/utils/default/DeviceFileReader.cpp b/gnss/common/utils/default/DeviceFileReader.cpp index dfc086a8b8..91e75eb460 100644 --- a/gnss/common/utils/default/DeviceFileReader.cpp +++ b/gnss/common/utils/default/DeviceFileReader.cpp @@ -32,40 +32,52 @@ void DeviceFileReader::getDataFromDeviceFile(const std::string& command, int mMi return; } - int mGnssFd = open(deviceFilePath.c_str(), O_RDWR | O_NONBLOCK); - - if (mGnssFd == -1) { + int gnss_fd, epoll_fd; + if ((gnss_fd = open(deviceFilePath.c_str(), O_RDWR | O_NONBLOCK)) == -1) { + return; + } + if (write(gnss_fd, command.c_str(), command.size()) <= 0) { + close(gnss_fd); return; } - int bytes_write = write(mGnssFd, command.c_str(), command.size()); - if (bytes_write <= 0) { - close(mGnssFd); + // Create an epoll instance. + if ((epoll_fd = epoll_create1(EPOLL_CLOEXEC)) < 0) { + close(gnss_fd); return; } + // Add file descriptor to epoll instance. struct epoll_event ev, events[1]; - ev.data.fd = mGnssFd; + memset(&ev, 0, sizeof(ev)); + ev.data.fd = gnss_fd; ev.events = EPOLLIN; - int epoll_fd = epoll_create1(0); - epoll_ctl(epoll_fd, EPOLL_CTL_ADD, mGnssFd, &ev); + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, gnss_fd, &ev) == -1) { + close(gnss_fd); + close(epoll_fd); + return; + } + + // Wait for device file event. + if (epoll_wait(epoll_fd, events, 1, mMinIntervalMs) == -1) { + close(gnss_fd); + close(epoll_fd); + return; + } + + // Handle event and write data to string buffer. int bytes_read = -1; std::string inputStr = ""; - int epoll_ret = epoll_wait(epoll_fd, events, 1, mMinIntervalMs); - - if (epoll_ret == -1) { - close(mGnssFd); - return; - } while (true) { memset(inputBuffer, 0, INPUT_BUFFER_SIZE); - bytes_read = read(mGnssFd, &inputBuffer, INPUT_BUFFER_SIZE); + bytes_read = read(gnss_fd, &inputBuffer, INPUT_BUFFER_SIZE); if (bytes_read <= 0) { break; } s_buffer_ += std::string(inputBuffer, bytes_read); } - close(mGnssFd); + close(gnss_fd); + close(epoll_fd); // Trim end of file mark(\n\n\n\n). auto pos = s_buffer_.find("\n\n\n\n"); From df791de79a3c72ae80b265608f53265be7f81597 Mon Sep 17 00:00:00 2001 From: matthuang Date: Wed, 22 Mar 2023 11:40:08 +0800 Subject: [PATCH 08/10] [DO NOT MERGE] Add group 'uhid' to sensors multi-HAL. Allow sensor hal to send SW_LID event through HID transport drivers when hall_effect event is detected. Bug: 262056923 Bug: 274537630 Test: Build pass. Change-Id: Iddbb4b83f20955d7c316d0eee391effcf30f5b4f --- .../multihal/android.hardware.sensors@2.1-service-multihal.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc b/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc index deea16e4d3..e149058f0f 100644 --- a/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc +++ b/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc @@ -1,7 +1,7 @@ service vendor.sensors-hal-2-1-multihal /vendor/bin/hw/android.hardware.sensors@2.1-service.multihal class hal user system - group system wakelock context_hub input + group system wakelock context_hub input uhid task_profiles ServiceCapacityLow capabilities BLOCK_SUSPEND rlimit rtprio 10 10 From 0fc06552d89c89e020d1663d01763bfa134afc3b Mon Sep 17 00:00:00 2001 From: matthuang Date: Wed, 22 Mar 2023 11:40:08 +0800 Subject: [PATCH 09/10] [DO NOT MERGE] Add group 'uhid' to sensors multi-HAL. Allow sensor hal to send SW_LID event through HID transport drivers when hall_effect event is detected. Bug: 262056923 Bug: 274537630 Test: Build pass. Change-Id: Iddbb4b83f20955d7c316d0eee391effcf30f5b4f Merged-In: Iddbb4b83f20955d7c316d0eee391effcf30f5b4f --- .../multihal/android.hardware.sensors@2.1-service-multihal.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc b/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc index f47e060f88..0b59841730 100644 --- a/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc +++ b/sensors/2.1/multihal/android.hardware.sensors@2.1-service-multihal.rc @@ -1,7 +1,7 @@ service vendor.sensors-hal-2-1-multihal /vendor/bin/hw/android.hardware.sensors@2.1-service.multihal class hal user system - group system wakelock context_hub + group system wakelock context_hub uhid task_profiles ServiceCapacityLow capabilities BLOCK_SUSPEND rlimit rtprio 10 10 From d00b8598bb9f5b993a2b80b5525cde1cb535369f Mon Sep 17 00:00:00 2001 From: ramindani Date: Sat, 25 Mar 2023 06:03:29 -0700 Subject: [PATCH 10/10] VTS add length is not zero check for executeSetClientTarget Test: atest VtsHalGraphicsComposerV2_1TargetTest BUG: 252764410 Change-Id: Icd15f6e7bfdd7b3e3d0d4b407195258d4171c560 (cherry picked from commit 708d49cfce0cfa4ef9bd222ea694dbc6338d8798) Merged-In: Icd15f6e7bfdd7b3e3d0d4b407195258d4171c560 --- .../utils/hal/include/composer-hal/2.1/ComposerCommandEngine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerCommandEngine.h b/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerCommandEngine.h index ab67eb10bc..9ae6173a91 100644 --- a/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerCommandEngine.h +++ b/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerCommandEngine.h @@ -207,7 +207,7 @@ class ComposerCommandEngine : protected CommandReaderBase { bool executeSetClientTarget(uint16_t length) { // 4 parameters followed by N rectangles - if ((length - 4) % 4 != 0) { + if (!length || (length - 4) % 4 != 0) { return false; }