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

Commit 8f26e540 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add tracing to RemoteViews" into main

parents 69b28036 e71016da
Loading
Loading
Loading
Loading
+42 −9
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.StrictMode;
import android.os.Trace;
import android.os.UserHandle;
import android.system.Os;
import android.text.TextUtils;
@@ -7003,6 +7004,18 @@ public class RemoteViews implements Parcelable, Filter {

    private View inflateView(Context context, RemoteViews rv, @Nullable ViewGroup parent,
            @StyleRes int applyThemeResId, @Nullable ColorResources colorResources) {
        try {
            Trace.beginSection(rv.hasDrawInstructions()
                    ? "RemoteViews#inflateViewWithDrawInstructions"
                    : "RemoteViews#inflateView");
            return inflateViewInternal(context, rv, parent, applyThemeResId, colorResources);
        } finally {
            Trace.endSection();
        }
    }

    private View inflateViewInternal(Context context, RemoteViews rv, @Nullable ViewGroup parent,
            @StyleRes int applyThemeResId, @Nullable ColorResources colorResources) {
        // RemoteViews may be built by an application installed in another
        // user. So build a context that loads resources from that user but
        // still returns the current users userId so settings like data / time formats
@@ -7169,11 +7182,18 @@ public class RemoteViews implements Parcelable, Filter {
                if (mRV.mActions != null) {
                    int count = mRV.mActions.size();
                    mActions = new Action[count];
                    try {
                        Trace.beginSection(hasDrawInstructions()
                                ? "RemoteViews#initActionAsyncWithDrawInstructions"
                                : "RemoteViews#initActionAsync");
                        for (int i = 0; i < count && !isCancelled(); i++) {
                            // TODO: check if isCancelled in nested views.
                            mActions[i] = mRV.mActions.get(i)
                                    .initActionAsync(mTree, mParent, mApplyParams);
                        }
                    } finally {
                        Trace.endSection();
                    }
                } else {
                    mActions = null;
                }
@@ -7194,14 +7214,20 @@ public class RemoteViews implements Parcelable, Filter {

                try {
                    if (mActions != null) {

                        ActionApplyParams applyParams = mApplyParams.clone();
                        if (applyParams.handler == null) {
                            applyParams.handler = DEFAULT_INTERACTION_HANDLER;
                        }
                        try {
                            Trace.beginSection(hasDrawInstructions()
                                    ? "RemoteViews#applyActionsAsyncWithDrawInstructions"
                                    : "RemoteViews#applyActionsAsync");
                            for (Action a : mActions) {
                                a.apply(viewTree.mRoot, mParent, applyParams);
                            }
                        } finally {
                            Trace.endSection();
                        }
                    }
                    // If the parent of the view is has is a root, resolve the recycling.
                    if (mTopLevel && mResult instanceof ViewGroup) {
@@ -7387,9 +7413,16 @@ public class RemoteViews implements Parcelable, Filter {
        }
        if (mActions != null) {
            final int count = mActions.size();
            try {
                Trace.beginSection(hasDrawInstructions()
                        ? "RemoteViews#applyActionsWithDrawInstructions"
                        : "RemoteViews#applyActions");
                for (int i = 0; i < count; i++) {
                    mActions.get(i).apply(v, parent, params);
                }
            } finally {
                Trace.endSection();
            }
        }
    }