diff options
author | 2018-04-03 16:31:10 -0700 | |
---|---|---|
committer | 2018-04-12 14:23:15 -0700 | |
commit | 1856a4cfcca8c18365e8fd855905b57679d3a280 (patch) | |
tree | 73f6f2214eef55092ff49d6af51a92f576fe4626 | |
parent | a87e56c97ad578e2014c81a02d7d744b5850686f (diff) |
Adding privacy tags to graphicsstats proto.
Creating a copy of the graphicsstats proto so that one can be tagged
with privacy annotations and the other can be used internally while
still using the protobuf-cpp-lite library.
Bug: 72570104
Test: flash device and check incident output
Merged-In: I2d72e7bd17689c1401a16d5a13956e6528ddb525
Change-Id: I0a46ee6cc463b133925be1cf8dee8cf3d107930c
-rw-r--r-- | core/proto/android/service/graphicsstats.proto | 12 | ||||
-rw-r--r-- | libs/hwui/Android.bp | 2 | ||||
-rw-r--r-- | libs/hwui/protos/graphicsstats.proto | 83 | ||||
-rw-r--r-- | libs/hwui/service/GraphicsStatsService.cpp | 26 | ||||
-rw-r--r-- | libs/hwui/service/GraphicsStatsService.h | 9 | ||||
-rw-r--r-- | libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp | 7 |
6 files changed, 116 insertions, 23 deletions
diff --git a/core/proto/android/service/graphicsstats.proto b/core/proto/android/service/graphicsstats.proto index c2fedf5a5722..d75f135be573 100644 --- a/core/proto/android/service/graphicsstats.proto +++ b/core/proto/android/service/graphicsstats.proto @@ -20,11 +20,19 @@ package android.service; option java_multiple_files = true; option java_outer_classname = "GraphicsStatsServiceProto"; +import "frameworks/base/libs/incident/proto/android/privacy.proto"; + +// This file is based on frameworks/base/libs/hwui/protos/graphicsstats.proto. +// Please try to keep the two files in sync. + message GraphicsStatsServiceDumpProto { + option (android.msg_privacy).dest = DEST_AUTOMATIC; + repeated GraphicsStatsProto stats = 1; } message GraphicsStatsProto { + option (android.msg_privacy).dest = DEST_AUTOMATIC; // The package name of the app optional string package_name = 1; @@ -46,6 +54,8 @@ message GraphicsStatsProto { } message GraphicsStatsJankSummaryProto { + option (android.msg_privacy).dest = DEST_AUTOMATIC; + // Distinct frame count. optional int32 total_frames = 1; @@ -73,6 +83,8 @@ message GraphicsStatsJankSummaryProto { } message GraphicsStatsHistogramBucketProto { + option (android.msg_privacy).dest = DEST_AUTOMATIC; + // Lower bound of render time in milliseconds. optional int32 render_millis = 1; // Number of frames in the bucket. diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp index 592a6e64a58b..213fa8e93320 100644 --- a/libs/hwui/Android.bp +++ b/libs/hwui/Android.bp @@ -69,7 +69,6 @@ cc_defaults { "libRScpp", ], static_libs: [ - "libplatformprotos", "libEGL_blobCache", ], } @@ -269,6 +268,7 @@ cc_defaults { "TextureCache.cpp", "VectorDrawable.cpp", "VkLayer.cpp", + "protos/graphicsstats.proto", "protos/hwui.proto", ], diff --git a/libs/hwui/protos/graphicsstats.proto b/libs/hwui/protos/graphicsstats.proto new file mode 100644 index 000000000000..1226d44ceb85 --- /dev/null +++ b/libs/hwui/protos/graphicsstats.proto @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; + +package android.uirenderer.protos; + +option optimize_for = LITE_RUNTIME; + +// frameworks/base/core/proto/android/service/graphicsstats.proto is based on +// this proto. Please only make valid protobuf changes to these messages, and +// keep the other file in sync with this one. + +message GraphicsStatsServiceDumpProto { + repeated GraphicsStatsProto stats = 1; +} + +message GraphicsStatsProto { + // The package name of the app + optional string package_name = 1; + + // The version code of the app + optional int64 version_code = 2; + + // The start & end timestamps in UTC as + // milliseconds since January 1, 1970 + // Compatible with java.util.Date#setTime() + optional int64 stats_start = 3; + optional int64 stats_end = 4; + + // The aggregated statistics for the package + optional GraphicsStatsJankSummaryProto summary = 5; + + // The frame time histogram for the package + repeated GraphicsStatsHistogramBucketProto histogram = 6; +} + +message GraphicsStatsJankSummaryProto { + // Distinct frame count. + optional int32 total_frames = 1; + + // Number of frames with slow render time. Frames are considered janky if + // they took more than a vsync interval (typically 16.667ms) to be rendered. + optional int32 janky_frames = 2; + + // Number of "missed vsync" events. + optional int32 missed_vsync_count = 3; + + // Number of frames in triple-buffering scenario (high input latency) + optional int32 high_input_latency_count = 4; + + // Number of "slow UI thread" events. + optional int32 slow_ui_thread_count = 5; + + // Number of "slow bitmap upload" events. + optional int32 slow_bitmap_upload_count = 6; + + // Number of "slow draw" events. + optional int32 slow_draw_count = 7; + + // Number of frames that missed their deadline (aka, visibly janked) + optional int32 missed_deadline_count = 8; +} + +message GraphicsStatsHistogramBucketProto { + // Lower bound of render time in milliseconds. + optional int32 render_millis = 1; + // Number of frames in the bucket. + optional int32 frame_count = 2; +} diff --git a/libs/hwui/service/GraphicsStatsService.cpp b/libs/hwui/service/GraphicsStatsService.cpp index 599226bebe84..7f8cb2d1f577 100644 --- a/libs/hwui/service/GraphicsStatsService.cpp +++ b/libs/hwui/service/GraphicsStatsService.cpp @@ -17,8 +17,8 @@ #include "GraphicsStatsService.h" #include "JankTracker.h" +#include "protos/graphicsstats.pb.h" -#include <frameworks/base/core/proto/android/service/graphicsstats.pb.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <log/log.h> @@ -41,10 +41,10 @@ static_assert(sizeof(sCurrentFileVersion) == sHeaderSize, "Header size is wrong" constexpr int sHistogramSize = ProfileData::HistogramSize(); -static bool mergeProfileDataIntoProto(service::GraphicsStatsProto* proto, +static bool mergeProfileDataIntoProto(protos::GraphicsStatsProto* proto, const std::string& package, int64_t versionCode, int64_t startTime, int64_t endTime, const ProfileData* data); -static void dumpAsTextToFd(service::GraphicsStatsProto* proto, int outFd); +static void dumpAsTextToFd(protos::GraphicsStatsProto* proto, int outFd); class FileDescriptor { public: @@ -104,7 +104,7 @@ private: }; bool GraphicsStatsService::parseFromFile(const std::string& path, - service::GraphicsStatsProto* output) { + protos::GraphicsStatsProto* output) { FileDescriptor fd{open(path.c_str(), O_RDONLY)}; if (!fd.valid()) { int err = errno; @@ -153,7 +153,7 @@ bool GraphicsStatsService::parseFromFile(const std::string& path, return success; } -bool mergeProfileDataIntoProto(service::GraphicsStatsProto* proto, const std::string& package, +bool mergeProfileDataIntoProto(protos::GraphicsStatsProto* proto, const std::string& package, int64_t versionCode, int64_t startTime, int64_t endTime, const ProfileData* data) { if (proto->stats_start() == 0 || proto->stats_start() > startTime) { @@ -193,7 +193,7 @@ bool mergeProfileDataIntoProto(service::GraphicsStatsProto* proto, const std::st data->histogramForEach([&](ProfileData::HistogramEntry entry) { if (hitMergeError) return; - service::GraphicsStatsHistogramBucketProto* bucket; + protos::GraphicsStatsHistogramBucketProto* bucket; if (creatingHistogram) { bucket = proto->add_histogram(); bucket->set_render_millis(entry.renderTimeMs); @@ -212,7 +212,7 @@ bool mergeProfileDataIntoProto(service::GraphicsStatsProto* proto, const std::st return !hitMergeError; } -static int32_t findPercentile(service::GraphicsStatsProto* proto, int percentile) { +static int32_t findPercentile(protos::GraphicsStatsProto* proto, int percentile) { int32_t pos = percentile * proto->summary().total_frames() / 100; int32_t remaining = proto->summary().total_frames() - pos; for (auto it = proto->histogram().rbegin(); it != proto->histogram().rend(); ++it) { @@ -224,7 +224,7 @@ static int32_t findPercentile(service::GraphicsStatsProto* proto, int percentile return 0; } -void dumpAsTextToFd(service::GraphicsStatsProto* proto, int fd) { +void dumpAsTextToFd(protos::GraphicsStatsProto* proto, int fd) { // This isn't a full validation, just enough that we can deref at will if (proto->package_name().empty() || !proto->has_summary()) { ALOGW("Skipping dump, invalid package_name() '%s' or summary %d", @@ -259,7 +259,7 @@ void dumpAsTextToFd(service::GraphicsStatsProto* proto, int fd) { void GraphicsStatsService::saveBuffer(const std::string& path, const std::string& package, int64_t versionCode, int64_t startTime, int64_t endTime, const ProfileData* data) { - service::GraphicsStatsProto statsProto; + protos::GraphicsStatsProto statsProto; if (!parseFromFile(path, &statsProto)) { statsProto.Clear(); } @@ -310,12 +310,12 @@ public: Dump(int outFd, DumpType type) : mFd(outFd), mType(type) {} int fd() { return mFd; } DumpType type() { return mType; } - service::GraphicsStatsServiceDumpProto& proto() { return mProto; } + protos::GraphicsStatsServiceDumpProto& proto() { return mProto; } private: int mFd; DumpType mType; - service::GraphicsStatsServiceDumpProto mProto; + protos::GraphicsStatsServiceDumpProto mProto; }; GraphicsStatsService::Dump* GraphicsStatsService::createDump(int outFd, DumpType type) { @@ -325,7 +325,7 @@ GraphicsStatsService::Dump* GraphicsStatsService::createDump(int outFd, DumpType void GraphicsStatsService::addToDump(Dump* dump, const std::string& path, const std::string& package, int64_t versionCode, int64_t startTime, int64_t endTime, const ProfileData* data) { - service::GraphicsStatsProto statsProto; + protos::GraphicsStatsProto statsProto; if (!path.empty() && !parseFromFile(path, &statsProto)) { statsProto.Clear(); } @@ -347,7 +347,7 @@ void GraphicsStatsService::addToDump(Dump* dump, const std::string& path, } void GraphicsStatsService::addToDump(Dump* dump, const std::string& path) { - service::GraphicsStatsProto statsProto; + protos::GraphicsStatsProto statsProto; if (!parseFromFile(path, &statsProto)) { return; } diff --git a/libs/hwui/service/GraphicsStatsService.h b/libs/hwui/service/GraphicsStatsService.h index bce0f3ddbb82..389f599f439f 100644 --- a/libs/hwui/service/GraphicsStatsService.h +++ b/libs/hwui/service/GraphicsStatsService.h @@ -22,12 +22,11 @@ #include "utils/Macros.h" namespace android { -namespace service { +namespace uirenderer { +namespace protos { class GraphicsStatsProto; } -namespace uirenderer { - /* * The exported entry points used by GraphicsStatsService.java in f/b/services/core * @@ -55,8 +54,8 @@ public: ANDROID_API static void finishDump(Dump* dump); // Visible for testing - static bool parseFromFile(const std::string& path, service::GraphicsStatsProto* output); + static bool parseFromFile(const std::string& path, protos::GraphicsStatsProto* output); }; } /* namespace uirenderer */ -} /* namespace android */
\ No newline at end of file +} /* namespace android */ diff --git a/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp b/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp index 30c3b4ea5ab3..098b4ccea8cf 100644 --- a/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp +++ b/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp @@ -16,10 +16,9 @@ #include <gtest/gtest.h> +#include "protos/graphicsstats.pb.h" #include "service/GraphicsStatsService.h" -#include <frameworks/base/core/proto/android/service/graphicsstats.pb.h> - #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> @@ -74,7 +73,7 @@ TEST(GraphicsStats, saveLoad) { mockData.editSlowFrameCounts()[i] = (i % 5) + 1; } GraphicsStatsService::saveBuffer(path, packageName, 5, 3000, 7000, &mockData); - service::GraphicsStatsProto loadedProto; + protos::GraphicsStatsProto loadedProto; EXPECT_TRUE(GraphicsStatsService::parseFromFile(path, &loadedProto)); // Clean up the file unlink(path.c_str()); @@ -130,7 +129,7 @@ TEST(GraphicsStats, merge) { } GraphicsStatsService::saveBuffer(path, packageName, 5, 7050, 10000, &mockData); - service::GraphicsStatsProto loadedProto; + protos::GraphicsStatsProto loadedProto; EXPECT_TRUE(GraphicsStatsService::parseFromFile(path, &loadedProto)); // Clean up the file unlink(path.c_str()); |