Add protolog support to Quickstep

Flag: EXEMPT changes cannot be flagged
Bug: 293182501
Test: launcher builds
Doc: go/launcher-protolog-support
Change-Id: I302b442b99165c9591b9349ea200285a5b9c074c
This commit is contained in:
Schneider Victor-Tulias
2024-09-23 13:34:25 -04:00
committed by Schneider Victor-tulias
parent 31aefc3290
commit 00b6996e6d
4 changed files with 178 additions and 2 deletions

View File

@@ -0,0 +1,102 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.quickstep.util;
import androidx.annotation.NonNull;
import com.android.internal.protolog.ProtoLog;
import com.android.internal.protolog.common.IProtoLogGroup;
import java.util.UUID;
/** Enums used to interface with the ProtoLog API. */
public enum QuickstepProtoLogGroup implements IProtoLogGroup {
ACTIVE_GESTURE_LOG(true, true, false, "ActiveGestureLog");
private final boolean mEnabled;
private volatile boolean mLogToProto;
private volatile boolean mLogToLogcat;
private final @NonNull String mTag;
public static void initProtoLog() {
ProtoLog.init(QuickstepProtoLogGroup.values());
}
/**
* @param enabled set to false to exclude all log statements for this group from
* compilation,
* they will not be available in runtime.
* @param logToProto enable binary logging for the group
* @param logToLogcat enable text logging for the group
* @param tag name of the source of the logged message
*/
QuickstepProtoLogGroup(
boolean enabled, boolean logToProto, boolean logToLogcat, @NonNull String tag) {
this.mEnabled = enabled;
this.mLogToProto = logToProto;
this.mLogToLogcat = logToLogcat;
this.mTag = tag;
}
@Override
public boolean isEnabled() {
return mEnabled;
}
@Override
public boolean isLogToProto() {
return mLogToProto;
}
@Override
public boolean isLogToLogcat() {
return mLogToLogcat;
}
@Override
public boolean isLogToAny() {
return mLogToLogcat || mLogToProto;
}
@Override
public int getId() {
return Constants.LOG_START_ID + this.ordinal();
}
@Override
public @NonNull String getTag() {
return mTag;
}
@Override
public void setLogToProto(boolean logToProto) {
this.mLogToProto = logToProto;
}
@Override
public void setLogToLogcat(boolean logToLogcat) {
this.mLogToLogcat = logToLogcat;
}
private static final class Constants {
private static final int LOG_START_ID =
(int) (UUID.nameUUIDFromBytes(QuickstepProtoLogGroup.class.getName().getBytes())
.getMostSignificantBits() % Integer.MAX_VALUE);
}
}