• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.wm.shell.protolog;
18 
19 import com.android.internal.protolog.common.IProtoLogGroup;
20 
21 /**
22  * Defines logging groups for ProtoLog.
23  *
24  * This file is used by the ProtoLogTool to generate optimized logging code.
25  */
26 public enum ShellProtoLogGroup implements IProtoLogGroup {
27     // NOTE: Since we enable these from the same WM ShellCommand, these names should not conflict
28     // with those in the framework ProtoLogGroup
29     WM_SHELL_INIT(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
30             Consts.TAG_WM_SHELL),
31     WM_SHELL_TASK_ORG(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
32             Consts.TAG_WM_SHELL),
33     WM_SHELL_TRANSITIONS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
34             Consts.TAG_WM_SHELL),
35     WM_SHELL_DRAG_AND_DROP(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
36             Consts.TAG_WM_SHELL),
37     WM_SHELL_STARTING_WINDOW(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
38             Consts.TAG_WM_STARTING_WINDOW),
39     WM_SHELL_BACK_PREVIEW(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
40             "ShellBackPreview"),
41     WM_SHELL_RECENT_TASKS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
42             Consts.TAG_WM_SHELL),
43     WM_SHELL_PICTURE_IN_PICTURE(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
44             Consts.TAG_WM_SHELL),
45     WM_SHELL_SPLIT_SCREEN(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
46             Consts.TAG_WM_SPLIT_SCREEN),
47     WM_SHELL_SYSUI_EVENTS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
48             Consts.TAG_WM_SHELL),
49     WM_SHELL_DESKTOP_MODE(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
50             Consts.TAG_WM_SHELL),
51     WM_SHELL_FLOATING_APPS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
52             Consts.TAG_WM_SHELL),
53     WM_SHELL_FOLDABLE(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
54             Consts.TAG_WM_SHELL),
55     TEST_GROUP(true, true, false, "WindowManagerShellProtoLogTest");
56 
57     private final boolean mEnabled;
58     private volatile boolean mLogToProto;
59     private volatile boolean mLogToLogcat;
60     private final String mTag;
61 
62     /**
63      * @param enabled     set to false to exclude all log statements for this group from
64      *                    compilation,
65      *                    they will not be available in runtime.
66      * @param logToProto  enable binary logging for the group
67      * @param logToLogcat enable text logging for the group
68      * @param tag         name of the source of the logged message
69      */
ShellProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag)70     ShellProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag) {
71         this.mEnabled = enabled;
72         this.mLogToProto = logToProto;
73         this.mLogToLogcat = logToLogcat;
74         this.mTag = tag;
75     }
76 
77     @Override
isEnabled()78     public boolean isEnabled() {
79         return mEnabled;
80     }
81 
82     @Override
isLogToProto()83     public boolean isLogToProto() {
84         return mLogToProto;
85     }
86 
87     @Override
isLogToLogcat()88     public boolean isLogToLogcat() {
89         return mLogToLogcat;
90     }
91 
92     @Override
isLogToAny()93     public boolean isLogToAny() {
94         return mLogToLogcat || mLogToProto;
95     }
96 
97     @Override
getTag()98     public String getTag() {
99         return mTag;
100     }
101 
102     @Override
setLogToProto(boolean logToProto)103     public void setLogToProto(boolean logToProto) {
104         this.mLogToProto = logToProto;
105     }
106 
107     @Override
setLogToLogcat(boolean logToLogcat)108     public void setLogToLogcat(boolean logToLogcat) {
109         this.mLogToLogcat = logToLogcat;
110     }
111 
112     private static class Consts {
113         private static final String TAG_WM_SHELL = "WindowManagerShell";
114         private static final String TAG_WM_STARTING_WINDOW = "ShellStartingWindow";
115         private static final String TAG_WM_SPLIT_SCREEN = "ShellSplitScreen";
116 
117         private static final boolean ENABLE_DEBUG = true;
118         private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true;
119     }
120 }
121