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

Commit f9e3eaa9 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Gerrit Code Review
Browse files

Merge "MAP: CleanUp for SDP record in MAP Service shutdown"

parents 68277e56 4b26248d
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -130,6 +130,17 @@ public class BluetoothMapMasInstance implements IObexConnectionHandler {
        init();
    }

    private void removeSdpRecord() {
        if (mAdapter != null && mSdpHandle >= 0 &&
                SdpManager.getDefaultManager() != null) {
            if (V) Log.d(TAG, "Removing SDP record for MAS instance: " + mMasInstanceId +
                    " Object reference: " + this + "SDP handle: " + mSdpHandle);
            boolean status = SdpManager.getDefaultManager().removeSdpRecord(mSdpHandle);
            Log.d(TAG, "RemoveSDPrecord returns " + status);
            mSdpHandle = -1;
        }
    }

    /* Needed only for test */
    protected BluetoothMapMasInstance() {
        TAG = "BluetoothMapMasInstance" + sInstanceCounter++;
@@ -277,11 +288,7 @@ public class BluetoothMapMasInstance implements IObexConnectionHandler {
                Log.e(TAG, "Failed to start the listeners");
                return;
            }
            if(mSdpHandle >= 0) {
                SdpManager.getDefaultManager().removeSdpRecord(mSdpHandle);
                if(V) Log.d(TAG, "Removing SDP record for MAS instance: " + mMasInstanceId +
                        " Object reference: " + this + "SDP handle: " + mSdpHandle);
            }
            removeSdpRecord();
            mSdpHandle = createMasSdpRecord(mServerSockets.getRfcommChannel(),
                    mServerSockets.getL2capPsm());
            // Here we might have changed crucial data, hence reset DB identifier
@@ -399,6 +406,8 @@ public class BluetoothMapMasInstance implements IObexConnectionHandler {
            mObserver = null;
        }

        removeSdpRecord();

        closeConnectionSocket();

        closeServerSockets(true);