Merge "BT: Use DeviceConfig for Bluetooth GD toggle" am: 6de2953232 am: ee25171aa1

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1661159

Change-Id: I690e850a6b67125a35e999a4faf86a3454140d3f
This commit is contained in:
Jack He
2021-04-14 06:07:23 +00:00
committed by Automerger Merge Worker
2 changed files with 121 additions and 8 deletions

View File

@@ -17,7 +17,7 @@
package com.android.settings.development;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -35,9 +35,9 @@ public class BluetoothGabeldorschePreferenceController extends
private static final String BLUETOOTH_GABELDORSCHE_KEY =
"bluetooth_gabeldorsche_enable";
@VisibleForTesting
static final String BLUETOOTH_GABELDORSCHE_PROPERTY =
"bluetooth.gd.enabled";
static final String CURRENT_GD_FLAG = "INIT_gd_scanning";
public BluetoothGabeldorschePreferenceController(Context context) {
super(context);
@@ -51,22 +51,23 @@ public class BluetoothGabeldorschePreferenceController extends
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
SystemProperties.set(BLUETOOTH_GABELDORSCHE_PROPERTY,
isEnabled ? "true" : "false");
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_BLUETOOTH,
CURRENT_GD_FLAG, isEnabled ? "true" : "false", false /* makeDefault */);
return true;
}
@Override
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_GABELDORSCHE_PROPERTY, false /* default */);
final boolean isEnabled = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_BLUETOOTH, CURRENT_GD_FLAG, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(BLUETOOTH_GABELDORSCHE_PROPERTY, "false");
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_BLUETOOTH,
CURRENT_GD_FLAG, null, false /* makeDefault */);
((SwitchPreference) mPreference).setChecked(false);
}
}