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

Commit b337e1c5 authored by Felipe Leme's avatar Felipe Leme
Browse files

Added trace points for ContentCapture.

Test: ./external/chromium-trace/systrace.py -o ~/tmp/trace.html -a android.contentcaptureservice.cts -t 1 view am
Fixes: 120440520

Change-Id: Ic6ad506ac88a9d04b096d58f568d04904b72fb04
parent 9789e55a
Loading
Loading
Loading
Loading
+45 −21
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import android.os.RemoteException;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.StrictMode;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.text.Selection;
import android.text.SpannableStringBuilder;
@@ -1049,8 +1050,28 @@ public class Activity extends ContextThemeWrapper
    @Retention(RetentionPolicy.SOURCE)
    @interface ContentCaptureNotificationType{}

    private String getContentCaptureTypeAsString(@ContentCaptureNotificationType int type) {
        switch (type) {
            case CONTENT_CAPTURE_START:
                return "START";
            case CONTENT_CAPTURE_PAUSE:
                return "PAUSE";
            case CONTENT_CAPTURE_RESUME:
                return "RESUME";
            case CONTENT_CAPTURE_STOP:
                return "STOP";
            default:
                return "UNKNOW-" + type;
        }
    }

    private void notifyContentCaptureManagerIfNeeded(@ContentCaptureNotificationType int type) {
        if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
            Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                    "notifyContentCapture(" + getContentCaptureTypeAsString(type) + ") for "
                            + mComponent.toShortString());
        }
        try {
            final ContentCaptureManager cm = getContentCaptureManager();
            if (cm == null) return;

@@ -1077,6 +1098,9 @@ public class Activity extends ContextThemeWrapper
                default:
                    Log.wtf(TAG, "Invalid @ContentCaptureNotificationType: " + type);
            }
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
        }
    }

    @Override
+21 −1
Original line number Diff line number Diff line
@@ -8222,7 +8222,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * </ul>
     */
    public void onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) {
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
            Trace.traceBegin(Trace.TRACE_TAG_VIEW,
                    "onProvideContentCaptureStructure() for " + getClass().getSimpleName());
        }
        try {
            onProvideStructure(structure, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE, flags);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
        }
    }
    /** @hide */
@@ -9013,6 +9021,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * </ol>
     */
    private void notifyAppearedOrDisappearedForContentCaptureIfNeeded(boolean appeared) {
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
            Trace.traceBegin(Trace.TRACE_TAG_VIEW,
                    "notifyContentCapture(" + appeared + ") for " + getClass().getSimpleName());
        }
        try {
            notifyAppearedOrDisappearedForContentCaptureIfNeededNoTrace(appeared);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
        }
    }
    private void notifyAppearedOrDisappearedForContentCaptureIfNeededNoTrace(boolean appeared) {
        // First check if context has client, so it saves a service lookup when it doesn't
        if (!mContext.isContentCaptureSupported()) return;