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/PreCallAction.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/PreCallAction.java')
-rw-r--r-- | java/com/android/dialer/precall/PreCallAction.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/java/com/android/dialer/precall/PreCallAction.java b/java/com/android/dialer/precall/PreCallAction.java index 9434694a4..9ddc6f205 100644 --- a/java/com/android/dialer/precall/PreCallAction.java +++ b/java/com/android/dialer/precall/PreCallAction.java @@ -16,6 +16,7 @@ package com.android.dialer.precall; +import android.content.Context; import android.support.annotation.MainThread; import com.android.dialer.callintent.CallIntentBuilder; @@ -28,12 +29,29 @@ import com.android.dialer.callintent.CallIntentBuilder; public interface PreCallAction { /** + * Whether the action requires an activity to operate. This method is called on all actions before + * {@link #runWithUi(PreCallCoordinator)} is called. If {@link true} is returned, {@link + * #runWithUi(PreCallCoordinator)} will be guaranteed to be called on the execution phase. + * Otherwise {@link #runWithoutUi(Context, CallIntentBuilder)} may be called instead and the + * action will not be able to show UI, perform async task, or abort the call. This method should + * not make any state changes. + */ + @MainThread + boolean requiresUi(Context context, CallIntentBuilder builder); + + /** + * Called when all actions returned {@code false} for {@link #requiresUi(Context, + * CallIntentBuilder)}. + */ + void runWithoutUi(Context context, CallIntentBuilder builder); + + /** * Runs the action. Should block on the main thread until the action is finished. If the action is * not instantaneous, {@link PreCallCoordinator#startPendingAction()} should be called to release * the thread and continue later. */ @MainThread - void run(PreCallCoordinator coordinator); + void runWithUi(PreCallCoordinator coordinator); /** * Called when the UI is being paused when a {@link PreCallCoordinator.PendingAction} is started, |