• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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        "liblog",
40        "libhidparser",
41        "server_configurable_flags",
42        "libaconfig_storage_read_api_cc",
43    ],
44
45    static_libs: [
46        "dynamic_sensors_flags_c_lib",
47    ],
48
49    cpp_std: "c++20",
50
51    target: {
52        android: {
53            srcs: [
54                "BaseDynamicSensorDaemon.cpp",
55                "BaseSensorObject.cpp",
56                "ConnectionDetector.cpp",
57                "DummyDynamicAccelDaemon.cpp",
58                "DynamicSensorManager.cpp",
59                "HidRawDevice.cpp",
60                "HidRawSensor.cpp",
61                "HidRawSensorDaemon.cpp",
62                "HidRawSensorDevice.cpp",
63                "RingBuffer.cpp",
64            ],
65            shared_libs: [
66                "libcutils",
67                "liblog",
68                "libutils",
69            ],
70            header_libs: [
71                "libbase_headers",
72                "libhardware_headers",
73                "libstagefright_foundation_headers",
74            ],
75        },
76
77        host: {
78            local_include_dirs: [
79                "test",
80                "HidUtils/test",
81            ],
82        },
83
84        // host test is targeting linux host only
85        darwin: {
86            enabled: false,
87        },
88    },
89}
90
91//
92// There are two ways to utilize the dynamic sensor module:
93//   1. Use as an extension in an existing hal: declare dependency on libdynamic_sensor_ext shared
94//      library in existing sensor hal.
95//   2. Use as a standalone sensor HAL and configure multihal to combine it with sensor hal that
96//      hosts other sensors: add dependency on sensors.dynamic_sensor_hal in device level makefile and
97//      write multihal configuration file accordingly.
98//
99// Please take only one of these two options to avoid conflict over hardware resource.
100//
101//
102// Option 1: sensor extension module
103//
104cc_library_shared {
105    name: "libdynamic_sensor_ext",
106    defaults: ["dynamic_sensor_defaults"],
107
108    cflags: ["-DLOG_TAG=\"DynamicSensorExt\""],
109}
110
111//
112// Option 2: independent sensor hal
113//
114cc_library_shared {
115    name: "sensors.dynamic_sensor_hal",
116    defaults: ["dynamic_sensor_defaults"],
117    relative_install_path: "hw",
118
119    cflags: ["-DLOG_TAG=\"DynamicSensorHal\""],
120
121    srcs: [
122        "DynamicSensorsSubHal.cpp",
123        "sensors.cpp",
124    ],
125    shared_libs: [
126        "android.hardware.sensors@2.0",
127        "android.hardware.sensors@2.0-ScopedWakelock",
128        "android.hardware.sensors@2.1",
129        "libhidlbase",
130    ],
131    static_libs: [
132        "android.hardware.sensors@1.0-convert",
133    ],
134    header_libs: [
135        "android.hardware.sensors@2.X-multihal.header",
136        "android.hardware.sensors@2.X-shared-utils",
137    ],
138}
139
140//
141// Host test for HidRawSensor. Test with dummy test HID descriptors.
142//
143cc_binary_host {
144    name: "hidrawsensor_host_test",
145    defaults: ["dynamic_sensor_defaults"],
146    static_libs: [
147        "libutils_binder",
148    ],
149    srcs: [
150        "HidRawSensor.cpp",
151        "BaseSensorObject.cpp",
152        "HidUtils/test/TestHidDescriptor.cpp",
153        "test/HidRawSensorTest.cpp",
154    ],
155}
156
157//
158// Host test for HidRawDevice and HidRawSensor. Test with hidraw
159// device node.
160//
161cc_binary_host {
162    name: "hidrawdevice_host_test",
163    defaults: ["dynamic_sensor_defaults"],
164    static_libs: [
165        "libutils_binder",
166    ],
167    srcs: [
168        "HidRawDevice.cpp",
169        "HidRawSensor.cpp",
170        "BaseSensorObject.cpp",
171        "test/HidRawDeviceTest.cpp",
172    ],
173}
174
175//
176// Android device test for HidRawDevice and HidRawSensor
177//
178// Assuming lunch target 1
179// $ cd test
180// $ mma -j .
181// $ adb push $ANDROID_BUILD_TOP/out/target/product/generic/vendor/bin/hidrawdevice_test /vendor/bin
182// $ adb shell hidrawdevice_test /dev/hidraw0
183//
184cc_binary {
185    name: "hidrawdevice_test",
186    defaults: ["dynamic_sensor_defaults"],
187
188    srcs: [
189        "test/HidRawDeviceTest.cpp",
190    ],
191
192    cflags: ["-DLOG_TO_CONSOLE=1"],
193
194    local_include_dirs: [
195        "test",
196        "HidUtils/test",
197    ],
198}
199
200aconfig_declarations {
201    name: "dynamic_sensors_flags",
202    package: "com.android.libhardware.dynamic.sensors.flags",
203    container: "system",
204    srcs: ["dynamic_sensors.aconfig"],
205}
206
207cc_aconfig_library {
208    name: "dynamic_sensors_flags_c_lib",
209    aconfig_declarations: "dynamic_sensors_flags",
210    host_supported: true,
211    vendor: true,
212}
213