Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5cb62f5 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android Git Automerger
Browse files

am 93724840: Don\'t crash if there\'s no bluetooth functionality (such as in...

am 93724840: Don\'t crash if there\'s no bluetooth functionality (such as in an emulator) do not merge.

* commit '93724840':
  Don't crash if there's no bluetooth functionality (such as in an emulator) do not merge.
parents 7b276302 93724840
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -138,21 +138,26 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
    public void onResume() {
        // resume BluetoothEnabler before calling super.onResume() so we don't get
        // any onDeviceAdded() callbacks before setting up view in updateContent()
        if (mBluetoothEnabler != null) {
            mBluetoothEnabler.resume();
        }
        super.onResume();

        if (mDiscoverableEnabler != null) {
            mDiscoverableEnabler.resume();
        }
        getActivity().registerReceiver(mReceiver, mIntentFilter);

        if (mLocalAdapter != null) {
            updateContent(mLocalAdapter.getBluetoothState(), mActivityStarted);
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mBluetoothEnabler != null) {
            mBluetoothEnabler.pause();
        }
        getActivity().unregisterReceiver(mReceiver);
        if (mDiscoverableEnabler != null) {
            mDiscoverableEnabler.pause();
@@ -161,6 +166,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        if (mLocalAdapter == null) return;
        boolean bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON;
        boolean isDiscovering = mLocalAdapter.isDiscovering();
        int textId = isDiscovering ? R.string.bluetooth_searching_for_devices :
+3 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ public abstract class DeviceListPreferenceFragment extends
    @Override
    public void onResume() {
        super.onResume();
        if (mLocalManager == null) return;

        mLocalManager.setForegroundActivity(getActivity());
        mLocalManager.getEventManager().registerCallback(this);
@@ -106,6 +107,8 @@ public abstract class DeviceListPreferenceFragment extends
    @Override
    public void onPause() {
        super.onPause();
        if (mLocalManager == null) return;

        removeAllDevices();
        mLocalManager.setForegroundActivity(null);
        mLocalManager.getEventManager().unregisterCallback(this);