Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 228b6d2a authored by Kweku Adams's avatar Kweku Adams
Browse files

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.

This is the same change as the pi-dev one (http://ag/3841646), but due
to changes in master, that change has a merge conflict, so I have to
create a separate CL for master.

Bug: 72570104
Test: it builds
Change-Id: I2d72e7bd17689c1401a16d5a13956e6528ddb525
parent 82e9122c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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.
+5 −1
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ cc_defaults {
        "libRScpp",
    ],
    static_libs: [
        "libplatformprotos",
        "libEGL_blobCache",
    ],
}
@@ -269,8 +268,13 @@ cc_defaults {
        "TextureCache.cpp",
        "VectorDrawable.cpp",
        "VkLayer.cpp",
        "protos/graphicsstats.proto",
    ],

    proto: {
        export_proto_headers: true,
    },

    export_include_dirs: ["."],
    export_shared_lib_headers: ["libRScpp"],
}
+83 −0
Original line number Diff line number Diff line
/*
 * 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;
}
+13 −13
Original line number Diff line number Diff line
@@ -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;
    }
+4 −5
Original line number Diff line number Diff line
@@ -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,7 +54,7 @@ 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 */
Loading