blob: 44a59fd246b5071649a5bf44bded42bdaa0af71c [file] [log] [blame]
Yiwei Zhang0102ad22018-05-02 17:37:17 -07001/*
2 * Copyright 2018 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 */
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080016
17// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
Yiwei Zhang0102ad22018-05-02 17:37:17 -070020#undef LOG_TAG
21#define LOG_TAG "TimeStats"
22#define ATRACE_TAG ATRACE_TAG_GRAPHICS
23
24#include "TimeStats.h"
25
26#include <android-base/stringprintf.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070027#include <log/log.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070028#include <utils/String8.h>
Yiwei Zhang3a226d22018-10-16 09:23:03 -070029#include <utils/Timers.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070030#include <utils/Trace.h>
31
32#include <algorithm>
Alec Mouri9519bf12019-11-15 16:54:44 -080033#include <chrono>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070034
35namespace android {
36
Alec Mourifb571ea2019-01-24 18:42:10 -080037namespace impl {
38
Alec Mouri8e2f31b2020-01-16 22:04:35 +000039status_pull_atom_return_t TimeStats::pullGlobalAtomCallback(int32_t atom_tag,
40 pulled_stats_event_list* data,
41 void* cookie) {
42 impl::TimeStats* timeStats = reinterpret_cast<impl::TimeStats*>(cookie);
43 if (atom_tag != android::util::SURFACEFLINGER_STATS_GLOBAL_INFO) {
44 return STATS_PULL_SKIP;
45 }
46
47 std::lock_guard<std::mutex> lock(timeStats->mMutex);
48
49 const auto& stats = timeStats->mTimeStats;
50 if (stats.statsStart == 0) {
51 return STATS_PULL_SKIP;
52 }
53 timeStats->flushPowerTimeLocked();
54
55 struct stats_event* event = timeStats->mStatsDelegate->addStatsEventToPullData(data);
56 timeStats->mStatsDelegate->statsEventSetAtomId(event,
57 android::util::SURFACEFLINGER_STATS_GLOBAL_INFO);
58 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.totalFrames);
59 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.missedFrames);
60 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.clientCompositionFrames);
61 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.displayOnTime);
62 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.presentToPresent.totalTime());
63 timeStats->mStatsDelegate->statsEventBuild(event);
64 timeStats->clearGlobalLocked();
65
66 return STATS_PULL_SUCCESS;
67}
68
69TimeStats::TimeStats() : TimeStats(nullptr) {}
70
71TimeStats::TimeStats(std::unique_ptr<StatsEventDelegate> statsDelegate) {
72 if (statsDelegate != nullptr) {
73 mStatsDelegate = std::move(statsDelegate);
74 }
75}
76
77void TimeStats::onBootFinished() {
Alec Mourib3885ad2019-09-06 17:08:55 -070078 // Temporarily enable TimeStats by default. Telemetry is disabled while
79 // we move onto statsd, so TimeStats is currently not exercised at all
Alec Mouri8e2f31b2020-01-16 22:04:35 +000080 // during testing without enabling by default.
81 // TODO: remove this, as we should only be paying this overhead on devices
82 // where statsd exists.
Alec Mourib3885ad2019-09-06 17:08:55 -070083 enable();
84}
85
Dominik Laskowskic2867142019-01-21 11:33:38 -080086void TimeStats::parseArgs(bool asProto, const Vector<String16>& args, std::string& result) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -070087 ATRACE_CALL();
88
Yiwei Zhang0102ad22018-05-02 17:37:17 -070089 std::unordered_map<std::string, int32_t> argsMap;
Dominik Laskowskic2867142019-01-21 11:33:38 -080090 for (size_t index = 0; index < args.size(); ++index) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -070091 argsMap[std::string(String8(args[index]).c_str())] = index;
Yiwei Zhang0102ad22018-05-02 17:37:17 -070092 }
93
94 if (argsMap.count("-disable")) {
95 disable();
96 }
97
98 if (argsMap.count("-dump")) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -070099 std::optional<uint32_t> maxLayers = std::nullopt;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700100 auto iter = argsMap.find("-maxlayers");
101 if (iter != argsMap.end() && iter->second + 1 < static_cast<int32_t>(args.size())) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700102 int64_t value = strtol(String8(args[iter->second + 1]).c_str(), nullptr, 10);
103 value = std::clamp(value, int64_t(0), int64_t(UINT32_MAX));
104 maxLayers = static_cast<uint32_t>(value);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700105 }
106
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700107 dump(asProto, maxLayers, result);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700108 }
109
110 if (argsMap.count("-clear")) {
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000111 clearAll();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700112 }
113
114 if (argsMap.count("-enable")) {
115 enable();
116 }
117}
118
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700119std::string TimeStats::miniDump() {
120 ATRACE_CALL();
121
122 std::string result = "TimeStats miniDump:\n";
123 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange926ab52019-08-14 15:16:00 -0700124 android::base::StringAppendF(&result, "Number of layers currently being tracked is %zu\n",
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700125 mTimeStatsTracker.size());
Yiwei Zhange926ab52019-08-14 15:16:00 -0700126 android::base::StringAppendF(&result, "Number of layers in the stats pool is %zu\n",
127 mTimeStats.stats.size());
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700128 return result;
129}
130
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700131void TimeStats::incrementTotalFrames() {
132 if (!mEnabled.load()) return;
133
134 ATRACE_CALL();
135
136 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700137 mTimeStats.totalFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700138}
139
Yiwei Zhang621f9d42018-05-07 10:40:55 -0700140void TimeStats::incrementMissedFrames() {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700141 if (!mEnabled.load()) return;
142
143 ATRACE_CALL();
144
145 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700146 mTimeStats.missedFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700147}
148
149void TimeStats::incrementClientCompositionFrames() {
150 if (!mEnabled.load()) return;
151
152 ATRACE_CALL();
153
154 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700155 mTimeStats.clientCompositionFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700156}
157
Alec Mouri9519bf12019-11-15 16:54:44 -0800158static int32_t msBetween(nsecs_t start, nsecs_t end) {
159 int64_t delta = std::chrono::duration_cast<std::chrono::milliseconds>(
160 std::chrono::nanoseconds(end - start))
161 .count();
162 delta = std::clamp(delta, int64_t(INT32_MIN), int64_t(INT32_MAX));
163 return static_cast<int32_t>(delta);
164}
165
166void TimeStats::recordFrameDuration(nsecs_t startTime, nsecs_t endTime) {
167 if (!mEnabled.load()) return;
168
169 std::lock_guard<std::mutex> lock(mMutex);
170 if (mPowerTime.powerMode == HWC_POWER_MODE_NORMAL) {
171 mTimeStats.frameDuration.insert(msBetween(startTime, endTime));
172 }
173}
174
Alec Mourie4034bb2019-11-19 12:45:54 -0800175void TimeStats::recordRenderEngineDuration(nsecs_t startTime, nsecs_t endTime) {
176 if (!mEnabled.load()) return;
177
178 std::lock_guard<std::mutex> lock(mMutex);
179 if (mGlobalRecord.renderEngineDurations.size() == MAX_NUM_TIME_RECORDS) {
180 ALOGE("RenderEngineTimes are already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
181 mGlobalRecord.renderEngineDurations.pop_front();
182 }
183 mGlobalRecord.renderEngineDurations.push_back({startTime, endTime});
184}
185
186void TimeStats::recordRenderEngineDuration(nsecs_t startTime,
187 const std::shared_ptr<FenceTime>& endTime) {
188 if (!mEnabled.load()) return;
189
190 std::lock_guard<std::mutex> lock(mMutex);
191 if (mGlobalRecord.renderEngineDurations.size() == MAX_NUM_TIME_RECORDS) {
192 ALOGE("RenderEngineTimes are already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
193 mGlobalRecord.renderEngineDurations.pop_front();
194 }
195 mGlobalRecord.renderEngineDurations.push_back({startTime, endTime});
196}
197
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800198bool TimeStats::recordReadyLocked(int32_t layerId, TimeRecord* timeRecord) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700199 if (!timeRecord->ready) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800200 ALOGV("[%d]-[%" PRIu64 "]-presentFence is still not received", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700201 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700202 return false;
203 }
204
205 if (timeRecord->acquireFence != nullptr) {
206 if (timeRecord->acquireFence->getSignalTime() == Fence::SIGNAL_TIME_PENDING) {
207 return false;
208 }
209 if (timeRecord->acquireFence->getSignalTime() != Fence::SIGNAL_TIME_INVALID) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700210 timeRecord->frameTime.acquireTime = timeRecord->acquireFence->getSignalTime();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700211 timeRecord->acquireFence = nullptr;
212 } else {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800213 ALOGV("[%d]-[%" PRIu64 "]-acquireFence signal time is invalid", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700214 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700215 }
216 }
217
218 if (timeRecord->presentFence != nullptr) {
219 if (timeRecord->presentFence->getSignalTime() == Fence::SIGNAL_TIME_PENDING) {
220 return false;
221 }
222 if (timeRecord->presentFence->getSignalTime() != Fence::SIGNAL_TIME_INVALID) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700223 timeRecord->frameTime.presentTime = timeRecord->presentFence->getSignalTime();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700224 timeRecord->presentFence = nullptr;
225 } else {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800226 ALOGV("[%d]-[%" PRIu64 "]-presentFence signal time invalid", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700227 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700228 }
229 }
230
231 return true;
232}
233
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800234void TimeStats::flushAvailableRecordsToStatsLocked(int32_t layerId) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700235 ATRACE_CALL();
236
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800237 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700238 TimeRecord& prevTimeRecord = layerRecord.prevTimeRecord;
Yiwei Zhangc5f2c452018-05-08 16:31:56 -0700239 std::deque<TimeRecord>& timeRecords = layerRecord.timeRecords;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700240 while (!timeRecords.empty()) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800241 if (!recordReadyLocked(layerId, &timeRecords[0])) break;
242 ALOGV("[%d]-[%" PRIu64 "]-presentFenceTime[%" PRId64 "]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700243 timeRecords[0].frameTime.frameNumber, timeRecords[0].frameTime.presentTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700244
245 if (prevTimeRecord.ready) {
Yiwei Zhangeafa5cc2019-07-26 15:06:25 -0700246 const std::string& layerName = layerRecord.layerName;
Yiwei Zhangdc224042018-10-18 15:34:00 -0700247 if (!mTimeStats.stats.count(layerName)) {
248 mTimeStats.stats[layerName].layerName = layerName;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700249 }
Yiwei Zhangdc224042018-10-18 15:34:00 -0700250 TimeStatsHelper::TimeStatsLayer& timeStatsLayer = mTimeStats.stats[layerName];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700251 timeStatsLayer.totalFrames++;
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700252 timeStatsLayer.droppedFrames += layerRecord.droppedFrames;
253 layerRecord.droppedFrames = 0;
254
255 const int32_t postToAcquireMs = msBetween(timeRecords[0].frameTime.postTime,
256 timeRecords[0].frameTime.acquireTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800257 ALOGV("[%d]-[%" PRIu64 "]-post2acquire[%d]", layerId,
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700258 timeRecords[0].frameTime.frameNumber, postToAcquireMs);
259 timeStatsLayer.deltas["post2acquire"].insert(postToAcquireMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700260
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700261 const int32_t postToPresentMs = msBetween(timeRecords[0].frameTime.postTime,
262 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800263 ALOGV("[%d]-[%" PRIu64 "]-post2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700264 timeRecords[0].frameTime.frameNumber, postToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700265 timeStatsLayer.deltas["post2present"].insert(postToPresentMs);
266
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700267 const int32_t acquireToPresentMs = msBetween(timeRecords[0].frameTime.acquireTime,
268 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800269 ALOGV("[%d]-[%" PRIu64 "]-acquire2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700270 timeRecords[0].frameTime.frameNumber, acquireToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700271 timeStatsLayer.deltas["acquire2present"].insert(acquireToPresentMs);
272
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700273 const int32_t latchToPresentMs = msBetween(timeRecords[0].frameTime.latchTime,
274 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800275 ALOGV("[%d]-[%" PRIu64 "]-latch2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700276 timeRecords[0].frameTime.frameNumber, latchToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700277 timeStatsLayer.deltas["latch2present"].insert(latchToPresentMs);
278
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700279 const int32_t desiredToPresentMs = msBetween(timeRecords[0].frameTime.desiredTime,
280 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800281 ALOGV("[%d]-[%" PRIu64 "]-desired2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700282 timeRecords[0].frameTime.frameNumber, desiredToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700283 timeStatsLayer.deltas["desired2present"].insert(desiredToPresentMs);
284
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700285 const int32_t presentToPresentMs = msBetween(prevTimeRecord.frameTime.presentTime,
286 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800287 ALOGV("[%d]-[%" PRIu64 "]-present2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700288 timeRecords[0].frameTime.frameNumber, presentToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700289 timeStatsLayer.deltas["present2present"].insert(presentToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700290 }
291 prevTimeRecord = timeRecords[0];
Yiwei Zhangc5f2c452018-05-08 16:31:56 -0700292 timeRecords.pop_front();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700293 layerRecord.waitData--;
294 }
295}
296
Yiwei Zhang8bec7e82019-10-07 18:08:26 -0700297static constexpr const char* kPopupWindowPrefix = "PopupWindow";
298static const size_t kMinLenLayerName = std::strlen(kPopupWindowPrefix);
Yiwei Zhangbd408322018-10-15 18:31:53 -0700299
Yiwei Zhang8bec7e82019-10-07 18:08:26 -0700300// Avoid tracking the "PopupWindow:<random hash>#<number>" layers
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700301static bool layerNameIsValid(const std::string& layerName) {
Yiwei Zhang8bec7e82019-10-07 18:08:26 -0700302 return layerName.length() >= kMinLenLayerName &&
303 layerName.compare(0, kMinLenLayerName, kPopupWindowPrefix) != 0;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700304}
305
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800306void TimeStats::setPostTime(int32_t layerId, uint64_t frameNumber, const std::string& layerName,
Yiwei Zhang8e8fe522018-11-02 18:34:07 -0700307 nsecs_t postTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700308 if (!mEnabled.load()) return;
309
310 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800311 ALOGV("[%d]-[%" PRIu64 "]-[%s]-PostTime[%" PRId64 "]", layerId, frameNumber, layerName.c_str(),
Yiwei Zhang8e8fe522018-11-02 18:34:07 -0700312 postTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700313
314 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange926ab52019-08-14 15:16:00 -0700315 if (!mTimeStats.stats.count(layerName) && mTimeStats.stats.size() >= MAX_NUM_LAYER_STATS) {
316 return;
317 }
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800318 if (!mTimeStatsTracker.count(layerId) && mTimeStatsTracker.size() < MAX_NUM_LAYER_RECORDS &&
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700319 layerNameIsValid(layerName)) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800320 mTimeStatsTracker[layerId].layerName = layerName;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700321 }
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800322 if (!mTimeStatsTracker.count(layerId)) return;
323 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700324 if (layerRecord.timeRecords.size() == MAX_NUM_TIME_RECORDS) {
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800325 ALOGE("[%d]-[%s]-timeRecords is at its maximum size[%zu]. Ignore this when unittesting.",
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800326 layerId, layerRecord.layerName.c_str(), MAX_NUM_TIME_RECORDS);
327 mTimeStatsTracker.erase(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700328 return;
329 }
330 // For most media content, the acquireFence is invalid because the buffer is
331 // ready at the queueBuffer stage. In this case, acquireTime should be given
332 // a default value as postTime.
333 TimeRecord timeRecord = {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700334 .frameTime =
335 {
336 .frameNumber = frameNumber,
337 .postTime = postTime,
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800338 .latchTime = postTime,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700339 .acquireTime = postTime,
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800340 .desiredTime = postTime,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700341 },
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700342 };
343 layerRecord.timeRecords.push_back(timeRecord);
344 if (layerRecord.waitData < 0 ||
345 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
346 layerRecord.waitData = layerRecord.timeRecords.size() - 1;
347}
348
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800349void TimeStats::setLatchTime(int32_t layerId, uint64_t frameNumber, nsecs_t latchTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700350 if (!mEnabled.load()) return;
351
352 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800353 ALOGV("[%d]-[%" PRIu64 "]-LatchTime[%" PRId64 "]", layerId, frameNumber, latchTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700354
355 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800356 if (!mTimeStatsTracker.count(layerId)) return;
357 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700358 if (layerRecord.waitData < 0 ||
359 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
360 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700361 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700362 if (timeRecord.frameTime.frameNumber == frameNumber) {
363 timeRecord.frameTime.latchTime = latchTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700364 }
365}
366
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800367void TimeStats::setDesiredTime(int32_t layerId, uint64_t frameNumber, nsecs_t desiredTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700368 if (!mEnabled.load()) return;
369
370 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800371 ALOGV("[%d]-[%" PRIu64 "]-DesiredTime[%" PRId64 "]", layerId, frameNumber, desiredTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700372
373 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800374 if (!mTimeStatsTracker.count(layerId)) return;
375 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700376 if (layerRecord.waitData < 0 ||
377 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
378 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700379 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700380 if (timeRecord.frameTime.frameNumber == frameNumber) {
381 timeRecord.frameTime.desiredTime = desiredTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700382 }
383}
384
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800385void TimeStats::setAcquireTime(int32_t layerId, uint64_t frameNumber, nsecs_t acquireTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700386 if (!mEnabled.load()) return;
387
388 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800389 ALOGV("[%d]-[%" PRIu64 "]-AcquireTime[%" PRId64 "]", layerId, frameNumber, acquireTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700390
391 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800392 if (!mTimeStatsTracker.count(layerId)) return;
393 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700394 if (layerRecord.waitData < 0 ||
395 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
396 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700397 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700398 if (timeRecord.frameTime.frameNumber == frameNumber) {
399 timeRecord.frameTime.acquireTime = acquireTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700400 }
401}
402
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800403void TimeStats::setAcquireFence(int32_t layerId, uint64_t frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700404 const std::shared_ptr<FenceTime>& acquireFence) {
405 if (!mEnabled.load()) return;
406
407 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800408 ALOGV("[%d]-[%" PRIu64 "]-AcquireFenceTime[%" PRId64 "]", layerId, frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700409 acquireFence->getSignalTime());
410
411 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800412 if (!mTimeStatsTracker.count(layerId)) return;
413 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700414 if (layerRecord.waitData < 0 ||
415 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
416 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700417 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700418 if (timeRecord.frameTime.frameNumber == frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700419 timeRecord.acquireFence = acquireFence;
420 }
421}
422
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800423void TimeStats::setPresentTime(int32_t layerId, uint64_t frameNumber, nsecs_t presentTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700424 if (!mEnabled.load()) return;
425
426 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800427 ALOGV("[%d]-[%" PRIu64 "]-PresentTime[%" PRId64 "]", layerId, frameNumber, presentTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700428
429 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800430 if (!mTimeStatsTracker.count(layerId)) return;
431 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700432 if (layerRecord.waitData < 0 ||
433 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
434 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700435 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700436 if (timeRecord.frameTime.frameNumber == frameNumber) {
437 timeRecord.frameTime.presentTime = presentTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700438 timeRecord.ready = true;
439 layerRecord.waitData++;
440 }
441
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800442 flushAvailableRecordsToStatsLocked(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700443}
444
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800445void TimeStats::setPresentFence(int32_t layerId, uint64_t frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700446 const std::shared_ptr<FenceTime>& presentFence) {
447 if (!mEnabled.load()) return;
448
449 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800450 ALOGV("[%d]-[%" PRIu64 "]-PresentFenceTime[%" PRId64 "]", layerId, frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700451 presentFence->getSignalTime());
452
453 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800454 if (!mTimeStatsTracker.count(layerId)) return;
455 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700456 if (layerRecord.waitData < 0 ||
457 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
458 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700459 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700460 if (timeRecord.frameTime.frameNumber == frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700461 timeRecord.presentFence = presentFence;
462 timeRecord.ready = true;
463 layerRecord.waitData++;
464 }
465
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800466 flushAvailableRecordsToStatsLocked(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700467}
468
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800469void TimeStats::onDestroy(int32_t layerId) {
Yiwei Zhangdc224042018-10-18 15:34:00 -0700470 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800471 ALOGV("[%d]-onDestroy", layerId);
Mikael Pessa90092f42019-08-26 17:22:04 -0700472 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800473 mTimeStatsTracker.erase(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700474}
475
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800476void TimeStats::removeTimeRecord(int32_t layerId, uint64_t frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700477 if (!mEnabled.load()) return;
478
479 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800480 ALOGV("[%d]-[%" PRIu64 "]-removeTimeRecord", layerId, frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700481
482 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800483 if (!mTimeStatsTracker.count(layerId)) return;
484 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700485 size_t removeAt = 0;
486 for (const TimeRecord& record : layerRecord.timeRecords) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700487 if (record.frameTime.frameNumber == frameNumber) break;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700488 removeAt++;
489 }
490 if (removeAt == layerRecord.timeRecords.size()) return;
491 layerRecord.timeRecords.erase(layerRecord.timeRecords.begin() + removeAt);
492 if (layerRecord.waitData > static_cast<int32_t>(removeAt)) {
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700493 layerRecord.waitData--;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700494 }
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700495 layerRecord.droppedFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700496}
497
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700498void TimeStats::flushPowerTimeLocked() {
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700499 if (!mEnabled.load()) return;
500
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700501 nsecs_t curTime = systemTime();
502 // elapsedTime is in milliseconds.
503 int64_t elapsedTime = (curTime - mPowerTime.prevTime) / 1000000;
504
505 switch (mPowerTime.powerMode) {
506 case HWC_POWER_MODE_NORMAL:
507 mTimeStats.displayOnTime += elapsedTime;
508 break;
509 case HWC_POWER_MODE_OFF:
510 case HWC_POWER_MODE_DOZE:
511 case HWC_POWER_MODE_DOZE_SUSPEND:
512 default:
513 break;
514 }
515
516 mPowerTime.prevTime = curTime;
517}
518
519void TimeStats::setPowerMode(int32_t powerMode) {
520 if (!mEnabled.load()) {
521 std::lock_guard<std::mutex> lock(mMutex);
522 mPowerTime.powerMode = powerMode;
523 return;
524 }
525
526 std::lock_guard<std::mutex> lock(mMutex);
527 if (powerMode == mPowerTime.powerMode) return;
528
529 flushPowerTimeLocked();
530 mPowerTime.powerMode = powerMode;
531}
532
Alec Mourifb571ea2019-01-24 18:42:10 -0800533void TimeStats::recordRefreshRate(uint32_t fps, nsecs_t duration) {
534 std::lock_guard<std::mutex> lock(mMutex);
535 if (mTimeStats.refreshRateStats.count(fps)) {
536 mTimeStats.refreshRateStats[fps] += duration;
537 } else {
538 mTimeStats.refreshRateStats.insert({fps, duration});
539 }
540}
541
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700542void TimeStats::flushAvailableGlobalRecordsToStatsLocked() {
543 ATRACE_CALL();
544
545 while (!mGlobalRecord.presentFences.empty()) {
546 const nsecs_t curPresentTime = mGlobalRecord.presentFences.front()->getSignalTime();
547 if (curPresentTime == Fence::SIGNAL_TIME_PENDING) break;
548
549 if (curPresentTime == Fence::SIGNAL_TIME_INVALID) {
550 ALOGE("GlobalPresentFence is invalid!");
551 mGlobalRecord.prevPresentTime = 0;
552 mGlobalRecord.presentFences.pop_front();
553 continue;
554 }
555
556 ALOGV("GlobalPresentFenceTime[%" PRId64 "]",
557 mGlobalRecord.presentFences.front()->getSignalTime());
558
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700559 if (mGlobalRecord.prevPresentTime != 0) {
560 const int32_t presentToPresentMs =
561 msBetween(mGlobalRecord.prevPresentTime, curPresentTime);
562 ALOGV("Global present2present[%d] prev[%" PRId64 "] curr[%" PRId64 "]",
563 presentToPresentMs, mGlobalRecord.prevPresentTime, curPresentTime);
564 mTimeStats.presentToPresent.insert(presentToPresentMs);
565 }
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700566
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700567 mGlobalRecord.prevPresentTime = curPresentTime;
568 mGlobalRecord.presentFences.pop_front();
569 }
Alec Mourie4034bb2019-11-19 12:45:54 -0800570 while (!mGlobalRecord.renderEngineDurations.empty()) {
571 const auto duration = mGlobalRecord.renderEngineDurations.front();
572 const auto& endTime = duration.endTime;
573
574 nsecs_t endNs = -1;
575
576 if (auto val = std::get_if<nsecs_t>(&endTime)) {
577 endNs = *val;
578 } else {
579 endNs = std::get<std::shared_ptr<FenceTime>>(endTime)->getSignalTime();
580 }
581
582 if (endNs == Fence::SIGNAL_TIME_PENDING) break;
583
584 if (endNs < 0) {
585 ALOGE("RenderEngineTiming is invalid!");
586 mGlobalRecord.renderEngineDurations.pop_front();
587 continue;
588 }
589
590 const int32_t renderEngineMs = msBetween(duration.startTime, endNs);
591 mTimeStats.renderEngineTiming.insert(renderEngineMs);
592
593 mGlobalRecord.renderEngineDurations.pop_front();
594 }
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700595}
596
597void TimeStats::setPresentFenceGlobal(const std::shared_ptr<FenceTime>& presentFence) {
598 if (!mEnabled.load()) return;
599
600 ATRACE_CALL();
601 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700602 if (presentFence == nullptr || !presentFence->isValid()) {
603 mGlobalRecord.prevPresentTime = 0;
604 return;
605 }
606
607 if (mPowerTime.powerMode != HWC_POWER_MODE_NORMAL) {
608 // Try flushing the last present fence on HWC_POWER_MODE_NORMAL.
609 flushAvailableGlobalRecordsToStatsLocked();
610 mGlobalRecord.presentFences.clear();
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700611 mGlobalRecord.prevPresentTime = 0;
612 return;
613 }
614
615 if (mGlobalRecord.presentFences.size() == MAX_NUM_TIME_RECORDS) {
616 // The front presentFence must be trapped in pending status in this
617 // case. Try dequeuing the front one to recover.
618 ALOGE("GlobalPresentFences is already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
619 mGlobalRecord.prevPresentTime = 0;
620 mGlobalRecord.presentFences.pop_front();
621 }
622
623 mGlobalRecord.presentFences.emplace_back(presentFence);
624 flushAvailableGlobalRecordsToStatsLocked();
625}
626
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700627void TimeStats::enable() {
628 if (mEnabled.load()) return;
629
630 ATRACE_CALL();
631
632 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700633 mEnabled.store(true);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700634 mTimeStats.statsStart = static_cast<int64_t>(std::time(0));
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700635 mPowerTime.prevTime = systemTime();
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000636 mStatsDelegate->registerStatsPullAtomCallback(android::util::SURFACEFLINGER_STATS_GLOBAL_INFO,
637 TimeStats::pullGlobalAtomCallback, nullptr, this);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700638 ALOGD("Enabled");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700639}
640
641void TimeStats::disable() {
642 if (!mEnabled.load()) return;
643
644 ATRACE_CALL();
645
646 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700647 flushPowerTimeLocked();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700648 mEnabled.store(false);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700649 mTimeStats.statsEnd = static_cast<int64_t>(std::time(0));
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000650 mStatsDelegate->unregisterStatsPullAtomCallback(
651 android::util::SURFACEFLINGER_STATS_GLOBAL_INFO);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700652 ALOGD("Disabled");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700653}
654
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000655void TimeStats::clearAll() {
656 std::lock_guard<std::mutex> lock(mMutex);
657 clearGlobalLocked();
658 clearLayersLocked();
659}
660
661void TimeStats::clearGlobalLocked() {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700662 ATRACE_CALL();
663
Yiwei Zhangdc224042018-10-18 15:34:00 -0700664 mTimeStats.statsStart = (mEnabled.load() ? static_cast<int64_t>(std::time(0)) : 0);
665 mTimeStats.statsEnd = 0;
666 mTimeStats.totalFrames = 0;
667 mTimeStats.missedFrames = 0;
668 mTimeStats.clientCompositionFrames = 0;
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700669 mTimeStats.displayOnTime = 0;
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700670 mTimeStats.presentToPresent.hist.clear();
Alec Mouri31ac64a2020-01-09 09:26:22 -0800671 mTimeStats.frameDuration.hist.clear();
672 mTimeStats.renderEngineTiming.hist.clear();
Alec Mourifb571ea2019-01-24 18:42:10 -0800673 mTimeStats.refreshRateStats.clear();
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700674 mPowerTime.prevTime = systemTime();
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700675 mGlobalRecord.prevPresentTime = 0;
676 mGlobalRecord.presentFences.clear();
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000677 ALOGD("Cleared global stats");
678}
679
680void TimeStats::clearLayersLocked() {
681 ATRACE_CALL();
682
683 mTimeStatsTracker.clear();
684 mTimeStats.stats.clear();
685 ALOGD("Cleared layer stats");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700686}
687
688bool TimeStats::isEnabled() {
689 return mEnabled.load();
690}
691
Yiwei Zhang5434a782018-12-05 18:06:32 -0800692void TimeStats::dump(bool asProto, std::optional<uint32_t> maxLayers, std::string& result) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700693 ATRACE_CALL();
694
695 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700696 if (mTimeStats.statsStart == 0) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700697 return;
698 }
699
Yiwei Zhangdc224042018-10-18 15:34:00 -0700700 mTimeStats.statsEnd = static_cast<int64_t>(std::time(0));
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700701
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700702 flushPowerTimeLocked();
703
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700704 if (asProto) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700705 ALOGD("Dumping TimeStats as proto");
Yiwei Zhangdc224042018-10-18 15:34:00 -0700706 SFTimeStatsGlobalProto timeStatsProto = mTimeStats.toProto(maxLayers);
Dominik Laskowski46470112019-08-02 13:13:11 -0700707 result.append(timeStatsProto.SerializeAsString());
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700708 } else {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700709 ALOGD("Dumping TimeStats as text");
Yiwei Zhang5434a782018-12-05 18:06:32 -0800710 result.append(mTimeStats.toString(maxLayers));
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700711 result.append("\n");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700712 }
713}
714
Alec Mourifb571ea2019-01-24 18:42:10 -0800715} // namespace impl
716
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700717} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800718
719// TODO(b/129481165): remove the #pragma below and fix conversion issues
720#pragma clang diagnostic pop // ignored "-Wconversion"