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

Commit 9e90e3d5 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

PBAP: Remove the PBAP pop up in various scenarios

    -If ACL is disconnected by remote device OR DUT(unbond from
    the DUT) before accepting incoming authorization request for
    PBAP connection. PBAP authorization pop up should be removed.

    - If authorization is cancelled due to USER_TIMEOUT(30 second),
    then PBAP authorization pop up should be removed.

Change-Id: I0a69f23c7882a43de9fe207c84926de91713c79b
parent 43ad30c6
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -227,6 +227,7 @@
            <intent-filter>
            <intent-filter>
                <action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
                <action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
                <action android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REPLY" />
                <action android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REPLY" />
                <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            </intent-filter>
        </receiver>
        </receiver>
+21 −1
Original line number Original line Diff line number Diff line
@@ -256,6 +256,26 @@ public class BluetoothPbapService extends Service {
            } else {
            } else {
                removeTimeoutMsg = false;
                removeTimeoutMsg = false;
            }
            }
        } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED) &&
                   isWaitingAuthorization) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            if (mRemoteDevice == null || device == null) {
                Log.e(TAG, "Unexpected error!");
                return;
            }

            if (DEBUG) Log.d(TAG,"ACL disconnected for "+ device);

            if (mRemoteDevice.equals(device)) {
                Intent cancelIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL);
                cancelIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
                cancelIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                                      BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
                sendBroadcast(cancelIntent);
                isWaitingAuthorization = false;
                stopObexServerSession();
            }
        } else if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY)) {
        } else if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY)) {
            int requestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
            int requestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                                           BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
                                           BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
@@ -646,7 +666,7 @@ public class BluetoothPbapService extends Service {
                    break;
                    break;
                case USER_TIMEOUT:
                case USER_TIMEOUT:
                    Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL);
                    Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL);
                    intent.setClassName(ACCESS_AUTHORITY_PACKAGE, ACCESS_AUTHORITY_CLASS);
                    intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice);
                    intent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                    intent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                                    BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
                                    BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
                    sendBroadcast(intent);
                    sendBroadcast(intent);