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

Commit 401a24ff authored by Hemant Gupta's avatar Hemant Gupta Committed by android-build-merger
Browse files

Merge "OPP: Remove sdp record during BT off to prevent leak" am: b2b8ac03

am: cd230909

Change-Id: I1fb2cbbfecde5b6a389c60ec62163dded3b63cb2
parents f04bc262 cd230909
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -227,14 +227,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case STOP_LISTENER:
                    if (mAdapter != null && mOppSdpHandle >= 0
                            && SdpManager.getDefaultManager() != null) {
                        if (D) Log.d(TAG, "Removing SDP record mOppSdpHandle :" + mOppSdpHandle);
                        boolean status =
                                SdpManager.getDefaultManager().removeSdpRecord(mOppSdpHandle);
                        Log.d(TAG, "RemoveSDPrecord returns " + status);
                        mOppSdpHandle = -1;
                    }
                    stopListeners();
                    mListenStarted = false;
                    //Stop Active INBOUND Transfer
@@ -366,8 +358,10 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                            + " mServerSocket:" + mServerSocket);
            return;
        }
        mOppSdpHandle =
                sdpManager.createOppOpsRecord("OBEX Object Push", mServerSocket.getRfcommChannel(),
                        mServerSocket.getL2capPsm(), 0x0102, SUPPORTED_OPP_FORMAT);
        if (D) Log.d(TAG, "mOppSdpHandle :" + mOppSdpHandle);
    }

    @Override
@@ -1066,6 +1060,12 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
    }

    private void stopListeners() {
        if (mAdapter != null && mOppSdpHandle >= 0 && SdpManager.getDefaultManager() != null) {
            if (D) Log.d(TAG, "Removing SDP record mOppSdpHandle :" + mOppSdpHandle);
            boolean status = SdpManager.getDefaultManager().removeSdpRecord(mOppSdpHandle);
            Log.d(TAG, "RemoveSDPrecord returns " + status);
            mOppSdpHandle = -1;
        }
        if (mServerSocket != null) {
            mServerSocket.shutdown(false);
            mServerSocket = null;