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

Commit 409c6a10 authored by Nitin Arora's avatar Nitin Arora Committed by Linux Build Service Account
Browse files

Bluetooth: Send Bluetooth Off intent based in BLEApp count

This change checks for the precense of an Always On
APP while moving Bluetooth state from ON to BLE_ON
state. If there is an app present, BT_OFF intent is
immidiately sent, else the intent is sent when BT is
completely turned OFF. This prevents the intermediate
state where BT Off intent, enables the BT toggle switch
while BT core services are still turning off.

Change-Id: I169af5a9aedd18e38ad990a793a437ac40cbe9ef
CRs-Fixed: 1047892
parent 2464d771
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    private final BluetoothHandler mHandler;
    private int mErrorRecoveryRetryCounter;
    private final int mSystemUiUid;
    private boolean mIntentPending = false;

    private void registerForAirplaneMode(IntentFilter filter) {
        final ContentResolver resolver = mContext.getContentResolver();
@@ -1460,7 +1461,10 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                    unbindAndFinish();
                    sendBleStateChanged(prevState, newState);
                    // Don't broadcast as it has already been broadcast before
                    if(!mIntentPending)
                        isStandardBroadcast = false;
                    else
                        mIntentPending = false;

                } else if (!intermediate_off) {
                    // connect to GattService
@@ -1488,6 +1492,13 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                    // Broadcast as STATE_OFF
                    newState = BluetoothAdapter.STATE_OFF;
                    sendBrEdrDownCallback();
                    if(!isBleAppPresent()){
                        isStandardBroadcast = false;
                        mIntentPending = true;
                    } else {
                        mIntentPending = false;
                        isStandardBroadcast = true;
                    }
                }
            } else if (newState == BluetoothAdapter.STATE_ON) {
                boolean isUp = (newState==BluetoothAdapter.STATE_ON);