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
This commit is contained in:
@@ -27,6 +27,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.util.Log;
|
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() {
|
public DevelopmentSettingsDashboardFragment() {
|
||||||
super(UserManager.DISALLOW_DEBUGGING_FEATURES);
|
super(UserManager.DISALLOW_DEBUGGING_FEATURES);
|
||||||
}
|
}
|
||||||
@@ -184,7 +199,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
registerReceivers();
|
registerReceivers();
|
||||||
|
SystemProperties.addChangeCallback(mSystemPropertiesChanged);
|
||||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.getProfileProxy(getActivity(), mBluetoothA2dpServiceListener,
|
adapter.getProfileProxy(getActivity(), mBluetoothA2dpServiceListener,
|
||||||
@@ -203,6 +218,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
adapter.closeProfileProxy(BluetoothProfile.A2DP, mBluetoothA2dp);
|
adapter.closeProfileProxy(BluetoothProfile.A2DP, mBluetoothA2dp);
|
||||||
mBluetoothA2dp = null;
|
mBluetoothA2dp = null;
|
||||||
}
|
}
|
||||||
|
SystemProperties.removeChangeCallback(mSystemPropertiesChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user