Make tether preference controllers extend BasePreferenceController

These controllers extended AbstractPreferenceController, which is not
quite compatible with some of the present framework. Especially for
indexable keys of settings search.

TetherEnabler and AllInOneTetherSettings are refactored based on the
change. Tests are updated.

Bug: 147272749
Test: CodeInspectionTest and other tests of classes touched by this CL
Change-Id: Ic3ad13e735d133c0959a0a309319a6fd5165b015
This commit is contained in:
Zhen Zhang
2020-02-05 10:09:27 -08:00
parent c240b27862
commit 258fb7f672
9 changed files with 77 additions and 102 deletions

View File

@@ -61,13 +61,14 @@ public final class TetherEnabler implements SwitchWidgetController.OnSwitchChang
public static final String SHARED_PREF = "tether_options";
// This KEY is used for a shared preference value, not for any displayed preferences.
public static final String KEY_ENABLE_WIFI_TETHERING = "enable_wifi_tethering";
@VisibleForTesting
static final String WIFI_TETHER_KEY =
WifiTetherDisablePreferenceController.KEY_ENABLE_WIFI_TETHERING;
static final String WIFI_TETHER_DISABLE_KEY = "disable_wifi_tethering";
@VisibleForTesting
static final String USB_TETHER_KEY = UsbTetherPreferenceController.PREF_KEY;
static final String USB_TETHER_KEY = "enable_usb_tethering";
@VisibleForTesting
static final String BLUETOOTH_TETHER_KEY = BluetoothTetherPreferenceController.PREF_KEY;
static final String BLUETOOTH_TETHER_KEY = "enable_bluetooth_tethering";
private final SwitchWidgetController mSwitchWidgetController;
private final WifiManager mWifiManager;
@@ -176,7 +177,7 @@ public final class TetherEnabler implements SwitchWidgetController.OnSwitchChang
private void stopTether() {
// Wi-Fi tether is selected by default.
if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
if (mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true)) {
stopTethering(TETHERING_WIFI);
}
@@ -202,7 +203,7 @@ public final class TetherEnabler implements SwitchWidgetController.OnSwitchChang
void startTether() {
// Wi-Fi tether is selected by default.
if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
if (mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true)) {
startTethering(TETHERING_WIFI);
}
@@ -328,7 +329,7 @@ public final class TetherEnabler implements SwitchWidgetController.OnSwitchChang
if (!mSwitchWidgetController.isChecked()) {
return;
}
if (TextUtils.equals(WIFI_TETHER_KEY, key)) {
if (TextUtils.equals(KEY_ENABLE_WIFI_TETHERING, key)) {
if (sharedPreferences.getBoolean(key, true)) {
startTethering(TETHERING_WIFI);
} else {