• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2023 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
17syntax = "proto3";
18
19package capo;
20
21// The message types used in capo nanoapp. Some of them are H2C
22// (Host-To-CHRE) and others are C2H (CHRE-To-Host). One message type must be
23// either H2C or C2H. Each message type can choose to have payload or not.
24enum MessageType {
25  // Explicitly prevents 0 from being used as a valid message type.
26  // Doing so protects from obscure bugs caused by default-initialized values.
27  INVALID = 0;
28
29  // Detector configuration related message start from 100.
30  // Signal for host to acknowledge the notification.
31  // It contains AckNotification payload.
32  ACK_NOTIFICATION = 100;
33
34  // Signal to enable the carried position detector for device. No payload.
35  ENABLE_DETECTOR = 101;
36
37  // Signal to disable the carried position detector for device. No payload.
38  DISABLE_DETECTOR = 102;
39
40  // Signal to request most recent carried position detector state. No payload.
41  REQUEST_UPDATE = 103;
42
43  // Signal to force carried position detector to refresh state. No payload.
44  FORCE_UPDATE = 104;
45
46  // Configure the detector with desired parameters. ConfigureDetector payload.
47  CONFIGURE_DETECTOR = 105;
48
49  // Position Detection related message start from 200.
50  // Signal while carried position of device detected.
51  // It contains PositionDetected payload.
52  POSITION_DETECTED = 200;
53}
54
55// Notification Type.
56enum NotificationType {
57  // Explicitly prevents 0 from being used as a valid notification type.
58  // Doing so protects from obscure bugs caused by default-initialized values.
59  INVALID_NOTIFICATION = 0;
60
61  // Notification of enabling the carried position detector for device.
62  ENABLE_NOTIFICATION = 1;
63
64  // Notification of disabling the carried position detector for device.
65  DISABLE_NOTIFICATION = 2;
66
67  // Notification of request update from the carried position detector.
68  REQUEST_UPDATE_NOTIFICATION = 3;
69
70  // Notification of force update from the carried position detector.
71  FORCE_UPDATE_NOTIFICATION = 4;
72
73  // Notification of configure message.
74  CONFIGURE_NOTIFICATION = 5;
75}
76
77// This message type used for host to acknowledge the notification.
78message AckNotification {
79  // Sent a notification type for host to acknowledge.
80  NotificationType notification_type = 1;
81}
82
83// Position type.
84enum PositionType {
85  // Explicitly prevents 0 from being used as a valid carried position type.
86  // Doing so protects from obscure bugs caused by default-initialized values.
87  UNKNOWN = 0;
88
89  // Carried position while device is in motion.
90  IN_MOTION = 1;
91
92  // Carried position while device is on table and faces up.
93  ON_TABLE_FACE_UP = 2;
94
95  // Carried position while device is on table and faces down.
96  ON_TABLE_FACE_DOWN = 3;
97
98  // Carried position while device is stationary in unknown orientation.
99  STATIONARY_UNKNOWN = 4;
100}
101
102// This message type used to notify host a position was a detected.
103message PositionDetected {
104  // Sent a position type that is defined in PositionTypes.
105  PositionType position_type = 1;
106}
107
108// Predefined configurations for detector.
109enum ConfigPresetType {
110  // Explicitly prevents 0 from being used as a valid type.
111  // Doing so protects from obscure bugs caused by default-initialized values.
112  CONFIG_PRESET_UNSPECIFIED = 0;
113
114  // Default preset.
115  CONFIG_PRESET_DEFAULT = 1;
116
117  // Preset for sticky-stationary behavior.
118  CONFIG_PRESET_STICKY_STATIONARY = 2;
119}
120
121message ConfigureDetector {
122  // Ref: cs/location/lbs/contexthub/nanoapps/motiondetector/motion_detector.h
123  message ConfigData {
124    // These algo parameters are exposed to enable tuning via server flags.
125    // The amount of time that the algorithm's computed stillness confidence
126    // must exceed still_confidence_threshold before entering the stationary
127    // state. Increasing this value will make the algorithm take longer to
128    // transition from the in motion state to the stationary state.
129    uint64 still_time_threshold_nanosecond = 1;
130
131    // The amount of time in which the variance should be averaged. Increasing
132    // this value will effectively smooth the input data, making the algorithm
133    // less likely to transition between states.
134    uint32 window_width_nanosecond = 2;
135
136    // The required confidence that the device is in motion before entering the
137    // motion state. Valid range is [0.0, 1.0], where 1.0 indicates that the
138    // algorithm must be 100% certain that the device is moving before entering
139    // the motion state. If the Instant Motion sensor is triggered, this value
140    // is ignored and the algorithm is immediately transitioned into the in
141    // motion state.
142    float motion_confidence_threshold = 3;
143
144    // The required confidence that the device is stationary before entering the
145    // stationary state. Valid range is [0.0, 1.0], where 1.0 indicates that the
146    // algorithm must be 100% certain that the device is stationary before
147    // entering the stationary state.
148    float still_confidence_threshold = 4;
149
150    // The variance threshold for the StillnessDetector algorithm. Increasing
151    // this value causes the algorithm to be less likely to detect motion.
152    float var_threshold = 5;
153
154    // The variance threshold delta for the StillnessDetector algorithm about
155    // which the stationary confidence is calculated. Valid range is
156    // [0.0, var_threshold].
157    float var_threshold_delta = 6;
158  }
159
160  oneof type {
161    ConfigPresetType preset_type = 1;
162    ConfigData config_data = 2;
163  }
164}
165