Merge "settings: Fix more NPEs when bluetooth is missing." into nyc-dev am: 023f7033ef

am: fe87ed9d40

* commit 'fe87ed9d406be2fa5ebe33f0213d66d77925b629':
  settings: Fix more NPEs when bluetooth is missing.
This commit is contained in:
Prathmesh Prabhu
2016-03-15 21:05:53 +00:00
committed by android-build-merger
2 changed files with 8 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings; package com.android.settings;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothManager;
import android.content.Context; import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
@@ -96,7 +97,10 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
BluetoothManager btManager = (BluetoothManager) BluetoothManager btManager = (BluetoothManager)
context.getSystemService(Context.BLUETOOTH_SERVICE); context.getSystemService(Context.BLUETOOTH_SERVICE);
if (btManager != null) { if (btManager != null) {
btManager.getAdapter().factoryReset(); BluetoothAdapter btAdapter = btManager.getAdapter();
if (btAdapter != null) {
btAdapter.factoryReset();
}
} }
ImsManager.factoryReset(context); ImsManager.factoryReset(context);

View File

@@ -454,6 +454,9 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
return STATE_UNKNOWN; // On emulator? return STATE_UNKNOWN; // On emulator?
} }
sLocalBluetoothAdapter = manager.getBluetoothAdapter(); sLocalBluetoothAdapter = manager.getBluetoothAdapter();
if (sLocalBluetoothAdapter == null) {
return STATE_UNKNOWN; // On emulator?
}
} }
return bluetoothStateToFiveState(sLocalBluetoothAdapter.getBluetoothState()); return bluetoothStateToFiveState(sLocalBluetoothAdapter.getBluetoothState());
} }