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

Commit 4a73afa5 authored by Steve Kondik's avatar Steve Kondik
Browse files

Bluetooth: Add support for enabling Bluetooth in airplane mode.

Check AIRPLANE_MODE_TOGGLEABLE_RADIOS for RADIO_BLUETOOTH so Bluetooth
can be enabled in airplane mode if configured.
parent 72b49de2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
                                                "Need BLUETOOTH_ADMIN permission");

        // Airplane mode can prevent Bluetooth radio from being turned on.
        if (mIsAirplaneSensitive && isAirplaneModeOn()) {
        if (mIsAirplaneSensitive && isAirplaneModeOn() && !isAirplaneToggleable()) {
            return false;
        }
        if (mBluetoothState != BluetoothDevice.BLUETOOTH_STATE_OFF) {
@@ -372,7 +372,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
                mEventLoop.onModeChanged(getModeNative());
            }

            if (mIsAirplaneSensitive && isAirplaneModeOn()) {
            if (mIsAirplaneSensitive && isAirplaneModeOn() && !isAirplaneToggleable()) {
                disable(false);
            }

@@ -1166,6 +1166,13 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
                Settings.System.AIRPLANE_MODE_ON, 0) == 1;
    }

     private boolean isAirplaneToggleable() {
         String toggleableRadios = Settings.System.getString(mContext.getContentResolver(),
                 Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
         return toggleableRadios != null
             && toggleableRadios.contains(Settings.System.RADIO_BLUETOOTH);
     }

    @Override
    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("\nmIsAirplaneSensitive = " + mIsAirplaneSensitive + "\n");
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
    <bool name="def_airplane_mode_on">false</bool>
    <!-- Comma-separated list of bluetooth, wifi, and cell. -->
    <string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi</string>
    <string name="airplane_mode_toggleable_radios" translatable="false">wifi</string>
    <string name="airplane_mode_toggleable_radios" translatable="false">wifi,bluetooth</string>
    <bool name="def_auto_time">true</bool>
    <bool name="def_accelerometer_rotation">true</bool>
    <!-- Default screen brightness, from 0 to 255.  102 is 40%. -->