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
diff --git a/Android.bp b/Android.bp
index 07b3018..721fa25 100644
--- a/Android.bp
+++ b/Android.bp
@@ -790,9 +790,10 @@
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 @@
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 @@
srcs: [
"core/proto/**/*.proto",
"libs/incident/**/*.proto",
+ "proto/src/stats_enums.proto",
],
target: {
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 6065bbf..eec3413 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -29,6 +29,7 @@
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 @@
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;
}
//////////////////////////////////////////////////////////////////////
diff --git a/proto/src/stats_enums.proto b/proto/src/stats_enums.proto
new file mode 100644
index 0000000..6c892cf
--- /dev/null
+++ b/proto/src/stats_enums.proto
@@ -0,0 +1,26 @@
+/*
+ * 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;
+}
diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java
index 556038f..41c0be6 100644
--- a/services/core/java/com/android/server/stats/StatsCompanionService.java
+++ b/services/core/java/com/android/server/stats/StatsCompanionService.java
@@ -19,7 +19,6 @@
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.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 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 @@
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 @@
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);