Add more logging to Telecom for NYC-DR.

Bug: 30411195
Change-Id: I074dcfc41f96ae056153b951cd272896fc116a86
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index c9dc852..ce2c1a5 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -1013,10 +1013,18 @@
                 connectionCapabilities = removeVideoCapabilities(connectionCapabilities);
             }
 
+            int previousCapabilities = mConnectionCapabilities;
             mConnectionCapabilities = connectionCapabilities;
             for (Listener l : mListeners) {
                 l.onConnectionCapabilitiesChanged(this);
             }
+
+            int xorCaps = previousCapabilities ^ mConnectionCapabilities;
+            Log.event(this, Log.Events.CAPABILITY_CHANGE,
+                    "Current: [%s], Removed [%s], Added [%s]",
+                    Connection.capabilitiesToStringShort(mConnectionCapabilities),
+                    Connection.capabilitiesToStringShort(previousCapabilities & xorCaps),
+                    Connection.capabilitiesToStringShort(mConnectionCapabilities & xorCaps));
         }
     }
 
@@ -1043,6 +1051,13 @@
                 }
 
             }
+
+            int xorProps = previousProperties ^ mConnectionProperties;
+            Log.event(this, Log.Events.PROPERTY_CHANGE,
+                    "Current: [%s], Removed [%s], Added [%s]",
+                    Connection.propertiesToStringShort(mConnectionProperties),
+                    Connection.propertiesToStringShort(previousProperties & xorProps),
+                    Connection.propertiesToStringShort(mConnectionProperties & xorProps));
         }
     }
 
@@ -1556,7 +1571,7 @@
      * {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL} property set.
      * <p>
      * An external call is a representation of a call which is taking place on another device
-     * associated with a PhoneAccount on this device.  Issuing a request to pull the external call 
+     * associated with a PhoneAccount on this device.  Issuing a request to pull the external call
      * tells the {@link android.telecom.ConnectionService} that it should move the call from the
      * other device to this one.  An example of this is the IMS multi-endpoint functionality.  A
      * user may have two phones with the same phone number.  If the user is engaged in an active
diff --git a/src/com/android/server/telecom/Log.java b/src/com/android/server/telecom/Log.java
index 5a397fd..29d9576 100644
--- a/src/com/android/server/telecom/Log.java
+++ b/src/com/android/server/telecom/Log.java
@@ -168,6 +168,8 @@
         public static final String SEND_VIDEO_REQUEST = "SEND_VIDEO_REQUEST";
         public static final String SEND_VIDEO_RESPONSE = "SEND_VIDEO_RESPONSE";
         public static final String IS_EXTERNAL = "IS_EXTERNAL";
+        public static final String PROPERTY_CHANGE = "PROPERTY_CHANGE";
+        public static final String CAPABILITY_CHANGE = "CAPABILITY_CHANGE";
 
         public static class Timings {
             public static final String ACCEPT_TIMING = "accept";
@@ -373,7 +375,7 @@
         }
     }
 
-    public static final int MAX_CALLS_TO_CACHE = 5;  // Arbitrarily chosen.
+    public static final int MAX_CALLS_TO_CACHE = 10;  // Arbitrarily chosen.
     public static final int MAX_CALLS_TO_CACHE_DEBUG = 20;  // Arbitrarily chosen.
     private static final long EXTENDED_LOGGING_DURATION_MILLIS = 60000 * 30; // 30 minutes
 
@@ -742,6 +744,20 @@
         }
     }
 
+    public static void event(Call call, String event, String format, Object... args) {
+        String msg;
+        try {
+            msg = (args == null || args.length == 0) ? format
+                    : String.format(Locale.US, format, args);
+        } catch (IllegalFormatException ife) {
+            e("Log", ife, "IllegalFormatException: formatString='%s' numArgs=%d", format,
+                    args.length);
+            msg = format + " (An error occurred while formatting the message.)";
+        }
+
+        event(call, event, msg);
+    }
+
     @VisibleForTesting
     public static synchronized void cleanupStaleSessions(long timeoutMs) {
         String logMessage = "Stale Sessions Cleaned:\n";