Log when AM gives/removes foreground service delegation

In android U, a new call lifecycle was introduced and specified in
TelecomManger#addCall. Clients MUST post a call-style notification in
order to gain foreground service delegation.

Clients who fail to post a notification will have their media playback
and audio recording suppressed. Its even possible that the application
will be cleaned up if its in the background.

Given the consequences, its important to log when Telecom gives FSD to
debug.

bug: 278310214
Test: manual / BR
Change-Id: I8e86161738d61576ca2e2869fa6086efa7166817
diff --git a/src/com/android/server/telecom/LogUtils.java b/src/com/android/server/telecom/LogUtils.java
index 8b1a256..8ce5dc3 100644
--- a/src/com/android/server/telecom/LogUtils.java
+++ b/src/com/android/server/telecom/LogUtils.java
@@ -223,6 +223,8 @@
         public static final String ICS_EXTRAS_CHANGED = "ICS_EXTRAS_CHANGED";
         public static final String FLASH_NOTIFICATION_START = "FLASH_NOTIFICATION_START";
         public static final String FLASH_NOTIFICATION_STOP = "FLASH_NOTIFICATION_STOP";
+        public static final String GAINED_FGS_DELEGATION = "GAINED_FGS_DELEGATION";
+        public static final String LOST_FGS_DELEGATION = "LOST_FGS_DELEGATION";
 
         public static class Timings {
             public static final String ACCEPT_TIMING = "accept";
diff --git a/src/com/android/server/telecom/voip/VoipCallMonitor.java b/src/com/android/server/telecom/voip/VoipCallMonitor.java
index 84fdb5d..d0304a9 100644
--- a/src/com/android/server/telecom/voip/VoipCallMonitor.java
+++ b/src/com/android/server/telecom/voip/VoipCallMonitor.java
@@ -37,6 +37,7 @@
 import com.android.server.LocalServices;
 import com.android.server.telecom.Call;
 import com.android.server.telecom.CallsManagerListenerBase;
+import com.android.server.telecom.LogUtils;
 import com.android.server.telecom.TelecomSystem;
 
 import java.util.ArrayList;
@@ -182,12 +183,14 @@
             ServiceConnection fgsConnection = new ServiceConnection() {
                 @Override
                 public void onServiceConnected(ComponentName name, IBinder service) {
+                    Log.addEvent(call, LogUtils.Events.GAINED_FGS_DELEGATION);
                     mServices.put(handle, this);
                     startMonitorWorks(call);
                 }
 
                 @Override
                 public void onServiceDisconnected(ComponentName name) {
+                    Log.addEvent(call, LogUtils.Events.LOST_FGS_DELEGATION);
                     mServices.remove(handle);
                 }
             };