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

Commit 6b029a22 authored by Hemant Gupta's avatar Hemant Gupta Committed by android-build-merger
Browse files

Merge "MAP: Handle following IOT Specific or remote issues :" am: 163e42a3 am: f3680ed9

am: 29dd9feb

Change-Id: I6213fa3c7e26eb1e5c6b0a68bb3bba37cf7837c5
parents 0d35c991 29dd9feb
Loading
Loading
Loading
Loading
+35 −0
Original line number 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 Diff line number Diff line
@@ -37,6 +37,7 @@ import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.util.Log;

import com.android.bluetooth.DeviceWorkArounds;
import com.android.bluetooth.SignedLongLong;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.map.BluetoothMapbMessageMime.MimePart;
@@ -1319,7 +1320,10 @@ public class BluetoothMapContent {
            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) {
                subject = c.getString(fi.mSmsColSubject);
            } else if (fi.mMsgType == FilterInfo.TYPE_MMS) {
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package com.android.bluetooth.map;

import android.util.Log;

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

import org.xmlpull.v1.XmlSerializer;
@@ -109,6 +110,15 @@ public class BluetoothMapMessageListing {
        } catch (IOException 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");
    }

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

import android.util.Log;

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

@@ -84,6 +85,25 @@ public class BluetoothMapbMessageSms extends BluetoothMapbMessage {
        if (mSmsBody != null) {
            String tmpBody = mSmsBody.replaceAll("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"));
        } else if (mSmsBodyPdus != null && mSmsBodyPdus.size() > 0) {
            for (SmsPdu pdu : mSmsBodyPdus) {