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
21namespace android {
22namespace SensorServiceUtil {
23
24// Keep in sync with sSensorReportingMode in Sensor.java
25size_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:
57            return 1;
58
59        default:
60            return 3;
61    }
62}
63
64} // namespace SensorServiceUtil
65} // namespace android;
66