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

Commit f68c8e42 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Don't let transition tracing exceptions bubble up

So that the tracing can never cause a transition to fail.

Test: n/a
Bug: 281929591
Change-Id: I805b2ccfa0dbfc6db375692ad5fc368005d4bd1d
parent 2d319490
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1516,7 +1516,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {

        mController.mLoggerHandler.post(mLogger::logOnSend);
        if (mLogger.mInfo != null) {
            mController.mTransitionTracer.logSentTransition(this, mTargets, info);
            mController.mTransitionTracer.logSentTransition(this, mTargets);
        }
    }

+50 −38
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.os.SystemClock;
import android.os.Trace;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.window.TransitionInfo;

import com.android.internal.util.TraceBuffer;
import com.android.server.wm.Transition.ChangeInfo;
@@ -69,10 +68,9 @@ public class TransitionTracer {
     *
     * @param transition The transition that has been sent to Shell.
     * @param targets Information about the target windows of the transition.
     * @param info The TransitionInfo send over to Shell to execute the transition.
     */
    public void logSentTransition(Transition transition, ArrayList<ChangeInfo> targets,
            TransitionInfo info) {
    public void logSentTransition(Transition transition, ArrayList<ChangeInfo> targets) {
        try {
            final ProtoOutputStream outputStream = new ProtoOutputStream();
            final long protoToken = outputStream
                    .start(com.android.server.wm.shell.TransitionTraceProto.TRANSITIONS);
@@ -89,6 +87,10 @@ public class TransitionTracer {
            outputStream.end(protoToken);

            mTraceBuffer.add(outputStream);
        } catch (Exception e) {
            // Don't let any errors in the tracing cause the transition to fail
            Log.e(LOG_TAG, "Unexpected exception thrown while logging transitions", e);
        }
    }

    /**
@@ -98,6 +100,7 @@ public class TransitionTracer {
     * @param transition The transition that has finished.
     */
    public void logFinishedTransition(Transition transition) {
        try {
            final ProtoOutputStream outputStream = new ProtoOutputStream();
            final long protoToken = outputStream
                    .start(com.android.server.wm.shell.TransitionTraceProto.TRANSITIONS);
@@ -107,6 +110,10 @@ public class TransitionTracer {
            outputStream.end(protoToken);

            mTraceBuffer.add(outputStream);
        } catch (Exception e) {
            // Don't let any errors in the tracing cause the transition to fail
            Log.e(LOG_TAG, "Unexpected exception thrown while logging transitions", e);
        }
    }

    /**
@@ -116,6 +123,7 @@ public class TransitionTracer {
     * @param transition The transition that has been aborted
     */
    public void logAbortedTransition(Transition transition) {
        try {
            final ProtoOutputStream outputStream = new ProtoOutputStream();
            final long protoToken = outputStream
                    .start(com.android.server.wm.shell.TransitionTraceProto.TRANSITIONS);
@@ -125,6 +133,10 @@ public class TransitionTracer {
            outputStream.end(protoToken);

            mTraceBuffer.add(outputStream);
        } catch (Exception e) {
            // Don't let any errors in the tracing cause the transition to fail
            Log.e(LOG_TAG, "Unexpected exception thrown while logging transitions", e);
        }
    }

    private void dumpTransitionTargetsToProto(ProtoOutputStream outputStream,