Add Recents Window logs to ProtoLog
Flag: com.android.launcher3.enable_recents_window_proto_log
Bug: 292269949
Test: checked protologs in winscope
Change-Id: Iaafe58a655e9ad7293b579c74b7e7ecaa2df1ea5
diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig
index 9fb5b7b..76b119f 100644
--- a/aconfig/launcher.aconfig
+++ b/aconfig/launcher.aconfig
@@ -434,6 +434,13 @@
bug: "293182501"
}
+flag {
+ name: "enable_recents_window_proto_log"
+ namespace: "launcher"
+ description: "Enables tracking recents window logs in ProtoLog"
+ bug: "292269949"
+}
+
flag {
name: "coordinate_workspace_scale"
diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt
index 8ce61f5..b5830fd 100644
--- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt
+++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt
@@ -18,11 +18,9 @@
import android.animation.AnimatorSet
import android.app.ActivityOptions
-import android.content.ComponentName
import android.content.Context
import android.content.LocusId
import android.os.Bundle
-import android.util.Log
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.MotionEvent
@@ -30,7 +28,6 @@
import android.view.RemoteAnimationTarget
import android.view.SurfaceControl
import android.view.View
-import android.view.Window
import android.view.WindowManager
import android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
import android.window.RemoteTransition
@@ -63,6 +60,7 @@
import com.android.quickstep.fallback.RecentsState.MODAL_TASK
import com.android.quickstep.fallback.RecentsState.OVERVIEW_SPLIT_SELECT
import com.android.quickstep.util.RecentsAtomicAnimationFactory
+import com.android.quickstep.util.RecentsWindowProtoLogProxy
import com.android.quickstep.util.SplitSelectStateController
import com.android.quickstep.util.TISBindHelper
import com.android.quickstep.views.OverviewActionsView
@@ -71,9 +69,12 @@
import java.util.function.Predicate
/**
- * Class that will manage RecentsView lifecycle within a window and interface correctly
- * where needed. This allows us to run RecentsView in a window where needed.
- * todo: b/365776320, b/365777482
+ * Class that will manage RecentsView lifecycle within a window and interface correctly where
+ * needed. This allows us to run RecentsView in a window where needed. todo: b/365776320,
+ * b/365777482
+ *
+ * To add new protologs, see [RecentsWindowProtoLogProxy]. To enable logging to logcat, see
+ * [QuickstepProtoLogGroup.Constants.DEBUG_RECENTS_WINDOW]
*/
class RecentsWindowManager(context: Context) :
RecentsWindowContext(context), RecentsViewContainer, StatefulContainer<RecentsState> {
@@ -81,12 +82,12 @@
companion object {
private const val HOME_APPEAR_DURATION: Long = 250
private const val TAG = "RecentsWindowManager"
- private const val DEBUG = false
}
protected var recentsView: FallbackRecentsView<RecentsWindowManager>? = null
private val windowContext: Context = createWindowContext(TYPE_APPLICATION_OVERLAY, null)
- private val windowManager: WindowManager = windowContext.getSystemService(WindowManager::class.java)!!
+ private val windowManager: WindowManager =
+ windowContext.getSystemService(WindowManager::class.java)!!
private var layoutInflater: LayoutInflater = LayoutInflater.from(this).cloneInContext(this)
private var stateManager: StateManager<RecentsState, RecentsWindowManager> =
StateManager<RecentsState, RecentsWindowManager>(this, RecentsState.BG_LAUNCHER)
@@ -138,11 +139,11 @@
private val mAnimationToHomeFactory =
RemoteAnimationFactory {
- _: Int,
- appTargets: Array<RemoteAnimationTarget>?,
- wallpaperTargets: Array<RemoteAnimationTarget>?,
- nonAppTargets: Array<RemoteAnimationTarget>?,
- result: LauncherAnimationRunner.AnimationResult? ->
+ _: Int,
+ appTargets: Array<RemoteAnimationTarget>?,
+ wallpaperTargets: Array<RemoteAnimationTarget>?,
+ nonAppTargets: Array<RemoteAnimationTarget>?,
+ result: LauncherAnimationRunner.AnimationResult? ->
val controller =
getStateManager().createAnimationToNewWorkspace(BG_LAUNCHER, HOME_APPEAR_DURATION)
controller.dispatchOnStart()
@@ -171,6 +172,7 @@
}
fun cleanup() {
+ RecentsWindowProtoLogProxy.logCleanup(isShown)
if (isShown) {
windowManager.removeViewImmediate(windowView)
isShown = false
@@ -178,6 +180,7 @@
}
fun startRecentsWindow() {
+ RecentsWindowProtoLogProxy.logStartRecentsWindow(isShown, windowView == null)
if (isShown) return
if (windowView == null) {
windowView = layoutInflater.inflate(R.layout.fallback_recents_activity, null)
@@ -245,37 +248,24 @@
override fun onStateSetStart(state: RecentsState?) {
super.onStateSetStart(state)
- logState(state, "state started:")
+ RecentsWindowProtoLogProxy.logOnStateSetStart(getStateName(state))
}
override fun onStateSetEnd(state: RecentsState?) {
super.onStateSetEnd(state)
- logState(state, "state ended:")
+ RecentsWindowProtoLogProxy.logOnStateSetEnd(getStateName(state))
}
- private fun logState(state: RecentsState?, prefix: String) {
- if (!DEBUG) {
- return
- }
- if (state != null) {
- when (state) {
- DEFAULT -> Log.d(TAG, prefix + "default")
- MODAL_TASK -> {
- Log.d(TAG, prefix + "MODAL_TASK")
- }
- BACKGROUND_APP -> {
- Log.d(TAG, prefix + "BACKGROUND_APP")
- }
- HOME -> {
- Log.d(TAG, prefix + "HOME")
- }
- BG_LAUNCHER -> {
- Log.d(TAG, prefix + "BG_LAUNCHER")
- }
- OVERVIEW_SPLIT_SELECT -> {
- Log.d(TAG, prefix + "OVERVIEW_SPLIT_SELECT")
- }
- }
+ private fun getStateName(state: RecentsState?): String {
+ return when (state) {
+ null -> "NULL"
+ DEFAULT -> "default"
+ MODAL_TASK -> "MODAL_TASK"
+ BACKGROUND_APP -> "BACKGROUND_APP"
+ HOME -> "HOME"
+ BG_LAUNCHER -> "BG_LAUNCHER"
+ OVERVIEW_SPLIT_SELECT -> "OVERVIEW_SPLIT_SELECT"
+ else -> "ordinal=" + state.ordinal
}
}
diff --git a/quickstep/src_protolog/com/android/quickstep/util/QuickstepProtoLogGroup.java b/quickstep/src_protolog/com/android/quickstep/util/QuickstepProtoLogGroup.java
index d0863f8..7b81b9a 100644
--- a/quickstep/src_protolog/com/android/quickstep/util/QuickstepProtoLogGroup.java
+++ b/quickstep/src_protolog/com/android/quickstep/util/QuickstepProtoLogGroup.java
@@ -26,7 +26,8 @@
/** Enums used to interface with the ProtoLog API. */
public enum QuickstepProtoLogGroup implements IProtoLogGroup {
- ACTIVE_GESTURE_LOG(true, true, false, "ActiveGestureLog");
+ ACTIVE_GESTURE_LOG(true, true, false, "ActiveGestureLog"),
+ RECENTS_WINDOW(true, true, Constants.DEBUG_RECENTS_WINDOW, "RecentsWindow");
private final boolean mEnabled;
private volatile boolean mLogToProto;
@@ -95,6 +96,8 @@
private static final class Constants {
+ private static final boolean DEBUG_RECENTS_WINDOW = false;
+
private static final int LOG_START_ID =
(int) (UUID.nameUUIDFromBytes(QuickstepProtoLogGroup.class.getName().getBytes())
.getMostSignificantBits() % Integer.MAX_VALUE);
diff --git a/quickstep/src_protolog/com/android/quickstep/util/RecentsWindowProtoLogProxy.java b/quickstep/src_protolog/com/android/quickstep/util/RecentsWindowProtoLogProxy.java
new file mode 100644
index 0000000..f54ad67
--- /dev/null
+++ b/quickstep/src_protolog/com/android/quickstep/util/RecentsWindowProtoLogProxy.java
@@ -0,0 +1,60 @@
+/*
+ * 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 static com.android.launcher3.Flags.enableRecentsWindowProtoLog;
+import static com.android.quickstep.util.QuickstepProtoLogGroup.RECENTS_WINDOW;
+
+import androidx.annotation.NonNull;
+
+import com.android.internal.protolog.ProtoLog;
+import com.android.internal.protolog.common.IProtoLogGroup;
+
+/**
+ * Proxy class used for Recents Window ProtoLog support.
+ * <p>
+ * This file will have all of its static strings in the
+ * {@link ProtoLog#d(IProtoLogGroup, String, Object...)} calls replaced by dynamic code/strings.
+ * <p>
+ * When a new Recents Window log needs to be added to the codebase, add it here under a new unique
+ * method. Or, if an existing entry needs to be modified, simply update it here.
+ */
+public class RecentsWindowProtoLogProxy {
+
+ public static void logOnStateSetStart(@NonNull String stateName) {
+ if (!enableRecentsWindowProtoLog()) return;
+ ProtoLog.d(RECENTS_WINDOW, "onStateSetStart: %s", stateName);
+ }
+
+ public static void logOnStateSetEnd(@NonNull String stateName) {
+ if (!enableRecentsWindowProtoLog()) return;
+ ProtoLog.d(RECENTS_WINDOW, "onStateSetEnd: %s", stateName);
+ }
+
+ public static void logStartRecentsWindow(boolean isShown, boolean windowViewIsNull) {
+ if (!enableRecentsWindowProtoLog()) return;
+ ProtoLog.d(RECENTS_WINDOW,
+ "Starting recents window: isShow= %b, windowViewIsNull=%b",
+ isShown,
+ windowViewIsNull);
+ }
+
+ public static void logCleanup(boolean isShown) {
+ if (!enableRecentsWindowProtoLog()) return;
+ ProtoLog.d(RECENTS_WINDOW, "Cleaning up recents window: isShow= %b", isShown);
+ }
+}