blob: 092c1483e3e8f8b29812f055f983f410a0c916c9 [file] [log] [blame]
Chris Wren16115512015-03-20 10:34:20 -04001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.internal.logging;
17
18
19import android.content.Context;
20import android.os.Build;
21
22/**
23 * Log all the things.
24 *
25 * @hide
26 */
27public class MetricsLogger implements MetricsConstants {
28 // These constants are temporary, they should migrate to MetricsConstants.
John Spurlock39581cc2015-04-10 11:59:01 -040029 // next value is 146;
John Spurlockb2278d62015-04-07 12:47:12 -040030
31 public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144;
John Spurlock39581cc2015-04-10 11:59:01 -040032 public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145;
Chris Wren3db024a2015-04-21 12:34:02 -040033 public static final int ACTION_BAN_APP_NOTES = 146;
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -070034
Chris Wren16115512015-03-20 10:34:20 -040035 public static void visible(Context context, int category) throws IllegalArgumentException {
36 if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
37 throw new IllegalArgumentException("Must define metric category");
38 }
39 EventLogTags.writeSysuiViewVisibility(category, 100);
40 }
41
42 public static void hidden(Context context, int category) {
43 if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
44 throw new IllegalArgumentException("Must define metric category");
45 }
46 EventLogTags.writeSysuiViewVisibility(category, 0);
47 }
Chris Wren4902da42015-03-27 10:06:00 -040048
49 public static void action(Context context, int category) {
Chris Wren3db024a2015-04-21 12:34:02 -040050 action(context, category, "");
51 }
52
53 public static void action(Context context, int category, String pkg) {
Chris Wren4902da42015-03-27 10:06:00 -040054 if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
55 throw new IllegalArgumentException("Must define metric category");
56 }
Chris Wren3db024a2015-04-21 12:34:02 -040057 EventLogTags.writeSysuiAction(category, pkg);
Chris Wren4902da42015-03-27 10:06:00 -040058 }
Chris Wren723aa762015-04-09 15:35:23 -040059
60 /** Add an integer value to the monotonically increasing counter with the given name. */
61 public static void count(Context context, String name, int value) {
62 EventLogTags.writeSysuiCount(name, value);
63 }
64
65 /** Increment the bucket with the integer label on the histogram with the given name. */
66 public static void histogram(Context context, String name, int bucket) {
67 EventLogTags.writeSysuiHistogram(name, bucket);
68 }
Chris Wren16115512015-03-20 10:34:20 -040069}