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

Commit 18cbfa28 authored by Stanislav Zholnin's avatar Stanislav Zholnin Committed by Automerger Merge Worker
Browse files

Merge "Allow listening for noted Ops if app is sampled for Stack trace...

Merge "Allow listening for noted Ops if app is sampled for Stack trace collection." into rvc-dev am: ae4605ee am: 0807ec1f am: 20aebac1

Change-Id: I19dd4387c99f3e33ad4bf2966f9246ed68132ebb
parents a6982b7a 20aebac1
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -233,12 +233,9 @@ public class AppOpsManager {
                }

                private void reportStackTraceIfNeeded(@NonNull SyncNotedAppOp op) {
                    if (sConfig.getSampledOpCode() == OP_NONE
                            && sConfig.getExpirationTimeSinceBootMillis()
                            >= SystemClock.elapsedRealtime()) {
                    if (!isCollectingStackTraces()) {
                        return;
                    }

                    MessageSamplingConfig config = sConfig;
                    if (leftCircularDistance(strOpToOp(op.getOp()), config.getSampledOpCode(),
                            _NUM_OP) <= config.getAcceptableLeftDistance()
@@ -8181,7 +8178,22 @@ public class AppOpsManager {
     * @hide
     */
    public static boolean isListeningForOpNoted() {
        return sOnOpNotedCallback != null;
        return sOnOpNotedCallback != null || isCollectingStackTraces();
    }

    /**
     * @return {@code true} iff the process is currently sampled for stacktrace collection.
     *
     * @see #setOnOpNotedCallback
     *
     * @hide
     */
    private static boolean isCollectingStackTraces() {
        if (sConfig.getSampledOpCode() == OP_NONE &&
                sConfig.getExpirationTimeSinceBootMillis() >= SystemClock.elapsedRealtime()) {
            return false;
        }
        return true;
    }

    /**