diff options
author | Danny Baumann <dannybaumann@web.de> | 2013-05-31 09:46:34 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2013-05-31 09:46:34 +0200 |
commit | 3c231e568b7fc15390d9881c43286629f4c2f64a (patch) | |
tree | f829e19b22ea30a13e1c55f3d7739f11034f1a7e | |
parent | 7f1df9eed0792f7a5c1d88979aa098c1facdbd42 (diff) | |
download | android_packages_apps_Bluetooth-3c231e568b7fc15390d9881c43286629f4c2f64a.tar.gz android_packages_apps_Bluetooth-3c231e568b7fc15390d9881c43286629f4c2f64a.tar.bz2 android_packages_apps_Bluetooth-3c231e568b7fc15390d9881c43286629f4c2f64a.zip |
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
-rw-r--r-- | src/com/android/bluetooth/map/BluetoothMasService.java | 20 | ||||
-rw-r--r-- | src/com/android/bluetooth/map/BluetoothMns.java | 5 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/com/android/bluetooth/map/BluetoothMasService.java b/src/com/android/bluetooth/map/BluetoothMasService.java index b356f84be..41de224f5 100644 --- a/src/com/android/bluetooth/map/BluetoothMasService.java +++ b/src/com/android/bluetooth/map/BluetoothMasService.java @@ -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()); diff --git a/src/com/android/bluetooth/map/BluetoothMns.java b/src/com/android/bluetooth/map/BluetoothMns.java index 9369846b2..b176e0c96 100644 --- a/src/com/android/bluetooth/map/BluetoothMns.java +++ b/src/com/android/bluetooth/map/BluetoothMns.java @@ -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); |