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

Commit ad6683cb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add tracing for Inset animations" into rvc-dev am: 5bf3f80f

Change-Id: I7799f6e7eadd8bf24c43de58933365d7842ad2c2
parents 2e9c51f5 5bf3f80f
Loading
Loading
Loading
Loading
+9 −10
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.SyncRtSurfaceTransactionApplier.applyParams;
import android.annotation.UiThread;
import android.annotation.UiThread;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Handler;
import android.os.Trace;
import android.util.SparseArray;
import android.util.SparseArray;
import android.view.InsetsController.AnimationType;
import android.view.InsetsController.AnimationType;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
@@ -60,6 +61,9 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro


        @Override
        @Override
        public void notifyFinished(InsetsAnimationControlRunner runner, boolean shown) {
        public void notifyFinished(InsetsAnimationControlRunner runner, boolean shown) {
            Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW,
                    "InsetsAsyncAnimation: " + WindowInsets.Type.toString(runner.getTypes()),
                    runner.getTypes());
            releaseControls(mControl.getControls());
            releaseControls(mControl.getControls());
            mMainThreadHandler.post(() ->
            mMainThreadHandler.post(() ->
                    mOuterCallbacks.notifyFinished(InsetsAnimationThreadControlRunner.this, shown));
                    mOuterCallbacks.notifyFinished(InsetsAnimationThreadControlRunner.this, shown));
@@ -93,7 +97,11 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
        mOuterCallbacks = controller;
        mOuterCallbacks = controller;
        mControl = new InsetsAnimationControlImpl(controls, frame, state, listener,
        mControl = new InsetsAnimationControlImpl(controls, frame, state, listener,
                types, mCallbacks, durationMs, interpolator, animationType);
                types, mCallbacks, durationMs, interpolator, animationType);
        InsetsAnimationThread.getHandler().post(() -> listener.onReady(mControl, types));
        InsetsAnimationThread.getHandler().post(() -> {
            Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW,
                    "InsetsAsyncAnimation: " + WindowInsets.Type.toString(types), types);
            listener.onReady(mControl, types);
        });
    }
    }


    private void releaseControls(SparseArray<InsetsSourceControl> controls) {
    private void releaseControls(SparseArray<InsetsSourceControl> controls) {
@@ -102,15 +110,6 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
        }
        }
    }
    }


    private SparseArray<InsetsSourceControl> copyControls(
            SparseArray<InsetsSourceControl> controls) {
        SparseArray<InsetsSourceControl> copy = new SparseArray<>(controls.size());
        for (int i = 0; i < controls.size(); i++) {
            copy.append(controls.keyAt(i), new InsetsSourceControl(controls.valueAt(i)));
        }
        return copy;
    }

    @Override
    @Override
    @UiThread
    @UiThread
    public int getTypes() {
    public int getTypes() {
+6 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.CancellationSignal;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Handler;
import android.os.Trace;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.Pair;
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseArray;
@@ -1139,6 +1140,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            if (controller.isCancelled()) {
            if (controller.isCancelled()) {
                return;
                return;
            }
            }
            Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW,
                    "InsetsAnimation: " + WindowInsets.Type.toString(types), types);
            for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
            for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
                RunningAnimation runningAnimation = mRunningAnimations.get(i);
                RunningAnimation runningAnimation = mRunningAnimations.get(i);
                if (runningAnimation.runner == controller) {
                if (runningAnimation.runner == controller) {
@@ -1155,6 +1158,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation


    @VisibleForTesting
    @VisibleForTesting
    public void dispatchAnimationEnd(WindowInsetsAnimation animation) {
    public void dispatchAnimationEnd(WindowInsetsAnimation animation) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW,
                "InsetsAnimation: " + WindowInsets.Type.toString(animation.getTypeMask()),
                animation.getTypeMask());
        mHost.dispatchWindowInsetsAnimationEnd(animation);
        mHost.dispatchWindowInsetsAnimationEnd(animation);
    }
    }


+29 −23
Original line number Original line Diff line number Diff line
@@ -1328,30 +1328,36 @@ public final class WindowInsets {
            }
            }
        }
        }


        static String toString(@InsetsType int type) {
        static String toString(@InsetsType int types) {
            switch (type) {
            StringBuilder result = new StringBuilder();
                case STATUS_BARS:
            if ((types & STATUS_BARS) != 0) {
                    return "statusBars";
                result.append("statusBars |");
                case NAVIGATION_BARS:
            }
                    return "navigationBars";
            if ((types & NAVIGATION_BARS) != 0) {
                case CAPTION_BAR:
                result.append("navigationBars |");
                    return "captionBar";
            }
                case IME:
            if ((types & IME) != 0) {
                    return "ime";
                result.append("ime |");
                case SYSTEM_GESTURES:
            }
                    return "systemGestures";
            if ((types & SYSTEM_GESTURES) != 0) {
                case MANDATORY_SYSTEM_GESTURES:
                result.append("systemGestures |");
                    return "mandatorySystemGestures";
            }
                case TAPPABLE_ELEMENT:
            if ((types & MANDATORY_SYSTEM_GESTURES) != 0) {
                    return "tappableElement";
                result.append("mandatorySystemGestures |");
                case DISPLAY_CUTOUT:
                    return "displayCutout";
                case WINDOW_DECOR:
                    return "windowDecor";
                default:
                    throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST,"
                            + " type=" + type);
            }
            }
            if ((types & TAPPABLE_ELEMENT) != 0) {
                result.append("tappableElement |");
            }
            if ((types & DISPLAY_CUTOUT) != 0) {
                result.append("displayCutout |");
            }
            if ((types & WINDOW_DECOR) != 0) {
                result.append("windowDecor |");
            }
            if (result.length() > 0) {
                result.delete(result.length() - 2, result.length());
            }
            return result.toString();
        }
        }


        private Type() {
        private Type() {