1// Copyright (C) 2017 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package { 16 // See: http://go/android-license-faq 17 // A large-scale-change added 'default_applicable_licenses' to import 18 // all of the 'license_kinds' from "hardware_libhardware_license" 19 // to get the below license kinds: 20 // SPDX-license-identifier-Apache-2.0 21 default_applicable_licenses: ["hardware_libhardware_license"], 22} 23 24cc_defaults { 25 name: "dynamic_sensor_defaults", 26 27 // intended to be integrated into hal, thus vendor 28 vendor: true, 29 30 cflags: [ 31 "-Wall", 32 "-Werror", 33 "-Wextra", 34 ], 35 export_include_dirs: ["."], 36 37 shared_libs: [ 38 "libbase", 39 "libhidparser", 40 "server_configurable_flags", 41 "libaconfig_storage_read_api_cc", 42 ], 43 44 static_libs: [ 45 "dynamic_sensors_flags_c_lib", 46 ], 47 48 cpp_std: "c++20", 49 50 target: { 51 android: { 52 srcs: [ 53 "BaseDynamicSensorDaemon.cpp", 54 "BaseSensorObject.cpp", 55 "ConnectionDetector.cpp", 56 "DummyDynamicAccelDaemon.cpp", 57 "DynamicSensorManager.cpp", 58 "HidRawDevice.cpp", 59 "HidRawSensor.cpp", 60 "HidRawSensorDaemon.cpp", 61 "HidRawSensorDevice.cpp", 62 "RingBuffer.cpp", 63 ], 64 shared_libs: [ 65 "libcutils", 66 "liblog", 67 "libutils", 68 ], 69 header_libs: [ 70 "libbase_headers", 71 "libhardware_headers", 72 "libstagefright_foundation_headers", 73 ], 74 }, 75 76 host: { 77 local_include_dirs: [ 78 "test", 79 "HidUtils/test", 80 ], 81 }, 82 83 // host test is targeting linux host only 84 darwin: { 85 enabled: false, 86 }, 87 }, 88} 89 90// 91// There are two ways to utilize the dynamic sensor module: 92// 1. Use as an extension in an existing hal: declare dependency on libdynamic_sensor_ext shared 93// library in existing sensor hal. 94// 2. Use as a standalone sensor HAL and configure multihal to combine it with sensor hal that 95// hosts other sensors: add dependency on sensors.dynamic_sensor_hal in device level makefile and 96// write multihal configuration file accordingly. 97// 98// Please take only one of these two options to avoid conflict over hardware resource. 99// 100// 101// Option 1: sensor extension module 102// 103cc_library_shared { 104 name: "libdynamic_sensor_ext", 105 defaults: ["dynamic_sensor_defaults"], 106 107 cflags: ["-DLOG_TAG=\"DynamicSensorExt\""], 108} 109 110// 111// Option 2: independent sensor hal 112// 113cc_library_shared { 114 name: "sensors.dynamic_sensor_hal", 115 defaults: ["dynamic_sensor_defaults"], 116 relative_install_path: "hw", 117 118 cflags: ["-DLOG_TAG=\"DynamicSensorHal\""], 119 120 srcs: [ 121 "DynamicSensorsSubHal.cpp", 122 "sensors.cpp", 123 ], 124 shared_libs: [ 125 "android.hardware.sensors@2.0", 126 "android.hardware.sensors@2.0-ScopedWakelock", 127 "android.hardware.sensors@2.1", 128 "libhidlbase", 129 ], 130 static_libs: [ 131 "android.hardware.sensors@1.0-convert", 132 ], 133 header_libs: [ 134 "android.hardware.sensors@2.X-multihal.header", 135 "android.hardware.sensors@2.X-shared-utils", 136 ], 137} 138 139// 140// Host test for HidRawSensor. Test with dummy test HID descriptors. 141// 142cc_binary_host { 143 name: "hidrawsensor_host_test", 144 defaults: ["dynamic_sensor_defaults"], 145 146 srcs: [ 147 "HidRawSensor.cpp", 148 "BaseSensorObject.cpp", 149 "HidUtils/test/TestHidDescriptor.cpp", 150 "test/HidRawSensorTest.cpp", 151 ], 152} 153 154// 155// Host test for HidRawDevice and HidRawSensor. Test with hidraw 156// device node. 157// 158cc_binary_host { 159 name: "hidrawdevice_host_test", 160 defaults: ["dynamic_sensor_defaults"], 161 162 srcs: [ 163 "HidRawDevice.cpp", 164 "HidRawSensor.cpp", 165 "BaseSensorObject.cpp", 166 "test/HidRawDeviceTest.cpp", 167 ], 168} 169 170// 171// Android device test for HidRawDevice and HidRawSensor 172// 173// Assuming lunch target 1 174// $ cd test 175// $ mma -j . 176// $ adb push $ANDROID_BUILD_TOP/out/target/product/generic/vendor/bin/hidrawdevice_test /vendor/bin 177// $ adb shell hidrawdevice_test /dev/hidraw0 178// 179cc_binary { 180 name: "hidrawdevice_test", 181 defaults: ["dynamic_sensor_defaults"], 182 183 srcs: [ 184 "test/HidRawDeviceTest.cpp", 185 ], 186 187 cflags: ["-DLOG_TO_CONSOLE=1"], 188 189 local_include_dirs: [ 190 "test", 191 "HidUtils/test", 192 ], 193} 194 195aconfig_declarations { 196 name: "dynamic_sensors_flags", 197 package: "com.android.libhardware.dynamic.sensors.flags", 198 container: "system", 199 srcs: ["dynamic_sensors.aconfig"], 200} 201 202cc_aconfig_library { 203 name: "dynamic_sensors_flags_c_lib", 204 aconfig_declarations: "dynamic_sensors_flags", 205 host_supported: true, 206 vendor: true, 207} 208