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

Commit 9e695017 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "gtbs: Fix for crash when uri is not set"

parents 8ee9cbb7 e9ff01b0
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -501,13 +501,25 @@ public class TbsGatt {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        for (Map.Entry<Integer, TbsCall> entry : callsList.entrySet()) {
            TbsCall call = entry.getValue();
            int listItemLength = Math.min(listItemLengthMax, 3 + call.getUri().getBytes().length);
            if (call == null) {
                Log.w(TAG, "setBearerListCurrentCalls: call is null");
                continue;
            }

            int uri_len = 0;
            if (call.getUri() != null) {
                uri_len =  call.getUri().getBytes().length;
            }

            int listItemLength = Math.min(listItemLengthMax, 3 + uri_len);
            stream.write((byte) (listItemLength & 0xff));
            stream.write((byte) (entry.getKey() & 0xff));
            stream.write((byte) (call.getState() & 0xff));
            stream.write((byte) (call.getFlags() & 0xff));
            if (uri_len > 0) {
                stream.write(call.getUri().getBytes(), 0, listItemLength - 3);
            }
        }

        return mBearerListCurrentCallsCharacteristic.setValue(stream.toByteArray());
    }