• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 
17 package com.android.settings.core.instrumentation;
18 
19 import android.content.Context;
20 import android.provider.DeviceConfig;
21 
22 import com.android.settings.core.SettingsUIDeviceConfig;
23 import com.android.settingslib.core.instrumentation.EventLogWriter;
24 
25 public class SettingsEventLogWriter extends EventLogWriter {
26 
27     @Override
visible(Context context, int source, int category, int latency)28     public void visible(Context context, int source, int category, int latency) {
29         if (shouldDisableGenericEventLogging()) {
30             return;
31         }
32         super.visible(context, source, category, latency);
33     }
34 
35     @Override
hidden(Context context, int category, int visibleTime)36     public void hidden(Context context, int category, int visibleTime) {
37         if (shouldDisableGenericEventLogging()) {
38             return;
39         }
40         super.hidden(context, category, visibleTime);
41     }
42 
43     @Override
clicked(int sourceCategory, String key)44     public void clicked(int sourceCategory, String key) {
45         if (shouldDisableGenericEventLogging()) {
46             return;
47         }
48         super.clicked(sourceCategory, key);
49     }
50 
51     @Override
changed(int category, String key, int value)52     public void changed(int category, String key, int value) {
53         if (shouldDisableGenericEventLogging()) {
54             return;
55         }
56         super.changed(category, key, value);
57     }
58 
59     @Override
action(Context context, int category, String pkg)60     public void action(Context context, int category, String pkg) {
61         if (shouldDisableGenericEventLogging()) {
62             return;
63         }
64         super.action(context, category, pkg);
65     }
66 
67     @Override
action(Context context, int category, int value)68     public void action(Context context, int category, int value) {
69         if (shouldDisableGenericEventLogging()) {
70             return;
71         }
72         super.action(context, category, value);
73     }
74 
75     @Override
action(Context context, int category, boolean value)76     public void action(Context context, int category, boolean value) {
77         if (shouldDisableGenericEventLogging()) {
78             return;
79         }
80         super.action(context, category, value);
81     }
82 
shouldDisableGenericEventLogging()83     private static boolean shouldDisableGenericEventLogging() {
84         return !DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
85                 SettingsUIDeviceConfig.GENERIC_EVENT_LOGGING_ENABLED, true /* default */);
86     }
87 }
88