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

Commit 3f81a584 authored by Hemant Gupta's avatar Hemant Gupta Committed by Hemant Gupta
Browse files

MAP: Fix IOT specific msgListing issue with BenzCarkit.

Benz NTG4.5 carkit in MCE role fail to list messages
when Messages-Listing XML object include standalone,
encoding and xml version flags in the beginning of
final XML output.
Add a IOT specific check to remove these flags before
responding with  final messagesList from MSE.

Test: IOT issues are not observed with specific carkits and normal MAP
      functioanlity works fine with non blacklisted devices.

Bug: 34960344

Change-Id: I4d0d6e4a86538a04a576c7d138a85ed5233b4cf3
parent 72807295
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+19 −4
Original line number Diff line number Diff line
@@ -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;
@@ -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
+4 −3
Original line number Diff line number Diff line
@@ -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;

@@ -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 = "---";