From ba48e99d4bf5828644043d3afe38abee26c6a8c6 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Mon, 7 Aug 2023 17:20:46 +0100 Subject: [PATCH] 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 --- .../android/systemui/qs/PagedTileLayout.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index 7523d6e976cef..ddd9463affd94 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -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 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 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 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 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();