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

Commit 1952ddfd authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Allow TraceSessionEnded reporting to be muted.

This will allow System UI's Issue Recording QS tile to start and stop
long traces.

Bug: 343538743
Test: Verified manually on device that the crash and the notification no
longer appear for long traces that have been stopped.
Flag: EXEMPT bug fix

Change-Id: If127aef17872a9fab54a916f008174e71b4cff6c
parent d4d63483
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.res.Resources
import android.net.Uri
import android.os.Handler
import android.os.UserHandle
import android.provider.Settings
import android.util.Log
import com.android.internal.logging.UiEventLogger
import com.android.systemui.animation.DialogTransitionAnimator
@@ -90,7 +91,16 @@ constructor(
                // ViewCapture needs to save it's data before it is disabled, or else the data will
                // be lost. This is expected to change in the near future, and when that happens
                // this line should be removed.
                bgExecutor.execute { traceurMessageSender.stopTracing() }
                bgExecutor.execute {
                    if (issueRecordingState.traceConfig.longTrace) {
                        Settings.Global.putInt(
                            contentResolver,
                            NOTIFY_SESSION_ENDED_SETTING,
                            DISABLED
                        )
                    }
                    traceurMessageSender.stopTracing()
                }
                issueRecordingState.isRecording = false
            }
            ACTION_SHARE -> {
@@ -125,6 +135,8 @@ constructor(
    companion object {
        private const val TAG = "IssueRecordingService"
        private const val CHANNEL_ID = "issue_record"
        private const val NOTIFY_SESSION_ENDED_SETTING = "should_notify_trace_session_ended"
        private const val DISABLED = 0

        /**
         * Get an intent to stop the issue recording service.
+16 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor.AutoCloseInputStream;
import android.os.ParcelFileDescriptor.AutoCloseOutputStream;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.tracing.TraceReportService;
import android.tracing.ITracingServiceProxy;
import android.tracing.TraceReportParams;
@@ -87,6 +88,8 @@ public class TracingServiceProxy extends SystemService {
            TRACING_SERVICE_REPORT_EVENT__EVENT__TRACING_SERVICE_REPORT_SVC_PERM_MISSING;
    private static final int REPORT_SVC_COMM_ERROR =
            TRACING_SERVICE_REPORT_EVENT__EVENT__TRACING_SERVICE_REPORT_SVC_COMM_ERROR;
    private static final String NOTIFY_SESSION_ENDED_SETTING = "should_notify_trace_session_ended";
    private static final int ENABLED = 1;

    private final Context mContext;
    private final PackageManager mPackageManager;
@@ -97,10 +100,22 @@ public class TracingServiceProxy extends SystemService {
        /**
         * Notifies system tracing app that a tracing session has ended. sessionStolen is ignored,
         * as trace sessions are no longer stolen and are always cloned instead.
         * <p>
         * Cases exist where user-flows besides Traceur's QS Tile may end long-trace sessions. In
         * these cases, a Global int will be set to flag the upcoming notifyTraceSessionEnded call
         * as purposely muted once.
         */
        @Override
        public void notifyTraceSessionEnded(boolean sessionStolen /* unused */) {
            long identity = Binder.clearCallingIdentity();
            if (Settings.Global.getInt(mContext.getContentResolver(),
                    NOTIFY_SESSION_ENDED_SETTING, ENABLED) == ENABLED) {
                TracingServiceProxy.this.notifyTraceur();
            } else {
                Settings.Global.putInt(mContext.getContentResolver(), NOTIFY_SESSION_ENDED_SETTING,
                        ENABLED);
            }
            Binder.restoreCallingIdentity(identity);
        }

        @Override