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

Commit 868688ed authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add annotation to atoms that represent a state change in atoms.proto"

parents 2cb882d6 9c1debe3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ cc_library_host_shared {
    name: "libstats_proto_host",
    srcs: [
        "src/atoms.proto",
        "src/atom_field_options.proto",
    ],

    shared_libs: [
@@ -30,6 +31,9 @@ cc_library_host_shared {
    proto: {
        type: "full",
        export_proto_headers: true,
        include_dirs: [
            "external/protobuf/src",
        ],
    },

    export_shared_lib_headers: [
+14 −6
Original line number Diff line number Diff line
@@ -17,9 +17,8 @@ LOCAL_PATH:= $(call my-dir)
statsd_common_src := \
    ../../core/java/android/os/IStatsCompanionService.aidl \
    ../../core/java/android/os/IStatsManager.aidl \
    src/stats_log.proto \
    src/stats_log_common.proto \
    src/statsd_config.proto \
    src/atoms.proto \
    src/FieldValue.cpp \
    src/stats_log_util.cpp \
    src/anomaly/AnomalyMonitor.cpp \
@@ -168,6 +167,9 @@ LOCAL_CFLAGS += \

LOCAL_SRC_FILES := \
    $(statsd_common_src) \
    src/atom_field_options.proto \
    src/atoms.proto \
    src/stats_log.proto \
    tests/AnomalyMonitor_test.cpp \
    tests/anomaly/AnomalyTracker_test.cpp \
    tests/ConfigManager_test.cpp \
@@ -202,9 +204,13 @@ LOCAL_STATIC_LIBRARIES := \
    $(statsd_common_static_libraries) \
    libgmock

LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries)
LOCAL_PROTOC_OPTIMIZE_TYPE := full

LOCAL_PROTOC_OPTIMIZE_TYPE := lite
LOCAL_PROTOC_FLAGS := \
    -Iexternal/protobuf/src

LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) \
                        libprotobuf-cpp-full

include $(BUILD_NATIVE_TEST)

@@ -217,6 +223,7 @@ LOCAL_MODULE := statsdprotolite

LOCAL_SRC_FILES := \
    src/stats_log.proto \
    src/stats_log_common.proto \
    src/statsd_config.proto \
    src/perfetto/perfetto_config.proto \
    src/atoms.proto
@@ -226,6 +233,9 @@ LOCAL_PROTOC_OPTIMIZE_TYPE := lite
LOCAL_STATIC_JAVA_LIBRARIES := \
    platformprotoslite

LOCAL_PROTOC_FLAGS := \
    -Iexternal/protobuf/src

include $(BUILD_STATIC_JAVA_LIBRARY)

##############################
@@ -261,8 +271,6 @@ LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) \
    libgtest_prod \
    libstatslog

LOCAL_PROTOC_OPTIMIZE_TYPE := lite

LOCAL_MODULE_TAGS := eng tests

include $(BUILD_NATIVE_BENCHMARK)
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@
namespace android {
namespace os {
namespace statsd {

using std::string;
using std::vector;

android::hash_t hashDimension(const HashableDimensionKey& value) {
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.os.statsd;
option java_package = "com.android.os";
option java_multiple_files = true;
option java_outer_classname = "AtomFieldOptions";

import "google/protobuf/descriptor.proto";

enum StateField {
    // Default value for fields that are not primary or exclusive state.
    STATE_FIELD_UNSET = 0;
    // Fields that represent the key that the state belongs to.
    PRIMARY = 1;
    // The field that represents the state. It's an exclusive state.
    EXCLUSIVE = 2;
}

// Used to annotate an atom that reprsents a state change. A state change atom must have exactly ONE
// exclusive state field, and any number of primary key fields.
// For example,
// message UidProcessStateChanged {
//    optional int32 uid = 1 [(stateFieldOption).option = PRIMARY];
//    optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE];
//  }
// Each of this UidProcessStateChanged atom represents a state change for a specific uid.
// A new state automatically overrides the previous state.
//
// If the atom has 2 or more primary fields, it means the combination of the primary fields are
// the primary key.
// For example:
// message ThreadStateChanged {
//    optional int32 pid = 1  [(stateFieldOption).option = PRIMARY];
//    optional int32 tid = 2  [(stateFieldOption).option = PRIMARY];
//    optional int32 state = 3 [(stateFieldOption).option = EXCLUSIVE];
// }
//
// Sometimes, there is no primary key field, when the state is GLOBAL.
// For example,
//
// message ScreenStateChanged {
//    optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE];
// }
//
// Only fields of primary types can be annotated. AttributionNode cannot be primary keys (and they
// usually are not).
message StateAtomFieldOption {
    optional StateField option = 1 [default = STATE_FIELD_UNSET];
}

extend google.protobuf.FieldOptions {
    // Flags to decorate an atom that presents a state change.
    optional StateAtomFieldOption stateFieldOption = 50000;
}
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package android.os.statsd;
option java_package = "com.android.os";
option java_outer_classname = "AtomsProto";

import "frameworks/base/cmds/statsd/src/atom_field_options.proto";
import "frameworks/base/core/proto/android/app/enums.proto";
import "frameworks/base/core/proto/android/os/enums.proto";
import "frameworks/base/core/proto/android/server/enums.proto";
@@ -179,7 +180,7 @@ message AttributionNode {
 */
message ScreenStateChanged {
    // New screen state, from frameworks/base/core/proto/android/view/enums.proto.
    optional android.view.DisplayStateEnum state = 1;
    optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE];
}

/**
@@ -189,10 +190,10 @@ message ScreenStateChanged {
 *   frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
 */
message UidProcessStateChanged {
    optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
    optional int32 uid = 1 [(stateFieldOption).option = PRIMARY];

    // The state, from frameworks/base/core/proto/android/app/enums.proto.
    optional android.app.ProcessStateEnum state = 2;
    optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE];
}

/**
@@ -1515,4 +1516,3 @@ message RemainingBatteryCapacity {
message FullBatteryCapacity {
    optional int32 capacity_uAh = 1;
}
 No newline at end of file
Loading