summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/preferredsim
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-04-24 13:51:08 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-25 11:44:51 -0700
commit66adad0ab9921afcf3aefab270c030ceee9888df (patch)
tree67dcecd86b8a100243a6daaabd11c28d3f347c4f /java/com/android/dialer/preferredsim
parent05d17bda619dfdb7a729959dad098c10d67f84c8 (diff)
Add "enabled" to SelectPhoneAccountDialogFragment.
This is used to inform the user an account cannot be used right now. On most dual SIM devices, only a single SIM can make calls at the same time. The UI will be implemented in a followup CL. This CL also packs the parameters of SelectPhoneAccountDialogFragment into a proto. There are too many arguments and it needs structured representation. TEST=TAP Bug: 69675796,72618783 Test: TAP PiperOrigin-RevId: 194139636 Change-Id: I7d9f92c73b650654fff28ba625a2c8e3dfa0b96c
Diffstat (limited to 'java/com/android/dialer/preferredsim')
-rw-r--r--java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java45
1 files changed, 17 insertions, 28 deletions
diff --git a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
index f710f734c..50ae01fd0 100644
--- a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
+++ b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
@@ -24,10 +24,9 @@ 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. */
+@SuppressWarnings("Guava")
public interface SuggestionProvider {
String EXTRA_SIM_SUGGESTION_REASON = "sim_suggestion_reason";
@@ -80,35 +79,25 @@ public interface SuggestionProvider {
@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.
+ * Return the hint for {@code phoneAccountHandle}. Absent if no hint is available for the account.
*/
- @Nullable
- static List<String> buildHint(
- Context context,
- List<PhoneAccountHandle> phoneAccountHandles,
- @Nullable Suggestion suggestion) {
+ static Optional<String> getHint(
+ Context context, PhoneAccountHandle phoneAccountHandle, @Nullable Suggestion suggestion) {
if (suggestion == null) {
- return null;
+ return Optional.absent();
}
- 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);
- }
+ if (!phoneAccountHandle.equals(suggestion.phoneAccountHandle)) {
+ return Optional.absent();
+ }
+ switch (suggestion.reason) {
+ case INTRA_CARRIER:
+ return Optional.of(
+ context.getString(R.string.pre_call_select_phone_account_hint_intra_carrier));
+ case FREQUENT:
+ return Optional.of(context.getString(R.string.pre_call_select_phone_account_hint_frequent));
+ default:
+ LogUtil.w("CallingAccountSelector.getHint", "unhandled reason " + suggestion.reason);
+ return Optional.absent();
}
- return hints;
}
}