Merge "Resolve multiple BT device switching and active device updates" into main
diff --git a/src/com/android/server/telecom/Timeouts.java b/src/com/android/server/telecom/Timeouts.java
index 0ed71df..ee18250 100644
--- a/src/com/android/server/telecom/Timeouts.java
+++ b/src/com/android/server/telecom/Timeouts.java
@@ -447,12 +447,12 @@
 
     /**
      * Returns the duration of time a VoIP call can be in an intermediate state before Telecom will
-     * try to clean up the call.
+     * try to clean up the call.  The default is 2 minutes.
      * @return the state timeout in millis.
      */
     public static long getVoipCallIntermediateStateTimeoutMillis() {
         return DeviceConfig.getLong(DeviceConfig.NAMESPACE_TELEPHONY,
-                INTERMEDIATE_STATE_VOIP_NORMAL_TIMEOUT_MILLIS, 60000L);
+                INTERMEDIATE_STATE_VOIP_NORMAL_TIMEOUT_MILLIS, 120000L);
     }
 
     /**
diff --git a/src/com/android/server/telecom/metrics/ApiStats.java b/src/com/android/server/telecom/metrics/ApiStats.java
index da9e04f..f0b5dc7 100644
--- a/src/com/android/server/telecom/metrics/ApiStats.java
+++ b/src/com/android/server/telecom/metrics/ApiStats.java
@@ -41,119 +41,122 @@
 
 public class ApiStats extends TelecomPulledAtom {
     public static final int API_UNSPECIFIC = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__UNSPECIFIED;
+            .TELECOM_API_STATS__API_NAME__API_UNSPECIFIED;
     public static final int API_ACCEPTHANDOVER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ACCEPT_HANDOVER;
+            .TELECOM_API_STATS__API_NAME__API_ACCEPT_HANDOVER;
     public static final int API_ACCEPTRINGINGCALL = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ACCEPT_RINGING_CALL;
+            .TELECOM_API_STATS__API_NAME__API_ACCEPT_RINGING_CALL;
     public static final int API_ACCEPTRINGINGCALLWITHVIDEOSTATE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ACCEPT_RINGING_CALL_WITH_VIDEO_STATE;
-    public static final int API_ADDCALL = TelecomStatsLog.TELECOM_API_STATS__API_NAME__ADD_CALL;
+            .TELECOM_API_STATS__API_NAME__API_ACCEPT_RINGING_CALL_WITH_VIDEO_STATE;
+    public static final int API_ADDCALL = TelecomStatsLog.TELECOM_API_STATS__API_NAME__API_ADD_CALL;
     public static final int API_ADDNEWINCOMINGCALL = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ADD_NEW_INCOMING_CALL;
+            .TELECOM_API_STATS__API_NAME__API_ADD_NEW_INCOMING_CALL;
     public static final int API_ADDNEWINCOMINGCONFERENCE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ADD_NEW_INCOMING_CONFERENCE;
+            .TELECOM_API_STATS__API_NAME__API_ADD_NEW_INCOMING_CONFERENCE;
     public static final int API_ADDNEWUNKNOWNCALL = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ADD_NEW_UNKNOWN_CALL;
+            .TELECOM_API_STATS__API_NAME__API_ADD_NEW_UNKNOWN_CALL;
     public static final int API_CANCELMISSEDCALLSNOTIFICATION = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__CANCEL_MISSED_CALLS_NOTIFICATION;
+            .TELECOM_API_STATS__API_NAME__API_CANCEL_MISSED_CALLS_NOTIFICATION;
     public static final int API_CLEARACCOUNTS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__CLEAR_ACCOUNTS;
+            .TELECOM_API_STATS__API_NAME__API_CLEAR_ACCOUNTS;
     public static final int API_CREATELAUNCHEMERGENCYDIALERINTENT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__CREATE_LAUNCH_EMERGENCY_DIALER_INTENT;
+            .TELECOM_API_STATS__API_NAME__API_CREATE_LAUNCH_EMERGENCY_DIALER_INTENT;
     public static final int API_CREATEMANAGEBLOCKEDNUMBERSINTENT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__CREATE_MANAGE_BLOCKED_NUMBERS_INTENT;
-    public static final int API_DUMP = TelecomStatsLog.TELECOM_API_STATS__API_NAME__DUMP;
+            .TELECOM_API_STATS__API_NAME__API_CREATE_MANAGE_BLOCKED_NUMBERS_INTENT;
+    public static final int API_DUMP = TelecomStatsLog.TELECOM_API_STATS__API_NAME__API_DUMP;
     public static final int API_DUMPCALLANALYTICS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__DUMP_CALL_ANALYTICS;
+            .TELECOM_API_STATS__API_NAME__API_DUMP_CALL_ANALYTICS;
     public static final int API_ENABLEPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__ENABLE_PHONE_ACCOUNT;
-    public static final int API_ENDCALL = TelecomStatsLog.TELECOM_API_STATS__API_NAME__END_CALL;
+            .TELECOM_API_STATS__API_NAME__API_ENABLE_PHONE_ACCOUNT;
+    public static final int API_ENDCALL = TelecomStatsLog.TELECOM_API_STATS__API_NAME__API_END_CALL;
     public static final int API_GETADNURIFORPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_ADN_URI_FOR_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_GET_ADN_URI_FOR_PHONE_ACCOUNT;
     public static final int API_GETALLPHONEACCOUNTHANDLES = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_ALL_PHONE_ACCOUNT_HANDLES;
+            .TELECOM_API_STATS__API_NAME__API_GET_ALL_PHONE_ACCOUNT_HANDLES;
     public static final int API_GETALLPHONEACCOUNTS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_ALL_PHONE_ACCOUNTS;
+            .TELECOM_API_STATS__API_NAME__API_GET_ALL_PHONE_ACCOUNTS;
     public static final int API_GETALLPHONEACCOUNTSCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_ALL_PHONE_ACCOUNTS_COUNT;
+            .TELECOM_API_STATS__API_NAME__API_GET_ALL_PHONE_ACCOUNTS_COUNT;
     public static final int API_GETCALLCAPABLEPHONEACCOUNTS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_CALL_CAPABLE_PHONE_ACCOUNTS;
+            .TELECOM_API_STATS__API_NAME__API_GET_CALL_CAPABLE_PHONE_ACCOUNTS;
     public static final int API_GETCALLSTATE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_CALL_STATE;
+            .TELECOM_API_STATS__API_NAME__API_GET_CALL_STATE;
     public static final int API_GETCALLSTATEUSINGPACKAGE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_CALL_STATE_USING_PACKAGE;
+            .TELECOM_API_STATS__API_NAME__API_GET_CALL_STATE_USING_PACKAGE;
     public static final int API_GETCURRENTTTYMODE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_CURRENT_TTY_MODE;
+            .TELECOM_API_STATS__API_NAME__API_GET_CURRENT_TTY_MODE;
     public static final int API_GETDEFAULTDIALERPACKAGE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_DEFAULT_DIALER_PACKAGE;
+            .TELECOM_API_STATS__API_NAME__API_GET_DEFAULT_DIALER_PACKAGE;
     public static final int API_GETDEFAULTDIALERPACKAGEFORUSER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_DEFAULT_DIALER_PACKAGE_FOR_USER;
+            .TELECOM_API_STATS__API_NAME__API_GET_DEFAULT_DIALER_PACKAGE_FOR_USER;
     public static final int API_GETDEFAULTOUTGOINGPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_DEFAULT_OUTGOING_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_GET_DEFAULT_OUTGOING_PHONE_ACCOUNT;
     public static final int API_GETDEFAULTPHONEAPP = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_DEFAULT_PHONE_APP;
+            .TELECOM_API_STATS__API_NAME__API_GET_DEFAULT_PHONE_APP;
     public static final int API_GETLINE1NUMBER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_LINE1_NUMBER;
+            .TELECOM_API_STATS__API_NAME__API_GET_LINE1_NUMBER;
     public static final int API_GETOWNSELFMANAGEDPHONEACCOUNTS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_OWN_SELF_MANAGED_PHONE_ACCOUNTS;
+            .TELECOM_API_STATS__API_NAME__API_GET_OWN_SELF_MANAGED_PHONE_ACCOUNTS;
     public static final int API_GETPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_GET_PHONE_ACCOUNT;
     public static final int API_GETPHONEACCOUNTSFORPACKAGE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_PHONE_ACCOUNTS_FOR_PACKAGE;
+            .TELECOM_API_STATS__API_NAME__API_GET_PHONE_ACCOUNTS_FOR_PACKAGE;
     public static final int API_GETPHONEACCOUNTSSUPPORTINGSCHEME = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_PHONE_ACCOUNTS_SUPPORTING_SCHEME;
+            .TELECOM_API_STATS__API_NAME__API_GET_PHONE_ACCOUNTS_SUPPORTING_SCHEME;
     public static final int API_GETREGISTEREDPHONEACCOUNTS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_REGISTERED_PHONE_ACCOUNTS;
+            .TELECOM_API_STATS__API_NAME__API_GET_REGISTERED_PHONE_ACCOUNTS;
     public static final int API_GETSELFMANAGEDPHONEACCOUNTS = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_SELF_MANAGED_PHONE_ACCOUNTS;
+            .TELECOM_API_STATS__API_NAME__API_GET_SELF_MANAGED_PHONE_ACCOUNTS;
     public static final int API_GETSIMCALLMANAGER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_SIM_CALL_MANAGER;
+            .TELECOM_API_STATS__API_NAME__API_GET_SIM_CALL_MANAGER;
     public static final int API_GETSIMCALLMANAGERFORUSER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_SIM_CALL_MANAGER_FOR_USER;
+            .TELECOM_API_STATS__API_NAME__API_GET_SIM_CALL_MANAGER_FOR_USER;
     public static final int API_GETSYSTEMDIALERPACKAGE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_SYSTEM_DIALER_PACKAGE;
+            .TELECOM_API_STATS__API_NAME__API_GET_SYSTEM_DIALER_PACKAGE;
     public static final int API_GETUSERSELECTEDOUTGOINGPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_GET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT;
     public static final int API_GETVOICEMAILNUMBER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__GET_VOICE_MAIL_NUMBER;
+            .TELECOM_API_STATS__API_NAME__API_GET_VOICE_MAIL_NUMBER;
     public static final int API_HANDLEPINMMI = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__HANDLE_PIN_MMI;
+            .TELECOM_API_STATS__API_NAME__API_HANDLE_PIN_MMI;
     public static final int API_HANDLEPINMMIFORPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__HANDLE_PIN_MMI_FOR_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_HANDLE_PIN_MMI_FOR_PHONE_ACCOUNT;
     public static final int API_HASMANAGEONGOINGCALLSPERMISSION = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__HAS_MANAGE_ONGOING_CALLS_PERMISSION;
-    public static final int API_ISINCALL = TelecomStatsLog.TELECOM_API_STATS__API_NAME__IS_IN_CALL;
+            .TELECOM_API_STATS__API_NAME__API_HAS_MANAGE_ONGOING_CALLS_PERMISSION;
+    public static final int API_ISINCALL = TelecomStatsLog
+            .TELECOM_API_STATS__API_NAME__API_IS_IN_CALL;
     public static final int API_ISINCOMINGCALLPERMITTED = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_IN_EMERGENCY_CALL;
+            .TELECOM_API_STATS__API_NAME__API_IS_IN_EMERGENCY_CALL;
     public static final int API_ISINEMERGENCYCALL = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_IN_MANAGED_CALL;
+            .TELECOM_API_STATS__API_NAME__API_IS_IN_MANAGED_CALL;
     public static final int API_ISINMANAGEDCALL = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_IN_SELF_MANAGED_CALL;
+            .TELECOM_API_STATS__API_NAME__API_IS_IN_SELF_MANAGED_CALL;
     public static final int API_ISINSELFMANAGEDCALL = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_INCOMING_CALL_PERMITTED;
+            .TELECOM_API_STATS__API_NAME__API_IS_INCOMING_CALL_PERMITTED;
     public static final int API_ISOUTGOINGCALLPERMITTED = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_OUTGOING_CALL_PERMITTED;
-    public static final int API_ISRINGING = TelecomStatsLog.TELECOM_API_STATS__API_NAME__IS_RINGING;
+            .TELECOM_API_STATS__API_NAME__API_IS_OUTGOING_CALL_PERMITTED;
+    public static final int API_ISRINGING = TelecomStatsLog
+            .TELECOM_API_STATS__API_NAME__API_IS_RINGING;
     public static final int API_ISTTYSUPPORTED = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_TTY_SUPPORTED;
+            .TELECOM_API_STATS__API_NAME__API_IS_TTY_SUPPORTED;
     public static final int API_ISVOICEMAILNUMBER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__IS_VOICE_MAIL_NUMBER;
-    public static final int API_PLACECALL = TelecomStatsLog.TELECOM_API_STATS__API_NAME__PLACE_CALL;
+            .TELECOM_API_STATS__API_NAME__API_IS_VOICE_MAIL_NUMBER;
+    public static final int API_PLACECALL = TelecomStatsLog
+            .TELECOM_API_STATS__API_NAME__API_PLACE_CALL;
     public static final int API_REGISTERPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__REGISTER_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_REGISTER_PHONE_ACCOUNT;
     public static final int API_SETDEFAULTDIALER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__SET_DEFAULT_DIALER;
+            .TELECOM_API_STATS__API_NAME__API_SET_DEFAULT_DIALER;
     public static final int API_SETUSERSELECTEDOUTGOINGPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__SET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_SET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT;
     public static final int API_SHOWINCALLSCREEN = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__SHOW_IN_CALL_SCREEN;
+            .TELECOM_API_STATS__API_NAME__API_SHOW_IN_CALL_SCREEN;
     public static final int API_SILENCERINGER = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__SILENCE_RINGER;
+            .TELECOM_API_STATS__API_NAME__API_SILENCE_RINGER;
     public static final int API_STARTCONFERENCE = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__START_CONFERENCE;
+            .TELECOM_API_STATS__API_NAME__API_START_CONFERENCE;
     public static final int API_UNREGISTERPHONEACCOUNT = TelecomStatsLog
-            .TELECOM_API_STATS__API_NAME__UNREGISTER_PHONE_ACCOUNT;
+            .TELECOM_API_STATS__API_NAME__API_UNREGISTER_PHONE_ACCOUNT;
     public static final int RESULT_UNKNOWN = TelecomStatsLog
             .TELECOM_API_STATS__API_RESULT__RESULT_UNKNOWN;
     public static final int RESULT_NORMAL = TelecomStatsLog