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

Commit 0546d54f authored by Howard Ro's avatar Howard Ro
Browse files

Add an enum file for stats event

The list of events in this file is meant to be used with Generic Atom
defined in atoms.proto in statsd. Instead of unique int, we would like
to log it with an enum that shows semantic meaning of events. Also, this
change re-sorts imports and removes unused imports and remove the
previous logging line to test GenericAtom.

Test: statsd_test
Change-Id: Ia9335e48ada68bee6d716ad4d7ac50238932da95
parent c84e940c
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -790,9 +790,10 @@ java_library_host {
    name: "platformprotos",
    srcs: [
        "cmds/am/proto/instrumentation_data.proto",
        "cmds/statsd/src/**/*.proto",
        "core/proto/**/*.proto",
        "libs/incident/proto/**/*.proto",
        "cmds/statsd/src/**/*.proto",
        "proto/src/stats_enums.proto",
    ],
    proto: {
        include_dirs: ["external/protobuf/src"],
@@ -830,6 +831,7 @@ java_library {
    srcs: [
        "core/proto/**/*.proto",
        "libs/incident/proto/android/os/**/*.proto",
        "proto/src/stats_enums.proto",
    ],
    // Protos have lots of MissingOverride and similar.
    errorprone: {
@@ -855,6 +857,7 @@ cc_library {
    srcs: [
        "core/proto/**/*.proto",
        "libs/incident/**/*.proto",
        "proto/src/stats_enums.proto",
    ],

    target: {
+2 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import "frameworks/base/core/proto/android/server/enums.proto";
import "frameworks/base/core/proto/android/telecomm/enums.proto";
import "frameworks/base/core/proto/android/telephony/enums.proto";
import "frameworks/base/core/proto/android/view/enums.proto";
import "frameworks/base/proto/src/stats_enums.proto";

/**
 * The master atom class. This message defines all of the available
@@ -1750,7 +1751,7 @@ message GenericAtom {
    optional int32 uid = 1 [(is_uid) = true];

    // An event_id indicates the type of event.
    optional int32 event_id = 2;
    optional android.os.statsd.EventType event_id = 2;
}

//////////////////////////////////////////////////////////////////////
+26 −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_outer_classname = "StatsEnums";

enum EventType {
  // Unknown.
  TYPE_UNKNOWN = 0;
}
+2 −6
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import android.annotation.Nullable;
import android.app.ActivityManagerInternal;
import android.app.AlarmManager;
import android.app.AlarmManager.OnAlarmListener;
import android.app.PendingIntent;
import android.app.ProcessMemoryState;
import android.app.StatsManager;
import android.bluetooth.BluetoothActivityEnergyInfo;
@@ -65,10 +64,10 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.net.NetworkStatsFactory;
import com.android.internal.os.BinderCallsStats.ExportedCallStat;
import com.android.internal.os.KernelCpuSpeedReader;
import com.android.internal.os.KernelUidCpuTimeReader;
import com.android.internal.os.KernelUidCpuClusterTimeReader;
import com.android.internal.os.KernelUidCpuActiveTimeReader;
import com.android.internal.os.KernelUidCpuClusterTimeReader;
import com.android.internal.os.KernelUidCpuFreqTimeReader;
import com.android.internal.os.KernelUidCpuTimeReader;
import com.android.internal.os.KernelWakelockReader;
import com.android.internal.os.KernelWakelockStats;
import com.android.internal.os.PowerProfile;
@@ -79,7 +78,6 @@ import com.android.server.SystemService;

import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -328,7 +326,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                            PackageManager pm = context.getPackageManager();
                            String app = intent.getData().getSchemeSpecificPart();
                            sStatsd.informOnePackageRemoved(app, uid);
                            StatsLog.write(StatsLog.GENERIC_ATOM, uid, 1000);
                        }
                    } else {
                        PackageManager pm = context.getPackageManager();
@@ -337,7 +334,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                        String app = intent.getData().getSchemeSpecificPart();
                        PackageInfo pi = pm.getPackageInfo(app, PackageManager.MATCH_ANY_USER);
                        sStatsd.informOnePackage(app, uid, pi.getLongVersionCode());
                        StatsLog.write(StatsLog.GENERIC_ATOM, uid, 1001);
                    }
                } catch (Exception e) {
                    Slog.w(TAG, "Failed to inform statsd of an app update", e);