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 import java.util.UUID; 22 23 /** 24 * Defines logging groups for ProtoLog. 25 * 26 * This file is used by the ProtoLogTool to generate optimized logging code. 27 */ 28 public enum ShellProtoLogGroup implements IProtoLogGroup { 29 // NOTE: Since we enable these from the same WM ShellCommand, these names should not conflict 30 // with those in the framework ProtoLogGroup 31 WM_SHELL(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 32 Consts.TAG_WM_SHELL), 33 WM_SHELL_INIT(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 34 Consts.TAG_WM_SHELL), 35 WM_SHELL_TASK_ORG(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 36 Consts.TAG_WM_SHELL), 37 WM_SHELL_TRANSITIONS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 38 Consts.TAG_WM_SHELL), 39 WM_SHELL_RECENTS_TRANSITION(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 40 "ShellRecents"), 41 WM_SHELL_DRAG_AND_DROP(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 42 "ShellDragAndDrop"), 43 WM_SHELL_STARTING_WINDOW(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 44 Consts.TAG_WM_STARTING_WINDOW), 45 WM_SHELL_BACK_PREVIEW(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 46 "ShellBackPreview"), 47 WM_SHELL_RECENT_TASKS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 48 Consts.TAG_WM_SHELL), 49 WM_SHELL_TASK_OBSERVER(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 50 Consts.TAG_WM_SHELL), 51 // TODO(b/282232877): turn logToLogcat to false. 52 WM_SHELL_PICTURE_IN_PICTURE(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 53 Consts.TAG_WM_SHELL), 54 WM_SHELL_SPLIT_SCREEN(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 55 Consts.TAG_WM_SPLIT_SCREEN), 56 WM_SHELL_SYSUI_EVENTS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 57 Consts.TAG_WM_SHELL), 58 WM_SHELL_DESKTOP_MODE(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 59 Consts.TAG_WM_DESKTOP_MODE), 60 WM_SHELL_FLOATING_APPS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 61 Consts.TAG_WM_SHELL), 62 WM_SHELL_FOLDABLE(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 63 Consts.TAG_WM_SHELL), 64 WM_SHELL_BUBBLES(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 65 "Bubbles"), 66 WM_SHELL_COMPAT_UI(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 67 Consts.TAG_WM_COMPAT_UI), 68 WM_SHELL_APP_COMPAT(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 69 Consts.TAG_WM_APP_COMPAT), 70 TEST_GROUP(true, true, false, "WindowManagerShellProtoLogTest"); 71 72 private final boolean mEnabled; 73 private volatile boolean mLogToProto; 74 private volatile boolean mLogToLogcat; 75 private final String mTag; 76 77 /** 78 * @param enabled set to false to exclude all log statements for this group from 79 * compilation, 80 * they will not be available in runtime. 81 * @param logToProto enable binary logging for the group 82 * @param logToLogcat enable text logging for the group 83 * @param tag name of the source of the logged message 84 */ ShellProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag)85 ShellProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag) { 86 this.mEnabled = enabled; 87 this.mLogToProto = logToProto; 88 this.mLogToLogcat = logToLogcat; 89 this.mTag = tag; 90 } 91 92 @Override isEnabled()93 public boolean isEnabled() { 94 return mEnabled; 95 } 96 97 @Override isLogToProto()98 public boolean isLogToProto() { 99 return mLogToProto; 100 } 101 102 @Override isLogToLogcat()103 public boolean isLogToLogcat() { 104 return mLogToLogcat; 105 } 106 107 @Override isLogToAny()108 public boolean isLogToAny() { 109 return mLogToLogcat || mLogToProto; 110 } 111 112 @Override getTag()113 public String getTag() { 114 return mTag; 115 } 116 117 @Override setLogToProto(boolean logToProto)118 public void setLogToProto(boolean logToProto) { 119 this.mLogToProto = logToProto; 120 } 121 122 @Override setLogToLogcat(boolean logToLogcat)123 public void setLogToLogcat(boolean logToLogcat) { 124 this.mLogToLogcat = logToLogcat; 125 } 126 127 @Override getId()128 public int getId() { 129 return Consts.START_ID + this.ordinal(); 130 } 131 132 private static class Consts { 133 private static final String TAG_WM_SHELL = "WindowManagerShell"; 134 private static final String TAG_WM_STARTING_WINDOW = "ShellStartingWindow"; 135 private static final String TAG_WM_SPLIT_SCREEN = "ShellSplitScreen"; 136 private static final String TAG_WM_DESKTOP_MODE = "ShellDesktopMode"; 137 private static final String TAG_WM_COMPAT_UI = "CompatUi"; 138 private static final String TAG_WM_APP_COMPAT = "AppCompat"; 139 140 private static final boolean ENABLE_DEBUG = true; 141 private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true; 142 143 private static final int START_ID = (int) ( 144 UUID.nameUUIDFromBytes(ShellProtoLogGroup.class.getName().getBytes()) 145 .getMostSignificantBits() % Integer.MAX_VALUE); 146 } 147 } 148