Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba48e99d authored by Michal Brzezinski's avatar Michal Brzezinski Committed by Michał Brzeziński
Browse files

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
parent a10268d7
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.PropertyValuesHolder;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Bundle;
@@ -549,10 +550,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        return mPages.get(0).mRecords.size();
        return mPages.get(0).mRecords.size();
    }
    }


    public void startTileReveal(Set<String> tileSpecs, final Runnable postAnimation) {
    public void startTileReveal(Set<String> tilesToReveal, final Runnable postAnimation) {
        if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) {
        if (shouldNotRunAnimation(tilesToReveal)) {
            // Do not start the reveal animation unless there are tiles to animate, multiple
            // TileLayouts available and the user has not already started dragging.
            return;
            return;
        }
        }


@@ -560,13 +559,13 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        final TileLayout lastPage = mPages.get(lastPageNumber);
        final TileLayout lastPage = mPages.get(lastPageNumber);
        final ArrayList<Animator> bounceAnims = new ArrayList<>();
        final ArrayList<Animator> bounceAnims = new ArrayList<>();
        for (TileRecord tr : lastPage.mRecords) {
        for (TileRecord tr : lastPage.mRecords) {
            if (tileSpecs.contains(tr.tile.getTileSpec())) {
            if (tilesToReveal.contains(tr.tile.getTileSpec())) {
                bounceAnims.add(setupBounceAnimator(tr.tileView, bounceAnims.size()));
                bounceAnims.add(setupBounceAnimator(tr.tileView, bounceAnims.size()));
            }
            }
        }
        }


        if (bounceAnims.isEmpty()) {
        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
            // TODO: potentially show a bounce animation for first page QS tiles
            endFakeDrag();
            endFakeDrag();
            return;
            return;
@@ -588,6 +587,16 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        postInvalidateOnAnimation();
        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) {
    private int sanitizePageAction(int action) {
        int pageLeftId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT.getId();
        int pageLeftId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT.getId();
        int pageRightId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT.getId();
        int pageRightId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT.getId();