aidl: sensors: Use multihal sources directly from hardware/interfaces

* Possible after https://android.googlesource.com/platform/hardware/interfaces/+/5a856698db49a2e78024f10c9ea5060235afe0b1

Change-Id: I7b4beaf08327431740ab24dd651bc133bdf65cf1
diff --git a/aidl/sensors/Android.bp b/aidl/sensors/Android.bp
index 7cdf37b..7e63d3c 100644
--- a/aidl/sensors/Android.bp
+++ b/aidl/sensors/Android.bp
@@ -1,5 +1,6 @@
 //
 // Copyright (C) 2020 The Android Open Source Project
+// Copyright (C) 2022-2024 The LineageOS Project
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,27 +16,23 @@
 
 cc_binary {
     name: "android.hardware.sensors-service.samsung-multihal",
-    defaults: [
-        "hidl_defaults",
-    ],
     vendor: true,
     relative_install_path: "hw",
     srcs: [
-        "ConvertUtils.cpp",
-        "HalProxyAidl.cpp",
+        "HalProxySamsung.cpp",
         "service.cpp",
     ],
-    local_include_dirs: ["include"],
     init_rc: ["android.hardware.sensors-service.samsung-multihal.rc"],
     vintf_fragments: ["android.hardware.sensors-samsung-multihal.xml"],
     header_libs: [
+        "android.hardware.sensors@2.X-multihal.header",
         "android.hardware.sensors@2.X-shared-utils",
     ],
     shared_libs: [
         "android.hardware.sensors@2.0",
         "android.hardware.sensors@2.0-ScopedWakelock",
         "android.hardware.sensors@2.1",
-        "android.hardware.sensors-V1-ndk",
+        "android.hardware.sensors-V2-ndk",
         "libbase",
         "libbinder_ndk",
         "libcutils",
@@ -48,6 +45,7 @@
     static_libs: [
         "android.hardware.sensors@1.0-convert",
         "android.hardware.sensors@2.X-multihal",
+        "android.hardware.sensors@aidl-multihal",
         "libaidlcommonsupport",
     ],
 }
diff --git a/aidl/sensors/ConvertUtils.cpp b/aidl/sensors/ConvertUtils.cpp
deleted file mode 100644
index bf56ed5..0000000
--- a/aidl/sensors/ConvertUtils.cpp
+++ /dev/null
@@ -1,363 +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.
- */
-
-#include "ConvertUtils.h"
-#include <android-base/logging.h>
-#include <log/log.h>
-
-using AidlSensorInfo = ::aidl::android::hardware::sensors::SensorInfo;
-using AidlSensorType = ::aidl::android::hardware::sensors::SensorType;
-using AidlEvent = ::aidl::android::hardware::sensors::Event;
-using AidlSensorStatus = ::aidl::android::hardware::sensors::SensorStatus;
-using ::aidl::android::hardware::sensors::AdditionalInfo;
-using ::aidl::android::hardware::sensors::DynamicSensorInfo;
-using ::android::hardware::sensors::V1_0::MetaDataEventType;
-using V1_0SensorStatus = ::android::hardware::sensors::V1_0::SensorStatus;
-using ::android::hardware::sensors::V1_0::AdditionalInfoType;
-using V2_1SensorInfo = ::android::hardware::sensors::V2_1::SensorInfo;
-using V2_1Event = ::android::hardware::sensors::V2_1::Event;
-using V2_1SensorType = ::android::hardware::sensors::V2_1::SensorType;
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-AidlSensorInfo convertSensorInfo(const V2_1SensorInfo& sensorInfo) {
-    AidlSensorInfo aidlSensorInfo;
-    aidlSensorInfo.sensorHandle = sensorInfo.sensorHandle;
-    aidlSensorInfo.name = sensorInfo.name;
-    aidlSensorInfo.vendor = sensorInfo.vendor;
-    aidlSensorInfo.version = sensorInfo.version;
-    aidlSensorInfo.type = (AidlSensorType)sensorInfo.type;
-    aidlSensorInfo.typeAsString = sensorInfo.typeAsString;
-    aidlSensorInfo.maxRange = sensorInfo.maxRange;
-    aidlSensorInfo.resolution = sensorInfo.resolution;
-    aidlSensorInfo.power = sensorInfo.power;
-    aidlSensorInfo.minDelayUs = sensorInfo.minDelay;
-    aidlSensorInfo.fifoReservedEventCount = sensorInfo.fifoReservedEventCount;
-    aidlSensorInfo.fifoMaxEventCount = sensorInfo.fifoMaxEventCount;
-    aidlSensorInfo.requiredPermission = sensorInfo.requiredPermission;
-    aidlSensorInfo.maxDelayUs = sensorInfo.maxDelay;
-    aidlSensorInfo.flags = sensorInfo.flags;
-    return aidlSensorInfo;
-}
-
-void convertToHidlEvent(const AidlEvent& aidlEvent, V2_1Event* hidlEvent) {
-    static_assert(decltype(hidlEvent->u.data)::elementCount() == 16);
-    hidlEvent->timestamp = aidlEvent.timestamp;
-    hidlEvent->sensorHandle = aidlEvent.sensorHandle;
-    hidlEvent->sensorType = (V2_1SensorType)aidlEvent.sensorType;
-
-    switch (aidlEvent.sensorType) {
-        case AidlSensorType::META_DATA:
-            hidlEvent->u.meta.what =
-                    (MetaDataEventType)aidlEvent.payload.get<Event::EventPayload::meta>().what;
-            break;
-        case AidlSensorType::ACCELEROMETER:
-        case AidlSensorType::MAGNETIC_FIELD:
-        case AidlSensorType::ORIENTATION:
-        case AidlSensorType::GYROSCOPE:
-        case AidlSensorType::GRAVITY:
-        case AidlSensorType::LINEAR_ACCELERATION:
-            hidlEvent->u.vec3.x = aidlEvent.payload.get<Event::EventPayload::vec3>().x;
-            hidlEvent->u.vec3.y = aidlEvent.payload.get<Event::EventPayload::vec3>().y;
-            hidlEvent->u.vec3.z = aidlEvent.payload.get<Event::EventPayload::vec3>().z;
-            hidlEvent->u.vec3.status =
-                    (V1_0SensorStatus)aidlEvent.payload.get<Event::EventPayload::vec3>().status;
-            break;
-        case AidlSensorType::GAME_ROTATION_VECTOR:
-            hidlEvent->u.vec4.x = aidlEvent.payload.get<Event::EventPayload::vec4>().x;
-            hidlEvent->u.vec4.y = aidlEvent.payload.get<Event::EventPayload::vec4>().y;
-            hidlEvent->u.vec4.z = aidlEvent.payload.get<Event::EventPayload::vec4>().z;
-            hidlEvent->u.vec4.w = aidlEvent.payload.get<Event::EventPayload::vec4>().w;
-            break;
-        case AidlSensorType::ROTATION_VECTOR:
-        case AidlSensorType::GEOMAGNETIC_ROTATION_VECTOR:
-            std::copy(aidlEvent.payload.get<Event::EventPayload::data>().values.data(),
-                      aidlEvent.payload.get<Event::EventPayload::data>().values.data() + 5,
-                      hidlEvent->u.data.data());
-            break;
-        case AidlSensorType::ACCELEROMETER_UNCALIBRATED:
-        case AidlSensorType::MAGNETIC_FIELD_UNCALIBRATED:
-        case AidlSensorType::GYROSCOPE_UNCALIBRATED:
-            hidlEvent->u.uncal.x = aidlEvent.payload.get<Event::EventPayload::uncal>().x;
-            hidlEvent->u.uncal.y = aidlEvent.payload.get<Event::EventPayload::uncal>().y;
-            hidlEvent->u.uncal.z = aidlEvent.payload.get<Event::EventPayload::uncal>().z;
-            hidlEvent->u.uncal.x_bias = aidlEvent.payload.get<Event::EventPayload::uncal>().xBias;
-            hidlEvent->u.uncal.y_bias = aidlEvent.payload.get<Event::EventPayload::uncal>().yBias;
-            hidlEvent->u.uncal.z_bias = aidlEvent.payload.get<Event::EventPayload::uncal>().zBias;
-            break;
-        case AidlSensorType::DEVICE_ORIENTATION:
-        case AidlSensorType::LIGHT:
-        case AidlSensorType::PRESSURE:
-        case AidlSensorType::PROXIMITY:
-        case AidlSensorType::RELATIVE_HUMIDITY:
-        case AidlSensorType::AMBIENT_TEMPERATURE:
-        case AidlSensorType::SIGNIFICANT_MOTION:
-        case AidlSensorType::STEP_DETECTOR:
-        case AidlSensorType::TILT_DETECTOR:
-        case AidlSensorType::WAKE_GESTURE:
-        case AidlSensorType::GLANCE_GESTURE:
-        case AidlSensorType::PICK_UP_GESTURE:
-        case AidlSensorType::WRIST_TILT_GESTURE:
-        case AidlSensorType::STATIONARY_DETECT:
-        case AidlSensorType::MOTION_DETECT:
-        case AidlSensorType::HEART_BEAT:
-        case AidlSensorType::LOW_LATENCY_OFFBODY_DETECT:
-        case AidlSensorType::HINGE_ANGLE:
-            hidlEvent->u.scalar = aidlEvent.payload.get<Event::EventPayload::scalar>();
-            break;
-        case AidlSensorType::STEP_COUNTER:
-            hidlEvent->u.stepCount = aidlEvent.payload.get<AidlEvent::EventPayload::stepCount>();
-            break;
-        case AidlSensorType::HEART_RATE:
-            hidlEvent->u.heartRate.bpm =
-                    aidlEvent.payload.get<AidlEvent::EventPayload::heartRate>().bpm;
-            hidlEvent->u.heartRate.status =
-                    (V1_0SensorStatus)aidlEvent.payload.get<Event::EventPayload::heartRate>()
-                            .status;
-            break;
-        case AidlSensorType::POSE_6DOF:
-            std::copy(std::begin(aidlEvent.payload.get<AidlEvent::EventPayload::pose6DOF>().values),
-                      std::end(aidlEvent.payload.get<AidlEvent::EventPayload::pose6DOF>().values),
-                      hidlEvent->u.pose6DOF.data());
-            break;
-        case AidlSensorType::DYNAMIC_SENSOR_META:
-            hidlEvent->u.dynamic.connected =
-                    aidlEvent.payload.get<Event::EventPayload::dynamic>().connected;
-            hidlEvent->u.dynamic.sensorHandle =
-                    aidlEvent.payload.get<Event::EventPayload::dynamic>().sensorHandle;
-            std::copy(
-                    std::begin(
-                            aidlEvent.payload.get<AidlEvent::EventPayload::dynamic>().uuid.values),
-                    std::end(aidlEvent.payload.get<AidlEvent::EventPayload::dynamic>().uuid.values),
-                    hidlEvent->u.dynamic.uuid.data());
-            break;
-        case AidlSensorType::ADDITIONAL_INFO: {
-            const AdditionalInfo& additionalInfo =
-                    aidlEvent.payload.get<AidlEvent::EventPayload::additional>();
-            hidlEvent->u.additional.type = (AdditionalInfoType)additionalInfo.type;
-            hidlEvent->u.additional.serial = additionalInfo.serial;
-
-            switch (additionalInfo.payload.getTag()) {
-                case AdditionalInfo::AdditionalInfoPayload::Tag::dataInt32: {
-                    const auto& aidlData =
-                            additionalInfo.payload
-                                    .get<AdditionalInfo::AdditionalInfoPayload::dataInt32>()
-                                    .values;
-                    std::copy(std::begin(aidlData), std::end(aidlData),
-                              hidlEvent->u.additional.u.data_int32.data());
-                    break;
-                }
-                case AdditionalInfo::AdditionalInfoPayload::Tag::dataFloat: {
-                    const auto& aidlData =
-                            additionalInfo.payload
-                                    .get<AdditionalInfo::AdditionalInfoPayload::dataFloat>()
-                                    .values;
-                    std::copy(std::begin(aidlData), std::end(aidlData),
-                              hidlEvent->u.additional.u.data_float.data());
-                    break;
-                }
-                default:
-                    ALOGE("Invalid sensor additioanl info tag: %d",
-                          static_cast<int32_t>(additionalInfo.payload.getTag()));
-                    break;
-            }
-            break;
-        }
-        case AidlSensorType::HEAD_TRACKER: {
-            const auto& ht = aidlEvent.payload.get<Event::EventPayload::headTracker>();
-            hidlEvent->u.data[0] = ht.rx;
-            hidlEvent->u.data[1] = ht.ry;
-            hidlEvent->u.data[2] = ht.rz;
-            hidlEvent->u.data[3] = ht.vx;
-            hidlEvent->u.data[4] = ht.vy;
-            hidlEvent->u.data[5] = ht.vz;
-
-            // IMPORTANT: Because we want to preserve the data range of discontinuityCount,
-            // we assume the data can be interpreted as an int32_t directly (e.g. the underlying
-            // HIDL HAL must be using memcpy or equivalent to store this value).
-            *(reinterpret_cast<int32_t*>(&hidlEvent->u.data[6])) = ht.discontinuityCount;
-            break;
-        }
-        default: {
-            CHECK_GE((int32_t)aidlEvent.sensorType, (int32_t)SensorType::DEVICE_PRIVATE_BASE);
-            std::copy(std::begin(aidlEvent.payload.get<AidlEvent::EventPayload::data>().values),
-                      std::end(aidlEvent.payload.get<AidlEvent::EventPayload::data>().values),
-                      hidlEvent->u.data.data());
-            break;
-        }
-    }
-}
-
-void convertToAidlEvent(const V2_1Event& hidlEvent, AidlEvent* aidlEvent) {
-    static_assert(decltype(hidlEvent.u.data)::elementCount() == 16);
-    aidlEvent->timestamp = hidlEvent.timestamp;
-    aidlEvent->sensorHandle = hidlEvent.sensorHandle;
-    aidlEvent->sensorType = (AidlSensorType)hidlEvent.sensorType;
-    switch (hidlEvent.sensorType) {
-        case V2_1SensorType::META_DATA: {
-            AidlEvent::EventPayload::MetaData meta;
-            meta.what = (Event::EventPayload::MetaData::MetaDataEventType)hidlEvent.u.meta.what;
-            aidlEvent->payload.set<Event::EventPayload::meta>(meta);
-            break;
-        }
-        case V2_1SensorType::ACCELEROMETER:
-        case V2_1SensorType::MAGNETIC_FIELD:
-        case V2_1SensorType::ORIENTATION:
-        case V2_1SensorType::GYROSCOPE:
-        case V2_1SensorType::GRAVITY:
-        case V2_1SensorType::LINEAR_ACCELERATION: {
-            AidlEvent::EventPayload::Vec3 vec3;
-            vec3.x = hidlEvent.u.vec3.x;
-            vec3.y = hidlEvent.u.vec3.y;
-            vec3.z = hidlEvent.u.vec3.z;
-            vec3.status = (SensorStatus)hidlEvent.u.vec3.status;
-            aidlEvent->payload.set<Event::EventPayload::vec3>(vec3);
-            break;
-        }
-        case V2_1SensorType::GAME_ROTATION_VECTOR: {
-            AidlEvent::EventPayload::Vec4 vec4;
-            vec4.x = hidlEvent.u.vec4.x;
-            vec4.y = hidlEvent.u.vec4.y;
-            vec4.z = hidlEvent.u.vec4.z;
-            vec4.w = hidlEvent.u.vec4.w;
-            aidlEvent->payload.set<Event::EventPayload::vec4>(vec4);
-            break;
-        }
-        case V2_1SensorType::ROTATION_VECTOR:
-        case V2_1SensorType::GEOMAGNETIC_ROTATION_VECTOR: {
-            AidlEvent::EventPayload::Data data;
-            std::copy(hidlEvent.u.data.data(), hidlEvent.u.data.data() + 5,
-                      std::begin(data.values));
-            aidlEvent->payload.set<Event::EventPayload::data>(data);
-            break;
-        }
-        case V2_1SensorType::MAGNETIC_FIELD_UNCALIBRATED:
-        case V2_1SensorType::GYROSCOPE_UNCALIBRATED:
-        case V2_1SensorType::ACCELEROMETER_UNCALIBRATED: {
-            AidlEvent::EventPayload::Uncal uncal;
-            uncal.x = hidlEvent.u.uncal.x;
-            uncal.y = hidlEvent.u.uncal.y;
-            uncal.z = hidlEvent.u.uncal.z;
-            uncal.xBias = hidlEvent.u.uncal.x_bias;
-            uncal.yBias = hidlEvent.u.uncal.y_bias;
-            uncal.zBias = hidlEvent.u.uncal.z_bias;
-            aidlEvent->payload.set<Event::EventPayload::uncal>(uncal);
-            break;
-        }
-        case V2_1SensorType::DEVICE_ORIENTATION:
-        case V2_1SensorType::LIGHT:
-        case V2_1SensorType::PRESSURE:
-        case V2_1SensorType::PROXIMITY:
-        case V2_1SensorType::RELATIVE_HUMIDITY:
-        case V2_1SensorType::AMBIENT_TEMPERATURE:
-        case V2_1SensorType::SIGNIFICANT_MOTION:
-        case V2_1SensorType::STEP_DETECTOR:
-        case V2_1SensorType::TILT_DETECTOR:
-        case V2_1SensorType::WAKE_GESTURE:
-        case V2_1SensorType::GLANCE_GESTURE:
-        case V2_1SensorType::PICK_UP_GESTURE:
-        case V2_1SensorType::WRIST_TILT_GESTURE:
-        case V2_1SensorType::STATIONARY_DETECT:
-        case V2_1SensorType::MOTION_DETECT:
-        case V2_1SensorType::HEART_BEAT:
-        case V2_1SensorType::LOW_LATENCY_OFFBODY_DETECT:
-        case V2_1SensorType::HINGE_ANGLE:
-            aidlEvent->payload.set<Event::EventPayload::scalar>(hidlEvent.u.scalar);
-            break;
-        case V2_1SensorType::STEP_COUNTER:
-            aidlEvent->payload.set<Event::EventPayload::stepCount>(hidlEvent.u.stepCount);
-            break;
-        case V2_1SensorType::HEART_RATE: {
-            AidlEvent::EventPayload::HeartRate heartRate;
-            heartRate.bpm = hidlEvent.u.heartRate.bpm;
-            heartRate.status = (SensorStatus)hidlEvent.u.heartRate.status;
-            aidlEvent->payload.set<Event::EventPayload::heartRate>(heartRate);
-            break;
-        }
-        case V2_1SensorType::POSE_6DOF: {
-            AidlEvent::EventPayload::Pose6Dof pose6Dof;
-            std::copy(hidlEvent.u.pose6DOF.data(),
-                      hidlEvent.u.pose6DOF.data() + hidlEvent.u.pose6DOF.size(),
-                      std::begin(pose6Dof.values));
-            aidlEvent->payload.set<Event::EventPayload::pose6DOF>(pose6Dof);
-            break;
-        }
-        case V2_1SensorType::DYNAMIC_SENSOR_META: {
-            DynamicSensorInfo dynamicSensorInfo;
-            dynamicSensorInfo.connected = hidlEvent.u.dynamic.connected;
-            dynamicSensorInfo.sensorHandle = hidlEvent.u.dynamic.sensorHandle;
-            std::copy(hidlEvent.u.dynamic.uuid.data(),
-                      hidlEvent.u.dynamic.uuid.data() + hidlEvent.u.dynamic.uuid.size(),
-                      std::begin(dynamicSensorInfo.uuid.values));
-            aidlEvent->payload.set<Event::EventPayload::dynamic>(dynamicSensorInfo);
-            break;
-        }
-        case V2_1SensorType::ADDITIONAL_INFO: {
-            AdditionalInfo additionalInfo;
-            additionalInfo.type = (AdditionalInfo::AdditionalInfoType)hidlEvent.u.additional.type;
-            additionalInfo.serial = hidlEvent.u.additional.serial;
-
-            AdditionalInfo::AdditionalInfoPayload::Int32Values int32Values;
-            std::copy(hidlEvent.u.additional.u.data_int32.data(),
-                      hidlEvent.u.additional.u.data_int32.data() +
-                              hidlEvent.u.additional.u.data_int32.size(),
-                      std::begin(int32Values.values));
-            additionalInfo.payload.set<AdditionalInfo::AdditionalInfoPayload::dataInt32>(
-                    int32Values);
-            aidlEvent->payload.set<Event::EventPayload::additional>(additionalInfo);
-            break;
-        }
-        default: {
-            if (static_cast<int32_t>(hidlEvent.sensorType) ==
-                static_cast<int32_t>(AidlSensorType::HEAD_TRACKER)) {
-                Event::EventPayload::HeadTracker headTracker;
-                headTracker.rx = hidlEvent.u.data[0];
-                headTracker.ry = hidlEvent.u.data[1];
-                headTracker.rz = hidlEvent.u.data[2];
-                headTracker.vx = hidlEvent.u.data[3];
-                headTracker.vy = hidlEvent.u.data[4];
-                headTracker.vz = hidlEvent.u.data[5];
-
-                // IMPORTANT: Because we want to preserve the data range of discontinuityCount,
-                // we assume the data can be interpreted as an int32_t directly (e.g. the underlying
-                // HIDL HAL must be using memcpy or equivalent to store this value).
-                headTracker.discontinuityCount =
-                        *(reinterpret_cast<const int32_t*>(&hidlEvent.u.data[6]));
-
-                aidlEvent->payload.set<Event::EventPayload::Tag::headTracker>(headTracker);
-            } else {
-                CHECK_GE((int32_t)hidlEvent.sensorType,
-                         (int32_t)V2_1SensorType::DEVICE_PRIVATE_BASE);
-                AidlEvent::EventPayload::Data data;
-                std::copy(hidlEvent.u.data.data(),
-                          hidlEvent.u.data.data() + hidlEvent.u.data.size(),
-                          std::begin(data.values));
-                aidlEvent->payload.set<Event::EventPayload::data>(data);
-            }
-            break;
-        }
-    }
-}
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
diff --git a/aidl/sensors/HalProxyAidl.cpp b/aidl/sensors/HalProxyAidl.cpp
deleted file mode 100644
index cdef73a..0000000
--- a/aidl/sensors/HalProxyAidl.cpp
+++ /dev/null
@@ -1,269 +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.
- */
-
-//#define VERBOSE
-
-#include "HalProxyAidl.h"
-#include <aidlcommonsupport/NativeHandle.h>
-#include <fmq/AidlMessageQueue.h>
-#include <hidl/Status.h>
-#include "ConvertUtils.h"
-#include "EventMessageQueueWrapperAidl.h"
-#include "ISensorsCallbackWrapperAidl.h"
-#include "WakeLockMessageQueueWrapperAidl.h"
-#include "convertV2_1.h"
-
-using ::aidl::android::hardware::common::fmq::MQDescriptor;
-using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
-using ::aidl::android::hardware::sensors::ISensors;
-using ::aidl::android::hardware::sensors::ISensorsCallback;
-using ::aidl::android::hardware::sensors::SensorInfo;
-using ::android::hardware::sensors::V2_1::implementation::convertToOldEvent;
-using ::ndk::ScopedAStatus;
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-static ScopedAStatus
-resultToAStatus(::android::hardware::sensors::V1_0::Result result) {
-  switch (result) {
-  case ::android::hardware::sensors::V1_0::Result::OK:
-    return ScopedAStatus::ok();
-  case ::android::hardware::sensors::V1_0::Result::PERMISSION_DENIED:
-    return ScopedAStatus::fromExceptionCode(EX_SECURITY);
-  case ::android::hardware::sensors::V1_0::Result::NO_MEMORY:
-    return ScopedAStatus::fromServiceSpecificError(ISensors::ERROR_NO_MEMORY);
-  case ::android::hardware::sensors::V1_0::Result::BAD_VALUE:
-    return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
-  case ::android::hardware::sensors::V1_0::Result::INVALID_OPERATION:
-    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
-  default:
-    return ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
-  }
-}
-
-static ::android::hardware::sensors::V1_0::RateLevel convertRateLevel(
-        ISensors::RateLevel rateLevel) {
-    switch (rateLevel) {
-        case ISensors::RateLevel::STOP:
-            return ::android::hardware::sensors::V1_0::RateLevel::STOP;
-        case ISensors::RateLevel::NORMAL:
-            return ::android::hardware::sensors::V1_0::RateLevel::NORMAL;
-        case ISensors::RateLevel::FAST:
-            return ::android::hardware::sensors::V1_0::RateLevel::FAST;
-        case ISensors::RateLevel::VERY_FAST:
-            return ::android::hardware::sensors::V1_0::RateLevel::VERY_FAST;
-        default:
-          assert(false);
-    }
-}
-
-static ::android::hardware::sensors::V1_0::OperationMode convertOperationMode(
-        ISensors::OperationMode operationMode) {
-    switch (operationMode) {
-        case ISensors::OperationMode::NORMAL:
-            return ::android::hardware::sensors::V1_0::OperationMode::NORMAL;
-        case ISensors::OperationMode::DATA_INJECTION:
-            return ::android::hardware::sensors::V1_0::OperationMode::DATA_INJECTION;
-        default:
-          assert(false);
-    }
-}
-
-static ::android::hardware::sensors::V1_0::SharedMemType convertSharedMemType(
-        ISensors::SharedMemInfo::SharedMemType sharedMemType) {
-    switch (sharedMemType) {
-        case ISensors::SharedMemInfo::SharedMemType::ASHMEM:
-            return ::android::hardware::sensors::V1_0::SharedMemType::ASHMEM;
-        case ISensors::SharedMemInfo::SharedMemType::GRALLOC:
-            return ::android::hardware::sensors::V1_0::SharedMemType::GRALLOC;
-        default:
-          assert(false);
-    }
-}
-
-static ::android::hardware::sensors::V1_0::SharedMemFormat convertSharedMemFormat(
-        ISensors::SharedMemInfo::SharedMemFormat sharedMemFormat) {
-    switch (sharedMemFormat) {
-        case ISensors::SharedMemInfo::SharedMemFormat::SENSORS_EVENT:
-            return ::android::hardware::sensors::V1_0::SharedMemFormat::SENSORS_EVENT;
-        default:
-          assert(false);
-    }
-}
-
-static ::android::hardware::sensors::V1_0::SharedMemInfo convertSharedMemInfo(
-        const ISensors::SharedMemInfo& sharedMemInfo) {
-    ::android::hardware::sensors::V1_0::SharedMemInfo v1SharedMemInfo;
-    v1SharedMemInfo.type = convertSharedMemType(sharedMemInfo.type);
-    v1SharedMemInfo.format = convertSharedMemFormat(sharedMemInfo.format);
-    v1SharedMemInfo.size = sharedMemInfo.size;
-    v1SharedMemInfo.memoryHandle =
-            ::android::hardware::hidl_handle(::android::makeFromAidl(sharedMemInfo.memoryHandle));
-    return v1SharedMemInfo;
-}
-
-ScopedAStatus HalProxyAidl::activate(int32_t in_sensorHandle, bool in_enabled) {
-  return resultToAStatus(HalProxy::activate(in_sensorHandle, in_enabled));
-}
-
-ScopedAStatus HalProxyAidl::batch(int32_t in_sensorHandle,
-                                  int64_t in_samplingPeriodNs,
-                                  int64_t in_maxReportLatencyNs) {
-  return resultToAStatus(HalProxy::batch(in_sensorHandle, in_samplingPeriodNs,
-                                         in_maxReportLatencyNs));
-}
-
-ScopedAStatus HalProxyAidl::configDirectReport(int32_t in_sensorHandle,
-                                               int32_t in_channelHandle,
-                                               ISensors::RateLevel in_rate,
-                                               int32_t *_aidl_return) {
-  ScopedAStatus status =
-      ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
-  HalProxy::configDirectReport(
-      in_sensorHandle, in_channelHandle, convertRateLevel(in_rate),
-      [&status, _aidl_return](::android::hardware::sensors::V1_0::Result result,
-                              int32_t reportToken) {
-        status = resultToAStatus(result);
-        *_aidl_return = reportToken;
-      });
-
-  return status;
-}
-
-ScopedAStatus HalProxyAidl::flush(int32_t in_sensorHandle) {
-  return resultToAStatus(HalProxy::flush(in_sensorHandle));
-}
-
-
-ScopedAStatus HalProxyAidl::getSensorsList(
-    std::vector<::aidl::android::hardware::sensors::SensorInfo> *_aidl_return) {
-  for (const auto &sensor : HalProxy::getSensors()) {
-    SensorInfo dst = sensor.second;
-
-    if (dst.requiredPermission == "com.samsung.permission.SSENSOR") {
-        dst.requiredPermission = "";
-    }
-
-    if (dst.typeAsString == "com.samsung.sensor.physical_proximity" ||
-            dst.typeAsString == "com.samsung.sensor.hover_proximity") {
-        ALOGI("Fixing %s", dst.typeAsString.c_str());
-        dst.type = ::android::hardware::sensors::V2_1::SensorType::PROXIMITY;
-        dst.typeAsString = SENSOR_STRING_TYPE_PROXIMITY;
-        dst.maxRange = 1;
-    }
-
-#ifdef VERBOSE
-    ALOGI( "SENSOR NAME:%s           ", dst.name.c_str());
-    ALOGI( "       VENDOR:%s         ", dst.name.c_str());
-    ALOGI( "       TYPE:%d           ", (uint32_t)dst.type);
-    ALOGI( "       TYPE_AS_STRING:%s ", dst.typeAsString.c_str());
-#endif
-
-    _aidl_return->push_back(convertSensorInfo(dst));
-  }
-  return ScopedAStatus::ok();
-}
-
-ScopedAStatus HalProxyAidl::initialize(
-    const MQDescriptor<::aidl::android::hardware::sensors::Event,
-                       SynchronizedReadWrite> &in_eventQueueDescriptor,
-    const MQDescriptor<int32_t, SynchronizedReadWrite> &in_wakeLockDescriptor,
-    const std::shared_ptr<ISensorsCallback> &in_sensorsCallback) {
-  ::android::sp<::android::hardware::sensors::V2_1::implementation::
-                    ISensorsCallbackWrapperBase>
-      dynamicCallback = new ISensorsCallbackWrapperAidl(in_sensorsCallback);
-
-  auto aidlEventQueue = std::make_unique<::android::AidlMessageQueue<
-      ::aidl::android::hardware::sensors::Event, SynchronizedReadWrite>>(
-      in_eventQueueDescriptor, true /* resetPointers */);
-  std::unique_ptr<::android::hardware::sensors::V2_1::implementation::
-                      EventMessageQueueWrapperBase>
-      eventQueue =
-          std::make_unique<EventMessageQueueWrapperAidl>(aidlEventQueue);
-
-  auto aidlWakeLockQueue = std::make_unique<
-      ::android::AidlMessageQueue<int32_t, SynchronizedReadWrite>>(
-      in_wakeLockDescriptor, true /* resetPointers */);
-  std::unique_ptr<::android::hardware::sensors::V2_1::implementation::
-                      WakeLockMessageQueueWrapperBase>
-      wakeLockQueue =
-          std::make_unique<WakeLockMessageQueueWrapperAidl>(aidlWakeLockQueue);
-
-  return resultToAStatus(
-      initializeCommon(eventQueue, wakeLockQueue, dynamicCallback));
-}
-
-ScopedAStatus HalProxyAidl::injectSensorData(
-    const ::aidl::android::hardware::sensors::Event &in_event) {
-  ::android::hardware::sensors::V2_1::Event hidlEvent;
-  convertToHidlEvent(in_event, &hidlEvent);
-  return resultToAStatus(
-      HalProxy::injectSensorData(convertToOldEvent(hidlEvent)));
-}
-
-ScopedAStatus
-HalProxyAidl::registerDirectChannel(const ISensors::SharedMemInfo &in_mem,
-                                    int32_t *_aidl_return) {
-  ScopedAStatus status =
-      ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
-  ::android::hardware::sensors::V1_0::SharedMemInfo sharedMemInfo =
-      convertSharedMemInfo(in_mem);
-
-  HalProxy::registerDirectChannel(
-      sharedMemInfo,
-      [&status, _aidl_return](::android::hardware::sensors::V1_0::Result result,
-                              int32_t reportToken) {
-        status = resultToAStatus(result);
-        *_aidl_return = reportToken;
-      });
-
-  native_handle_delete(const_cast<native_handle_t *>(
-      sharedMemInfo.memoryHandle.getNativeHandle()));
-
-  return status;
-}
-
-ScopedAStatus HalProxyAidl::setOperationMode(
-    ::aidl::android::hardware::sensors::ISensors::OperationMode in_mode) {
-  return resultToAStatus(
-      HalProxy::setOperationMode(convertOperationMode(in_mode)));
-}
-
-ScopedAStatus HalProxyAidl::unregisterDirectChannel(int32_t in_channelHandle) {
-  return resultToAStatus(HalProxy::unregisterDirectChannel(in_channelHandle));
-}
-
-binder_status_t HalProxyAidl::dump(int fd, const char ** /* args */,
-                                   uint32_t /* numArgs */) {
-  native_handle_t *nativeHandle =
-      native_handle_create(1 /* numFds */, 0 /* numInts */);
-  nativeHandle->data[0] = fd;
-
-  HalProxy::debug(nativeHandle, {} /* args */);
-
-  native_handle_delete(nativeHandle);
-  return STATUS_OK;
-}
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
diff --git a/aidl/sensors/HalProxySamsung.cpp b/aidl/sensors/HalProxySamsung.cpp
new file mode 100644
index 0000000..eecd4d8
--- /dev/null
+++ b/aidl/sensors/HalProxySamsung.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "HalProxySamsung.h"
+
+#include <ConvertUtils.h>
+
+// #define VERBOSE
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace implementation {
+
+ndk::ScopedAStatus HalProxySamsung::getSensorsList(
+        std::vector<::aidl::android::hardware::sensors::SensorInfo>* _aidl_return) {
+    for (const auto& sensor : HalProxy::getSensors()) {
+        SensorInfo dst = sensor.second;
+
+        if (dst.requiredPermission == "com.samsung.permission.SSENSOR") {
+            dst.requiredPermission = "";
+        }
+
+        if (dst.typeAsString == "com.samsung.sensor.physical_proximity" ||
+            dst.typeAsString == "com.samsung.sensor.hover_proximity") {
+            ALOGI("Fixing %s", dst.typeAsString.c_str());
+            dst.type = ::android::hardware::sensors::V2_1::SensorType::PROXIMITY;
+            dst.typeAsString = SENSOR_STRING_TYPE_PROXIMITY;
+            dst.maxRange = 1;
+        }
+
+#ifdef VERBOSE
+        ALOGI("SENSOR NAME:%s           ", dst.name.c_str());
+        ALOGI("       VENDOR:%s         ", dst.name.c_str());
+        ALOGI("       TYPE:%d           ", (uint32_t)dst.type);
+        ALOGI("       TYPE_AS_STRING:%s ", dst.typeAsString.c_str());
+#endif
+
+        _aidl_return->push_back(convertSensorInfo(dst));
+    }
+
+    return ndk::ScopedAStatus::ok();
+}
+
+}  // namespace implementation
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
+}  // namespace aidl
diff --git a/aidl/sensors/HalProxySamsung.h b/aidl/sensors/HalProxySamsung.h
new file mode 100644
index 0000000..053010f
--- /dev/null
+++ b/aidl/sensors/HalProxySamsung.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include <HalProxyAidl.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace implementation {
+
+class HalProxySamsung : public HalProxyAidl {
+    ndk::ScopedAStatus getSensorsList(
+            std::vector<::aidl::android::hardware::sensors::SensorInfo>* _aidl_return) override;
+};
+
+}  // namespace implementation
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
+}  // namespace aidl
diff --git a/aidl/sensors/android.hardware.sensors-samsung-multihal.xml b/aidl/sensors/android.hardware.sensors-samsung-multihal.xml
index f7b8f0a..15a28fe 100644
--- a/aidl/sensors/android.hardware.sensors-samsung-multihal.xml
+++ b/aidl/sensors/android.hardware.sensors-samsung-multihal.xml
@@ -17,7 +17,7 @@
 <manifest version="1.0" type="device">
     <hal format="aidl" override="true">
         <name>android.hardware.sensors</name>
-        <version>1</version>
+        <version>2</version>
         <fqname>ISensors/default</fqname>
     </hal>
 </manifest>
diff --git a/aidl/sensors/include/ConvertUtils.h b/aidl/sensors/include/ConvertUtils.h
deleted file mode 100644
index 91dfabd..0000000
--- a/aidl/sensors/include/ConvertUtils.h
+++ /dev/null
@@ -1,50 +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.
- */
-
-#pragma once
-
-#include <aidl/android/hardware/sensors/BnSensors.h>
-#include <android/hardware/sensors/2.1/types.h>
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-/**
- * Generates an AIDL SensorInfo instance from the passed HIDL V2.1 SensorInfo instance.
- */
-::aidl::android::hardware::sensors::SensorInfo convertSensorInfo(
-        const ::android::hardware::sensors::V2_1::SensorInfo& sensorInfo);
-
-/**
- * Populates a HIDL V2.1 Event instance based on an AIDL Event instance.
- */
-void convertToHidlEvent(const ::aidl::android::hardware::sensors::Event& aidlEvent,
-                        ::android::hardware::sensors::V2_1::Event* hidlEvent);
-
-/**
- * Populates an AIDL Event instance based on a HIDL V2.1 Event instance.
- */
-void convertToAidlEvent(const ::android::hardware::sensors::V2_1::Event& hidlEvent,
-                        ::aidl::android::hardware::sensors::Event* aidlEvent);
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
\ No newline at end of file
diff --git a/aidl/sensors/include/EventMessageQueueWrapperAidl.h b/aidl/sensors/include/EventMessageQueueWrapperAidl.h
deleted file mode 100644
index 3eaa1d4..0000000
--- a/aidl/sensors/include/EventMessageQueueWrapperAidl.h
+++ /dev/null
@@ -1,99 +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.
- */
-
-#pragma once
-
-#include <android/hardware/sensors/2.1/types.h>
-#include <fmq/AidlMessageQueue.h>
-#include "ConvertUtils.h"
-#include "EventMessageQueueWrapper.h"
-#include "ISensorsWrapper.h"
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-class EventMessageQueueWrapperAidl
-    : public ::android::hardware::sensors::V2_1::implementation::EventMessageQueueWrapperBase {
-  public:
-    EventMessageQueueWrapperAidl(
-            std::unique_ptr<::android::AidlMessageQueue<
-                    ::aidl::android::hardware::sensors::Event,
-                    ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>>& queue)
-        : mQueue(std::move(queue)) {}
-
-    virtual std::atomic<uint32_t>* getEventFlagWord() override {
-        return mQueue->getEventFlagWord();
-    }
-
-    virtual size_t availableToRead() override { return mQueue->availableToRead(); }
-
-    size_t availableToWrite() override { return mQueue->availableToWrite(); }
-
-    virtual bool read(::android::hardware::sensors::V2_1::Event* events,
-                      size_t numToRead) override {
-        bool success = mQueue->read(mIntermediateEventBuffer.data(), numToRead);
-        for (int i = 0; i < numToRead; ++i) {
-            convertToHidlEvent(mIntermediateEventBuffer[i], &events[i]);
-        }
-        return success;
-    }
-
-    bool write(const ::android::hardware::sensors::V2_1::Event* events,
-               size_t numToWrite) override {
-        for (int i = 0; i < numToWrite; ++i) {
-            convertToAidlEvent(events[i], &mIntermediateEventBuffer[i]);
-        }
-        return mQueue->write(mIntermediateEventBuffer.data(), numToWrite);
-    }
-
-    virtual bool write(
-            const std::vector<::android::hardware::sensors::V2_1::Event>& events) override {
-        for (int i = 0; i < events.size(); ++i) {
-            convertToAidlEvent(events[i], &mIntermediateEventBuffer[i]);
-        }
-        return mQueue->write(mIntermediateEventBuffer.data(), events.size());
-    }
-
-    bool writeBlocking(const ::android::hardware::sensors::V2_1::Event* events, size_t count,
-                       uint32_t readNotification, uint32_t writeNotification, int64_t timeOutNanos,
-                       ::android::hardware::EventFlag* evFlag) override {
-        for (int i = 0; i < count; ++i) {
-            convertToAidlEvent(events[i], &mIntermediateEventBuffer[i]);
-        }
-        return mQueue->writeBlocking(mIntermediateEventBuffer.data(), count, readNotification,
-                                     writeNotification, timeOutNanos, evFlag);
-    }
-
-    size_t getQuantumCount() override { return mQueue->getQuantumCount(); }
-
-  private:
-    std::unique_ptr<::android::AidlMessageQueue<
-            ::aidl::android::hardware::sensors::Event,
-            ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>>
-            mQueue;
-    std::array<::aidl::android::hardware::sensors::Event,
-               ::android::hardware::sensors::V2_1::implementation::MAX_RECEIVE_BUFFER_EVENT_COUNT>
-            mIntermediateEventBuffer;
-};
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
diff --git a/aidl/sensors/include/HalProxyAidl.h b/aidl/sensors/include/HalProxyAidl.h
deleted file mode 100644
index 5c81715..0000000
--- a/aidl/sensors/include/HalProxyAidl.h
+++ /dev/null
@@ -1,66 +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.
- */
-
-#pragma once
-
-#include <aidl/android/hardware/sensors/BnSensors.h>
-#include "HalProxy.h"
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-class HalProxyAidl : public ::android::hardware::sensors::V2_1::implementation::HalProxy,
-                     public ::aidl::android::hardware::sensors::BnSensors {
-    ::ndk::ScopedAStatus activate(int32_t in_sensorHandle, bool in_enabled) override;
-    ::ndk::ScopedAStatus batch(int32_t in_sensorHandle, int64_t in_samplingPeriodNs,
-                               int64_t in_maxReportLatencyNs) override;
-    ::ndk::ScopedAStatus configDirectReport(
-            int32_t in_sensorHandle, int32_t in_channelHandle,
-            ::aidl::android::hardware::sensors::ISensors::RateLevel in_rate,
-            int32_t* _aidl_return) override;
-    ::ndk::ScopedAStatus flush(int32_t in_sensorHandle) override;
-    ::ndk::ScopedAStatus getSensorsList(
-            std::vector<::aidl::android::hardware::sensors::SensorInfo>* _aidl_return) override;
-    ::ndk::ScopedAStatus initialize(
-            const ::aidl::android::hardware::common::fmq::MQDescriptor<
-                    ::aidl::android::hardware::sensors::Event,
-                    ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>&
-                    in_eventQueueDescriptor,
-            const ::aidl::android::hardware::common::fmq::MQDescriptor<
-                    int32_t, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>&
-                    in_wakeLockDescriptor,
-            const std::shared_ptr<::aidl::android::hardware::sensors::ISensorsCallback>&
-                    in_sensorsCallback) override;
-    ::ndk::ScopedAStatus injectSensorData(
-            const ::aidl::android::hardware::sensors::Event& in_event) override;
-    ::ndk::ScopedAStatus registerDirectChannel(
-            const ::aidl::android::hardware::sensors::ISensors::SharedMemInfo& in_mem,
-            int32_t* _aidl_return) override;
-    ::ndk::ScopedAStatus setOperationMode(
-            ::aidl::android::hardware::sensors::ISensors::OperationMode in_mode) override;
-    ::ndk::ScopedAStatus unregisterDirectChannel(int32_t in_channelHandle) override;
-
-    binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
-};
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
diff --git a/aidl/sensors/include/ISensorsCallbackWrapperAidl.h b/aidl/sensors/include/ISensorsCallbackWrapperAidl.h
deleted file mode 100644
index 6ef6c63..0000000
--- a/aidl/sensors/include/ISensorsCallbackWrapperAidl.h
+++ /dev/null
@@ -1,66 +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.
- */
-
-#pragma once
-
-#include "ConvertUtils.h"
-#include "ISensorsCallbackWrapper.h"
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-static std::vector<::aidl::android::hardware::sensors::SensorInfo> convertToAidlSensorInfos(
-        const ::android::hardware::hidl_vec<::android::hardware::sensors::V2_1::SensorInfo>&
-                sensorInfos) {
-    std::vector<::aidl::android::hardware::sensors::SensorInfo> aidlSensorInfos;
-    for (const auto& sensorInfo : sensorInfos) {
-        aidlSensorInfos.push_back(convertSensorInfo(sensorInfo));
-    }
-    return aidlSensorInfos;
-}
-
-class ISensorsCallbackWrapperAidl
-    : public ::android::hardware::sensors::V2_1::implementation::ISensorsCallbackWrapperBase {
-  public:
-    ISensorsCallbackWrapperAidl(
-            std::shared_ptr<::aidl::android::hardware::sensors::ISensorsCallback> sensorsCallback)
-        : mSensorsCallback(sensorsCallback) {}
-
-    ::android::hardware::Return<void> onDynamicSensorsConnected(
-            const ::android::hardware::hidl_vec<::android::hardware::sensors::V2_1::SensorInfo>&
-                    sensorInfos) override {
-        mSensorsCallback->onDynamicSensorsConnected(convertToAidlSensorInfos(sensorInfos));
-        return ::android::hardware::Void();
-    }
-
-    ::android::hardware::Return<void> onDynamicSensorsDisconnected(
-            const ::android::hardware::hidl_vec<int32_t>& sensorHandles) override {
-        mSensorsCallback->onDynamicSensorsDisconnected(sensorHandles);
-        return ::android::hardware::Void();
-    }
-
-  private:
-    std::shared_ptr<::aidl::android::hardware::sensors::ISensorsCallback> mSensorsCallback;
-};
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
\ No newline at end of file
diff --git a/aidl/sensors/include/WakeLockMessageQueueWrapperAidl.h b/aidl/sensors/include/WakeLockMessageQueueWrapperAidl.h
deleted file mode 100644
index 6be0b69..0000000
--- a/aidl/sensors/include/WakeLockMessageQueueWrapperAidl.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-#pragma once
-
-#include <android/hardware/sensors/2.1/types.h>
-#include <fmq/AidlMessageQueue.h>
-#include "WakeLockMessageQueueWrapper.h"
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace sensors {
-namespace implementation {
-
-class WakeLockMessageQueueWrapperAidl
-    : public ::android::hardware::sensors::V2_1::implementation::WakeLockMessageQueueWrapperBase {
-  public:
-    WakeLockMessageQueueWrapperAidl(
-            std::unique_ptr<::android::AidlMessageQueue<
-                    int32_t, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>>& queue)
-        : mQueue(std::move(queue)) {}
-
-    virtual std::atomic<uint32_t>* getEventFlagWord() override {
-        return mQueue->getEventFlagWord();
-    }
-
-    bool readBlocking(uint32_t* wakeLocks, size_t numToRead, uint32_t readNotification,
-                      uint32_t writeNotification, int64_t timeOutNanos,
-                      ::android::hardware::EventFlag* evFlag) override {
-        return mQueue->readBlocking(reinterpret_cast<int32_t*>(wakeLocks), numToRead,
-                                    readNotification, writeNotification, timeOutNanos, evFlag);
-    }
-
-    bool write(const uint32_t* wakeLock) override {
-        return mQueue->write(reinterpret_cast<const int32_t*>(wakeLock));
-    }
-
-  private:
-    std::unique_ptr<::android::AidlMessageQueue<
-            int32_t, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>>
-            mQueue;
-};
-
-}  // namespace implementation
-}  // namespace sensors
-}  // namespace hardware
-}  // namespace android
-}  // namespace aidl
diff --git a/aidl/sensors/service.cpp b/aidl/sensors/service.cpp
index 11c108a..2575e9a 100644
--- a/aidl/sensors/service.cpp
+++ b/aidl/sensors/service.cpp
@@ -17,16 +17,17 @@
 #include <android-base/logging.h>
 #include <android/binder_manager.h>
 #include <android/binder_process.h>
-#include "HalProxyAidl.h"
 
-using ::aidl::android::hardware::sensors::implementation::HalProxyAidl;
+#include "HalProxySamsung.h"
+
+using ::aidl::android::hardware::sensors::implementation::HalProxySamsung;
 
 int main() {
     ABinderProcess_setThreadPoolMaxThreadCount(0);
 
     // Make a default multihal sensors service
-    auto halProxy = ndk::SharedRefBase::make<HalProxyAidl>();
-    const std::string halProxyName = std::string() + HalProxyAidl::descriptor + "/default";
+    auto halProxy = ndk::SharedRefBase::make<HalProxySamsung>();
+    const std::string halProxyName = std::string() + HalProxySamsung::descriptor + "/default";
     binder_status_t status =
             AServiceManager_addService(halProxy->asBinder().get(), halProxyName.c_str());
     CHECK_EQ(status, STATUS_OK);