Merge "Add jank monitoring for taskbar appearing and disappearing" into tm-qpr-dev

This commit is contained in:
Nicolò Mazzucato
2022-06-28 15:15:35 +00:00
committed by Android (Google) Code Review

View File

@@ -31,13 +31,15 @@ import android.animation.AnimatorSet;
import android.annotation.Nullable;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowInsets;
import androidx.annotation.NonNull;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.AnimatedFloat;
@@ -45,6 +47,8 @@ import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.system.WindowManagerWrapper;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.function.IntPredicate;
@@ -54,6 +58,8 @@ import java.util.function.IntPredicate;
*/
public class TaskbarStashController implements TaskbarControllers.LoggableTaskbarController {
private static final String TAG = "TaskbarStashController";
public static final int FLAG_IN_APP = 1 << 0;
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
public static final int FLAG_STASHED_IN_APP_PINNED = 1 << 2; // app pinning
@@ -403,6 +409,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
mAnimator.cancel();
}
mAnimator = new AnimatorSet();
addJankMonitorListener(mAnimator, /* appearing= */ !mIsStashed);
if (!supportsVisualStashing()) {
// Just hide/show the icons and background instead of stashing into a handle.
@@ -498,6 +505,28 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
});
}
private void addJankMonitorListener(AnimatorSet animator, boolean expanding) {
Optional<View> optionalView =
Arrays.stream(mControllers.taskbarViewController.getIconViews()).findFirst();
if (optionalView.isEmpty()) {
Log.wtf(TAG, "No views to start Interaction jank monitor with.", new Exception());
return;
}
View v = optionalView.get();
int action = expanding ? InteractionJankMonitor.CUJ_TASKBAR_EXPAND :
InteractionJankMonitor.CUJ_TASKBAR_COLLAPSE;
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(@NonNull Animator animation) {
InteractionJankMonitor.getInstance().begin(v, action);
}
@Override
public void onAnimationEnd(@NonNull Animator animation) {
InteractionJankMonitor.getInstance().end(action);
}
});
}
/**
* Creates and starts a partial stash animation, hinting at the new state that will trigger when
* long press is detected.