From 73a74c3c709c87d4ad9860c1fbda585c139235e0 Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 7 Mar 2018 12:12:24 -0800 Subject: Handle preferred SIM for ACTION_CALL Previously preferred SIM is handled only by precall, which covers dialing with dialer or with the special receiver contacts uses. If a third party app uses ACTION_CALL or telecomManager.placeCall(), then the in call UI will be launched directly and the old account selection dialog will be used without preferred SIM support. In this CL logic from CallingAccountSelector is refactored out so InCallActivity can use it for the dialog. Bug: 73718976 Test: Unit tests, In call UI not covered. PiperOrigin-RevId: 188214007 Change-Id: Ifaacf982a3e98601dc362b649c3501d4ee96e63e --- .../preferredsim/suggestion/AndroidManifest.xml | 19 +++++++++++ .../suggestion/SuggestionProvider.java | 37 ++++++++++++++++++++++ .../preferredsim/suggestion/res/values/strings.xml | 25 +++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 java/com/android/dialer/preferredsim/suggestion/AndroidManifest.xml create mode 100644 java/com/android/dialer/preferredsim/suggestion/res/values/strings.xml (limited to 'java/com/android/dialer/preferredsim/suggestion') diff --git a/java/com/android/dialer/preferredsim/suggestion/AndroidManifest.xml b/java/com/android/dialer/preferredsim/suggestion/AndroidManifest.xml new file mode 100644 index 000000000..78f7c26d9 --- /dev/null +++ b/java/com/android/dialer/preferredsim/suggestion/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + diff --git a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java index 0a91d1511..cfa37c883 100644 --- a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java +++ b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java @@ -18,10 +18,14 @@ package com.android.dialer.preferredsim.suggestion; import android.content.Context; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; import com.google.common.base.Optional; +import java.util.ArrayList; +import java.util.List; /** Provides hints to the user when selecting a SIM to make a call. */ public interface SuggestionProvider { @@ -72,4 +76,37 @@ public interface SuggestionProvider { @WorkerThread void reportIncorrectSuggestion( @NonNull Context context, @NonNull String number, @NonNull PhoneAccountHandle newAccount); + + /** + * Return a list of suggestion strings matching the list position of the {@code + * phoneAccountHandles}. The list will contain {@code null} if the PhoneAccountHandle does not + * have suggestions. + */ + @Nullable + static List buildHint( + Context context, + List phoneAccountHandles, + @Nullable Suggestion suggestion) { + if (suggestion == null) { + return null; + } + List hints = new ArrayList<>(); + for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandles) { + if (!phoneAccountHandle.equals(suggestion.phoneAccountHandle)) { + hints.add(null); + continue; + } + switch (suggestion.reason) { + case INTRA_CARRIER: + hints.add(context.getString(R.string.pre_call_select_phone_account_hint_intra_carrier)); + break; + case FREQUENT: + hints.add(context.getString(R.string.pre_call_select_phone_account_hint_frequent)); + break; + default: + LogUtil.w("CallingAccountSelector.buildHint", "unhandled reason " + suggestion.reason); + } + } + return hints; + } } diff --git a/java/com/android/dialer/preferredsim/suggestion/res/values/strings.xml b/java/com/android/dialer/preferredsim/suggestion/res/values/strings.xml new file mode 100644 index 000000000..c4175313d --- /dev/null +++ b/java/com/android/dialer/preferredsim/suggestion/res/values/strings.xml @@ -0,0 +1,25 @@ + + + + +Uses same carrier + + +Recently used + \ No newline at end of file -- cgit v1.2.3