From 6b094edbb54f0fed2eec9fc49ee876c377fb1a6a Mon Sep 17 00:00:00 2001 From: lindatseng Date: Tue, 2 Apr 2019 13:07:11 -0700 Subject: [PATCH] Make DevloperOptions frag listen to sysprop change Add System Properties change callback in DevelopmentSettingsDashboardFragment, to listen to the changed and update preference states accordingly. This will fix the bug that the pref is not updated accordingly when user modifies the setting from quick-settings. Test: Manual/Visual Verification Fixes: 127761520 Change-Id: I478775902a1d0df1e91f98027d4b8d65d6e9fd28 --- .../DevelopmentSettingsDashboardFragment.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index 77b104b66f1..9af8891e390 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; +import android.os.SystemProperties; import android.os.UserManager; import android.provider.SearchIndexableResource; import android.util.Log; @@ -136,6 +137,20 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra } }; + private final Runnable mSystemPropertiesChanged = new Runnable() { + @Override + public void run() { + synchronized (this) { + Activity activity = getActivity(); + if (activity != null) { + activity.runOnUiThread(() -> { + updatePreferenceStates(); + }); + } + } + } + }; + public DevelopmentSettingsDashboardFragment() { super(UserManager.DISALLOW_DEBUGGING_FEATURES); } @@ -184,7 +199,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { registerReceivers(); - + SystemProperties.addChangeCallback(mSystemPropertiesChanged); final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { adapter.getProfileProxy(getActivity(), mBluetoothA2dpServiceListener, @@ -203,6 +218,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra adapter.closeProfileProxy(BluetoothProfile.A2DP, mBluetoothA2dp); mBluetoothA2dp = null; } + SystemProperties.removeChangeCallback(mSystemPropertiesChanged); } @Override