Chris Wren | 1611551 | 2015-03-20 10:34:20 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.android.internal.logging; |
| 17 | |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.os.Build; |
| 21 | |
| 22 | /** |
| 23 | * Log all the things. |
| 24 | * |
| 25 | * @hide |
| 26 | */ |
| 27 | public class MetricsLogger implements MetricsConstants { |
| 28 | // These constants are temporary, they should migrate to MetricsConstants. |
John Spurlock | 39581cc | 2015-04-10 11:59:01 -0400 | [diff] [blame] | 29 | // next value is 146; |
John Spurlock | b2278d6 | 2015-04-07 12:47:12 -0400 | [diff] [blame] | 30 | |
| 31 | public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144; |
John Spurlock | 39581cc | 2015-04-10 11:59:01 -0400 | [diff] [blame] | 32 | public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145; |
Chris Wren | 3db024a | 2015-04-21 12:34:02 -0400 | [diff] [blame] | 33 | public static final int ACTION_BAN_APP_NOTES = 146; |
Fabrice Di Meglio | d3d8a32 | 2015-04-01 15:58:47 -0700 | [diff] [blame] | 34 | |
Chris Wren | 1611551 | 2015-03-20 10:34:20 -0400 | [diff] [blame] | 35 | 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 Wren | 4902da4 | 2015-03-27 10:06:00 -0400 | [diff] [blame] | 48 | |
| 49 | public static void action(Context context, int category) { |
Chris Wren | 3db024a | 2015-04-21 12:34:02 -0400 | [diff] [blame] | 50 | action(context, category, ""); |
| 51 | } |
| 52 | |
| 53 | public static void action(Context context, int category, String pkg) { |
Chris Wren | 4902da4 | 2015-03-27 10:06:00 -0400 | [diff] [blame] | 54 | if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) { |
| 55 | throw new IllegalArgumentException("Must define metric category"); |
| 56 | } |
Chris Wren | 3db024a | 2015-04-21 12:34:02 -0400 | [diff] [blame] | 57 | EventLogTags.writeSysuiAction(category, pkg); |
Chris Wren | 4902da4 | 2015-03-27 10:06:00 -0400 | [diff] [blame] | 58 | } |
Chris Wren | 723aa76 | 2015-04-09 15:35:23 -0400 | [diff] [blame] | 59 | |
| 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 Wren | 1611551 | 2015-03-20 10:34:20 -0400 | [diff] [blame] | 69 | } |