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

Commit 0607b8d6 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "MAP: PushMessage parse BMessage content body till END:MSG."

parents 51f081eb c0c0c308
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -365,6 +365,17 @@ public abstract class BluetoothMapbMessage {
            }
            return data;
        }

        public String getStringTerminator(String terminator) {
                StringBuilder dataStr= new StringBuilder();
                String lineCur = getLine();
                while( lineCur != null && (!lineCur.equals(terminator)))
                {
                  dataStr.append(lineCur);
                  lineCur = getLine();
                }
            return dataStr.toString();
        }
    };

    public BluetoothMapbMessage(){
@@ -614,23 +625,17 @@ public abstract class BluetoothMapbMessage {
                 * Since errata ???(bluetooth.org is down at the moment) introduced escaping of END:MSG
                 * in the actual message content, it is now safe to use the END:MSG tag as terminator,
                 * and simply ignore the length field.*/
                byte[] rawData = reader.getDataBytes(bMsgLength - (line.getBytes().length + 2)); // 2 added to compensate for the removed \r\n
                String data;
                try {
                    data = new String(rawData, "UTF-8");
                //byte[] rawData = reader.getDataBytes(bMsgLength - (line.getBytes().length + 2)); // 2 added to compensate for the removed \r\n
                String data = reader.getStringTerminator("END:MSG");
                if(V) {
                    Log.v(TAG,"MsgLength: " + bMsgLength);
                        Log.v(TAG,"line.getBytes().length: " + line.getBytes().length);
                    Log.v(TAG,"data.getBytes().length: " + data.getBytes().length);
                    String debug = line.replaceAll("\\n", "<LF>\n");
                    debug = debug.replaceAll("\\r", "<CR>");
                    Log.v(TAG,"The line: \"" + debug + "\"");
                    debug = data.replaceAll("\\n", "<LF>\n");
                    debug = debug.replaceAll("\\r", "<CR>");
                        Log.v(TAG,"The msgString: \"" + debug + "\"");
                    }
                } catch (UnsupportedEncodingException e) {
                    Log.w(TAG,e);
                    throw new IllegalArgumentException("Unable to convert to UTF-8");
                    Log.v(TAG,"The msgString: \"" + data + "\"");
                }
                /* Decoding of MSG:
                 * 1) split on "\r\nEND:MSG\r\n"