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

Commit 6c1e7442 authored by Hemant Gutpa's avatar Hemant Gutpa Committed by Andre Eisenbach
Browse files

PBAP: Set Pbap connection state to DISCONNECTED on ACL_DISCONNECT.

Usecase:
1) Establish Pbap session with Pbap client.
2) Remote goes out of range or turns off BT so that
   Pbap server receives ACL_DISCONNECTED

Issue:
Pbap connection state is not changed to STATE_DISCONNECTED.

Root Cause:
stopObexServerSession() is not invoked from ServerSession
close event to set the state to STATE_DISCONNECTED.

Fix:
Handle the case to set state to STATE_DISCONNECTED on
receiving intent ACL_DISCONNECTED.

Test: PBAP is now always restarted in case of ACL disconnect
leading to no issues in PBAP reconnection as confirmed after
following above usecase.

Bug: 65714305
Change-Id: I2af5c0a691d393a9aae869811109453d06021b70
parent 59cb37dd
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -266,15 +266,16 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
            return;
        }

        if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED) && mIsWaitingAuthorization) {
        if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            if (mRemoteDevice == null) return;
            if (DEBUG) Log.d(TAG,"ACL disconnected for "+ device);
            if (mRemoteDevice.equals(device)) {
            if (mIsWaitingAuthorization && mRemoteDevice.equals(device)) {
                mSessionStatusHandler.removeMessages(USER_TIMEOUT);
                mSessionStatusHandler.obtainMessage(USER_TIMEOUT).sendToTarget();
            }
            mSessionStatusHandler.obtainMessage(MSG_SERVERSESSION_CLOSE).sendToTarget();
            return;
        }

@@ -305,7 +306,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
                    if (mConnSocket != null) {
                        startObexServerSession();
                    } else {
                        stopObexServerSession();
                        mSessionStatusHandler.obtainMessage(MSG_SERVERSESSION_CLOSE).sendToTarget();
                    }
                } catch (IOException ex) {
                    Log.e(TAG, "Caught the error: " + ex.toString());
@@ -318,7 +319,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
                        Log.v(TAG, "setPhonebookAccessPermission(ACCESS_REJECTED)=" + result);
                    }
                }
                stopObexServerSession();
                mSessionStatusHandler.obtainMessage(MSG_SERVERSESSION_CLOSE).sendToTarget();
            }
            return;
        }