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

Commit 8c86d3e8 authored by Wenhui Yang's avatar Wenhui Yang
Browse files

Allow SurfaceControlRegistry to be able to update at runtime

Fixes: 346397738
Test: adb shell setprop persist.wm.debug.sc.tx.log_match_call setAlpha,setPosition
Flag: TEST_ONLY
Change-Id: Ie5dd4f800a31732a2dcca69ae0dd265dada4004b
parent 09672b7c
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -295,16 +295,7 @@ public class SurfaceControlRegistry {
        }

        sCallStackDebuggingInitialized = true;
        sCallStackDebuggingMatchCall =
                SystemProperties.get("persist.wm.debug.sc.tx.log_match_call", null)
                        .toLowerCase();
        sCallStackDebuggingMatchName =
                SystemProperties.get("persist.wm.debug.sc.tx.log_match_name", null)
                        .toLowerCase();
        sLogAllTxCallsOnApply = sCallStackDebuggingMatchCall.contains("apply");
        // Only enable stack debugging if any of the match filters are set
        sCallStackDebuggingEnabled = !sCallStackDebuggingMatchCall.isEmpty()
                || !sCallStackDebuggingMatchName.isEmpty();
        updateCallStackDebuggingParams();
        if (sCallStackDebuggingEnabled) {
            Log.d(TAG, "Enabling transaction call stack debugging:"
                    + " matchCall=" + sCallStackDebuggingMatchCall
@@ -325,6 +316,11 @@ public class SurfaceControlRegistry {
    final void checkCallStackDebugging(@NonNull String call,
            @Nullable SurfaceControl.Transaction tx, @Nullable SurfaceControl sc,
            @Nullable String details) {

        if (sCallStackDebuggingInitialized && sCallStackDebuggingEnabled) {
            updateCallStackDebuggingParams();
        }

        if (!sCallStackDebuggingEnabled) {
            return;
        }
@@ -355,6 +351,22 @@ public class SurfaceControlRegistry {
        }
    }

    /**
     * Updates the call stack debugging params from the system properties.
     */
    private static void updateCallStackDebuggingParams() {
        sCallStackDebuggingMatchCall =
                SystemProperties.get("persist.wm.debug.sc.tx.log_match_call", null)
                        .toLowerCase();
        sCallStackDebuggingMatchName =
                SystemProperties.get("persist.wm.debug.sc.tx.log_match_name", null)
                        .toLowerCase();
        sLogAllTxCallsOnApply = sCallStackDebuggingMatchCall.contains("apply");
        // Only enable stack debugging if any of the match filters are set
        sCallStackDebuggingEnabled = !sCallStackDebuggingMatchCall.isEmpty()
                || !sCallStackDebuggingMatchName.isEmpty();
    }

    /**
     * Tests whether the given surface control name/method call matches the filters set for the
     * call stack debugging.
+4 −2
Original line number Diff line number Diff line
@@ -81,9 +81,11 @@ adb logcat -s "SurfaceControlRegistry"
# Disabling logging
adb shell setprop persist.wm.debug.sc.tx.log_match_call \"\"
adb shell setprop persist.wm.debug.sc.tx.log_match_name \"\"
adb reboot
```

A reboot is required to enable the logging. Once enabled, reboot is not needed to update the
properties.

It is not necessary to set both `log_match_call` and `log_match_name`, but note logs can be quite
noisy if unfiltered.