Loading android/app/src/com/android/bluetooth/DeviceWorkArounds.java 0 → 100644 +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()); } } android/app/src/com/android/bluetooth/map/BluetoothMapContent.java +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading android/app/src/com/android/bluetooth/map/BluetoothMapMessageListing.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -109,6 +110,15 @@ public class BluetoothMapMessageListing { } catch (IOException e) { Log.w(TAG, e); } /* Fix IOT issue to replace '&' by '&', < by < and '> by '>' in MessageListing */ if (DeviceWorkArounds.addressStartsWith(BluetoothMapService.getRemoteDevice().getAddress(), DeviceWorkArounds.BREZZA_ZDI_CARKIT)) { return sw.toString() .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .getBytes("UTF-8"); } return sw.toString().getBytes("UTF-8"); } Loading android/app/src/com/android/bluetooth/map/BluetoothMapbMessageSms.java +20 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading
android/app/src/com/android/bluetooth/DeviceWorkArounds.java 0 → 100644 +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()); } }
android/app/src/com/android/bluetooth/map/BluetoothMapContent.java +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading
android/app/src/com/android/bluetooth/map/BluetoothMapMessageListing.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -109,6 +110,15 @@ public class BluetoothMapMessageListing { } catch (IOException e) { Log.w(TAG, e); } /* Fix IOT issue to replace '&' by '&', < by < and '> by '>' in MessageListing */ if (DeviceWorkArounds.addressStartsWith(BluetoothMapService.getRemoteDevice().getAddress(), DeviceWorkArounds.BREZZA_ZDI_CARKIT)) { return sw.toString() .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .getBytes("UTF-8"); } return sw.toString().getBytes("UTF-8"); } Loading
android/app/src/com/android/bluetooth/map/BluetoothMapbMessageSms.java +20 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading