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

Commit b4fcf2a0 authored by Andrew Cheng's avatar Andrew Cheng Committed by Automerger Merge Worker
Browse files

Merge "Fix MMS returns Bad Request" am: 62f8d282 am: c3ce9a5b am: b02b1a01

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1587537

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I79d15e3948fec643d39b7977a9a3bace850f08f0
parents ca432b38 b02b1a01
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -3856,10 +3856,20 @@ public class BluetoothMapContent {
                    // according to spec, "charset" should not be set. However, if the attachment
                    // is replaced with a text string, the bMessage now contains text and should
                    // have charset set to UTF-8 according to spec.
                    if (!message.getIncludeAttachments()) {
                    if (!part.mContentType.toUpperCase().contains("TEXT")
                            && !message.getIncludeAttachments()) {
                        StringBuilder sb = new StringBuilder();
                        try {
                            part.encodePlainText(sb);
                            // Each time {@code encodePlainText} is called, it adds {@code "\r\n"}
                            // to the string. {@code encodePlainText} is called here to replace
                            // an image with a string, but later on, when we encode the entire
                            // bMessage in {@link BluetoothMapbMessageMime#encode()},
                            // {@code encodePlainText} will be called again on this {@code
                            // MimePart} (as text this time), adding a second {@code "\r\n"}. So
                            // we remove the extra newline from the end.
                            int newlineIndex = sb.lastIndexOf("\r\n");
                            if (newlineIndex != -1) sb.delete(newlineIndex, newlineIndex + 4);
                            text = sb.toString();
                            part.mContentType = "text";
                        } catch (UnsupportedEncodingException e) {