Fix NPE in WirelessSettings.onCreate() for SDK and non-BT devices.
Fix NPE when entering Settings app in the SDK (and for devices without Bluetooth). Also remove the "Bluetooth settings" item in addition to the Bluetooth toggle item from Wireless settings when BT is missing. Bug: 4149307 Change-Id: Iecc5960a193cf88664d3217b4d7bdbc2276dabc0
This commit is contained in:
@@ -50,17 +50,19 @@ public final class BluetoothEnabler implements Preference.OnPreferenceChangeList
|
||||
}
|
||||
};
|
||||
|
||||
public BluetoothEnabler(Context context, LocalBluetoothAdapter adapter,
|
||||
CheckBoxPreference checkBox) {
|
||||
public BluetoothEnabler(Context context, CheckBoxPreference checkBox) {
|
||||
mContext = context;
|
||||
mCheckBox = checkBox;
|
||||
mOriginalSummary = checkBox.getSummary();
|
||||
checkBox.setPersistent(false);
|
||||
|
||||
mLocalAdapter = adapter;
|
||||
if (adapter == null) {
|
||||
LocalBluetoothManager manager = LocalBluetoothManager.getInstance(context);
|
||||
if (manager == null) {
|
||||
// Bluetooth is not supported
|
||||
mLocalAdapter = null;
|
||||
checkBox.setEnabled(false);
|
||||
} else {
|
||||
mLocalAdapter = manager.getBluetoothAdapter();
|
||||
}
|
||||
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
}
|
||||
|
Reference in New Issue
Block a user