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 | |
Anthony Stange | 9bb1670 | 2023-01-03 22:42:31 +0000 | [diff] [blame] | 19 | #include <android-base/properties.h> |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 20 | #include <hardware/sensors.h> |
| 21 | |
| 22 | namespace android { |
| 23 | namespace SensorServiceUtil { |
| 24 | |
| 25 | // Keep in sync with sSensorReportingMode in Sensor.java |
| 26 | size_t eventSizeBySensorType(int type) { |
| 27 | if (type >= SENSOR_TYPE_DEVICE_PRIVATE_BASE) { |
| 28 | return 16; |
| 29 | } |
| 30 | switch (type) { |
| 31 | case SENSOR_TYPE_POSE_6DOF: |
| 32 | return 16; |
| 33 | |
Eva Chen | c0420b7 | 2021-04-09 15:44:12 -0700 | [diff] [blame] | 34 | case SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED: |
| 35 | case SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED: |
| 36 | return 9; |
| 37 | |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 38 | case SENSOR_TYPE_ROTATION_VECTOR: |
| 39 | case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR: |
| 40 | return 5; |
| 41 | |
| 42 | case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: |
Eva Chen | 65fb441 | 2022-03-28 19:01:00 -0700 | [diff] [blame] | 43 | case SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED: |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 44 | case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: |
Eva Chen | c0420b7 | 2021-04-09 15:44:12 -0700 | [diff] [blame] | 45 | case SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES: |
| 46 | case SENSOR_TYPE_GYROSCOPE_LIMITED_AXES: |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 47 | return 6; |
| 48 | |
| 49 | case SENSOR_TYPE_GAME_ROTATION_VECTOR: |
| 50 | return 4; |
| 51 | |
| 52 | case SENSOR_TYPE_SIGNIFICANT_MOTION: |
| 53 | case SENSOR_TYPE_STEP_DETECTOR: |
| 54 | case SENSOR_TYPE_STEP_COUNTER: |
| 55 | case SENSOR_TYPE_HEART_RATE: |
| 56 | case SENSOR_TYPE_TILT_DETECTOR: |
| 57 | case SENSOR_TYPE_WAKE_GESTURE: |
| 58 | case SENSOR_TYPE_GLANCE_GESTURE: |
| 59 | case SENSOR_TYPE_PICK_UP_GESTURE: |
| 60 | case SENSOR_TYPE_WRIST_TILT_GESTURE: |
| 61 | case SENSOR_TYPE_DEVICE_ORIENTATION: |
| 62 | case SENSOR_TYPE_STATIONARY_DETECT: |
| 63 | case SENSOR_TYPE_MOTION_DETECT: |
| 64 | case SENSOR_TYPE_HEART_BEAT: |
Nick Vaccaro | 2e990eb | 2017-01-12 21:13:58 -0800 | [diff] [blame] | 65 | case SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT: |
Anthony Stange | fdb1fc8 | 2020-01-16 15:02:48 -0500 | [diff] [blame] | 66 | case SENSOR_TYPE_HINGE_ANGLE: |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 67 | return 1; |
| 68 | |
Brian Duddie | 573da3b | 2021-12-10 14:34:07 -0800 | [diff] [blame] | 69 | case SENSOR_TYPE_HEAD_TRACKER: |
| 70 | return 7; |
| 71 | |
Eva Chen | 72c7104 | 2022-01-10 21:07:51 -0800 | [diff] [blame] | 72 | case SENSOR_TYPE_HEADING: |
| 73 | return 2; |
| 74 | |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 75 | default: |
| 76 | return 3; |
| 77 | } |
| 78 | } |
| 79 | |
Anthony Stange | 9bb1670 | 2023-01-03 22:42:31 +0000 | [diff] [blame] | 80 | bool isUserBuild() { |
| 81 | std::string buildType = android::base::GetProperty("ro.build.type", "user"); |
| 82 | return "user" == buildType; |
| 83 | } |
| 84 | |
Peng Xu | 6a2d3a0 | 2015-12-21 12:00:23 -0800 | [diff] [blame] | 85 | } // namespace SensorServiceUtil |
| 86 | } // namespace android; |