Dupe BluetoothSettings and DeviceListPreferenceFragment
Create the obsolete version of the belowing fragments, so we could flip between old page and new page. BluetoothSettingsObsolete and DeviceListPreferenceObsoleteFragment contains all the old logic but: 1. Logic about BluetoothPairingPreferenceController(ag/2239482), since this preference shouldn't be checked in without the flag :( This cl also adds logic in MasterSwitchPreferenceController to flip these two pages. Following cl will refactor these fragment to make it compatible to new framework. Bug: 35877041 Test: RunSettingsRoboTests Change-Id: I1cc1bc2d49d8a3e11c3127e56f6409fbc84028d8
This commit is contained in:
@@ -49,6 +49,7 @@ import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.location.ScanningSettings;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
@@ -64,7 +65,6 @@ import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
|
||||
@@ -72,7 +72,9 @@ import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
|
||||
/**
|
||||
* BluetoothSettings is the Settings screen for Bluetooth configuration and
|
||||
* connection management.
|
||||
*
|
||||
*/
|
||||
// TODO: Refactor this fragment
|
||||
public class BluetoothSettings extends DeviceListPreferenceFragment implements Indexable {
|
||||
private static final String TAG = "BluetoothSettings";
|
||||
|
||||
@@ -107,7 +109,8 @@ public class BluetoothSettings extends DeviceListPreferenceFragment implements I
|
||||
private BluetoothPairingPreferenceController mPairingPrefController;
|
||||
|
||||
// For Search
|
||||
private static final String DATA_KEY_REFERENCE = "main_toggle_bluetooth";
|
||||
@VisibleForTesting
|
||||
static final String DATA_KEY_REFERENCE = "main_toggle_bluetooth";
|
||||
|
||||
// accessed from inner class (not private to avoid thunks)
|
||||
FooterPreference mMyDevicePreference;
|
||||
@@ -593,23 +596,18 @@ public class BluetoothSettings extends DeviceListPreferenceFragment implements I
|
||||
data.key = DATA_KEY_REFERENCE;
|
||||
result.add(data);
|
||||
|
||||
// Add cached paired BT devices
|
||||
LocalBluetoothManager lbtm = Utils.getLocalBtManager(context);
|
||||
// LocalBluetoothManager.getInstance can return null if the device does not
|
||||
// support bluetooth (e.g. the emulator).
|
||||
if (lbtm != null) {
|
||||
Set<BluetoothDevice> bondedDevices =
|
||||
lbtm.getBluetoothAdapter().getBondedDevices();
|
||||
|
||||
for (BluetoothDevice device : bondedDevices) {
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = device.getName();
|
||||
data.screenTitle = res.getString(R.string.bluetooth_settings);
|
||||
data.enabled = enabled;
|
||||
result.add(data);
|
||||
}
|
||||
}
|
||||
// Removed paired bluetooth device indexing. See BluetoothSettingsObsolete.java.
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
if (!FeatureFactory.getFactory(context).getBluetoothFeatureProvider(
|
||||
context).isPairingPageEnabled()) {
|
||||
keys.add(DATA_KEY_REFERENCE);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user