diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index 5ae5aac82c..b87b1a64fd 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -577,6 +577,7 @@ android.hardware.sensors + 2 ISensors default diff --git a/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/ISensors.aidl b/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/ISensors.aidl index f60f5bb247..b26040b56d 100644 --- a/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/ISensors.aidl +++ b/sensors/aidl/aidl_api/android.hardware.sensors/current/android/hardware/sensors/ISensors.aidl @@ -58,6 +58,8 @@ interface ISensors { const int DIRECT_REPORT_SENSOR_EVENT_OFFSET_SIZE_DATA = 24; const int DIRECT_REPORT_SENSOR_EVENT_OFFSET_SIZE_RESERVED = 88; const int DIRECT_REPORT_SENSOR_EVENT_TOTAL_LENGTH = 104; + const int RUNTIME_SENSORS_HANDLE_BASE = 1593835520; + const int RUNTIME_SENSORS_HANDLE_END = 1610612735; @Backing(type="int") @VintfStability enum RateLevel { STOP = 0, diff --git a/sensors/aidl/android/hardware/sensors/ISensors.aidl b/sensors/aidl/android/hardware/sensors/ISensors.aidl index 2c684897cf..5e276dd90a 100644 --- a/sensors/aidl/android/hardware/sensors/ISensors.aidl +++ b/sensors/aidl/android/hardware/sensors/ISensors.aidl @@ -371,4 +371,13 @@ interface ISensors { const int DIRECT_REPORT_SENSOR_EVENT_OFFSET_SIZE_DATA = 0x18; const int DIRECT_REPORT_SENSOR_EVENT_OFFSET_SIZE_RESERVED = 0x58; const int DIRECT_REPORT_SENSOR_EVENT_TOTAL_LENGTH = 104; + + /** + * Constants related to reserved sensor handle ranges. + * + * The following range (inclusive) is reserved for usage by the system for + * runtime sensors. + */ + const int RUNTIME_SENSORS_HANDLE_BASE = 0x5F000000; + const int RUNTIME_SENSORS_HANDLE_END = 0x5FFFFFFF; } diff --git a/sensors/aidl/convert/Android.bp b/sensors/aidl/convert/Android.bp index 0b31597478..53060b958a 100644 --- a/sensors/aidl/convert/Android.bp +++ b/sensors/aidl/convert/Android.bp @@ -35,7 +35,7 @@ cc_library_static { "libhardware", "libbase", "libutils", - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", ], whole_static_libs: [ "sensors_common_convert", diff --git a/sensors/aidl/default/Android.bp b/sensors/aidl/default/Android.bp index 3c66744324..16b4d3558a 100644 --- a/sensors/aidl/default/Android.bp +++ b/sensors/aidl/default/Android.bp @@ -41,7 +41,7 @@ cc_library_static { "libfmq", "libpower", "libbinder_ndk", - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", ], export_include_dirs: ["include"], srcs: [ @@ -68,7 +68,7 @@ cc_binary { "libcutils", "liblog", "libutils", - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", ], static_libs: [ "libsensorsexampleimpl", diff --git a/sensors/aidl/default/multihal/Android.bp b/sensors/aidl/default/multihal/Android.bp index eee10625bb..a20d6d7434 100644 --- a/sensors/aidl/default/multihal/Android.bp +++ b/sensors/aidl/default/multihal/Android.bp @@ -38,7 +38,7 @@ cc_library_static { "android.hardware.sensors@1.0", "android.hardware.sensors@2.0", "android.hardware.sensors@2.1", - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", ], export_include_dirs: ["include"], srcs: [ diff --git a/sensors/aidl/default/sensors-default.xml b/sensors/aidl/default/sensors-default.xml index 7898a6bab0..36b28ed0a6 100644 --- a/sensors/aidl/default/sensors-default.xml +++ b/sensors/aidl/default/sensors-default.xml @@ -1,7 +1,7 @@ android.hardware.sensors - 1 + 2 ISensors/default diff --git a/sensors/aidl/multihal/Android.bp b/sensors/aidl/multihal/Android.bp index 6d35dafd6d..522d305d86 100644 --- a/sensors/aidl/multihal/Android.bp +++ b/sensors/aidl/multihal/Android.bp @@ -40,7 +40,7 @@ cc_binary { "android.hardware.sensors@2.0-ScopedWakelock", "android.hardware.sensors@2.0", "android.hardware.sensors@2.1", - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", "libbase", "libcutils", "libfmq", diff --git a/sensors/aidl/multihal/android.hardware.sensors-multihal.xml b/sensors/aidl/multihal/android.hardware.sensors-multihal.xml index d78edffaf9..5da4fbd9a1 100644 --- a/sensors/aidl/multihal/android.hardware.sensors-multihal.xml +++ b/sensors/aidl/multihal/android.hardware.sensors-multihal.xml @@ -17,7 +17,7 @@ android.hardware.sensors - 1 + 2 ISensors/default diff --git a/sensors/aidl/vts/Android.bp b/sensors/aidl/vts/Android.bp index f3972ec2a3..c17a5585fd 100644 --- a/sensors/aidl/vts/Android.bp +++ b/sensors/aidl/vts/Android.bp @@ -41,7 +41,7 @@ cc_test { "android.hardware.common.fmq-V1-ndk", ], static_libs: [ - "android.hardware.sensors-V1-ndk", + "android.hardware.sensors-V2-ndk", "VtsHalSensorsTargetTestUtils", "libaidlcommonsupport", ], diff --git a/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp b/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp index d536e290b2..ad58e213ef 100644 --- a/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp +++ b/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp @@ -560,10 +560,15 @@ TEST_P(SensorsAidlTest, SensorListValid) { EXPECT_NO_FATAL_FAILURE(assertTypeMatchStringType(info.type, info.typeAsString)); } - // Test if all sensor has name and vendor + // Test if all sensors have name and vendor EXPECT_FALSE(info.name.empty()); EXPECT_FALSE(info.vendor.empty()); + // Make sure that the sensor handle is not within the reserved range for runtime + // sensors. + EXPECT_FALSE(ISensors::RUNTIME_SENSORS_HANDLE_BASE <= info.sensorHandle && + info.sensorHandle <= ISensors::RUNTIME_SENSORS_HANDLE_END); + // Make sure that sensors of the same type have a unique name. std::vector& v = sensorTypeNameMap[static_cast(info.type)]; bool isUniqueName = std::find(v.begin(), v.end(), info.name) == v.end();