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

Commit e07b3e69 authored by lindatseng's avatar lindatseng Committed by Linda Tseng
Browse files

Add removeCallback for System change callbacks

This CL is to fix the development options settings are not listening
to the system properties changes.  Also add removeChangeCallback
in SystemProperties to remove the callback when the view is destroyed
to avoid memory leak.

Test: Manual/Visual inspection
Bug: 127761520
Change-Id: I40178297fcd8b6a6d645f4b33660cdc95c529cef
parent 515904df
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -212,6 +212,21 @@ public class SystemProperties {
        }
    }

    /**
     * Remove the target callback.
     *
     * @param callback The {@link Runnable} that should be removed.
     * @hide
     */
    @UnsupportedAppUsage
    public static void removeChangeCallback(@NonNull Runnable callback) {
        synchronized (sChangeCallbacks) {
            if (sChangeCallbacks.contains(callback)) {
                sChangeCallbacks.remove(callback);
            }
        }
    }

    @SuppressWarnings("unused")  // Called from native code.
    private static void callChangeCallbacks() {
        synchronized (sChangeCallbacks) {