Gen. anamoly report when Telecom & Telephony default out are diff
To better understand what series of events are causing telecoms and
telephonys default outgoing accounts to get out of sync, an anamoly
report should be generated whenver this happens.
bug: 277989583
Test: existing unit tests + CTS
Change-Id: If7e6eab3c20f02e17b190d60b7f21e250c62c243
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index abf3478..330a7a5 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -295,6 +295,10 @@
UUID.fromString("2e994acb-1997-4345-8bf3-bad04303de26");
public static final String EMERGENCY_CALL_ABORTED_NO_PHONE_ACCOUNTS_ERROR_MSG =
"An emergency call was aborted since there were no available phone accounts.";
+ public static final UUID DEFAULT_CALLING_ACCOUNT_MISMATCH_UUID =
+ UUID.fromString("64b6d6b0-3c7c-11ee-be56-0242ac120002");
+ public static final String DEFAULT_CALLING_ACCOUNT_MISMATCH_MSG =
+ "Telecom and Telephony have different default calling accounts.";
private static final int[] OUTGOING_CALL_STATES =
{CallState.CONNECTING, CallState.SELECT_PHONE_ACCOUNT, CallState.DIALING,
@@ -2192,9 +2196,33 @@
}
return CompletableFuture.completedFuture(callToUse);
}, new LoggedHandlerExecutor(outgoingCallHandler, "CM.pASP", mLock));
+ maybeGenAnomReportForDefaultMismatch(initiatingUser);
return mLatestPostSelectionProcessingFuture;
}
+ /**
+ * If the Telecom default outgoing account ID is not the same as the Telephony voice sub ID,
+ * this can cause unwanted behavior.
+ */
+ private void maybeGenAnomReportForDefaultMismatch(UserHandle userHandle) {
+ try {
+ PhoneAccountHandle handle =
+ mPhoneAccountRegistrar.getUserSelectedOutgoingPhoneAccount(userHandle);
+ int currentTelecomId = -1;
+ if (handle != null) {
+ currentTelecomId = Integer.parseInt(handle.getId());
+ }
+ int currentVoiceSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
+ if (currentTelecomId != currentVoiceSubId) {
+ mAnomalyReporter.reportAnomaly(
+ DEFAULT_CALLING_ACCOUNT_MISMATCH_UUID,
+ DEFAULT_CALLING_ACCOUNT_MISMATCH_MSG);
+ }
+ } catch (Exception e) {
+ // ignore exceptions. This should not affect the outgoing call.
+ }
+ }
+
private static int getManagedProfileUserId(Context context, int userId) {
UserManager um = context.getSystemService(UserManager.class);
List<UserInfo> userProfiles = um.getProfiles(userId);