diff options
author | twyen <twyen@google.com> | 2018-03-07 12:12:24 -0800 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2018-03-07 12:50:21 -0800 |
commit | 73a74c3c709c87d4ad9860c1fbda585c139235e0 (patch) | |
tree | a998b9dae213f71b989f533245ca399c06e08178 /java/com/android/dialer/preferredsim/suggestion | |
parent | 28b252f6e0e4d42551a31d1b197f2eedf7b6a7d5 (diff) |
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
Diffstat (limited to 'java/com/android/dialer/preferredsim/suggestion')
3 files changed, 81 insertions, 0 deletions
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 @@ +<!-- + ~ Copyright (C) 2018 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> +<manifest + xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.dialer.preferredsim.suggestion"> +</manifest> 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<String> buildHint( + Context context, + List<PhoneAccountHandle> phoneAccountHandles, + @Nullable Suggestion suggestion) { + if (suggestion == null) { + return null; + } + List<String> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2018 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> +<resources> +<!-- Hint text under a SIM when selecting SIM to call, indicating the SIM is on the same carrier + as the outgoing call.[CHAR LIMIT=40]--> +<string name="pre_call_select_phone_account_hint_intra_carrier">Uses same carrier</string> + + <!-- Hint text under a SIM when selecting SIM to call, indicating user often use the SIM to call + the contact.[CHAR LIMIT=40]--> +<string name="pre_call_select_phone_account_hint_frequent">Recently used</string> +</resources>
\ No newline at end of file |