Merge "Add Jank test for unfold transition"

This commit is contained in:
Nicolò Mazzucato
2022-01-14 10:59:12 +00:00
committed by Android (Google) Code Review
3 changed files with 51 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_AVD;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_EXIT_ANIM;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__UNFOLD_ANIM;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__USER_SWITCH;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION;
@@ -174,6 +175,7 @@ public class InteractionJankMonitor {
public static final int CUJ_SCREEN_OFF_SHOW_AOD = 41;
public static final int CUJ_ONE_HANDED_ENTER_TRANSITION = 42;
public static final int CUJ_ONE_HANDED_EXIT_TRANSITION = 43;
public static final int CUJ_UNFOLD_ANIM = 44;
private static final int NO_STATSD_LOGGING = -1;
@@ -226,6 +228,7 @@ public class InteractionJankMonitor {
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SCREEN_OFF_SHOW_AOD,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__ONE_HANDED_ENTER_TRANSITION,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__ONE_HANDED_EXIT_TRANSITION,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__UNFOLD_ANIM,
};
private static volatile InteractionJankMonitor sInstance;
@@ -290,6 +293,7 @@ public class InteractionJankMonitor {
CUJ_SCREEN_OFF_SHOW_AOD,
CUJ_ONE_HANDED_ENTER_TRANSITION,
CUJ_ONE_HANDED_EXIT_TRANSITION,
CUJ_UNFOLD_ANIM,
})
@Retention(RetentionPolicy.SOURCE)
public @interface CujType {
@@ -695,6 +699,8 @@ public class InteractionJankMonitor {
return "ONE_HANDED_ENTER_TRANSITION";
case CUJ_ONE_HANDED_EXIT_TRANSITION:
return "ONE_HANDED_EXIT_TRANSITION";
case CUJ_UNFOLD_ANIM:
return "UNFOLD_ANIM";
}
return "UNKNOWN";
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2022 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.systemui.unfold.util
import android.view.View
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor.CUJ_UNFOLD_ANIM
import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener
import java.util.function.Supplier
class JankMonitorTransitionProgressListener(private val attachedViewProvider: Supplier<View>) :
TransitionProgressListener {
private val interactionJankMonitor = InteractionJankMonitor.getInstance()
override fun onTransitionStarted() {
interactionJankMonitor.begin(attachedViewProvider.get(), CUJ_UNFOLD_ANIM)
}
override fun onTransitionFinished() {
interactionJankMonitor.end(CUJ_UNFOLD_ANIM)
}
}

View File

@@ -47,6 +47,8 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider;
import com.android.systemui.unfold.UnfoldTransitionProgressProvider;
import com.android.systemui.unfold.util.JankMonitorTransitionProgressListener;
import java.util.Optional;
@@ -81,7 +83,8 @@ public class StatusBarWindowController {
WindowManager windowManager,
IWindowManager iWindowManager,
StatusBarContentInsetsProvider contentInsetsProvider,
@Main Resources resources) {
@Main Resources resources,
Optional<UnfoldTransitionProgressProvider> unfoldTransitionProgressProvider) {
mContext = context;
mWindowManager = windowManager;
mIWindowManager = iWindowManager;
@@ -94,6 +97,10 @@ public class StatusBarWindowController {
if (mBarHeight < 0) {
mBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
}
unfoldTransitionProgressProvider.ifPresent(
unfoldProgressProvider -> unfoldProgressProvider.addCallback(
new JankMonitorTransitionProgressListener(
/* attachedViewProvider=*/ () -> mStatusBarWindowView)));
}
public int getStatusBarHeight() {