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

Commit 9eb34d0f authored by Danny Baumann's avatar Danny Baumann Committed by Steve Kondik
Browse files

Fix MAP SDP record generation [3/3].

Register MAS server sockets for UUID/port pair instead of only port so
lower layers have the chance to correctly generate the SDP record.

Change-Id: Ia93f79a290aa23b4ad8370096606678c31d12df5
parent bfc70a42
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
@@ -183,11 +184,13 @@ public class BluetoothMasService extends Service {
    public static class MasInstanceInfo {
        int mSupportedMessageTypes;
        Class<? extends MnsClient> mMnsClientClass;
        String mName;
        int mRfcommPort;

        public MasInstanceInfo(int smt, Class<? extends MnsClient> _class, int port) {
        public MasInstanceInfo(int smt, Class<? extends MnsClient> _class, String name, int port) {
            mSupportedMessageTypes = smt;
            mMnsClientClass = _class;
            mName = name;
            mRfcommPort = port;
        }
    }
@@ -201,8 +204,8 @@ public class BluetoothMasService extends Service {
    // SDP records supported message types and port number
    // Please refer sdptool.c, BluetoothService.java, & init.qcom.rc
    static {
        MAS_INS_INFO[0] = new MasInstanceInfo(MESSAGE_TYPE_SMS_MMS, BluetoothMnsSmsMms.class, 16);
        MAS_INS_INFO[1] = new MasInstanceInfo(MESSAGE_TYPE_EMAIL, BluetoothMnsEmail.class, 17);
        MAS_INS_INFO[0] = new MasInstanceInfo(MESSAGE_TYPE_SMS_MMS, BluetoothMnsSmsMms.class, "SMS/MMS", 16);
        MAS_INS_INFO[1] = new MasInstanceInfo(MESSAGE_TYPE_EMAIL, BluetoothMnsEmail.class, "E-Mail", 17);
    }

    private ContentObserver mEmailAccountObserver;
@@ -497,7 +500,8 @@ public class BluetoothMasService extends Service {
        public BluetoothMasObexConnectionManager() {
            for (int i = 0; i < MAX_INSTANCES; i ++) {
                mConnections.add(new BluetoothMasObexConnection(
                        MAS_INS_INFO[i].mSupportedMessageTypes, i, MAS_INS_INFO[i].mRfcommPort));
                        MAS_INS_INFO[i].mSupportedMessageTypes, i,
                        MAS_INS_INFO[i].mName, MAS_INS_INFO[i].mRfcommPort));
            }
        }

@@ -631,13 +635,15 @@ public class BluetoothMasService extends Service {
        private BluetoothMasObexServer mMapServer = null;

        private int mSupportedMessageTypes;
        private String mName;
        private int mPortNum;
        private int mMasId;
        boolean mWaitingForConfirmation = false;

        public BluetoothMasObexConnection(int supportedMessageTypes, int masId, int portNumber) {
        public BluetoothMasObexConnection(int supportedMessageTypes, int masId, String name, int portNumber) {
                mSupportedMessageTypes = supportedMessageTypes;
                mMasId = masId;
                mName = name;
                mPortNum = portNumber;
        }

@@ -662,7 +668,9 @@ public class BluetoothMasService extends Service {
            // It's possible that create will fail in some cases. retry for 10 times
            for (int i = 0; i < CREATE_RETRY_TIME && !mInterrupted; i++) {
                try {
                    mServerSocket = mAdapter.listenUsingRfcommOn(mPortNum);
                    mServerSocket = mAdapter.listenUsingRfcommWithServiceRecordOn(
                            "OBEX Message Access " + mName + " Server",
                            mPortNum, BluetoothUuid.MessageAccessServer.getUuid());
                    initSocketOK = true;
                } catch (IOException e) {
                    Log.e(TAG, "Error create RfcommServerSocket " + e.toString());
+2 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ package com.android.bluetooth.map;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.bluetooth.BluetoothUuid;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -121,8 +122,6 @@ public class BluetoothMns implements MessageNotificationListener {
    private EventHandler mSessionHandler;

    private List<MnsClient> mMnsClients = new ArrayList<MnsClient>();
    public static final ParcelUuid BluetoothUuid_ObexMns = ParcelUuid
            .fromString("00001133-0000-1000-8000-00805F9B34FB");

    private HashSet<Integer> mWaitingMasId = new HashSet<Integer>();
    private final Queue<Pair<Integer, String>> mEventQueue = new ConcurrentLinkedQueue<Pair<Integer, String>>();
@@ -645,7 +644,7 @@ public class BluetoothMns implements MessageNotificationListener {
            BluetoothSocket btSocket = null;
            try {
                btSocket = device.createInsecureRfcommSocketToServiceRecord(
                        BluetoothUuid_ObexMns.getUuid());
                        BluetoothUuid.MessageNotificationServer.getUuid());
                btSocket.connect();
            } catch (IOException e) {
                Log.e(TAG, "BtSocket Connect error " + e.getMessage(), e);