diff options
| author | 2018-08-30 16:23:44 -0700 | |
|---|---|---|
| committer | 2018-08-31 16:21:28 -0700 | |
| commit | 0546d54fb44ab3bae0d6a4c0f2e3a0ebbdaebe1a (patch) | |
| tree | e74882c22bd898791e9a7591728b8548c5078c5e | |
| parent | c84e940ca74ed809e3423a70c01baad507208d1e (diff) | |
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
| -rw-r--r-- | Android.bp | 5 | ||||
| -rw-r--r-- | cmds/statsd/src/atoms.proto | 3 | ||||
| -rw-r--r-- | proto/src/stats_enums.proto | 26 | ||||
| -rw-r--r-- | services/core/java/com/android/server/stats/StatsCompanionService.java | 8 |
4 files changed, 34 insertions, 8 deletions
diff --git a/Android.bp b/Android.bp index 07b301867129..721fa25017bc 100644 --- a/Android.bp +++ b/Android.bp @@ -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: { diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 6065bbfc3f90..eec34136a931 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -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; } ////////////////////////////////////////////////////////////////////// diff --git a/proto/src/stats_enums.proto b/proto/src/stats_enums.proto new file mode 100644 index 000000000000..6c892cfeae6c --- /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 556038f3f646..41c0be63a5bb 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.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); |