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
diff --git a/src/com/android/server/telecom/Analytics.java b/src/com/android/server/telecom/Analytics.java
index 6a22883..50ff14d 100644
--- a/src/com/android/server/telecom/Analytics.java
+++ b/src/com/android/server/telecom/Analytics.java
@@ -468,16 +468,25 @@
             int prefixLength = CallsManager.TELECOM_CALL_ID_PREFIX.length();
             List<String> callIds = new ArrayList<>(sCallIdToInfo.keySet());
             // Sort the analytics in increasing order of call IDs
-            Collections.sort(callIds, (id1, id2) -> {
-                int i1, i2;
-                try {
-                    i1 = Integer.valueOf(id1.substring(prefixLength));
-                    i2 = Integer.valueOf(id2.substring(prefixLength));
-                } catch (NumberFormatException e) {
-                    return 0;
-                }
-                return i1 - i2;
-            });
+            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) {
+                        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);