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

Commit 72ebf3a7 authored by Chienyuan's avatar Chienyuan Committed by Chienyuan Huang
Browse files

SAP: set priority after user confirm access permission

For current design, the priority will stay in PRIORITY_UNDEFINED even
thought SAP connected, it will cause the toggle in device detail page
display wrong state. Set priority after user confirm access permission
to fix this.

Use EXTRA_ACCESS_REQUEST_TYPE instead of mIsWaitingAuthorization when
receive ACTION_CONNECTION_ACCESS_REPLY intend, it can prevent we mislead
by intend for other profiles, such as MAP and PBAP.

Bug:130870422
Test: connect SAP, check settings UI
Change-Id: I1549fbd173180bc8871ffc661773d29fabd81424
parent 87f96493
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -782,8 +782,9 @@ public class SapService extends ProfileService {

            if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY)) {
                Log.v(TAG, " - Received BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY");
                if (!mIsWaitingAuthorization) {
                    // this reply is not for us

                int requestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, -1);
                if (requestType != BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
                    return;
                }

@@ -800,6 +801,9 @@ public class SapService extends ProfileService {
                            Log.v(TAG, "setSimAccessPermission(ACCESS_ALLOWED) result=" + result);
                        }
                    }
                    boolean result = setPriority(mRemoteDevice, BluetoothProfile.PRIORITY_ON);
                    Log.d(TAG, "setPriority ON, result = " + result);

                    try {
                        if (mConnSocket != null) {
                            // start obex server and rfcomm connection
@@ -818,6 +822,8 @@ public class SapService extends ProfileService {
                            Log.v(TAG, "setSimAccessPermission(ACCESS_REJECTED) result=" + result);
                        }
                    }
                    boolean result = setPriority(mRemoteDevice, BluetoothProfile.PRIORITY_OFF);
                    Log.d(TAG, "setPriority OFF, result = " + result);
                    // Ensure proper cleanup, and prepare for new connect.
                    mSessionStatusHandler.sendEmptyMessage(MSG_SERVERSESSION_CLOSE);
                }