Use BluetoothAdapter instead of LocalBluetoothAdapter

LocalBluetoothAdapter only has a few APIs that is not supported
by BluetoothAdapter, and lots of LocalBluetoothAdapter function
pass parameter to BluetoothAdapter directly.
Do the refactor in Settings, use BluetoothAdapter instead of
LocalBluetoothAdapter.

Bug: 111769754
Test: make -j42 RunSettingsRoboTests
Change-Id: I88e5a8377b5d1106c7679e6a8c3fd1ca1a80ea6f
This commit is contained in:
hughchen
2018-07-26 11:22:01 +08:00
parent 75bafefa49
commit e94b02206e
32 changed files with 327 additions and 341 deletions

View File

@@ -26,8 +26,6 @@ import com.android.settings.location.ScanningSettings;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.utils.AnnotationSpan;
import com.android.settings.widget.SwitchWidgetController;
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -43,10 +41,6 @@ public class BluetoothSwitchPreferenceController
implements LifecycleObserver, OnStart, OnStop,
SwitchWidgetController.OnSwitchChangeListener, View.OnClickListener {
@VisibleForTesting
LocalBluetoothAdapter mBluetoothAdapter;
private LocalBluetoothManager mBluetoothManager;
private BluetoothEnabler mBluetoothEnabler;
private RestrictionUtils mRestrictionUtils;
private SwitchWidgetController mSwitch;
@@ -56,15 +50,12 @@ public class BluetoothSwitchPreferenceController
public BluetoothSwitchPreferenceController(Context context,
SwitchWidgetController switchController,
FooterPreference footerPreference) {
this(context, Utils.getLocalBtManager(context), new RestrictionUtils(), switchController,
footerPreference);
this(context, new RestrictionUtils(), switchController, footerPreference);
}
@VisibleForTesting
public BluetoothSwitchPreferenceController(Context context,
LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils,
public BluetoothSwitchPreferenceController(Context context, RestrictionUtils restrictionUtils,
SwitchWidgetController switchController, FooterPreference footerPreference) {
mBluetoothManager = bluetoothManager;
mRestrictionUtils = restrictionUtils;
mSwitch = switchController;
mContext = context;
@@ -73,12 +64,9 @@ public class BluetoothSwitchPreferenceController
mSwitch.setupView();
updateText(mSwitch.isChecked());
if (mBluetoothManager != null) {
mBluetoothAdapter = mBluetoothManager.getBluetoothAdapter();
}
mBluetoothEnabler = new BluetoothEnabler(context,
switchController,
FeatureFactory.getFactory(context).getMetricsFeatureProvider(), mBluetoothManager,
FeatureFactory.getFactory(context).getMetricsFeatureProvider(),
MetricsEvent.ACTION_SETTINGS_MASTER_SWITCH_BLUETOOTH_TOGGLE,
mRestrictionUtils);
mBluetoothEnabler.setToggleCallback(this);