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

Commit 790c33a4 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Update tracing restriction to ro.debuggable=1

Previously we checked if it was a user build, but this doesn't work for OEMs that run user builds + debuggable=1 for testing, to bypass app restrictions.

Context: go/winscope-debuggable-user-builds

Bug: 407861081
Test: atest FlickerTests
Flag: EXEMPT bugfix
Change-Id: Iee19e2580b441fac3d1b1af24582b03ca7ee819f
parent c582e387
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -16,10 +16,9 @@

package com.android.internal.inputmethod;

import static android.os.Build.IS_USER;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Build;
import android.os.SystemClock;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
@@ -173,8 +172,8 @@ class ImeTracingServerImpl extends ImeTracing {
    @GuardedBy("mEnabledLock")
    @Override
    public void startTrace(@Nullable PrintWriter pw) {
        if (IS_USER) {
            Log.w(TAG, "Warn: Tracing is not supported on user builds.");
        if (!Build.isDebuggable()) {
            Log.w(TAG, "Warn: Tracing is not supported on non debuggable builds.");
            return;
        }

@@ -193,8 +192,8 @@ class ImeTracingServerImpl extends ImeTracing {

    @Override
    public void stopTrace(@Nullable PrintWriter pw) {
        if (IS_USER) {
            Log.w(TAG, "Warn: Tracing is not supported on user builds.");
        if (!Build.isDebuggable()) {
            Log.w(TAG, "Warn: Tracing is not supported on non debuggable builds.");
            return;
        }

@@ -217,7 +216,7 @@ class ImeTracingServerImpl extends ImeTracing {
     */
    @Override
    public void saveForBugreport(@Nullable PrintWriter pw) {
        if (IS_USER) {
        if (!Build.isDebuggable()) {
            return;
        }
        synchronized (mEnabledLock) {
+7 −7
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@

package com.android.server.wm;

import static android.os.Build.IS_USER;

import static com.android.server.wm.WindowManagerTraceProto.ELAPSED_REALTIME_NANOS;
import static com.android.server.wm.WindowManagerTraceProto.WHERE;
import static com.android.server.wm.WindowManagerTraceProto.WINDOW_MANAGER_SERVICE;

import android.annotation.Nullable;
import android.os.Build;
import android.os.ShellCommand;
import android.os.Trace;
import android.util.Log;
@@ -69,16 +69,16 @@ abstract class WindowTracing {
    }

    void startTrace(@Nullable PrintWriter pw) {
        if (IS_USER) {
            logAndPrintln(pw, "Error: Tracing is not supported on user builds.");
        if (!Build.isDebuggable()) {
            logAndPrintln(pw, "Error: Tracing is not supported on non debuggable builds.");
            return;
        }
        startTraceInternal(pw);
    }

    void stopTrace(@Nullable PrintWriter pw) {
        if (IS_USER) {
            logAndPrintln(pw, "Error: Tracing is not supported on user builds.");
        if (!Build.isDebuggable()) {
            logAndPrintln(pw, "Error: Tracing is not supported on non debuggable builds.");
            return;
        }
        stopTraceInternal(pw);
@@ -93,8 +93,8 @@ abstract class WindowTracing {
     * @param pw Print writer
     */
    void saveForBugreport(@Nullable PrintWriter pw) {
        if (IS_USER) {
            logAndPrintln(pw, "Error: Tracing is not supported on user builds.");
        if (!Build.isDebuggable()) {
            logAndPrintln(pw, "Error: Tracing is not supported on non debuggable builds.");
            return;
        }
        if (!android.tracing.Flags.perfettoProtologTracing()
+2 −2
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ class WindowTracingPerfetto extends WindowTracing {
    protected void log(String where) {
        try {
            Trace.beginSection(TracingUtils.uiTracingSliceName("Window::log"));
            boolean isStartLogEvent = where == WHERE_START_TRACING;
            boolean isOnFrameLogEvent = where == WHERE_ON_FRAME;
            boolean isStartLogEvent = WHERE_START_TRACING.equals(where);
            boolean isOnFrameLogEvent = WHERE_ON_FRAME.equals(where);

            ArrayList<Runnable> pendingStopDones = new ArrayList<>();