summaryrefslogtreecommitdiff
path: root/core/java/android/os/SystemProperties.java
diff options
context:
space:
mode:
authorlindatseng <lindatseng@google.com>2019-04-02 16:09:34 -0700
committerLinda Tseng <lindatseng@google.com>2019-04-10 00:50:58 +0000
commite07b3e6995644370030ec7664a3e4ca4f3269a5e (patch)
tree7c6498b8d678d746ed4b35d6a84d721a9ebea774 /core/java/android/os/SystemProperties.java
parent515904df171ee3619c4880e2c18226d24bc1caf9 (diff)
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
Diffstat (limited to 'core/java/android/os/SystemProperties.java')
-rw-r--r--core/java/android/os/SystemProperties.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java
index edfdda8bb760..b69f5885c2e5 100644
--- a/core/java/android/os/SystemProperties.java
+++ b/core/java/android/os/SystemProperties.java
@@ -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) {