blob: 884b66e482ddb9cc6b1146b0de2753f55d917c77 [file] [log] [blame]
Paul Ramirezbe9c5442024-07-10 00:12:41 +00001/**
2 * Copyright 2024 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#define LOG_TAG "LegacyResampler"
18
19#include <algorithm>
20#include <chrono>
Paul Ramirez4d3b03a2024-09-30 01:39:00 +000021#include <ostream>
Paul Ramirezbe9c5442024-07-10 00:12:41 +000022
23#include <android-base/logging.h>
24#include <android-base/properties.h>
Paul Ramirezcf1b06e2024-08-01 17:11:58 +000025#include <ftl/enum.h>
Paul Ramirezbe9c5442024-07-10 00:12:41 +000026
27#include <input/Resampler.h>
28#include <utils/Timers.h>
29
Paul Ramirezbe9c5442024-07-10 00:12:41 +000030namespace android {
Paul Ramirezbe9c5442024-07-10 00:12:41 +000031namespace {
32
33const bool IS_DEBUGGABLE_BUILD =
34#if defined(__ANDROID__)
35 android::base::GetBoolProperty("ro.debuggable", false);
36#else
37 true;
38#endif
39
40bool debugResampling() {
41 if (!IS_DEBUGGABLE_BUILD) {
42 static const bool DEBUG_TRANSPORT_RESAMPLING =
43 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Resampling",
44 ANDROID_LOG_INFO);
45 return DEBUG_TRANSPORT_RESAMPLING;
46 }
47 return __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Resampling", ANDROID_LOG_INFO);
48}
49
Paul Ramirez4d3b03a2024-09-30 01:39:00 +000050using std::chrono::nanoseconds;
51
Paul Ramirezbe9c5442024-07-10 00:12:41 +000052constexpr std::chrono::milliseconds RESAMPLE_LATENCY{5};
53
54constexpr std::chrono::milliseconds RESAMPLE_MIN_DELTA{2};
55
56constexpr std::chrono::milliseconds RESAMPLE_MAX_DELTA{20};
57
58constexpr std::chrono::milliseconds RESAMPLE_MAX_PREDICTION{8};
59
Paul Ramirezcf1b06e2024-08-01 17:11:58 +000060bool canResampleTool(ToolType toolType) {
61 return toolType == ToolType::FINGER || toolType == ToolType::MOUSE ||
62 toolType == ToolType::STYLUS || toolType == ToolType::UNKNOWN;
63}
64
Paul Ramirezbe9c5442024-07-10 00:12:41 +000065inline float lerp(float a, float b, float alpha) {
66 return a + alpha * (b - a);
67}
68
Paul Ramirez486ca6d2024-08-12 14:37:02 +000069PointerCoords calculateResampledCoords(const PointerCoords& a, const PointerCoords& b,
70 float alpha) {
Paul Ramirez68ca3d12024-08-12 23:00:50 +000071 // We use the value of alpha to initialize resampledCoords with the latest sample information.
72 PointerCoords resampledCoords = (alpha < 1.0f) ? a : b;
Paul Ramirezbe9c5442024-07-10 00:12:41 +000073 resampledCoords.isResampled = true;
74 resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_X, lerp(a.getX(), b.getX(), alpha));
75 resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, lerp(a.getY(), b.getY(), alpha));
76 return resampledCoords;
77}
Paul Ramirez4d3b03a2024-09-30 01:39:00 +000078
79bool equalXY(const PointerCoords& a, const PointerCoords& b) {
80 return (a.getX() == b.getX()) && (a.getY() == b.getY());
81}
82
83void setMotionEventPointerCoords(MotionEvent& motionEvent, size_t sampleIndex, size_t pointerIndex,
84 const PointerCoords& pointerCoords) {
85 // Ideally, we should not cast away const. In this particular case, it's safe to cast away const
86 // and dereference getHistoricalRawPointerCoords returned pointer because motionEvent is a
87 // nonconst reference to a MotionEvent object, so mutating the object should not be undefined
88 // behavior; moreover, the invoked method guarantees to return a valid pointer. Otherwise, it
89 // fatally logs. Alternatively, we could've created a new MotionEvent from scratch, but this
90 // approach is simpler and more efficient.
91 PointerCoords& motionEventCoords = const_cast<PointerCoords&>(
92 *(motionEvent.getHistoricalRawPointerCoords(pointerIndex, sampleIndex)));
93 motionEventCoords.setAxisValue(AMOTION_EVENT_AXIS_X, pointerCoords.getX());
94 motionEventCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, pointerCoords.getY());
95 motionEventCoords.isResampled = pointerCoords.isResampled;
96}
97
98std::ostream& operator<<(std::ostream& os, const PointerCoords& pointerCoords) {
99 os << "(" << pointerCoords.getX() << ", " << pointerCoords.getY() << ")";
100 return os;
101}
102
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000103} // namespace
104
105void LegacyResampler::updateLatestSamples(const MotionEvent& motionEvent) {
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000106 const size_t numSamples = motionEvent.getHistorySize() + 1;
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000107 const size_t latestIndex = numSamples - 1;
108 const size_t secondToLatestIndex = (latestIndex > 0) ? (latestIndex - 1) : 0;
109 for (size_t sampleIndex = secondToLatestIndex; sampleIndex < numSamples; ++sampleIndex) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000110 PointerMap pointerMap;
111 for (size_t pointerIndex = 0; pointerIndex < motionEvent.getPointerCount();
112 ++pointerIndex) {
113 pointerMap.insert(Pointer{*(motionEvent.getPointerProperties(pointerIndex)),
114 *(motionEvent.getHistoricalRawPointerCoords(pointerIndex,
115 sampleIndex))});
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000116 }
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000117 mLatestSamples.pushBack(
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000118 Sample{nanoseconds{motionEvent.getHistoricalEventTime(sampleIndex)}, pointerMap});
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000119 }
120}
121
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000122LegacyResampler::Sample LegacyResampler::messageToSample(const InputMessage& message) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000123 PointerMap pointerMap;
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000124 for (uint32_t i = 0; i < message.body.motion.pointerCount; ++i) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000125 pointerMap.insert(Pointer{message.body.motion.pointers[i].properties,
126 message.body.motion.pointers[i].coords});
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000127 }
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000128 return Sample{nanoseconds{message.body.motion.eventTime}, pointerMap};
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000129}
130
131bool LegacyResampler::pointerPropertiesResampleable(const Sample& target, const Sample& auxiliary) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000132 for (const Pointer& pointer : target.pointerMap) {
133 const std::optional<Pointer> auxiliaryPointer =
134 auxiliary.pointerMap.find(PointerMap::PointerId{pointer.properties.id});
135 if (!auxiliaryPointer.has_value()) {
136 LOG_IF(INFO, debugResampling())
137 << "Not resampled. Auxiliary sample does not contain all pointers from target.";
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000138 return false;
139 }
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000140 if (pointer.properties.toolType != auxiliaryPointer->properties.toolType) {
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000141 LOG_IF(INFO, debugResampling()) << "Not resampled. Pointer ToolType mismatch.";
142 return false;
143 }
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000144 if (!canResampleTool(pointer.properties.toolType)) {
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000145 LOG_IF(INFO, debugResampling())
146 << "Not resampled. Cannot resample "
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000147 << ftl::enum_string(pointer.properties.toolType) << " ToolType.";
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000148 return false;
149 }
150 }
151 return true;
152}
153
154bool LegacyResampler::canInterpolate(const InputMessage& message) const {
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000155 LOG_IF(FATAL, mLatestSamples.empty())
156 << "Not resampled. mLatestSamples must not be empty to interpolate.";
157
158 const Sample& pastSample = *(mLatestSamples.end() - 1);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000159 const Sample& futureSample = messageToSample(message);
160
161 if (!pointerPropertiesResampleable(pastSample, futureSample)) {
162 return false;
163 }
164
165 const nanoseconds delta = futureSample.eventTime - pastSample.eventTime;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000166 if (delta < RESAMPLE_MIN_DELTA) {
167 LOG_IF(INFO, debugResampling()) << "Not resampled. Delta is too small: " << delta << "ns.";
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000168 return false;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000169 }
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000170 return true;
171}
172
173std::optional<LegacyResampler::Sample> LegacyResampler::attemptInterpolation(
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000174 nanoseconds resampleTime, const InputMessage& futureMessage) const {
175 if (!canInterpolate(futureMessage)) {
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000176 return std::nullopt;
177 }
178 LOG_IF(FATAL, mLatestSamples.empty())
179 << "Not resampled. mLatestSamples must not be empty to interpolate.";
180
181 const Sample& pastSample = *(mLatestSamples.end() - 1);
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000182 const Sample& futureSample = messageToSample(futureMessage);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000183
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000184 const nanoseconds delta = nanoseconds{futureSample.eventTime} - pastSample.eventTime;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000185 const float alpha =
186 std::chrono::duration<float, std::milli>(resampleTime - pastSample.eventTime) / delta;
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000187
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000188 PointerMap resampledPointerMap;
189 for (const Pointer& pointer : pastSample.pointerMap) {
190 if (std::optional<Pointer> futureSamplePointer =
191 futureSample.pointerMap.find(PointerMap::PointerId{pointer.properties.id});
192 futureSamplePointer.has_value()) {
193 const PointerCoords& resampledCoords =
194 calculateResampledCoords(pointer.coords, futureSamplePointer->coords, alpha);
195 resampledPointerMap.insert(Pointer{pointer.properties, resampledCoords});
196 }
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000197 }
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000198 return Sample{resampleTime, resampledPointerMap};
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000199}
200
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000201bool LegacyResampler::canExtrapolate() const {
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000202 if (mLatestSamples.size() < 2) {
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000203 LOG_IF(INFO, debugResampling()) << "Not resampled. Not enough data.";
204 return false;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000205 }
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000206
207 const Sample& pastSample = *(mLatestSamples.end() - 2);
208 const Sample& presentSample = *(mLatestSamples.end() - 1);
209
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000210 if (!pointerPropertiesResampleable(presentSample, pastSample)) {
211 return false;
212 }
213
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000214 const nanoseconds delta = presentSample.eventTime - pastSample.eventTime;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000215 if (delta < RESAMPLE_MIN_DELTA) {
216 LOG_IF(INFO, debugResampling()) << "Not resampled. Delta is too small: " << delta << "ns.";
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000217 return false;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000218 } else if (delta > RESAMPLE_MAX_DELTA) {
219 LOG_IF(INFO, debugResampling()) << "Not resampled. Delta is too large: " << delta << "ns.";
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000220 return false;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000221 }
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000222 return true;
223}
224
225std::optional<LegacyResampler::Sample> LegacyResampler::attemptExtrapolation(
226 nanoseconds resampleTime) const {
227 if (!canExtrapolate()) {
228 return std::nullopt;
229 }
230 LOG_IF(FATAL, mLatestSamples.size() < 2)
231 << "Not resampled. mLatestSamples must have at least two samples to extrapolate.";
232
233 const Sample& pastSample = *(mLatestSamples.end() - 2);
234 const Sample& presentSample = *(mLatestSamples.end() - 1);
235
236 const nanoseconds delta = presentSample.eventTime - pastSample.eventTime;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000237 // The farthest future time to which we can extrapolate. If the given resampleTime exceeds this,
238 // we use this value as the resample time target.
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000239 const nanoseconds farthestPrediction =
240 presentSample.eventTime + std::min<nanoseconds>(delta / 2, RESAMPLE_MAX_PREDICTION);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000241 const nanoseconds newResampleTime =
242 (resampleTime > farthestPrediction) ? (farthestPrediction) : (resampleTime);
243 LOG_IF(INFO, debugResampling() && newResampleTime == farthestPrediction)
244 << "Resample time is too far in the future. Adjusting prediction from "
245 << (resampleTime - presentSample.eventTime) << " to "
246 << (farthestPrediction - presentSample.eventTime) << "ns.";
247 const float alpha =
248 std::chrono::duration<float, std::milli>(newResampleTime - pastSample.eventTime) /
249 delta;
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000250
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000251 PointerMap resampledPointerMap;
252 for (const Pointer& pointer : presentSample.pointerMap) {
253 if (std::optional<Pointer> pastSamplePointer =
254 pastSample.pointerMap.find(PointerMap::PointerId{pointer.properties.id});
255 pastSamplePointer.has_value()) {
256 const PointerCoords& resampledCoords =
257 calculateResampledCoords(pastSamplePointer->coords, pointer.coords, alpha);
258 resampledPointerMap.insert(Pointer{pointer.properties, resampledCoords});
259 }
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000260 }
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000261 return Sample{newResampleTime, resampledPointerMap};
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000262}
263
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000264inline void LegacyResampler::addSampleToMotionEvent(const Sample& sample,
265 MotionEvent& motionEvent) {
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000266 motionEvent.addSample(sample.eventTime.count(), sample.asPointerCoords().data(),
267 motionEvent.getId());
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000268}
269
Paul Ramirezcd7488c2024-09-13 23:01:12 +0000270nanoseconds LegacyResampler::getResampleLatency() const {
271 return RESAMPLE_LATENCY;
272}
273
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000274/**
275 * The resampler is unaware of ACTION_DOWN. Thus, it needs to constantly check for pointer IDs
276 * occurrences. This problem could be fixed if the resampler has access to the entire stream of
277 * MotionEvent actions. That way, both ACTION_DOWN and ACTION_UP will be visible; therefore,
278 * facilitating pointer tracking between samples.
279 */
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000280void LegacyResampler::overwriteMotionEventSamples(MotionEvent& motionEvent) const {
281 const size_t numSamples = motionEvent.getHistorySize() + 1;
282 for (size_t sampleIndex = 0; sampleIndex < numSamples; ++sampleIndex) {
283 overwriteStillPointers(motionEvent, sampleIndex);
Paul Ramirez4679e552024-10-01 01:17:39 +0000284 overwriteOldPointers(motionEvent, sampleIndex);
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000285 }
286}
287
288void LegacyResampler::overwriteStillPointers(MotionEvent& motionEvent, size_t sampleIndex) const {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000289 if (!mLastRealSample.has_value() || !mPreviousPrediction.has_value()) {
290 LOG_IF(INFO, debugResampling()) << "Still pointers not overwritten. Not enough data.";
291 return;
292 }
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000293 for (size_t pointerIndex = 0; pointerIndex < motionEvent.getPointerCount(); ++pointerIndex) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000294 const std::optional<Pointer> lastRealPointer = mLastRealSample->pointerMap.find(
295 PointerMap::PointerId{motionEvent.getPointerId(pointerIndex)});
296 const std::optional<Pointer> previousPointer = mPreviousPrediction->pointerMap.find(
297 PointerMap::PointerId{motionEvent.getPointerId(pointerIndex)});
298 // This could happen because resampler only receives ACTION_MOVE events.
299 if (!lastRealPointer.has_value() || !previousPointer.has_value()) {
300 continue;
301 }
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000302 const PointerCoords& pointerCoords =
303 *(motionEvent.getHistoricalRawPointerCoords(pointerIndex, sampleIndex));
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000304 if (equalXY(pointerCoords, lastRealPointer->coords)) {
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000305 LOG_IF(INFO, debugResampling())
306 << "Pointer ID: " << motionEvent.getPointerId(pointerIndex)
307 << " did not move. Overwriting its coordinates from " << pointerCoords << " to "
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000308 << previousPointer->coords;
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000309 setMotionEventPointerCoords(motionEvent, sampleIndex, pointerIndex,
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000310 previousPointer->coords);
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000311 }
312 }
313}
314
Paul Ramirez4679e552024-10-01 01:17:39 +0000315void LegacyResampler::overwriteOldPointers(MotionEvent& motionEvent, size_t sampleIndex) const {
316 if (!mPreviousPrediction.has_value()) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000317 LOG_IF(INFO, debugResampling()) << "Old sample not overwritten. Not enough data.";
Paul Ramirez4679e552024-10-01 01:17:39 +0000318 return;
319 }
320 if (nanoseconds{motionEvent.getHistoricalEventTime(sampleIndex)} <
321 mPreviousPrediction->eventTime) {
322 LOG_IF(INFO, debugResampling())
323 << "Motion event sample older than predicted sample. Overwriting event time from "
324 << motionEvent.getHistoricalEventTime(sampleIndex) << "ns to "
325 << mPreviousPrediction->eventTime.count() << "ns.";
326 for (size_t pointerIndex = 0; pointerIndex < motionEvent.getPointerCount();
327 ++pointerIndex) {
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000328 const std::optional<Pointer> previousPointer = mPreviousPrediction->pointerMap.find(
329 PointerMap::PointerId{motionEvent.getPointerId(pointerIndex)});
330 // This could happen because resampler only receives ACTION_MOVE events.
331 if (!previousPointer.has_value()) {
332 continue;
333 }
Paul Ramirez4679e552024-10-01 01:17:39 +0000334 setMotionEventPointerCoords(motionEvent, sampleIndex, pointerIndex,
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000335 previousPointer->coords);
Paul Ramirez4679e552024-10-01 01:17:39 +0000336 }
337 }
338}
339
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000340void LegacyResampler::resampleMotionEvent(nanoseconds frameTime, MotionEvent& motionEvent,
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000341 const InputMessage* futureSample) {
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000342 const nanoseconds resampleTime = frameTime - RESAMPLE_LATENCY;
343
Paul Ramirez7f1efed2024-09-29 23:55:23 +0000344 if (resampleTime.count() == motionEvent.getEventTime()) {
345 LOG_IF(INFO, debugResampling()) << "Not resampled. Resample time equals motion event time.";
346 return;
347 }
348
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000349 updateLatestSamples(motionEvent);
Paul Ramirez486ca6d2024-08-12 14:37:02 +0000350
351 const std::optional<Sample> sample = (futureSample != nullptr)
352 ? (attemptInterpolation(resampleTime, *futureSample))
353 : (attemptExtrapolation(resampleTime));
354 if (sample.has_value()) {
355 addSampleToMotionEvent(*sample, motionEvent);
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000356 if (mPreviousPrediction.has_value()) {
357 overwriteMotionEventSamples(motionEvent);
358 }
359 // mPreviousPrediction is only updated whenever extrapolation occurs because extrapolation
360 // is about predicting upcoming scenarios.
361 if (futureSample == nullptr) {
362 mPreviousPrediction = sample;
363 }
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000364 }
Paul Ramirez29ee27c2024-10-02 08:18:53 +0000365 LOG_IF(FATAL, mLatestSamples.empty()) << "mLatestSamples must contain at least one sample.";
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000366 mLastRealSample = *(mLatestSamples.end() - 1);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000367}
Paul Ramirez4d3b03a2024-09-30 01:39:00 +0000368
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000369} // namespace android