diff options
author | twyen <twyen@google.com> | 2018-01-09 17:33:48 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-09 18:29:31 -0800 |
commit | 06fee1b28472f1019443c9b63ea9bd8aad9f5757 (patch) | |
tree | ca5a7198d176ad17ddb3ce16d2208f6825c3a05a /java | |
parent | 6518fdb6a4adc054d4c9400a734cc4b194734b5c (diff) |
Allow SimSuggestionProvider to auto select phone account.
Bug: 70503524
Test: Unit tests.
PiperOrigin-RevId: 181400523
Change-Id: I07f2f2cd7c1402d1acb6bfbde9db8d90c888edf6
Diffstat (limited to 'java')
5 files changed, 34 insertions, 3 deletions
diff --git a/java/com/android/dialer/logging/dialer_impression.proto b/java/com/android/dialer/logging/dialer_impression.proto index a17d365b1..705420c3a 100644 --- a/java/com/android/dialer/logging/dialer_impression.proto +++ b/java/com/android/dialer/logging/dialer_impression.proto @@ -12,7 +12,7 @@ message DialerImpression { // Event enums to be used for Impression Logging in Dialer. // It's perfectly acceptable for this enum to be large // Values should be from 1000 to 100000. - // Next Tag: 1322 + // Next Tag: 1323 enum Type { UNKNOWN_AOSP_EVENT_TYPE = 1000; @@ -648,5 +648,7 @@ message DialerImpression { BUBBLE_V2_BOTTOM_ACTION_DISMISS = 1320; // Drag bubble to bottom and end call BUBBLE_V2_BOTTOM_ACTION_END_CALL = 1321; + + DUAL_SIM_SELECTION_SUGGESTION_AUTO_SELECTED = 1322; } } diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java index d407296da..9397d1848 100644 --- a/java/com/android/dialer/precall/impl/CallingAccountSelector.java +++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java @@ -175,6 +175,16 @@ public class CallingAccountSelector implements PreCallAction { LogUtil.i( "CallingAccountSelector.processPreferredAccount", "SIM suggested: " + result.suggestion.get().reason); + if (result.suggestion.get().shouldAutoSelect) { + Logger.get(coordinator.getActivity()) + .logImpression( + DialerImpression.Type.DUAL_SIM_SELECTION_SUGGESTION_AUTO_SELECTED); + LogUtil.i( + "CallingAccountSelector.processPreferredAccount", "Auto selected suggestion"); + builder.setPhoneAccountHandle(result.suggestion.get().phoneAccountHandle); + pendingAction.finish(); + return; + } } showDialog( coordinator, diff --git a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java index 61a831b5e..c1114b3f3 100644 --- a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java +++ b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java @@ -32,17 +32,25 @@ public interface SuggestionProvider { // The SIM has the same carrier as the callee. INTRA_CARRIER, // The user has selected the SIM for the callee multiple times. - FREQUENT + FREQUENT, + // The user has select the SIM for this category of calls (contacts from certain accounts, + // etc.). + USER_SET, } /** The suggestion. */ class Suggestion { @NonNull public final PhoneAccountHandle phoneAccountHandle; @NonNull public final Reason reason; + public final boolean shouldAutoSelect; - public Suggestion(@NonNull PhoneAccountHandle phoneAccountHandle, @NonNull Reason reason) { + public Suggestion( + @NonNull PhoneAccountHandle phoneAccountHandle, + @NonNull Reason reason, + boolean shouldAutoSelect) { this.phoneAccountHandle = Assert.isNotNull(phoneAccountHandle); this.reason = Assert.isNotNull(reason); + this.shouldAutoSelect = shouldAutoSelect; } } @@ -55,4 +63,7 @@ public interface SuggestionProvider { @NonNull Context context, @NonNull String number, @NonNull PhoneAccountHandle phoneAccountHandle); + + @WorkerThread + void reportIncorrectSuggestion(@NonNull Context context, @NonNull String number); } diff --git a/java/com/android/dialer/preferredsim/suggestion/stub/StubSuggestionProvider.java b/java/com/android/dialer/preferredsim/suggestion/stub/StubSuggestionProvider.java index e3240448d..6fb73ac5d 100644 --- a/java/com/android/dialer/preferredsim/suggestion/stub/StubSuggestionProvider.java +++ b/java/com/android/dialer/preferredsim/suggestion/stub/StubSuggestionProvider.java @@ -41,4 +41,7 @@ public class StubSuggestionProvider implements SuggestionProvider { @NonNull Context context, @NonNull String number, @NonNull PhoneAccountHandle phoneAccountHandle) {} + + @Override + public void reportIncorrectSuggestion(@NonNull Context context, @NonNull String number) {} } diff --git a/java/com/android/incallui/multisim/SwapSimWorker.java b/java/com/android/incallui/multisim/SwapSimWorker.java index 73c18c442..28cf293b0 100644 --- a/java/com/android/incallui/multisim/SwapSimWorker.java +++ b/java/com/android/incallui/multisim/SwapSimWorker.java @@ -31,6 +31,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.ThreadUtil; +import com.android.dialer.preferredsim.suggestion.SimSuggestionComponent; import com.android.dialer.util.PermissionsUtil; import com.android.incallui.call.CallList; import com.android.incallui.call.DialerCall; @@ -99,6 +100,10 @@ public class SwapSimWorker implements Worker<Void, Void>, DialerCallListener, Ca @SuppressWarnings("MissingPermission") public Void doInBackground(Void unused) { try { + SimSuggestionComponent.get(context) + .getSuggestionProvider() + .reportIncorrectSuggestion(context, number); + if (!PermissionsUtil.hasPhonePermissions(context)) { LogUtil.e("SwapSimWorker.doInBackground", "missing phone permission"); return null; |