Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "SensorServiceUtils.h" |
| 18 | |
| 19 | #include <hardware/sensors.h> |
| 20 | |
| 21 | namespace android { |
| 22 | namespace SensorServiceUtil { |
| 23 | |
| 24 | // Keep in sync with sSensorReportingMode in Sensor.java |
| 25 | size_t eventSizeBySensorType(int type) { |
| 26 | if (type >= SENSOR_TYPE_DEVICE_PRIVATE_BASE) { |
| 27 | return 16; |
| 28 | } |
| 29 | switch (type) { |
| 30 | case SENSOR_TYPE_POSE_6DOF: |
| 31 | return 16; |
| 32 | |
| 33 | case SENSOR_TYPE_ROTATION_VECTOR: |
| 34 | case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR: |
| 35 | return 5; |
| 36 | |
| 37 | case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: |
| 38 | case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: |
| 39 | return 6; |
| 40 | |
| 41 | case SENSOR_TYPE_GAME_ROTATION_VECTOR: |
| 42 | return 4; |
| 43 | |
| 44 | case SENSOR_TYPE_SIGNIFICANT_MOTION: |
| 45 | case SENSOR_TYPE_STEP_DETECTOR: |
| 46 | case SENSOR_TYPE_STEP_COUNTER: |
| 47 | case SENSOR_TYPE_HEART_RATE: |
| 48 | case SENSOR_TYPE_TILT_DETECTOR: |
| 49 | case SENSOR_TYPE_WAKE_GESTURE: |
| 50 | case SENSOR_TYPE_GLANCE_GESTURE: |
| 51 | case SENSOR_TYPE_PICK_UP_GESTURE: |
| 52 | case SENSOR_TYPE_WRIST_TILT_GESTURE: |
| 53 | case SENSOR_TYPE_DEVICE_ORIENTATION: |
| 54 | case SENSOR_TYPE_STATIONARY_DETECT: |
| 55 | case SENSOR_TYPE_MOTION_DETECT: |
| 56 | case SENSOR_TYPE_HEART_BEAT: |
Nick Vaccaro | 2e990eb | 2017-01-12 21:13:58 -0800 | [diff] [blame] | 57 | case SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT: |
Anthony Stange | fdb1fc8 | 2020-01-16 15:02:48 -0500 | [diff] [blame^] | 58 | case SENSOR_TYPE_HINGE_ANGLE: |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 59 | return 1; |
| 60 | |
| 61 | default: |
| 62 | return 3; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | } // namespace SensorServiceUtil |
| 67 | } // namespace android; |