diff options
author | twyen <twyen@google.com> | 2017-11-16 15:39:03 -0800 |
---|---|---|
committer | zachh <zachh@google.com> | 2017-11-18 07:33:27 +0000 |
commit | af7735260b0bf4539fb7327c9a36ea163ba1f2e1 (patch) | |
tree | 4196eb54cb7b763f255ddde571ede500243bbc03 /java/com/android/dialer/precall/impl/CallingAccountSelector.java | |
parent | 7b86f5621bb130bc1517db11a706d1518d141a52 (diff) |
Implement headless PreCall
If no actions require an activity, instead of launching the PreCallActivity, all actions will be performed immediately, and the call intent will be sent to telecom directly.
This reduces the latency & risk when mutli SIM is not supported.
Bug: 68953196
Test: PreCallImplTest, HeadlessPreCallCoordinatorTest
PiperOrigin-RevId: 176032790
Change-Id: I03258e8643f18c65a8e5b1a84b18b71b30638044
Diffstat (limited to 'java/com/android/dialer/precall/impl/CallingAccountSelector.java')
-rw-r--r-- | java/com/android/dialer/precall/impl/CallingAccountSelector.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java index ca74bef08..d763c7a5f 100644 --- a/java/com/android/dialer/precall/impl/CallingAccountSelector.java +++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java @@ -59,16 +59,27 @@ public class CallingAccountSelector implements PreCallAction { private boolean isDiscarding; @Override - @MainThread - public void run(PreCallCoordinator coordinator) { - CallIntentBuilder builder = coordinator.getBuilder(); + public boolean requiresUi(Context context, CallIntentBuilder builder) { if (builder.getPhoneAccountHandle() != null) { - return; + return false; } - Activity activity = coordinator.getActivity(); - TelecomManager telecomManager = activity.getSystemService(TelecomManager.class); + TelecomManager telecomManager = context.getSystemService(TelecomManager.class); List<PhoneAccountHandle> accounts = telecomManager.getCallCapablePhoneAccounts(); if (accounts.size() <= 1) { + return false; + } + return true; + } + + @Override + public void runWithoutUi(Context context, CallIntentBuilder builder) { + // do nothing. + } + + @Override + public void runWithUi(PreCallCoordinator coordinator) { + CallIntentBuilder builder = coordinator.getBuilder(); + if (!requiresUi(coordinator.getActivity(), builder)) { return; } switch (builder.getUri().getScheme()) { |