xref: /aosp_15_r20/external/libchrome-gestures/src/activity_log.cc (revision aed3e5085e770be5b69ce25295ecf6ddf906af95)
1*aed3e508SAndroid Build Coastguard Worker // Copyright 2012 The ChromiumOS Authors
2*aed3e508SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*aed3e508SAndroid Build Coastguard Worker // found in the LICENSE file.
4*aed3e508SAndroid Build Coastguard Worker 
5*aed3e508SAndroid Build Coastguard Worker #include "include/activity_log.h"
6*aed3e508SAndroid Build Coastguard Worker 
7*aed3e508SAndroid Build Coastguard Worker #include <errno.h>
8*aed3e508SAndroid Build Coastguard Worker #include <fcntl.h>
9*aed3e508SAndroid Build Coastguard Worker #include <set>
10*aed3e508SAndroid Build Coastguard Worker #include <string>
11*aed3e508SAndroid Build Coastguard Worker #include <sys/stat.h>
12*aed3e508SAndroid Build Coastguard Worker #include <sys/types.h>
13*aed3e508SAndroid Build Coastguard Worker 
14*aed3e508SAndroid Build Coastguard Worker #include <json/value.h>
15*aed3e508SAndroid Build Coastguard Worker #include <json/writer.h>
16*aed3e508SAndroid Build Coastguard Worker 
17*aed3e508SAndroid Build Coastguard Worker #include "include/file_util.h"
18*aed3e508SAndroid Build Coastguard Worker #include "include/logging.h"
19*aed3e508SAndroid Build Coastguard Worker #include "include/prop_registry.h"
20*aed3e508SAndroid Build Coastguard Worker #include "include/string_util.h"
21*aed3e508SAndroid Build Coastguard Worker 
22*aed3e508SAndroid Build Coastguard Worker #define QUINTTAP_COUNT 5  /* BTN_TOOL_QUINTTAP - Five fingers on trackpad */
23*aed3e508SAndroid Build Coastguard Worker 
24*aed3e508SAndroid Build Coastguard Worker using std::set;
25*aed3e508SAndroid Build Coastguard Worker using std::string;
26*aed3e508SAndroid Build Coastguard Worker 
27*aed3e508SAndroid Build Coastguard Worker namespace {
28*aed3e508SAndroid Build Coastguard Worker 
29*aed3e508SAndroid Build Coastguard Worker // Helper to std::visit with lambdas.
30*aed3e508SAndroid Build Coastguard Worker template <typename... V>
31*aed3e508SAndroid Build Coastguard Worker struct Visitor : V... {
32*aed3e508SAndroid Build Coastguard Worker   using V::operator()...;
33*aed3e508SAndroid Build Coastguard Worker };
34*aed3e508SAndroid Build Coastguard Worker // Explicit deduction guide (not needed as of C++20).
35*aed3e508SAndroid Build Coastguard Worker template <typename... V>
36*aed3e508SAndroid Build Coastguard Worker Visitor(V...) -> Visitor<V...>;
37*aed3e508SAndroid Build Coastguard Worker 
38*aed3e508SAndroid Build Coastguard Worker } // namespace
39*aed3e508SAndroid Build Coastguard Worker 
40*aed3e508SAndroid Build Coastguard Worker namespace gestures {
41*aed3e508SAndroid Build Coastguard Worker 
ActivityLog(PropRegistry * prop_reg)42*aed3e508SAndroid Build Coastguard Worker ActivityLog::ActivityLog(PropRegistry* prop_reg)
43*aed3e508SAndroid Build Coastguard Worker     : head_idx_(0), size_(0), max_fingers_(0), hwprops_(),
44*aed3e508SAndroid Build Coastguard Worker       prop_reg_(prop_reg) {}
45*aed3e508SAndroid Build Coastguard Worker 
SetHardwareProperties(const HardwareProperties & hwprops)46*aed3e508SAndroid Build Coastguard Worker void ActivityLog::SetHardwareProperties(const HardwareProperties& hwprops) {
47*aed3e508SAndroid Build Coastguard Worker   hwprops_ = hwprops;
48*aed3e508SAndroid Build Coastguard Worker 
49*aed3e508SAndroid Build Coastguard Worker   // For old devices(such as mario, alex, zgb..), the reporting touch count
50*aed3e508SAndroid Build Coastguard Worker   // or 'max_touch_cnt' will be less than number of slots or 'max_finger_cnt'
51*aed3e508SAndroid Build Coastguard Worker   // they support. As kernel evdev drivers do not have a bitset to report
52*aed3e508SAndroid Build Coastguard Worker   // touch count greater than five (bitset for five-fingers gesture is
53*aed3e508SAndroid Build Coastguard Worker   // BTN_TOOL_QUINTAP), we respect 'max_finger_cnt' than 'max_touch_cnt'
54*aed3e508SAndroid Build Coastguard Worker   // reported from kernel driver as the 'max_fingers_' instead.
55*aed3e508SAndroid Build Coastguard Worker   if (hwprops.max_touch_cnt < QUINTTAP_COUNT) {
56*aed3e508SAndroid Build Coastguard Worker     max_fingers_ = std::min<size_t>(hwprops.max_finger_cnt,
57*aed3e508SAndroid Build Coastguard Worker                                     hwprops.max_touch_cnt);
58*aed3e508SAndroid Build Coastguard Worker   } else {
59*aed3e508SAndroid Build Coastguard Worker     max_fingers_ = std::max<size_t>(hwprops.max_finger_cnt,
60*aed3e508SAndroid Build Coastguard Worker                                     hwprops.max_touch_cnt);
61*aed3e508SAndroid Build Coastguard Worker   }
62*aed3e508SAndroid Build Coastguard Worker 
63*aed3e508SAndroid Build Coastguard Worker   finger_states_.reset(new FingerState[kBufferSize * max_fingers_]);
64*aed3e508SAndroid Build Coastguard Worker }
65*aed3e508SAndroid Build Coastguard Worker 
LogHardwareState(const HardwareState & hwstate)66*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogHardwareState(const HardwareState& hwstate) {
67*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
68*aed3e508SAndroid Build Coastguard Worker   entry->details = hwstate;
69*aed3e508SAndroid Build Coastguard Worker   HardwareState& entry_hwstate = std::get<HardwareState>(entry->details);
70*aed3e508SAndroid Build Coastguard Worker   if (hwstate.finger_cnt > max_fingers_) {
71*aed3e508SAndroid Build Coastguard Worker     Err("Too many fingers! Max is %zu, but I got %d",
72*aed3e508SAndroid Build Coastguard Worker         max_fingers_, hwstate.finger_cnt);
73*aed3e508SAndroid Build Coastguard Worker     entry_hwstate.fingers = nullptr;
74*aed3e508SAndroid Build Coastguard Worker     entry_hwstate.finger_cnt = 0;
75*aed3e508SAndroid Build Coastguard Worker     return;
76*aed3e508SAndroid Build Coastguard Worker   }
77*aed3e508SAndroid Build Coastguard Worker   if (!finger_states_.get())
78*aed3e508SAndroid Build Coastguard Worker     return;
79*aed3e508SAndroid Build Coastguard Worker   entry_hwstate.fingers = &finger_states_[TailIdx() * max_fingers_];
80*aed3e508SAndroid Build Coastguard Worker   std::copy(&hwstate.fingers[0], &hwstate.fingers[hwstate.finger_cnt],
81*aed3e508SAndroid Build Coastguard Worker             entry_hwstate.fingers);
82*aed3e508SAndroid Build Coastguard Worker }
83*aed3e508SAndroid Build Coastguard Worker 
LogTimerCallback(stime_t now)84*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogTimerCallback(stime_t now) {
85*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
86*aed3e508SAndroid Build Coastguard Worker   entry->details = TimerCallbackEntry{now};
87*aed3e508SAndroid Build Coastguard Worker }
88*aed3e508SAndroid Build Coastguard Worker 
LogCallbackRequest(stime_t when)89*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogCallbackRequest(stime_t when) {
90*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
91*aed3e508SAndroid Build Coastguard Worker   entry->details = CallbackRequestEntry{when};
92*aed3e508SAndroid Build Coastguard Worker }
93*aed3e508SAndroid Build Coastguard Worker 
LogGesture(const Gesture & gesture)94*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogGesture(const Gesture& gesture) {
95*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
96*aed3e508SAndroid Build Coastguard Worker   entry->details = gesture;
97*aed3e508SAndroid Build Coastguard Worker }
98*aed3e508SAndroid Build Coastguard Worker 
LogPropChange(const PropChangeEntry & prop_change)99*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogPropChange(const PropChangeEntry& prop_change) {
100*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
101*aed3e508SAndroid Build Coastguard Worker   entry->details = prop_change;
102*aed3e508SAndroid Build Coastguard Worker }
103*aed3e508SAndroid Build Coastguard Worker 
LogGestureConsume(const std::string & name,const Gesture & gesture)104*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogGestureConsume(
105*aed3e508SAndroid Build Coastguard Worker     const std::string& name, const Gesture& gesture) {
106*aed3e508SAndroid Build Coastguard Worker   GestureConsume gesture_consume { name, gesture };
107*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
108*aed3e508SAndroid Build Coastguard Worker   entry->details = gesture_consume;
109*aed3e508SAndroid Build Coastguard Worker }
110*aed3e508SAndroid Build Coastguard Worker 
LogGestureProduce(const std::string & name,const Gesture & gesture)111*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogGestureProduce(
112*aed3e508SAndroid Build Coastguard Worker     const std::string& name, const Gesture& gesture) {
113*aed3e508SAndroid Build Coastguard Worker   GestureProduce gesture_produce { name, gesture };
114*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
115*aed3e508SAndroid Build Coastguard Worker   entry->details = gesture_produce;
116*aed3e508SAndroid Build Coastguard Worker }
117*aed3e508SAndroid Build Coastguard Worker 
LogHardwareStatePre(const std::string & name,const HardwareState & hwstate)118*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogHardwareStatePre(const std::string& name,
119*aed3e508SAndroid Build Coastguard Worker                                       const HardwareState& hwstate) {
120*aed3e508SAndroid Build Coastguard Worker   HardwareStatePre hwstate_pre { name, hwstate };
121*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
122*aed3e508SAndroid Build Coastguard Worker   entry->details = hwstate_pre;
123*aed3e508SAndroid Build Coastguard Worker }
124*aed3e508SAndroid Build Coastguard Worker 
LogHardwareStatePost(const std::string & name,const HardwareState & hwstate)125*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogHardwareStatePost(const std::string& name,
126*aed3e508SAndroid Build Coastguard Worker                                        const HardwareState& hwstate) {
127*aed3e508SAndroid Build Coastguard Worker   HardwareStatePost hwstate_post { name, hwstate };
128*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
129*aed3e508SAndroid Build Coastguard Worker   entry->details = hwstate_post;
130*aed3e508SAndroid Build Coastguard Worker }
131*aed3e508SAndroid Build Coastguard Worker 
LogHandleTimerPre(const std::string & name,stime_t now,const stime_t * timeout)132*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogHandleTimerPre(const std::string& name,
133*aed3e508SAndroid Build Coastguard Worker                                     stime_t now, const stime_t* timeout) {
134*aed3e508SAndroid Build Coastguard Worker   HandleTimerPre handle;
135*aed3e508SAndroid Build Coastguard Worker   handle.name = name;
136*aed3e508SAndroid Build Coastguard Worker   handle.now = now;
137*aed3e508SAndroid Build Coastguard Worker   handle.timeout_is_present = (timeout != nullptr);
138*aed3e508SAndroid Build Coastguard Worker   handle.timeout = (timeout == nullptr) ? 0 : *timeout;
139*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
140*aed3e508SAndroid Build Coastguard Worker   entry->details = handle;
141*aed3e508SAndroid Build Coastguard Worker }
142*aed3e508SAndroid Build Coastguard Worker 
LogHandleTimerPost(const std::string & name,stime_t now,const stime_t * timeout)143*aed3e508SAndroid Build Coastguard Worker void ActivityLog::LogHandleTimerPost(const std::string& name,
144*aed3e508SAndroid Build Coastguard Worker                                      stime_t now, const stime_t* timeout) {
145*aed3e508SAndroid Build Coastguard Worker   HandleTimerPost handle;
146*aed3e508SAndroid Build Coastguard Worker   handle.name = name;
147*aed3e508SAndroid Build Coastguard Worker   handle.now = now;
148*aed3e508SAndroid Build Coastguard Worker   handle.timeout_is_present = (timeout != nullptr);
149*aed3e508SAndroid Build Coastguard Worker   handle.timeout = (timeout == nullptr) ? 0 : *timeout;
150*aed3e508SAndroid Build Coastguard Worker   Entry* entry = PushBack();
151*aed3e508SAndroid Build Coastguard Worker   entry->details = handle;
152*aed3e508SAndroid Build Coastguard Worker }
153*aed3e508SAndroid Build Coastguard Worker 
Dump(const char * filename)154*aed3e508SAndroid Build Coastguard Worker void ActivityLog::Dump(const char* filename) {
155*aed3e508SAndroid Build Coastguard Worker   string data = Encode();
156*aed3e508SAndroid Build Coastguard Worker   WriteFile(filename, data.c_str(), data.size());
157*aed3e508SAndroid Build Coastguard Worker }
158*aed3e508SAndroid Build Coastguard Worker 
PushBack()159*aed3e508SAndroid Build Coastguard Worker ActivityLog::Entry* ActivityLog::PushBack() {
160*aed3e508SAndroid Build Coastguard Worker   if (size_ == kBufferSize) {
161*aed3e508SAndroid Build Coastguard Worker     Entry* ret = &buffer_[head_idx_];
162*aed3e508SAndroid Build Coastguard Worker     head_idx_ = (head_idx_ + 1) % kBufferSize;
163*aed3e508SAndroid Build Coastguard Worker     return ret;
164*aed3e508SAndroid Build Coastguard Worker   }
165*aed3e508SAndroid Build Coastguard Worker   ++size_;
166*aed3e508SAndroid Build Coastguard Worker   return &buffer_[TailIdx()];
167*aed3e508SAndroid Build Coastguard Worker }
168*aed3e508SAndroid Build Coastguard Worker 
EncodeHardwareProperties() const169*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHardwareProperties() const {
170*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
171*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropLeft] = Json::Value(hwprops_.left);
172*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropTop] = Json::Value(hwprops_.top);
173*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropRight] = Json::Value(hwprops_.right);
174*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropBottom] = Json::Value(hwprops_.bottom);
175*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropXResolution] = Json::Value(hwprops_.res_x);
176*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropYResolution] = Json::Value(hwprops_.res_y);
177*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropOrientationMinimum] =
178*aed3e508SAndroid Build Coastguard Worker       Json::Value(hwprops_.orientation_minimum);
179*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropOrientationMaximum] =
180*aed3e508SAndroid Build Coastguard Worker       Json::Value(hwprops_.orientation_maximum);
181*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropMaxFingerCount] = Json::Value(hwprops_.max_finger_cnt);
182*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropMaxTouchCount] = Json::Value(hwprops_.max_touch_cnt);
183*aed3e508SAndroid Build Coastguard Worker 
184*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropSupportsT5R2] = Json::Value(hwprops_.supports_t5r2 != 0);
185*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropSemiMt] = Json::Value(hwprops_.support_semi_mt != 0);
186*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropIsButtonPad] = Json::Value(hwprops_.is_button_pad != 0);
187*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwarePropHasWheel] = Json::Value(hwprops_.has_wheel != 0);
188*aed3e508SAndroid Build Coastguard Worker   return ret;
189*aed3e508SAndroid Build Coastguard Worker }
190*aed3e508SAndroid Build Coastguard Worker 
EncodeHardwareStateCommon(const HardwareState & hwstate)191*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHardwareStateCommon(
192*aed3e508SAndroid Build Coastguard Worker     const HardwareState& hwstate) {
193*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
194*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateButtonsDown] = Json::Value(hwstate.buttons_down);
195*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateTouchCnt] = Json::Value(hwstate.touch_cnt);
196*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateTimestamp] = Json::Value(hwstate.timestamp);
197*aed3e508SAndroid Build Coastguard Worker   Json::Value fingers(Json::arrayValue);
198*aed3e508SAndroid Build Coastguard Worker   for (size_t i = 0; i < hwstate.finger_cnt; ++i) {
199*aed3e508SAndroid Build Coastguard Worker     if (hwstate.fingers == nullptr) {
200*aed3e508SAndroid Build Coastguard Worker       Err("Have finger_cnt %d but fingers is null!", hwstate.finger_cnt);
201*aed3e508SAndroid Build Coastguard Worker       break;
202*aed3e508SAndroid Build Coastguard Worker     }
203*aed3e508SAndroid Build Coastguard Worker     const FingerState& fs = hwstate.fingers[i];
204*aed3e508SAndroid Build Coastguard Worker     Json::Value finger(Json::objectValue);
205*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateTouchMajor] = Json::Value(fs.touch_major);
206*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateTouchMinor] = Json::Value(fs.touch_minor);
207*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateWidthMajor] = Json::Value(fs.width_major);
208*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateWidthMinor] = Json::Value(fs.width_minor);
209*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStatePressure] = Json::Value(fs.pressure);
210*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateOrientation] = Json::Value(fs.orientation);
211*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStatePositionX] = Json::Value(fs.position_x);
212*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStatePositionY] = Json::Value(fs.position_y);
213*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateTrackingId] = Json::Value(fs.tracking_id);
214*aed3e508SAndroid Build Coastguard Worker     finger[kKeyFingerStateFlags] = Json::Value(static_cast<int>(fs.flags));
215*aed3e508SAndroid Build Coastguard Worker     fingers.append(finger);
216*aed3e508SAndroid Build Coastguard Worker   }
217*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateFingers] = fingers;
218*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateRelX] = Json::Value(hwstate.rel_x);
219*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateRelY] = Json::Value(hwstate.rel_y);
220*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateRelWheel] = Json::Value(hwstate.rel_wheel);
221*aed3e508SAndroid Build Coastguard Worker   ret[kKeyHardwareStateRelHWheel] = Json::Value(hwstate.rel_hwheel);
222*aed3e508SAndroid Build Coastguard Worker   return ret;
223*aed3e508SAndroid Build Coastguard Worker }
224*aed3e508SAndroid Build Coastguard Worker 
EncodeHardwareState(const HardwareState & hwstate)225*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHardwareState(const HardwareState& hwstate) {
226*aed3e508SAndroid Build Coastguard Worker   auto ret = EncodeHardwareStateCommon(hwstate);
227*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyHardwareState);
228*aed3e508SAndroid Build Coastguard Worker   return ret;
229*aed3e508SAndroid Build Coastguard Worker }
230*aed3e508SAndroid Build Coastguard Worker 
EncodeHardwareState(const HardwareStatePre & pre_hwstate)231*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHardwareState(
232*aed3e508SAndroid Build Coastguard Worker     const HardwareStatePre& pre_hwstate) {
233*aed3e508SAndroid Build Coastguard Worker   auto ret = EncodeHardwareStateCommon(pre_hwstate.hwstate);
234*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyHardwareStatePre);
235*aed3e508SAndroid Build Coastguard Worker   ret[kKeyMethodName] = Json::Value(pre_hwstate.name);
236*aed3e508SAndroid Build Coastguard Worker   return ret;
237*aed3e508SAndroid Build Coastguard Worker }
238*aed3e508SAndroid Build Coastguard Worker 
EncodeHardwareState(const HardwareStatePost & post_hwstate)239*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHardwareState(
240*aed3e508SAndroid Build Coastguard Worker     const HardwareStatePost& post_hwstate) {
241*aed3e508SAndroid Build Coastguard Worker   auto ret = EncodeHardwareStateCommon(post_hwstate.hwstate);
242*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyHardwareStatePost);
243*aed3e508SAndroid Build Coastguard Worker   ret[kKeyMethodName] = Json::Value(post_hwstate.name);
244*aed3e508SAndroid Build Coastguard Worker   return ret;
245*aed3e508SAndroid Build Coastguard Worker }
246*aed3e508SAndroid Build Coastguard Worker 
EncodeHandleTimer(const HandleTimerPre & handle)247*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHandleTimer(const HandleTimerPre& handle) {
248*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
249*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyHandleTimerPre);
250*aed3e508SAndroid Build Coastguard Worker   ret[kKeyMethodName] = Json::Value(handle.name);
251*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimerNow] = Json::Value(handle.now);
252*aed3e508SAndroid Build Coastguard Worker   if (handle.timeout_is_present)
253*aed3e508SAndroid Build Coastguard Worker     ret[kKeyHandleTimerTimeout] = Json::Value(handle.timeout);
254*aed3e508SAndroid Build Coastguard Worker   return ret;
255*aed3e508SAndroid Build Coastguard Worker }
256*aed3e508SAndroid Build Coastguard Worker 
EncodeHandleTimer(const HandleTimerPost & handle)257*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHandleTimer(const HandleTimerPost& handle) {
258*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
259*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyHandleTimerPost);
260*aed3e508SAndroid Build Coastguard Worker   ret[kKeyMethodName] = Json::Value(handle.name);
261*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimerNow] = Json::Value(handle.now);
262*aed3e508SAndroid Build Coastguard Worker   if (handle.timeout_is_present)
263*aed3e508SAndroid Build Coastguard Worker     ret[kKeyHandleTimerTimeout] = Json::Value(handle.timeout);
264*aed3e508SAndroid Build Coastguard Worker   return ret;
265*aed3e508SAndroid Build Coastguard Worker }
266*aed3e508SAndroid Build Coastguard Worker 
EncodeTimerCallback(stime_t timestamp)267*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeTimerCallback(stime_t timestamp) {
268*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
269*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyTimerCallback);
270*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimerNow] = Json::Value(timestamp);
271*aed3e508SAndroid Build Coastguard Worker   return ret;
272*aed3e508SAndroid Build Coastguard Worker }
273*aed3e508SAndroid Build Coastguard Worker 
EncodeCallbackRequest(stime_t timestamp)274*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeCallbackRequest(stime_t timestamp) {
275*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
276*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyCallbackRequest);
277*aed3e508SAndroid Build Coastguard Worker   ret[kKeyCallbackRequestWhen] = Json::Value(timestamp);
278*aed3e508SAndroid Build Coastguard Worker   return ret;
279*aed3e508SAndroid Build Coastguard Worker }
280*aed3e508SAndroid Build Coastguard Worker 
EncodeGestureCommon(const Gesture & gesture)281*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeGestureCommon(const Gesture& gesture) {
282*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
283*aed3e508SAndroid Build Coastguard Worker   ret[kKeyGestureStartTime] = Json::Value(gesture.start_time);
284*aed3e508SAndroid Build Coastguard Worker   ret[kKeyGestureEndTime] = Json::Value(gesture.end_time);
285*aed3e508SAndroid Build Coastguard Worker 
286*aed3e508SAndroid Build Coastguard Worker   switch (gesture.type) {
287*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeNull:
288*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value("null");
289*aed3e508SAndroid Build Coastguard Worker       break;
290*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeContactInitiated:
291*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeContactInitiated);
292*aed3e508SAndroid Build Coastguard Worker       break;
293*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeMove:
294*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeMove);
295*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDX] = Json::Value(gesture.details.move.dx);
296*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDY] = Json::Value(gesture.details.move.dy);
297*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDX] = Json::Value(gesture.details.move.ordinal_dx);
298*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDY] = Json::Value(gesture.details.move.ordinal_dy);
299*aed3e508SAndroid Build Coastguard Worker       break;
300*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeScroll:
301*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeScroll);
302*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDX] = Json::Value(gesture.details.scroll.dx);
303*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDY] = Json::Value(gesture.details.scroll.dy);
304*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDX] =
305*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.scroll.ordinal_dx);
306*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDY] =
307*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.scroll.ordinal_dy);
308*aed3e508SAndroid Build Coastguard Worker       break;
309*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeMouseWheel:
310*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeMouseWheel);
311*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDX] = Json::Value(gesture.details.wheel.dx);
312*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDY] = Json::Value(gesture.details.wheel.dy);
313*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureMouseWheelTicksDX] =
314*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.wheel.tick_120ths_dx);
315*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureMouseWheelTicksDY] =
316*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.wheel.tick_120ths_dy);
317*aed3e508SAndroid Build Coastguard Worker       break;
318*aed3e508SAndroid Build Coastguard Worker     case kGestureTypePinch:
319*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypePinch);
320*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGesturePinchDZ] = Json::Value(gesture.details.pinch.dz);
321*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGesturePinchOrdinalDZ] =
322*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.pinch.ordinal_dz);
323*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGesturePinchZoomState] =
324*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.pinch.zoom_state);
325*aed3e508SAndroid Build Coastguard Worker       break;
326*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeButtonsChange:
327*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeButtonsChange);
328*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureButtonsChangeDown] =
329*aed3e508SAndroid Build Coastguard Worker           Json::Value(static_cast<int>(gesture.details.buttons.down));
330*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureButtonsChangeUp] =
331*aed3e508SAndroid Build Coastguard Worker           Json::Value(static_cast<int>(gesture.details.buttons.up));
332*aed3e508SAndroid Build Coastguard Worker       break;
333*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeFling:
334*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeFling);
335*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureFlingVX] = Json::Value(gesture.details.fling.vx);
336*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureFlingVY] = Json::Value(gesture.details.fling.vy);
337*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureFlingOrdinalVX] =
338*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.fling.ordinal_vx);
339*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureFlingOrdinalVY] =
340*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.fling.ordinal_vy);
341*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureFlingState] =
342*aed3e508SAndroid Build Coastguard Worker           Json::Value(static_cast<int>(gesture.details.fling.fling_state));
343*aed3e508SAndroid Build Coastguard Worker       break;
344*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeSwipe:
345*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeSwipe);
346*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDX] = Json::Value(gesture.details.swipe.dx);
347*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDY] = Json::Value(gesture.details.swipe.dy);
348*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDX] =
349*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.swipe.ordinal_dx);
350*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDY] =
351*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.swipe.ordinal_dy);
352*aed3e508SAndroid Build Coastguard Worker       break;
353*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeSwipeLift:
354*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeSwipeLift);
355*aed3e508SAndroid Build Coastguard Worker       break;
356*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeFourFingerSwipe:
357*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeFourFingerSwipe);
358*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDX] =
359*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.four_finger_swipe.dx);
360*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureDY] =
361*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.four_finger_swipe.dy);
362*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDX] =
363*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.four_finger_swipe.ordinal_dx);
364*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureOrdinalDY] =
365*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.four_finger_swipe.ordinal_dy);
366*aed3e508SAndroid Build Coastguard Worker       break;
367*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeFourFingerSwipeLift:
368*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeFourFingerSwipeLift);
369*aed3e508SAndroid Build Coastguard Worker       break;
370*aed3e508SAndroid Build Coastguard Worker     case kGestureTypeMetrics:
371*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] = Json::Value(kValueGestureTypeMetrics);
372*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureMetricsType] =
373*aed3e508SAndroid Build Coastguard Worker           Json::Value(static_cast<int>(gesture.details.metrics.type));
374*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureMetricsData1] =
375*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.metrics.data[0]);
376*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureMetricsData2] =
377*aed3e508SAndroid Build Coastguard Worker           Json::Value(gesture.details.metrics.data[1]);
378*aed3e508SAndroid Build Coastguard Worker       break;
379*aed3e508SAndroid Build Coastguard Worker     default:
380*aed3e508SAndroid Build Coastguard Worker       ret[kKeyGestureType] =
381*aed3e508SAndroid Build Coastguard Worker           Json::Value(StringPrintf("Unhandled %d", gesture.type));
382*aed3e508SAndroid Build Coastguard Worker   }
383*aed3e508SAndroid Build Coastguard Worker   return ret;
384*aed3e508SAndroid Build Coastguard Worker }
385*aed3e508SAndroid Build Coastguard Worker 
EncodeGesture(const Gesture & gesture)386*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeGesture(const Gesture& gesture) {
387*aed3e508SAndroid Build Coastguard Worker   auto ret = EncodeGestureCommon(gesture);
388*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyGesture);
389*aed3e508SAndroid Build Coastguard Worker   return ret;
390*aed3e508SAndroid Build Coastguard Worker }
391*aed3e508SAndroid Build Coastguard Worker 
EncodeGesture(const GestureConsume & gesture_consume)392*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeGesture(const GestureConsume& gesture_consume) {
393*aed3e508SAndroid Build Coastguard Worker   auto ret = EncodeGestureCommon(gesture_consume.gesture);
394*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyGestureConsume);
395*aed3e508SAndroid Build Coastguard Worker   ret[kKeyMethodName] = Json::Value(gesture_consume.name);
396*aed3e508SAndroid Build Coastguard Worker   return ret;
397*aed3e508SAndroid Build Coastguard Worker }
398*aed3e508SAndroid Build Coastguard Worker 
EncodeGesture(const GestureProduce & gesture_produce)399*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeGesture(const GestureProduce& gesture_produce) {
400*aed3e508SAndroid Build Coastguard Worker   auto ret = EncodeGestureCommon(gesture_produce.gesture);
401*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyGestureProduce);
402*aed3e508SAndroid Build Coastguard Worker   ret[kKeyMethodName] = Json::Value(gesture_produce.name);
403*aed3e508SAndroid Build Coastguard Worker   return ret;
404*aed3e508SAndroid Build Coastguard Worker }
405*aed3e508SAndroid Build Coastguard Worker 
EncodePropChange(const PropChangeEntry & prop_change)406*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodePropChange(const PropChangeEntry& prop_change) {
407*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
408*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyPropChange);
409*aed3e508SAndroid Build Coastguard Worker   ret[kKeyPropChangeName] = Json::Value(prop_change.name);
410*aed3e508SAndroid Build Coastguard Worker   Json::Value val;
411*aed3e508SAndroid Build Coastguard Worker   Json::Value type;
412*aed3e508SAndroid Build Coastguard Worker   std::visit(
413*aed3e508SAndroid Build Coastguard Worker     Visitor {
414*aed3e508SAndroid Build Coastguard Worker       [&val, &type](GesturesPropBool value) {
415*aed3e508SAndroid Build Coastguard Worker         val = Json::Value(value);
416*aed3e508SAndroid Build Coastguard Worker         type = Json::Value(kValuePropChangeTypeBool);
417*aed3e508SAndroid Build Coastguard Worker       },
418*aed3e508SAndroid Build Coastguard Worker       [&val, &type](double value) {
419*aed3e508SAndroid Build Coastguard Worker         val = Json::Value(value);
420*aed3e508SAndroid Build Coastguard Worker         type = Json::Value(kValuePropChangeTypeDouble);
421*aed3e508SAndroid Build Coastguard Worker       },
422*aed3e508SAndroid Build Coastguard Worker       [&val, &type](int value) {
423*aed3e508SAndroid Build Coastguard Worker         val = Json::Value(value);
424*aed3e508SAndroid Build Coastguard Worker         type = Json::Value(kValuePropChangeTypeInt);
425*aed3e508SAndroid Build Coastguard Worker       },
426*aed3e508SAndroid Build Coastguard Worker       [&val, &type](short value) {
427*aed3e508SAndroid Build Coastguard Worker         val = Json::Value(value);
428*aed3e508SAndroid Build Coastguard Worker         type = Json::Value(kValuePropChangeTypeShort);
429*aed3e508SAndroid Build Coastguard Worker       },
430*aed3e508SAndroid Build Coastguard Worker       [](auto arg) {
431*aed3e508SAndroid Build Coastguard Worker         Err("Invalid value type");
432*aed3e508SAndroid Build Coastguard Worker       }
433*aed3e508SAndroid Build Coastguard Worker     }, prop_change.value);
434*aed3e508SAndroid Build Coastguard Worker   if (!val.isNull())
435*aed3e508SAndroid Build Coastguard Worker     ret[kKeyPropChangeValue] = val;
436*aed3e508SAndroid Build Coastguard Worker   if (!type.isNull())
437*aed3e508SAndroid Build Coastguard Worker     ret[kKeyPropChangeType] = type;
438*aed3e508SAndroid Build Coastguard Worker   return ret;
439*aed3e508SAndroid Build Coastguard Worker }
440*aed3e508SAndroid Build Coastguard Worker 
EncodeGestureDebug(const AccelGestureDebug & debug_data)441*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeGestureDebug(
442*aed3e508SAndroid Build Coastguard Worker     const AccelGestureDebug& debug_data) {
443*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
444*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyAccelGestureDebug);
445*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugDroppedGesture] = Json::Value(debug_data.dropped_gesture);
446*aed3e508SAndroid Build Coastguard Worker   if (debug_data.no_accel_for_gesture_type)
447*aed3e508SAndroid Build Coastguard Worker     ret[kKeyAccelDebugNoAccelGestureType] = Json::Value(true);
448*aed3e508SAndroid Build Coastguard Worker   else if (debug_data.no_accel_for_small_dt)
449*aed3e508SAndroid Build Coastguard Worker     ret[kKeyAccelDebugNoAccelSmallDt] = Json::Value(true);
450*aed3e508SAndroid Build Coastguard Worker   else if (debug_data.no_accel_for_small_speed)
451*aed3e508SAndroid Build Coastguard Worker     ret[kKeyAccelDebugNoAccelSmallSpeed] = Json::Value(true);
452*aed3e508SAndroid Build Coastguard Worker   else if (debug_data.no_accel_for_bad_gain)
453*aed3e508SAndroid Build Coastguard Worker     ret[kKeyAccelDebugNoAccelBadGain] = Json::Value(true);
454*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugXYAreVelocity] = Json::Value(debug_data.x_y_are_velocity);
455*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugXScale] = Json::Value(debug_data.x_scale);
456*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugYScale] = Json::Value(debug_data.y_scale);
457*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugDt] = Json::Value(debug_data.dt);
458*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugAdjustedDt] = Json::Value(debug_data.adjusted_dt);
459*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugSpeed] = Json::Value(debug_data.speed);
460*aed3e508SAndroid Build Coastguard Worker   if (debug_data.speed != debug_data.smoothed_speed)
461*aed3e508SAndroid Build Coastguard Worker     ret[kKeyAccelDebugSmoothSpeed] = Json::Value(debug_data.smoothed_speed);
462*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugGainX] = Json::Value(debug_data.gain_x);
463*aed3e508SAndroid Build Coastguard Worker   ret[kKeyAccelDebugGainY] = Json::Value(debug_data.gain_y);
464*aed3e508SAndroid Build Coastguard Worker   return ret;
465*aed3e508SAndroid Build Coastguard Worker }
466*aed3e508SAndroid Build Coastguard Worker 
EncodeGestureDebug(const TimestampGestureDebug & debug_data)467*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeGestureDebug(
468*aed3e508SAndroid Build Coastguard Worker     const TimestampGestureDebug& debug_data) {
469*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
470*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyTimestampGestureDebug);
471*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimestampDebugSkew] = Json::Value(debug_data.skew);
472*aed3e508SAndroid Build Coastguard Worker   return ret;
473*aed3e508SAndroid Build Coastguard Worker }
474*aed3e508SAndroid Build Coastguard Worker 
EncodeHardwareStateDebug(const TimestampHardwareStateDebug & debug_data)475*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeHardwareStateDebug(
476*aed3e508SAndroid Build Coastguard Worker     const TimestampHardwareStateDebug& debug_data) {
477*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
478*aed3e508SAndroid Build Coastguard Worker   ret[kKeyType] = Json::Value(kKeyTimestampHardwareStateDebug);
479*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimestampDebugIsUsingFake] = Json::Value(debug_data.is_using_fake);
480*aed3e508SAndroid Build Coastguard Worker   if (debug_data.is_using_fake) {
481*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugWasFirstOrBackward] =
482*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.was_first_or_backward);
483*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugPrevMscTimestampIn] =
484*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.prev_msc_timestamp_in);
485*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugPrevMscTimestampOut] =
486*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.prev_msc_timestamp_out);
487*aed3e508SAndroid Build Coastguard Worker   } else {
488*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugWasDivergenceReset] =
489*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.was_divergence_reset);
490*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugFakeTimestampIn] =
491*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.fake_timestamp_in);
492*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugFakeTimestampDelta] =
493*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.fake_timestamp_delta);
494*aed3e508SAndroid Build Coastguard Worker     ret[kKeyTimestampDebugFakeTimestampOut] =
495*aed3e508SAndroid Build Coastguard Worker         Json::Value(debug_data.fake_timestamp_out);
496*aed3e508SAndroid Build Coastguard Worker   }
497*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimestampDebugSkew] = Json::Value(debug_data.skew);
498*aed3e508SAndroid Build Coastguard Worker   ret[kKeyTimestampDebugMaxSkew] = Json::Value(debug_data.max_skew);
499*aed3e508SAndroid Build Coastguard Worker   return ret;
500*aed3e508SAndroid Build Coastguard Worker }
501*aed3e508SAndroid Build Coastguard Worker 
EncodePropRegistry()502*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodePropRegistry() {
503*aed3e508SAndroid Build Coastguard Worker   Json::Value ret(Json::objectValue);
504*aed3e508SAndroid Build Coastguard Worker   if (!prop_reg_)
505*aed3e508SAndroid Build Coastguard Worker     return ret;
506*aed3e508SAndroid Build Coastguard Worker 
507*aed3e508SAndroid Build Coastguard Worker   const set<Property*>& props = prop_reg_->props();
508*aed3e508SAndroid Build Coastguard Worker   for (set<Property*>::const_iterator it = props.begin(), e = props.end();
509*aed3e508SAndroid Build Coastguard Worker        it != e; ++it) {
510*aed3e508SAndroid Build Coastguard Worker     ret[(*it)->name()] = (*it)->NewValue();
511*aed3e508SAndroid Build Coastguard Worker   }
512*aed3e508SAndroid Build Coastguard Worker   return ret;
513*aed3e508SAndroid Build Coastguard Worker }
514*aed3e508SAndroid Build Coastguard Worker 
EncodeCommonInfo()515*aed3e508SAndroid Build Coastguard Worker Json::Value ActivityLog::EncodeCommonInfo() {
516*aed3e508SAndroid Build Coastguard Worker   Json::Value root(Json::objectValue);
517*aed3e508SAndroid Build Coastguard Worker   Json::Value entries(Json::arrayValue);
518*aed3e508SAndroid Build Coastguard Worker   for (size_t i = 0; i < size_; ++i) {
519*aed3e508SAndroid Build Coastguard Worker     const Entry& entry = buffer_[(i + head_idx_) % kBufferSize];
520*aed3e508SAndroid Build Coastguard Worker     std::visit(
521*aed3e508SAndroid Build Coastguard Worker       Visitor {
522*aed3e508SAndroid Build Coastguard Worker         [this, &entries](HardwareState hwstate) {
523*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeHardwareState(hwstate));
524*aed3e508SAndroid Build Coastguard Worker         },
525*aed3e508SAndroid Build Coastguard Worker         [this, &entries](HardwareStatePre hwstate) {
526*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeHardwareState(hwstate));
527*aed3e508SAndroid Build Coastguard Worker         },
528*aed3e508SAndroid Build Coastguard Worker         [this, &entries](HardwareStatePost hwstate) {
529*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeHardwareState(hwstate));
530*aed3e508SAndroid Build Coastguard Worker         },
531*aed3e508SAndroid Build Coastguard Worker         [this, &entries](TimerCallbackEntry now) {
532*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeTimerCallback(now.timestamp));
533*aed3e508SAndroid Build Coastguard Worker         },
534*aed3e508SAndroid Build Coastguard Worker         [this, &entries](CallbackRequestEntry when) {
535*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeCallbackRequest(when.timestamp));
536*aed3e508SAndroid Build Coastguard Worker         },
537*aed3e508SAndroid Build Coastguard Worker         [this, &entries](Gesture gesture) {
538*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeGesture(gesture));
539*aed3e508SAndroid Build Coastguard Worker         },
540*aed3e508SAndroid Build Coastguard Worker         [this, &entries](GestureConsume gesture) {
541*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeGesture(gesture));
542*aed3e508SAndroid Build Coastguard Worker         },
543*aed3e508SAndroid Build Coastguard Worker         [this, &entries](GestureProduce gesture) {
544*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeGesture(gesture));
545*aed3e508SAndroid Build Coastguard Worker         },
546*aed3e508SAndroid Build Coastguard Worker         [this, &entries](PropChangeEntry prop_change) {
547*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodePropChange(prop_change));
548*aed3e508SAndroid Build Coastguard Worker         },
549*aed3e508SAndroid Build Coastguard Worker         [this, &entries](HandleTimerPre handle) {
550*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeHandleTimer(handle));
551*aed3e508SAndroid Build Coastguard Worker         },
552*aed3e508SAndroid Build Coastguard Worker         [this, &entries](HandleTimerPost handle) {
553*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeHandleTimer(handle));
554*aed3e508SAndroid Build Coastguard Worker         },
555*aed3e508SAndroid Build Coastguard Worker         [this, &entries](AccelGestureDebug debug_data) {
556*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeGestureDebug(debug_data));
557*aed3e508SAndroid Build Coastguard Worker         },
558*aed3e508SAndroid Build Coastguard Worker         [this, &entries](TimestampGestureDebug debug_data) {
559*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeGestureDebug(debug_data));
560*aed3e508SAndroid Build Coastguard Worker         },
561*aed3e508SAndroid Build Coastguard Worker         [this, &entries](TimestampHardwareStateDebug debug_data) {
562*aed3e508SAndroid Build Coastguard Worker           entries.append(EncodeHardwareStateDebug(debug_data));
563*aed3e508SAndroid Build Coastguard Worker         },
564*aed3e508SAndroid Build Coastguard Worker         [](auto arg) {
565*aed3e508SAndroid Build Coastguard Worker           Err("Unknown entry type");
566*aed3e508SAndroid Build Coastguard Worker         }
567*aed3e508SAndroid Build Coastguard Worker       }, entry.details);
568*aed3e508SAndroid Build Coastguard Worker   }
569*aed3e508SAndroid Build Coastguard Worker   root[kKeyRoot] = entries;
570*aed3e508SAndroid Build Coastguard Worker   root[kKeyHardwarePropRoot] = EncodeHardwareProperties();
571*aed3e508SAndroid Build Coastguard Worker 
572*aed3e508SAndroid Build Coastguard Worker   return root;
573*aed3e508SAndroid Build Coastguard Worker }
574*aed3e508SAndroid Build Coastguard Worker 
AddEncodeInfo(Json::Value * root)575*aed3e508SAndroid Build Coastguard Worker void ActivityLog::AddEncodeInfo(Json::Value* root) {
576*aed3e508SAndroid Build Coastguard Worker   (*root)["version"] = Json::Value(1);
577*aed3e508SAndroid Build Coastguard Worker   string gestures_version = VCSID;
578*aed3e508SAndroid Build Coastguard Worker 
579*aed3e508SAndroid Build Coastguard Worker   // Strip tailing whitespace.
580*aed3e508SAndroid Build Coastguard Worker   gestures_version = TrimWhitespaceASCII(gestures_version);
581*aed3e508SAndroid Build Coastguard Worker   (*root)["gesturesVersion"] = Json::Value(gestures_version);
582*aed3e508SAndroid Build Coastguard Worker   (*root)[kKeyProperties] = EncodePropRegistry();
583*aed3e508SAndroid Build Coastguard Worker }
584*aed3e508SAndroid Build Coastguard Worker 
Encode()585*aed3e508SAndroid Build Coastguard Worker string ActivityLog::Encode() {
586*aed3e508SAndroid Build Coastguard Worker   Json::Value root = EncodeCommonInfo();
587*aed3e508SAndroid Build Coastguard Worker   AddEncodeInfo(&root);
588*aed3e508SAndroid Build Coastguard Worker   return root.toStyledString();
589*aed3e508SAndroid Build Coastguard Worker }
590*aed3e508SAndroid Build Coastguard Worker 
591*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyInterpreterName[] = "interpreterName";
592*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyNext[] = "nextLayer";
593*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyRoot[] = "entries";
594*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyType[] = "type";
595*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyMethodName[] = "methodName";
596*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareState[] = "hardwareState";
597*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStatePre[] = "debugHardwareStatePre";
598*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStatePost[] = "debugHardwareStatePost";
599*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimerCallback[] = "timerCallback";
600*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyCallbackRequest[] = "callbackRequest";
601*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGesture[] = "gesture";
602*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureConsume[] = "debugGestureConsume";
603*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureProduce[] = "debugGestureProduce";
604*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHandleTimerPre[] = "debugHandleTimerPre";
605*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHandleTimerPost[] = "debugHandleTimerPost";
606*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimerNow[] = "now";
607*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHandleTimerTimeout[] = "timeout";
608*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyPropChange[] = "propertyChange";
609*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateTimestamp[] = "timestamp";
610*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateButtonsDown[] = "buttonsDown";
611*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateTouchCnt[] = "touchCount";
612*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateFingers[] = "fingers";
613*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateRelX[] = "relX";
614*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateRelY[] = "relY";
615*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateRelWheel[] = "relWheel";
616*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwareStateRelHWheel[] = "relHWheel";
617*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateTouchMajor[] = "touchMajor";
618*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateTouchMinor[] = "touchMinor";
619*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateWidthMajor[] = "widthMajor";
620*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateWidthMinor[] = "widthMinor";
621*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStatePressure[] = "pressure";
622*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateOrientation[] = "orientation";
623*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStatePositionX[] = "positionX";
624*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStatePositionY[] = "positionY";
625*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateTrackingId[] = "trackingId";
626*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyFingerStateFlags[] = "flags";
627*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyCallbackRequestWhen[] = "when";
628*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureType[] = "gestureType";
629*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeContactInitiated[] =
630*aed3e508SAndroid Build Coastguard Worker     "contactInitiated";
631*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeMove[] = "move";
632*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeScroll[] = "scroll";
633*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeMouseWheel[] = "mouseWheel";
634*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypePinch[] = "pinch";
635*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeButtonsChange[] = "buttonsChange";
636*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeFling[] = "fling";
637*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeSwipe[] = "swipe";
638*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeSwipeLift[] = "swipeLift";
639*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeFourFingerSwipe[] = "fourFingerSwipe";
640*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeFourFingerSwipeLift[] =
641*aed3e508SAndroid Build Coastguard Worker     "fourFingerSwipeLift";
642*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValueGestureTypeMetrics[] = "metrics";
643*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureStartTime[] = "startTime";
644*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureEndTime[] = "endTime";
645*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureDX[] = "dx";
646*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureDY[] = "dy";
647*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureOrdinalDX[] = "ordinalDx";
648*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureOrdinalDY[] = "ordinalDy";
649*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureMouseWheelTicksDX[] = "ticksDx";
650*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureMouseWheelTicksDY[] = "ticksDy";
651*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGesturePinchDZ[] = "dz";
652*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGesturePinchOrdinalDZ[] = "ordinalDz";
653*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGesturePinchZoomState[] = "zoomState";
654*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureButtonsChangeDown[] = "down";
655*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureButtonsChangeUp[] = "up";
656*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureFlingVX[] = "vx";
657*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureFlingVY[] = "vy";
658*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureFlingOrdinalVX[] = "ordinalVx";
659*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureFlingOrdinalVY[] = "ordinalVy";
660*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureFlingState[] = "flingState";
661*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureMetricsType[] = "metricsType";
662*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureMetricsData1[] = "data1";
663*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyGestureMetricsData2[] = "data2";
664*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyPropChangeType[] = "propChangeType";
665*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyPropChangeName[] = "name";
666*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyPropChangeValue[] = "value";
667*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValuePropChangeTypeBool[] = "bool";
668*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValuePropChangeTypeDouble[] = "double";
669*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValuePropChangeTypeInt[] = "int";
670*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kValuePropChangeTypeShort[] = "short";
671*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropRoot[] = "hardwareProperties";
672*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropLeft[] = "left";
673*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropTop[] = "top";
674*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropRight[] = "right";
675*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropBottom[] = "bottom";
676*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropXResolution[] = "xResolution";
677*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropYResolution[] = "yResolution";
678*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropXDpi[] = "xDpi";
679*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropYDpi[] = "yDpi";
680*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropOrientationMinimum[] =
681*aed3e508SAndroid Build Coastguard Worker     "orientationMinimum";
682*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropOrientationMaximum[] =
683*aed3e508SAndroid Build Coastguard Worker     "orientationMaximum";
684*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropMaxFingerCount[] = "maxFingerCount";
685*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropMaxTouchCount[] = "maxTouchCount";
686*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropSupportsT5R2[] = "supportsT5R2";
687*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropSemiMt[] = "semiMt";
688*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropIsButtonPad[] = "isButtonPad";
689*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyHardwarePropHasWheel[] = "hasWheel";
690*aed3e508SAndroid Build Coastguard Worker 
691*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyProperties[] = "properties";
692*aed3e508SAndroid Build Coastguard Worker 
693*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelGestureDebug[] = "debugAccelGesture";
694*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugNoAccelBadGain[] = "noAccelBadGain";
695*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugNoAccelGestureType[] = "noAccelBadType";
696*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugNoAccelSmallDt[] = "noAccelSmallDt";
697*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugNoAccelSmallSpeed[] =
698*aed3e508SAndroid Build Coastguard Worker     "noAccelSmallSpeed";
699*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugDroppedGesture[] = "gestureDropped";
700*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugXYAreVelocity[] = "XYAreVelocity";
701*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugXScale[] = "XScale";
702*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugYScale[] = "YScale";
703*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugDt[] = "dt";
704*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugAdjustedDt[] = "adjDt";
705*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugSpeed[] = "speed";
706*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugSmoothSpeed[] = "smoothSpeed";
707*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugGainX[] = "gainX";
708*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyAccelDebugGainY[] = "gainY";
709*aed3e508SAndroid Build Coastguard Worker 
710*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampGestureDebug[] = "debugTimestampGesture";
711*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampHardwareStateDebug[] =
712*aed3e508SAndroid Build Coastguard Worker     "debugTimestampHardwareState";
713*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugIsUsingFake[] = "isUsingFake";
714*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugWasFirstOrBackward[] =
715*aed3e508SAndroid Build Coastguard Worker     "wasFirstOrBackward";
716*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugPrevMscTimestampIn[] =
717*aed3e508SAndroid Build Coastguard Worker     "prevMscTimestampIn";
718*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugPrevMscTimestampOut[] =
719*aed3e508SAndroid Build Coastguard Worker     "prevMscTimestampOut";
720*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugWasDivergenceReset[] =
721*aed3e508SAndroid Build Coastguard Worker     "wasDivergenceReset";
722*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugFakeTimestampIn[] =
723*aed3e508SAndroid Build Coastguard Worker     "fakeTimestampIn";
724*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugFakeTimestampDelta[] =
725*aed3e508SAndroid Build Coastguard Worker     "fakeTimestampDelta";
726*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugFakeTimestampOut[] =
727*aed3e508SAndroid Build Coastguard Worker     "fakeTimestampOut";
728*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugSkew[] = "skew";
729*aed3e508SAndroid Build Coastguard Worker const char ActivityLog::kKeyTimestampDebugMaxSkew[] = "maxSkew";
730*aed3e508SAndroid Build Coastguard Worker 
731*aed3e508SAndroid Build Coastguard Worker }  // namespace gestures
732