Loading sensors/2.0/multihal/Android.bp +33 −13 Original line number Diff line number Diff line Loading @@ -13,18 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. cc_binary { name: "android.hardware.sensors@2.0-service.multihal", defaults: ["hidl_defaults"], vendor: true, relative_install_path: "hw", srcs: [ "service.cpp", "HalProxy.cpp", ], init_rc: ["android.hardware.sensors@2.0-service-multihal.rc"], cc_defaults { name: "android.hardware.sensors@2.0-multihal-defaults", header_libs: [ "android.hardware.sensors@2.0-subhal.header", "android.hardware.sensors@2.0-multihal.header", ], shared_libs: [ "android.hardware.sensors@1.0", Loading @@ -37,11 +29,39 @@ cc_binary { "libpower", "libutils", ], } cc_binary { name: "android.hardware.sensors@2.0-service.multihal", defaults: [ "hidl_defaults", "android.hardware.sensors@2.0-multihal-defaults", ], vendor: true, relative_install_path: "hw", srcs: [ "service.cpp", "HalProxy.cpp", ], init_rc: ["android.hardware.sensors@2.0-service-multihal.rc"], vintf_fragments: ["android.hardware.sensors@2.0-multihal.xml"], } cc_library_headers { name: "android.hardware.sensors@2.0-subhal.header", vendor: true, name: "android.hardware.sensors@2.0-multihal.header", vendor_available: true, export_include_dirs: ["include"], } // The below targets should only be used for testing. cc_test_library { name: "android.hardware.sensors@2.0-HalProxy", defaults: ["android.hardware.sensors@2.0-multihal-defaults"], vendor_available: true, srcs: [ "HalProxy.cpp", ], export_header_lib_headers: [ "android.hardware.sensors@2.0-multihal.header", ], } sensors/2.0/multihal/HalProxy.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,10 @@ HalProxy::HalProxy() { // TODO: Discover sensors } HalProxy::HalProxy(std::vector<ISensorsSubHal*>& subHalList) : mSubHalList(subHalList) { // TODO: Perform the same steps as the empty constructor. } HalProxy::~HalProxy() { // TODO: Join any running threads and clean up FMQs and any other allocated // state. Loading sensors/2.0/multihal/HalProxy.h→sensors/2.0/multihal/include/HalProxy.h +4 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,9 @@ struct HalProxy : public ISensors { using Result = ::android::hardware::sensors::V1_0::Result; using SharedMemInfo = ::android::hardware::sensors::V1_0::SharedMemInfo; HalProxy(); explicit HalProxy(); // Test only constructor. explicit HalProxy(std::vector<ISensorsSubHal*>& subHalList); ~HalProxy(); // Methods from ::android::hardware::sensors::V2_0::ISensors follow. Loading Loading @@ -78,7 +80,7 @@ struct HalProxy : public ISensors { Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override; // Below methods from ::android::hardware::sensors::V2_0::ISensorsCaback with a minor change // Below methods from ::android::hardware::sensors::V2_0::ISensorsCallback with a minor change // to pass in the sub-HAL index. While the above methods are invoked from the sensors framework // via the binder, these methods are invoked from a callback provided to sub-HALs inside the // same process as the HalProxy, but potentially running on different threads. Loading sensors/2.0/multihal/testing/Android.bp→sensors/2.0/multihal/tests/Android.bp +38 −4 Original line number Diff line number Diff line Loading @@ -15,14 +15,13 @@ cc_defaults { name: "android.hardware.sensors@2.0-fakesubhal-defaults", vendor: true, srcs: [ "Sensor.cpp", "SensorsSubHal.cpp", "fake_subhal/*.cpp", ], header_libs: [ "android.hardware.sensors@2.0-subhal.header", "android.hardware.sensors@2.0-multihal.header", ], export_include_dirs: ["fake_subhal"], shared_libs: [ "android.hardware.sensors@1.0", "android.hardware.sensors@2.0", Loading @@ -38,6 +37,7 @@ cc_defaults { cc_library { name: "android.hardware.sensors@2.0-fakesubhal-config1", vendor: true, defaults: ["android.hardware.sensors@2.0-fakesubhal-defaults"], cflags: [ "-DSUPPORT_CONTINUOUS_SENSORS", Loading @@ -47,9 +47,43 @@ cc_library { cc_library { name: "android.hardware.sensors@2.0-fakesubhal-config2", vendor: true, defaults: ["android.hardware.sensors@2.0-fakesubhal-defaults"], cflags: [ "-DSUPPORT_ON_CHANGE_SENSORS", "-DSUB_HAL_NAME=\"FakeSubHal-OnChange\"", ], } cc_test_library { name: "android.hardware.sensors@2.0-fakesubhal-unittest", vendor_available: true, defaults: ["android.hardware.sensors@2.0-fakesubhal-defaults"], cflags: [ "-DSUPPORT_ON_CHANGE_SENSORS", "-DSUPPORT_CONTINUOUS_SENSORS", "-DSUB_HAL_NAME=\"FakeSubHal-Test\"", ], } cc_test { name: "android.hardware.sensors@2.0-halproxy-unit-tests", srcs: ["HalProxy_test.cpp"], vendor: true, static_libs: [ "android.hardware.sensors@2.0-HalProxy", "android.hardware.sensors@2.0-fakesubhal-unittest", ], shared_libs: [ "android.hardware.sensors@1.0", "android.hardware.sensors@2.0", "libcutils", "libfmq", "libhidlbase", "libhidltransport", "liblog", "libpower", "libutils", ], test_suites: ["device-tests"], } No newline at end of file sensors/2.0/multihal/tests/HalProxy_test.cpp 0 → 100644 +39 −0 Original line number Diff line number Diff line // // Copyright (C) 2019 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 <gtest/gtest.h> #include "HalProxy.h" #include "SensorsSubHal.h" using ::android::hardware::sensors::V2_0::implementation::HalProxy; using ::android::hardware::sensors::V2_0::subhal::implementation::SensorsSubHal; // TODO: Add more interesting tests such as // - verify setOperationMode invokes all subhals // - verify if a subhal fails to change operation mode, that state is reset properly // - Available sensors are obtained during initialization // // You can run this suite using "atest android.hardware.sensors@2.0-halproxy-unit-tests". // // See https://source.android.com/compatibility/tests/development/native-func-e2e.md for more info // on how tests are set up and for information on the gtest framework itself. TEST(HalProxyTest, ExampleTest) { SensorsSubHal subHal; std::vector<ISensorsSubHal*> fakeSubHals; fakeSubHals.push_back(&subHal); HalProxy proxy(fakeSubHals); } No newline at end of file Loading
sensors/2.0/multihal/Android.bp +33 −13 Original line number Diff line number Diff line Loading @@ -13,18 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. cc_binary { name: "android.hardware.sensors@2.0-service.multihal", defaults: ["hidl_defaults"], vendor: true, relative_install_path: "hw", srcs: [ "service.cpp", "HalProxy.cpp", ], init_rc: ["android.hardware.sensors@2.0-service-multihal.rc"], cc_defaults { name: "android.hardware.sensors@2.0-multihal-defaults", header_libs: [ "android.hardware.sensors@2.0-subhal.header", "android.hardware.sensors@2.0-multihal.header", ], shared_libs: [ "android.hardware.sensors@1.0", Loading @@ -37,11 +29,39 @@ cc_binary { "libpower", "libutils", ], } cc_binary { name: "android.hardware.sensors@2.0-service.multihal", defaults: [ "hidl_defaults", "android.hardware.sensors@2.0-multihal-defaults", ], vendor: true, relative_install_path: "hw", srcs: [ "service.cpp", "HalProxy.cpp", ], init_rc: ["android.hardware.sensors@2.0-service-multihal.rc"], vintf_fragments: ["android.hardware.sensors@2.0-multihal.xml"], } cc_library_headers { name: "android.hardware.sensors@2.0-subhal.header", vendor: true, name: "android.hardware.sensors@2.0-multihal.header", vendor_available: true, export_include_dirs: ["include"], } // The below targets should only be used for testing. cc_test_library { name: "android.hardware.sensors@2.0-HalProxy", defaults: ["android.hardware.sensors@2.0-multihal-defaults"], vendor_available: true, srcs: [ "HalProxy.cpp", ], export_header_lib_headers: [ "android.hardware.sensors@2.0-multihal.header", ], }
sensors/2.0/multihal/HalProxy.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,10 @@ HalProxy::HalProxy() { // TODO: Discover sensors } HalProxy::HalProxy(std::vector<ISensorsSubHal*>& subHalList) : mSubHalList(subHalList) { // TODO: Perform the same steps as the empty constructor. } HalProxy::~HalProxy() { // TODO: Join any running threads and clean up FMQs and any other allocated // state. Loading
sensors/2.0/multihal/HalProxy.h→sensors/2.0/multihal/include/HalProxy.h +4 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,9 @@ struct HalProxy : public ISensors { using Result = ::android::hardware::sensors::V1_0::Result; using SharedMemInfo = ::android::hardware::sensors::V1_0::SharedMemInfo; HalProxy(); explicit HalProxy(); // Test only constructor. explicit HalProxy(std::vector<ISensorsSubHal*>& subHalList); ~HalProxy(); // Methods from ::android::hardware::sensors::V2_0::ISensors follow. Loading Loading @@ -78,7 +80,7 @@ struct HalProxy : public ISensors { Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override; // Below methods from ::android::hardware::sensors::V2_0::ISensorsCaback with a minor change // Below methods from ::android::hardware::sensors::V2_0::ISensorsCallback with a minor change // to pass in the sub-HAL index. While the above methods are invoked from the sensors framework // via the binder, these methods are invoked from a callback provided to sub-HALs inside the // same process as the HalProxy, but potentially running on different threads. Loading
sensors/2.0/multihal/testing/Android.bp→sensors/2.0/multihal/tests/Android.bp +38 −4 Original line number Diff line number Diff line Loading @@ -15,14 +15,13 @@ cc_defaults { name: "android.hardware.sensors@2.0-fakesubhal-defaults", vendor: true, srcs: [ "Sensor.cpp", "SensorsSubHal.cpp", "fake_subhal/*.cpp", ], header_libs: [ "android.hardware.sensors@2.0-subhal.header", "android.hardware.sensors@2.0-multihal.header", ], export_include_dirs: ["fake_subhal"], shared_libs: [ "android.hardware.sensors@1.0", "android.hardware.sensors@2.0", Loading @@ -38,6 +37,7 @@ cc_defaults { cc_library { name: "android.hardware.sensors@2.0-fakesubhal-config1", vendor: true, defaults: ["android.hardware.sensors@2.0-fakesubhal-defaults"], cflags: [ "-DSUPPORT_CONTINUOUS_SENSORS", Loading @@ -47,9 +47,43 @@ cc_library { cc_library { name: "android.hardware.sensors@2.0-fakesubhal-config2", vendor: true, defaults: ["android.hardware.sensors@2.0-fakesubhal-defaults"], cflags: [ "-DSUPPORT_ON_CHANGE_SENSORS", "-DSUB_HAL_NAME=\"FakeSubHal-OnChange\"", ], } cc_test_library { name: "android.hardware.sensors@2.0-fakesubhal-unittest", vendor_available: true, defaults: ["android.hardware.sensors@2.0-fakesubhal-defaults"], cflags: [ "-DSUPPORT_ON_CHANGE_SENSORS", "-DSUPPORT_CONTINUOUS_SENSORS", "-DSUB_HAL_NAME=\"FakeSubHal-Test\"", ], } cc_test { name: "android.hardware.sensors@2.0-halproxy-unit-tests", srcs: ["HalProxy_test.cpp"], vendor: true, static_libs: [ "android.hardware.sensors@2.0-HalProxy", "android.hardware.sensors@2.0-fakesubhal-unittest", ], shared_libs: [ "android.hardware.sensors@1.0", "android.hardware.sensors@2.0", "libcutils", "libfmq", "libhidlbase", "libhidltransport", "liblog", "libpower", "libutils", ], test_suites: ["device-tests"], } No newline at end of file
sensors/2.0/multihal/tests/HalProxy_test.cpp 0 → 100644 +39 −0 Original line number Diff line number Diff line // // Copyright (C) 2019 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 <gtest/gtest.h> #include "HalProxy.h" #include "SensorsSubHal.h" using ::android::hardware::sensors::V2_0::implementation::HalProxy; using ::android::hardware::sensors::V2_0::subhal::implementation::SensorsSubHal; // TODO: Add more interesting tests such as // - verify setOperationMode invokes all subhals // - verify if a subhal fails to change operation mode, that state is reset properly // - Available sensors are obtained during initialization // // You can run this suite using "atest android.hardware.sensors@2.0-halproxy-unit-tests". // // See https://source.android.com/compatibility/tests/development/native-func-e2e.md for more info // on how tests are set up and for information on the gtest framework itself. TEST(HalProxyTest, ExampleTest) { SensorsSubHal subHal; std::vector<ISensorsSubHal*> fakeSubHals; fakeSubHals.push_back(&subHal); HalProxy proxy(fakeSubHals); } No newline at end of file