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

Commit 4a614336 authored by Hemant Gupta's avatar Hemant Gupta Committed by android-build-merger
Browse files

OPP: Remove sdp record during BT off to prevent leak

am: 0069fef3

Change-Id: I90655073a1731f6f94afe0f9f0283d457285ca9c
parents bb709f54 0069fef3
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
@@ -227,14 +227,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            switch (msg.what) {
                case STOP_LISTENER:
                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();
                    stopListeners();
                    mListenStarted = false;
                    mListenStarted = false;
                    //Stop Active INBOUND Transfer
                    //Stop Active INBOUND Transfer
@@ -366,8 +358,10 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                            + " mServerSocket:" + mServerSocket);
                            + " mServerSocket:" + mServerSocket);
            return;
            return;
        }
        }
        mOppSdpHandle =
                sdpManager.createOppOpsRecord("OBEX Object Push", mServerSocket.getRfcommChannel(),
                sdpManager.createOppOpsRecord("OBEX Object Push", mServerSocket.getRfcommChannel(),
                        mServerSocket.getL2capPsm(), 0x0102, SUPPORTED_OPP_FORMAT);
                        mServerSocket.getL2capPsm(), 0x0102, SUPPORTED_OPP_FORMAT);
        if (D) Log.d(TAG, "mOppSdpHandle :" + mOppSdpHandle);
    }
    }


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


    private void stopListeners() {
    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) {
        if (mServerSocket != null) {
            mServerSocket.shutdown(false);
            mServerSocket.shutdown(false);
            mServerSocket = null;
            mServerSocket = null;