Loading android/app/src/com/android/bluetooth/DeviceWorkArounds.java +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ public final class DeviceWorkArounds { public static final String HONDA_CARKIT = "64:D4:BD"; public static final String SYNC_CARKIT = "D0:39:72"; public static final String BREZZA_ZDI_CARKIT = "28:a1:83"; public static final String MERCEDES_BENZ_CARKIT = "00:26:e8"; /** * @hide Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +2 −1 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelUuid; Loading Loading @@ -394,7 +395,7 @@ public class AdapterService extends Service { public void onCreate() { super.onCreate(); debugLog("onCreate()"); mRemoteDevices = new RemoteDevices(this); mRemoteDevices = new RemoteDevices(this, Looper.getMainLooper()); mRemoteDevices.init(); mBinder = new AdapterServiceBinder(this); mAdapterProperties = new AdapterProperties(this); Loading android/app/src/com/android/bluetooth/btservice/RemoteDevices.java +27 −15 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelUuid; import android.support.annotation.VisibleForTesting; Loading Loading @@ -59,6 +60,30 @@ final class RemoteDevices { private final HashMap<String, DeviceProperties> mDevices; private Queue<String> mDeviceQueue; private final Handler mHandler; private class RemoteDevicesHandler extends Handler { /** * Handler must be created from an explicit looper to avoid threading ambiguity * @param looper The looper that this handler should be executed on */ RemoteDevicesHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_UUID_INTENT: BluetoothDevice device = (BluetoothDevice) msg.obj; if (device != null) { sendUuidIntent(device); } break; } } } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading @@ -80,12 +105,13 @@ final class RemoteDevices { } }; RemoteDevices(AdapterService service) { RemoteDevices(AdapterService service, Looper looper) { sAdapter = BluetoothAdapter.getDefaultAdapter(); sAdapterService = service; sSdpTracker = new ArrayList<BluetoothDevice>(); mDevices = new HashMap<String, DeviceProperties>(); mDeviceQueue = new LinkedList<String>(); mHandler = new RemoteDevicesHandler(looper); } /** Loading Loading @@ -782,20 +808,6 @@ final class RemoteDevices { return batteryLevel * 100 / numberOfLevels; } private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_UUID_INTENT: BluetoothDevice device = (BluetoothDevice) msg.obj; if (device != null) { sendUuidIntent(device); } break; } } }; private static void errorLog(String msg) { Log.e(TAG, msg); } Loading android/app/src/com/android/bluetooth/map/BluetoothMapMessageListing.java +19 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package com.android.bluetooth.map; import android.util.Log; import android.util.Xml; import com.android.bluetooth.DeviceWorkArounds; import com.android.internal.util.FastXmlSerializer; Loading Loading @@ -90,11 +91,25 @@ public class BluetoothMapMessageListing { public byte[] encode(boolean includeThreadId, String version) throws UnsupportedEncodingException { StringWriter sw = new StringWriter(); XmlSerializer xmlMsgElement = new FastXmlSerializer(); XmlSerializer xmlMsgElement = null; boolean isBenzCarkit = DeviceWorkArounds.addressStartsWith( BluetoothMapService.getRemoteDevice().getAddress(), DeviceWorkArounds.MERCEDES_BENZ_CARKIT); try { if (isBenzCarkit) { Log.d(TAG, "java_interop: Remote is Mercedes Benz, " + "using Xml Workaround."); xmlMsgElement = Xml.newSerializer(); xmlMsgElement.setOutput(sw); xmlMsgElement.text("\n"); } else { xmlMsgElement = new FastXmlSerializer(); xmlMsgElement.setOutput(sw); xmlMsgElement.startDocument("UTF-8", true); xmlMsgElement.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); xmlMsgElement.text("\n"); xmlMsgElement.setFeature( "http://xmlpull.org/v1/doc/features.html#indent-output", true); } xmlMsgElement.startTag(null, "MAP-msg-listing"); xmlMsgElement.attribute(null, "version", version); // Do the XML encoding of list Loading android/app/src/com/android/bluetooth/map/BluetoothMapMessageListingElement.java +4 −3 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ */ package com.android.bluetooth.map; import com.android.bluetooth.DeviceWorkArounds; import com.android.bluetooth.map.BluetoothMapUtils.TYPE; import com.android.bluetooth.util.Interop; import org.xmlpull.v1.XmlSerializer; Loading Loading @@ -274,8 +274,9 @@ public class BluetoothMapMessageListingElement if (mSubject != null) { String stripped = BluetoothMapUtils.stripInvalidChars(mSubject); if (Interop.matchByAddress(Interop.INTEROP_MAP_ASCIIONLY, BluetoothMapService.getRemoteDevice().getAddress())) { if (DeviceWorkArounds.addressStartsWith(BluetoothMapService .getRemoteDevice().getAddress(), DeviceWorkArounds .MERCEDES_BENZ_CARKIT)) { stripped = stripped.replaceAll("[\\P{ASCII}&\"><]", ""); if (stripped.isEmpty()) { stripped = "---"; Loading Loading
android/app/src/com/android/bluetooth/DeviceWorkArounds.java +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ public final class DeviceWorkArounds { public static final String HONDA_CARKIT = "64:D4:BD"; public static final String SYNC_CARKIT = "D0:39:72"; public static final String BREZZA_ZDI_CARKIT = "28:a1:83"; public static final String MERCEDES_BENZ_CARKIT = "00:26:e8"; /** * @hide Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +2 −1 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelUuid; Loading Loading @@ -394,7 +395,7 @@ public class AdapterService extends Service { public void onCreate() { super.onCreate(); debugLog("onCreate()"); mRemoteDevices = new RemoteDevices(this); mRemoteDevices = new RemoteDevices(this, Looper.getMainLooper()); mRemoteDevices.init(); mBinder = new AdapterServiceBinder(this); mAdapterProperties = new AdapterProperties(this); Loading
android/app/src/com/android/bluetooth/btservice/RemoteDevices.java +27 −15 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelUuid; import android.support.annotation.VisibleForTesting; Loading Loading @@ -59,6 +60,30 @@ final class RemoteDevices { private final HashMap<String, DeviceProperties> mDevices; private Queue<String> mDeviceQueue; private final Handler mHandler; private class RemoteDevicesHandler extends Handler { /** * Handler must be created from an explicit looper to avoid threading ambiguity * @param looper The looper that this handler should be executed on */ RemoteDevicesHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_UUID_INTENT: BluetoothDevice device = (BluetoothDevice) msg.obj; if (device != null) { sendUuidIntent(device); } break; } } } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading @@ -80,12 +105,13 @@ final class RemoteDevices { } }; RemoteDevices(AdapterService service) { RemoteDevices(AdapterService service, Looper looper) { sAdapter = BluetoothAdapter.getDefaultAdapter(); sAdapterService = service; sSdpTracker = new ArrayList<BluetoothDevice>(); mDevices = new HashMap<String, DeviceProperties>(); mDeviceQueue = new LinkedList<String>(); mHandler = new RemoteDevicesHandler(looper); } /** Loading Loading @@ -782,20 +808,6 @@ final class RemoteDevices { return batteryLevel * 100 / numberOfLevels; } private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_UUID_INTENT: BluetoothDevice device = (BluetoothDevice) msg.obj; if (device != null) { sendUuidIntent(device); } break; } } }; private static void errorLog(String msg) { Log.e(TAG, msg); } Loading
android/app/src/com/android/bluetooth/map/BluetoothMapMessageListing.java +19 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package com.android.bluetooth.map; import android.util.Log; import android.util.Xml; import com.android.bluetooth.DeviceWorkArounds; import com.android.internal.util.FastXmlSerializer; Loading Loading @@ -90,11 +91,25 @@ public class BluetoothMapMessageListing { public byte[] encode(boolean includeThreadId, String version) throws UnsupportedEncodingException { StringWriter sw = new StringWriter(); XmlSerializer xmlMsgElement = new FastXmlSerializer(); XmlSerializer xmlMsgElement = null; boolean isBenzCarkit = DeviceWorkArounds.addressStartsWith( BluetoothMapService.getRemoteDevice().getAddress(), DeviceWorkArounds.MERCEDES_BENZ_CARKIT); try { if (isBenzCarkit) { Log.d(TAG, "java_interop: Remote is Mercedes Benz, " + "using Xml Workaround."); xmlMsgElement = Xml.newSerializer(); xmlMsgElement.setOutput(sw); xmlMsgElement.text("\n"); } else { xmlMsgElement = new FastXmlSerializer(); xmlMsgElement.setOutput(sw); xmlMsgElement.startDocument("UTF-8", true); xmlMsgElement.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); xmlMsgElement.text("\n"); xmlMsgElement.setFeature( "http://xmlpull.org/v1/doc/features.html#indent-output", true); } xmlMsgElement.startTag(null, "MAP-msg-listing"); xmlMsgElement.attribute(null, "version", version); // Do the XML encoding of list Loading
android/app/src/com/android/bluetooth/map/BluetoothMapMessageListingElement.java +4 −3 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ */ package com.android.bluetooth.map; import com.android.bluetooth.DeviceWorkArounds; import com.android.bluetooth.map.BluetoothMapUtils.TYPE; import com.android.bluetooth.util.Interop; import org.xmlpull.v1.XmlSerializer; Loading Loading @@ -274,8 +274,9 @@ public class BluetoothMapMessageListingElement if (mSubject != null) { String stripped = BluetoothMapUtils.stripInvalidChars(mSubject); if (Interop.matchByAddress(Interop.INTEROP_MAP_ASCIIONLY, BluetoothMapService.getRemoteDevice().getAddress())) { if (DeviceWorkArounds.addressStartsWith(BluetoothMapService .getRemoteDevice().getAddress(), DeviceWorkArounds .MERCEDES_BENZ_CARKIT)) { stripped = stripped.replaceAll("[\\P{ASCII}&\"><]", ""); if (stripped.isEmpty()) { stripped = "---"; Loading