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