blob: 24b5d0da3650052c4751df53709f9eb55e7036f2 [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;
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -070033
Chris Wren16115512015-03-20 10:34:20 -040034 public static void visible(Context context, int category) throws IllegalArgumentException {
35 if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
36 throw new IllegalArgumentException("Must define metric category");
37 }
38 EventLogTags.writeSysuiViewVisibility(category, 100);
39 }
40
41 public static void hidden(Context context, int category) {
42 if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
43 throw new IllegalArgumentException("Must define metric category");
44 }
45 EventLogTags.writeSysuiViewVisibility(category, 0);
46 }
Chris Wren4902da42015-03-27 10:06:00 -040047
48 public static void action(Context context, int category) {
49 if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
50 throw new IllegalArgumentException("Must define metric category");
51 }
52 EventLogTags.writeSysuiAction(category);
53 }
Chris Wren723aa762015-04-09 15:35:23 -040054
55 /** Add an integer value to the monotonically increasing counter with the given name. */
56 public static void count(Context context, String name, int value) {
57 EventLogTags.writeSysuiCount(name, value);
58 }
59
60 /** Increment the bucket with the integer label on the histogram with the given name. */
61 public static void histogram(Context context, String name, int bucket) {
62 EventLogTags.writeSysuiHistogram(name, bucket);
63 }
Chris Wren16115512015-03-20 10:34:20 -040064}