Merge "Add Rename device on Bluetooth screen" into pi-dev am: 667cbc5846
am: 5783578aad
Change-Id: Ibc9a0adc76de9c411391d612238fa39d42d1ddc3
This commit is contained in:
@@ -32,7 +32,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
@@ -44,16 +43,16 @@ public class BluetoothDeviceNamePreferenceController extends BasePreferenceContr
|
||||
LifecycleObserver, OnStart, OnStop {
|
||||
private static final String TAG = "BluetoothNamePrefCtrl";
|
||||
|
||||
public static final String KEY_DEVICE_NAME = "device_name";
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
Preference mPreference;
|
||||
private LocalBluetoothManager mLocalManager;
|
||||
private LocalBluetoothAdapter mLocalAdapter;
|
||||
|
||||
public BluetoothDeviceNamePreferenceController(Context context, Lifecycle lifecycle) {
|
||||
this(context, (LocalBluetoothAdapter) null);
|
||||
/**
|
||||
* Constructor exclusively used for Slice.
|
||||
*/
|
||||
public BluetoothDeviceNamePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
|
||||
mLocalManager = Utils.getLocalBtManager(context);
|
||||
if (mLocalManager == null) {
|
||||
@@ -61,22 +60,12 @@ public class BluetoothDeviceNamePreferenceController extends BasePreferenceContr
|
||||
return;
|
||||
}
|
||||
mLocalAdapter = mLocalManager.getBluetoothAdapter();
|
||||
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor exclusively used for Slice.
|
||||
*/
|
||||
public BluetoothDeviceNamePreferenceController(Context context) {
|
||||
this(context, (Lifecycle) null);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
BluetoothDeviceNamePreferenceController(Context context, LocalBluetoothAdapter localAdapter) {
|
||||
super(context, KEY_DEVICE_NAME);
|
||||
BluetoothDeviceNamePreferenceController(Context context, LocalBluetoothAdapter localAdapter,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mLocalAdapter = localAdapter;
|
||||
}
|
||||
|
||||
@@ -102,11 +91,6 @@ public class BluetoothDeviceNamePreferenceController extends BasePreferenceContr
|
||||
return mLocalAdapter != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_DEVICE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
updateDeviceName(preference);
|
||||
@@ -134,7 +118,7 @@ public class BluetoothDeviceNamePreferenceController extends BasePreferenceContr
|
||||
public Preference createBluetoothDeviceNamePreference(PreferenceScreen screen, int order) {
|
||||
mPreference = new Preference(screen.getContext());
|
||||
mPreference.setOrder(order);
|
||||
mPreference.setKey(KEY_DEVICE_NAME);
|
||||
mPreference.setKey(getPreferenceKey());
|
||||
screen.addPreference(mPreference);
|
||||
|
||||
return mPreference;
|
||||
|
Reference in New Issue
Block a user