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

Commit 7699bec7 authored by Hemant Gupta's avatar Hemant Gupta Committed by android-build-merger
Browse files

Merge "SAP: Remove sdp record while BT is being turned off to prevent leak" am: a51595cc

am: d5438b4b

* commit 'd5438b4b':
  SAP: Remove sdp record while BT is being turned off to prevent leak
parents 8f0c0646 d5438b4b
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -121,7 +121,14 @@ public class SapService extends ProfileService {
        }
    }


    private void removeSdpRecord() {
        if (mAdapter != null && mSdpHandle >= 0 &&
                                SdpManager.getDefaultManager() != null) {
            if(VERBOSE) Log.d(TAG, "Removing SDP record handle: " + mSdpHandle);
            boolean status = SdpManager.getDefaultManager().removeSdpRecord(mSdpHandle);
            mSdpHandle = -1;
        }
    }

    private void startRfcommSocketListener() {
        if (VERBOSE) Log.v(TAG, "Sap Service startRfcommSocketListener");
@@ -148,10 +155,7 @@ public class SapService extends ProfileService {
                //       for multiple connections.
                mServerSocket = mAdapter.listenUsingRfcommOn(
                        BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP, true, true);
                if (mSdpHandle >= 0) {
                    SdpManager.getDefaultManager().removeSdpRecord(mSdpHandle);
                    if (VERBOSE) Log.d(TAG, "Removing SDP record");
                }
                removeSdpRecord();
                mSdpHandle = SdpManager.getDefaultManager().createSapsRecord(SDP_SAP_SERVICE_NAME,
                        mServerSocket.getChannel(), SDP_SAP_VERSION);
            } catch (IOException e) {
@@ -656,6 +660,7 @@ public class SapService extends ProfileService {
            mIsWaitingAuthorization = false;
            cancelUserTimeoutAlarm();
        }
        removeSdpRecord();
        mSessionStatusHandler.removeCallbacksAndMessages(null);
        // Request release of all resources
        mSessionStatusHandler.obtainMessage(SHUTDOWN).sendToTarget();