summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-05-14 22:16:23 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-14 22:16:23 +0000
commit5bf3f80f207be52e2aec2ad27041154dbe227bac (patch)
treeb618560196bf06aece018cbb0bbddeae0fc29433
parent8c211a713b538c83f686611b9c85683e82c38203 (diff)
parentcb28ae6d17d67401ae9ee84f1998d8c5b717085f (diff)
Merge "Add tracing for Inset animations" into rvc-dev
-rw-r--r--core/java/android/view/InsetsAnimationThreadControlRunner.java19
-rw-r--r--core/java/android/view/InsetsController.java6
-rw-r--r--core/java/android/view/WindowInsets.java52
3 files changed, 44 insertions, 33 deletions
diff --git a/core/java/android/view/InsetsAnimationThreadControlRunner.java b/core/java/android/view/InsetsAnimationThreadControlRunner.java
index 9dfdd0604e6b..3215b7c89b83 100644
--- a/core/java/android/view/InsetsAnimationThreadControlRunner.java
+++ b/core/java/android/view/InsetsAnimationThreadControlRunner.java
@@ -21,6 +21,7 @@ import static android.view.SyncRtSurfaceTransactionApplier.applyParams;
import android.annotation.UiThread;
import android.graphics.Rect;
import android.os.Handler;
+import android.os.Trace;
import android.util.SparseArray;
import android.view.InsetsController.AnimationType;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
@@ -60,6 +61,9 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
@Override
public void notifyFinished(InsetsAnimationControlRunner runner, boolean shown) {
+ Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW,
+ "InsetsAsyncAnimation: " + WindowInsets.Type.toString(runner.getTypes()),
+ runner.getTypes());
releaseControls(mControl.getControls());
mMainThreadHandler.post(() ->
mOuterCallbacks.notifyFinished(InsetsAnimationThreadControlRunner.this, shown));
@@ -93,7 +97,11 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
mOuterCallbacks = controller;
mControl = new InsetsAnimationControlImpl(controls, frame, state, listener,
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) {
@@ -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
@UiThread
public int getTypes() {
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 7335bfcbe7da..d12a1221ac95 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -35,6 +35,7 @@ import android.graphics.Insets;
import android.graphics.Rect;
import android.os.CancellationSignal;
import android.os.Handler;
+import android.os.Trace;
import android.util.ArraySet;
import android.util.Pair;
import android.util.SparseArray;
@@ -1139,6 +1140,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
if (controller.isCancelled()) {
return;
}
+ Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW,
+ "InsetsAnimation: " + WindowInsets.Type.toString(types), types);
for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
RunningAnimation runningAnimation = mRunningAnimations.get(i);
if (runningAnimation.runner == controller) {
@@ -1155,6 +1158,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
@VisibleForTesting
public void dispatchAnimationEnd(WindowInsetsAnimation animation) {
+ Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW,
+ "InsetsAnimation: " + WindowInsets.Type.toString(animation.getTypeMask()),
+ animation.getTypeMask());
mHost.dispatchWindowInsetsAnimationEnd(animation);
}
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index aad1c60d7b7e..4d6b72f96aab 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -1328,30 +1328,36 @@ public final class WindowInsets {
}
}
- static String toString(@InsetsType int type) {
- switch (type) {
- case STATUS_BARS:
- return "statusBars";
- case NAVIGATION_BARS:
- return "navigationBars";
- case CAPTION_BAR:
- return "captionBar";
- case IME:
- return "ime";
- case SYSTEM_GESTURES:
- return "systemGestures";
- case MANDATORY_SYSTEM_GESTURES:
- return "mandatorySystemGestures";
- case TAPPABLE_ELEMENT:
- return "tappableElement";
- case DISPLAY_CUTOUT:
- return "displayCutout";
- case WINDOW_DECOR:
- return "windowDecor";
- default:
- throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST,"
- + " type=" + type);
+ static String toString(@InsetsType int types) {
+ StringBuilder result = new StringBuilder();
+ if ((types & STATUS_BARS) != 0) {
+ result.append("statusBars |");
+ }
+ if ((types & NAVIGATION_BARS) != 0) {
+ result.append("navigationBars |");
+ }
+ if ((types & IME) != 0) {
+ result.append("ime |");
+ }
+ if ((types & SYSTEM_GESTURES) != 0) {
+ result.append("systemGestures |");
+ }
+ if ((types & MANDATORY_SYSTEM_GESTURES) != 0) {
+ result.append("mandatorySystemGestures |");
+ }
+ 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() {