From af7735260b0bf4539fb7327c9a36ea163ba1f2e1 Mon Sep 17 00:00:00 2001 From: twyen Date: Thu, 16 Nov 2017 15:39:03 -0800 Subject: 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 --- java/com/android/dialer/precall/PreCallAction.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'java/com/android/dialer/precall/PreCallAction.java') 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; @@ -27,13 +28,30 @@ 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, -- cgit v1.2.3