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

Commit cc907398 authored by Hemant Gupta's avatar Hemant Gupta Committed by Myles Watson
Browse files

MAP: Handle following IOT Specific or remote issues :

- Fix Message Display issue with PCM carkit.
  PCM carkit is unable to parse message if carriage
  return(\r) is present in it and displaying
  incomplete message. Add change to  remove carriage
  return (\r) from message to fix this IOT issue.

- Fix Message Display issue with FORD SYNC carkit.
  FORD SYNC carkit is unable to parse message if line
  feed (\n) is present in it and displaying incomplete
  message. Add change to remove line feed (\n) from
  message and keep only carriage return (\r) in the
  message, to fix this IOT issue.

- Fix Subject Display issue with HONDA Carkit.
  Honda Carkit always masks subject field in message
  listing and hence always shows a blank subject in UI.
  Add change to always send subject field in Messagelisting
  for honda carkit,so that it can show proper subject fields
  in UI and better user experience.

- Fix Message Display issue with SYNC carkit.
  SYNC carkit is unable to parse message if line feed
  ('\n') is present in the message body end. It can
  parse line feed's present in the middle of the message
  body. Add change to remove trailing line feed (\n)
  present in the message body, to fix this IOT issue.

- Fix Message Display issue with Brezza ZDI carkit.
  Brezza ZDI carkit is unable to parse message if & <
  and > are present in the message body.
  Add change to replace them by &, < and > resp. in the message body,
  to fix this IOT issue.

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

Bug: 34960344
Change-Id: Ieaf257095875fadb0ae46dc91b4e1e79aaf9931c
parent e42bd8ae
Loading
Loading
Loading
Loading
+35 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.bluetooth;

/**
 * @hide
 */
public final class DeviceWorkArounds {
    public static final String PCM_CARKIT = "9C:DF:03";
    public static final String FORD_SYNC_CARKIT = "00:1E:AE";
    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";

    /**
     * @hide
     */
    public static boolean addressStartsWith(String bdAddr, String carkitAddr) {
        return bdAddr.toLowerCase().startsWith(carkitAddr.toLowerCase());
    }
}
+5 −1
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.text.util.Rfc822Tokenizer;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.DeviceWorkArounds;
import com.android.bluetooth.SignedLongLong;
import com.android.bluetooth.SignedLongLong;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.map.BluetoothMapbMessageMime.MimePart;
import com.android.bluetooth.map.BluetoothMapbMessageMime.MimePart;
@@ -1319,7 +1320,10 @@ public class BluetoothMapContent {
            subLength = 256;
            subLength = 256;
        }
        }


        if ((ap.getParameterMask() & MASK_SUBJECT) != 0) {
        // Fix Subject Display issue with HONDA Carkit - Ignore subject Mask.
        if (DeviceWorkArounds.addressStartsWith(BluetoothMapService.getRemoteDevice().getAddress(),
                    DeviceWorkArounds.HONDA_CARKIT)
                || (ap.getParameterMask() & MASK_SUBJECT) != 0) {
            if (fi.mMsgType == FilterInfo.TYPE_SMS) {
            if (fi.mMsgType == FilterInfo.TYPE_SMS) {
                subject = c.getString(fi.mSmsColSubject);
                subject = c.getString(fi.mSmsColSubject);
            } else if (fi.mMsgType == FilterInfo.TYPE_MMS) {
            } else if (fi.mMsgType == FilterInfo.TYPE_MMS) {
+10 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ package com.android.bluetooth.map;


import android.util.Log;
import android.util.Log;


import com.android.bluetooth.DeviceWorkArounds;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.FastXmlSerializer;


import org.xmlpull.v1.XmlSerializer;
import org.xmlpull.v1.XmlSerializer;
@@ -109,6 +110,15 @@ public class BluetoothMapMessageListing {
        } catch (IOException e) {
        } catch (IOException e) {
            Log.w(TAG, e);
            Log.w(TAG, e);
        }
        }
        /* Fix IOT issue to replace '&amp;' by '&', &lt; by < and '&gt; by '>' in MessageListing */
        if (DeviceWorkArounds.addressStartsWith(BluetoothMapService.getRemoteDevice().getAddress(),
                    DeviceWorkArounds.BREZZA_ZDI_CARKIT)) {
            return sw.toString()
                    .replaceAll("&amp;", "&")
                    .replaceAll("&lt;", "<")
                    .replaceAll("&gt;", ">")
                    .getBytes("UTF-8");
        }
        return sw.toString().getBytes("UTF-8");
        return sw.toString().getBytes("UTF-8");
    }
    }


+20 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ package com.android.bluetooth.map;


import android.util.Log;
import android.util.Log;


import com.android.bluetooth.DeviceWorkArounds;
import com.android.bluetooth.map.BluetoothMapSmsPdu.SmsPdu;
import com.android.bluetooth.map.BluetoothMapSmsPdu.SmsPdu;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;


@@ -84,6 +85,25 @@ public class BluetoothMapbMessageSms extends BluetoothMapbMessage {
        if (mSmsBody != null) {
        if (mSmsBody != null) {
            String tmpBody = mSmsBody.replaceAll("END:MSG",
            String tmpBody = mSmsBody.replaceAll("END:MSG",
                    "/END\\:MSG"); // Replace any occurrences of END:MSG with \END:MSG
                    "/END\\:MSG"); // Replace any occurrences of END:MSG with \END:MSG
            String remoteAddress = BluetoothMapService.getRemoteDevice().getAddress();
            /* Fix IOT issue with PCM carkit where carkit is unable to parse
               message if carriage return is present in it */
            if (DeviceWorkArounds.addressStartsWith(remoteAddress, DeviceWorkArounds.PCM_CARKIT)) {
                tmpBody = tmpBody.replaceAll("\r", "");
                /* Fix Message Display issue with FORD SYNC carkit -
                 * Remove line feed and include only carriage return */
            } else if (DeviceWorkArounds.addressStartsWith(
                               remoteAddress, DeviceWorkArounds.FORD_SYNC_CARKIT)) {
                tmpBody = tmpBody.replaceAll("\n", "");
                /* Fix IOT issue with SYNC carkit to remove trailing line feeds in the message body
                 */
            } else if (DeviceWorkArounds.addressStartsWith(
                               remoteAddress, DeviceWorkArounds.SYNC_CARKIT)
                    && tmpBody.length() > 0) {
                int trailingLF = 0;
                while ((tmpBody.charAt(tmpBody.length() - trailingLF - 1)) == '\n') trailingLF++;
                tmpBody = tmpBody.substring(0, (tmpBody.length() - trailingLF));
            }
            bodyFragments.add(tmpBody.getBytes("UTF-8"));
            bodyFragments.add(tmpBody.getBytes("UTF-8"));
        } else if (mSmsBodyPdus != null && mSmsBodyPdus.size() > 0) {
        } else if (mSmsBodyPdus != null && mSmsBodyPdus.size() > 0) {
            for (SmsPdu pdu : mSmsBodyPdus) {
            for (SmsPdu pdu : mSmsBodyPdus) {