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

Commit d7e370d9 authored by Hall Liu's avatar Hall Liu
Browse files

Fix analytics dumping to not throw an exception

Sorting calls during analytics dump did not take conf calls into
account. Modify the sort fn to place all non-standard-name calls at the
end and put a big try-catch around the call to Collections.sort so that
it doesn't screw up the rest of the dumpsys.

Change-Id: I443c8e022e3847359971ea4033797b8309bc011c
Fix: 30145377
parent b5776701
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -468,16 +468,25 @@ public class Analytics {
            int prefixLength = CallsManager.TELECOM_CALL_ID_PREFIX.length();
            List<String> callIds = new ArrayList<>(sCallIdToInfo.keySet());
            // Sort the analytics in increasing order of call IDs
            try {
                Collections.sort(callIds, (id1, id2) -> {
                    int i1, i2;
                    try {
                        i1 = Integer.valueOf(id1.substring(prefixLength));
                    } catch (NumberFormatException e) {
                        i1 = Integer.MAX_VALUE;
                    }

                    try {
                        i2 = Integer.valueOf(id2.substring(prefixLength));
                    } catch (NumberFormatException e) {
                    return 0;
                        i2 = Integer.MAX_VALUE;
                    }
                    return i1 - i2;
                });
            } catch (IllegalArgumentException e) {
                // do nothing, leave the list in a partially sorted state.
            }

            for (String callId : callIds) {
                writer.printf("Call %s: ", callId);