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_TASK_ORG(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 30 Consts.TAG_WM_SHELL), 31 WM_SHELL_TRANSITIONS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true, 32 Consts.TAG_WM_SHELL), 33 WM_SHELL_DRAG_AND_DROP(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, 34 Consts.TAG_WM_SHELL), 35 TEST_GROUP(true, true, false, "WindowManagerShellProtoLogTest"); 36 37 private final boolean mEnabled; 38 private volatile boolean mLogToProto; 39 private volatile boolean mLogToLogcat; 40 private final String mTag; 41 42 /** 43 * @param enabled set to false to exclude all log statements for this group from 44 * compilation, 45 * they will not be available in runtime. 46 * @param logToProto enable binary logging for the group 47 * @param logToLogcat enable text logging for the group 48 * @param tag name of the source of the logged message 49 */ ShellProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag)50 ShellProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag) { 51 this.mEnabled = enabled; 52 this.mLogToProto = logToProto; 53 this.mLogToLogcat = logToLogcat; 54 this.mTag = tag; 55 } 56 57 @Override isEnabled()58 public boolean isEnabled() { 59 return mEnabled; 60 } 61 62 @Override isLogToProto()63 public boolean isLogToProto() { 64 return mLogToProto; 65 } 66 67 @Override isLogToLogcat()68 public boolean isLogToLogcat() { 69 return mLogToLogcat; 70 } 71 72 @Override isLogToAny()73 public boolean isLogToAny() { 74 return mLogToLogcat || mLogToProto; 75 } 76 77 @Override getTag()78 public String getTag() { 79 return mTag; 80 } 81 82 @Override setLogToProto(boolean logToProto)83 public void setLogToProto(boolean logToProto) { 84 this.mLogToProto = logToProto; 85 } 86 87 @Override setLogToLogcat(boolean logToLogcat)88 public void setLogToLogcat(boolean logToLogcat) { 89 this.mLogToLogcat = logToLogcat; 90 } 91 92 private static class Consts { 93 private static final String TAG_WM_SHELL = "WindowManagerShell"; 94 95 private static final boolean ENABLE_DEBUG = true; 96 private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true; 97 } 98 } 99