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

Commit f8601845 authored by Yi Jin's avatar Yi Jin
Browse files

Automatically generate section_list.cpp file from incident.proto

with the SectionFlags field annotations

Bug: 64728679
Test: tested manually on device
Change-Id: I5b067b09cd6ccc3528f0845d7290cc9e2bc63a07
parent 46b65e61
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -37,7 +37,7 @@ gen_src_dir := $(local-generated-sources-dir)
gen := $(gen_src_dir)/incident_sections.cpp
gen := $(gen_src_dir)/incident_sections.cpp
$(gen): $(HOST_OUT_EXECUTABLES)/incident-section-gen
$(gen): $(HOST_OUT_EXECUTABLES)/incident-section-gen
$(gen): PRIVATE_CUSTOM_TOOL = \
$(gen): PRIVATE_CUSTOM_TOOL = \
    $(HOST_OUT_EXECUTABLES)/incident-section-gen > $@
    $(HOST_OUT_EXECUTABLES)/incident-section-gen incident > $@
$(gen): $(HOST_OUT_EXECUTABLES)/incident-section-gen
$(gen): $(HOST_OUT_EXECUTABLES)/incident-section-gen
	$(transform-generated-source)
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(gen)
LOCAL_GENERATED_SOURCES += $(gen)
+18 −3
Original line number Original line Diff line number Diff line
@@ -29,8 +29,7 @@ LOCAL_SRC_FILES := \
        src/Section.cpp \
        src/Section.cpp \
        src/main.cpp \
        src/main.cpp \
        src/protobuf.cpp \
        src/protobuf.cpp \
        src/report_directory.cpp \
        src/report_directory.cpp
        src/section_list.cpp \


LOCAL_CFLAGS += \
LOCAL_CFLAGS += \
        -Wall -Werror -Wno-missing-field-initializers -Wno-unused-variable -Wunused-parameter
        -Wall -Werror -Wno-missing-field-initializers -Wno-unused-variable -Wunused-parameter
@@ -44,6 +43,8 @@ else
            -Os
            -Os
endif
endif


LOCAL_C_INCLUDES += $(LOCAL_PATH)/src

LOCAL_SHARED_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
        libbase \
        libbase \
        libbinder \
        libbinder \
@@ -54,6 +55,20 @@ LOCAL_SHARED_LIBRARIES := \
        libservices \
        libservices \
        libutils
        libutils


LOCAL_MODULE_CLASS := EXECUTABLES
gen_src_dir := $(local-generated-sources-dir)

GEN := $(gen_src_dir)/src/section_list.cpp
$(GEN): $(HOST_OUT_EXECUTABLES)/incident-section-gen
$(GEN): PRIVATE_CUSTOM_TOOL = \
    $(HOST_OUT_EXECUTABLES)/incident-section-gen incidentd > $@
$(GEN): $(HOST_OUT_EXECUTABLES)/incident-section-gen
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

gen_src_dir:=
GEN:=

LOCAL_INIT_RC := incidentd.rc
LOCAL_INIT_RC := incidentd.rc


include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
@@ -78,7 +93,7 @@ LOCAL_SRC_FILES := \
    src/Section.cpp \
    src/Section.cpp \
    src/protobuf.cpp \
    src/protobuf.cpp \
    src/report_directory.cpp \
    src/report_directory.cpp \
    src/section_list.cpp \
    tests/section_list.cpp \
    tests/FdBuffer_test.cpp \
    tests/FdBuffer_test.cpp \
    tests/Reporter_test.cpp \
    tests/Reporter_test.cpp \
    tests/Section_test.cpp \
    tests/Section_test.cpp \
+6 −0
Original line number Original line Diff line number Diff line
// This file is a dummy section_list.cpp used for test only.
#include "section_list.h"

const Section* SECTION_LIST[] = {
    NULL
};
+13 −3
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ option java_multiple_files = true;
option java_outer_classname = "IncidentProtoMetadata";
option java_outer_classname = "IncidentProtoMetadata";


import "frameworks/base/libs/incident/proto/android/privacy.proto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
import "frameworks/base/libs/incident/proto/android/section.proto";
import "frameworks/base/core/proto/android/service/appwidget.proto";
import "frameworks/base/core/proto/android/service/appwidget.proto";
import "frameworks/base/core/proto/android/service/battery.proto";
import "frameworks/base/core/proto/android/service/battery.proto";
import "frameworks/base/core/proto/android/service/fingerprint.proto";
import "frameworks/base/core/proto/android/service/fingerprint.proto";
@@ -54,12 +55,21 @@ message IncidentProto {
    //SystemProperties system_properties = 1000;
    //SystemProperties system_properties = 1000;


    // Linux services
    // Linux services
    Procrank procrank = 2000;
    Procrank procrank = 2000 [
        (section).type = SECTION_COMMAND,
        (section).args = "/system/xbin/procrank"
    ];
    //PageTypeInfo page_type_info = 2001;
    //PageTypeInfo page_type_info = 2001;
    KernelWakeSources kernel_wake_sources = 2002;
    KernelWakeSources kernel_wake_sources = 2002 [
        (section).type = SECTION_FILE,
        (section).args = "/d/wakeup_sources"
    ];


    // System Services
    // System Services
    android.service.fingerprint.FingerprintServiceDumpProto fingerprint = 3000;
    android.service.fingerprint.FingerprintServiceDumpProto fingerprint = 3000 [
        (section).type = SECTION_DUMPSYS,
        (section).args = "fingerprint --proto --incident"
    ];
    android.service.NetworkStatsServiceDumpProto netstats = 3001;
    android.service.NetworkStatsServiceDumpProto netstats = 3001;
    android.providers.settings.SettingsServiceDumpProto settings = 3002;
    android.providers.settings.SettingsServiceDumpProto settings = 3002;
    android.service.appwidget.AppWidgetServiceDumpProto appwidget = 3003;
    android.service.appwidget.AppWidgetServiceDumpProto appwidget = 3003;
+50 −0
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2016 The Android Open Source Project
 * Copyright (C) 2017 The Android Open Source Project
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -14,17 +14,37 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include "section_list.h"
syntax = "proto2";


/**
option java_package = "android";
 * This is the mapping of section IDs to the commands that are run to get those commands.
option java_multiple_files = true;
 */

const Section* SECTION_LIST[] = {
import "google/protobuf/descriptor.proto";
    // Linux Services

    new CommandSection(2000, "/system/xbin/procrank", NULL),
package android;
    new FileSection(2002, "/d/wakeup_sources"),


// SectionType defines how incidentd gonna get the field's data
    // System Services
enum SectionType {
    new DumpsysSection(3000, "fingerprint", "--proto", "--incident", NULL),

    NULL
    // Default fields, not available in incidentd
};
    SECTION_NONE = 0;

    // incidentd reads a file to get the data for annotated field
    SECTION_FILE = 1;

    // incidentd executes the given command for annotated field
    SECTION_COMMAND = 2;

    // incidentd calls dumpsys for annotated field
    SECTION_DUMPSYS = 3;
}

message SectionFlags {
  optional SectionType type = 1 [default = SECTION_NONE];
  optional string args = 2;
}

extend google.protobuf.FieldOptions {
    // Flags for automatically section list generation
    optional SectionFlags section = 155792027;
}
Loading