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 <android-base/properties.h> 20 #include <hardware/sensors.h> 21 22 namespace android { 23 namespace SensorServiceUtil { 24 25 // Keep in sync with sSensorReportingMode in Sensor.java eventSizeBySensorType(int type)26size_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 34 case SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED: 35 case SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED: 36 return 9; 37 38 case SENSOR_TYPE_ROTATION_VECTOR: 39 case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR: 40 return 5; 41 42 case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: 43 case SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED: 44 case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: 45 case SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES: 46 case SENSOR_TYPE_GYROSCOPE_LIMITED_AXES: 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: 65 case SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT: 66 case SENSOR_TYPE_HINGE_ANGLE: 67 return 1; 68 69 case SENSOR_TYPE_HEAD_TRACKER: 70 return 7; 71 72 case SENSOR_TYPE_HEADING: 73 return 2; 74 75 default: 76 return 3; 77 } 78 } 79 isUserBuild()80bool isUserBuild() { 81 std::string buildType = android::base::GetProperty("ro.build.type", "user"); 82 return "user" == buildType; 83 } 84 85 } // namespace SensorServiceUtil 86 } // namespace android; 87