mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 18:06:48 +00:00
Add jank monitoring for taskbar appearing and disappearing
Bug: 228969045 Test: record a perfetto trace and make sure the interaction is there Change-Id: Id220f8eef5b08fb69410e08c230f867ffe21d126
This commit is contained in:
@@ -30,13 +30,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;
|
||||
@@ -44,6 +46,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;
|
||||
|
||||
@@ -53,6 +57,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
|
||||
@@ -401,6 +407,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.
|
||||
@@ -496,6 +503,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.
|
||||
|
||||
Reference in New Issue
Block a user