Removing tile reveal animation in functional tests

Not running reveal animation if we recognize we're in test harness mode.

Fixes: 293234595
Fixes: 293292855
Bug: 253493927
Test: Running flaky tests many times on CI to check flakiness
Test:
1. Enter test harness mode: adb shell setprop ro.test_harness 1
2. adb shell settings delete secure qs_auto_tiles && adb shell settings delete secure sysui_qs_tiles && adb shell rm /data/user_de/0/com.android.systemui/shared_prefs/com.android.systemui.xml
3. turn on hotspot
4. Open QS and see they are not autoscrolled to the end

Merged-In: I98ef228376d944680f681ca5a5ed60be2b183788
Change-Id: I98ef228376d944680f681ca5a5ed60be2b183788
This commit is contained in:
Michal Brzezinski
2023-08-07 17:20:46 +01:00
committed by Michał Brzeziński
parent a10268d777
commit ba48e99d4b

View File

@@ -7,6 +7,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
@@ -549,10 +550,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
return mPages.get(0).mRecords.size();
}
public void startTileReveal(Set<String> tileSpecs, final Runnable postAnimation) {
if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) {
// Do not start the reveal animation unless there are tiles to animate, multiple
// TileLayouts available and the user has not already started dragging.
public void startTileReveal(Set<String> tilesToReveal, final Runnable postAnimation) {
if (shouldNotRunAnimation(tilesToReveal)) {
return;
}
@@ -560,13 +559,13 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
final TileLayout lastPage = mPages.get(lastPageNumber);
final ArrayList<Animator> bounceAnims = new ArrayList<>();
for (TileRecord tr : lastPage.mRecords) {
if (tileSpecs.contains(tr.tile.getTileSpec())) {
if (tilesToReveal.contains(tr.tile.getTileSpec())) {
bounceAnims.add(setupBounceAnimator(tr.tileView, bounceAnims.size()));
}
}
if (bounceAnims.isEmpty()) {
// All tileSpecs are on the first page. Nothing to do.
// All tilesToReveal are on the first page. Nothing to do.
// TODO: potentially show a bounce animation for first page QS tiles
endFakeDrag();
return;
@@ -588,6 +587,16 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
postInvalidateOnAnimation();
}
private boolean shouldNotRunAnimation(Set<String> tilesToReveal) {
boolean noAnimationNeeded = tilesToReveal.isEmpty() || mPages.size() < 2;
boolean scrollingInProgress = getScrollX() != 0 || !beginFakeDrag();
// isRunningInTestHarness() to disable animation in functional testing as it caused
// flakiness and is not needed there. Alternative solutions were more complex and would
// still be either potentially flaky or modify internal data.
// For more info see b/253493927 and b/293234595
return noAnimationNeeded || scrollingInProgress || ActivityManager.isRunningInTestHarness();
}
private int sanitizePageAction(int action) {
int pageLeftId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT.getId();
int pageRightId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT.getId();