• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.dialer.precall;
18 
19 import android.content.Context;
20 import android.support.annotation.MainThread;
21 import com.android.dialer.callintent.CallIntentBuilder;
22 
23 /**
24  * An action to perform before the call is made. The action should inspect and modify the {@link
25  * CallIntentBuilder} to generate full information for the call. For example, showing a dialog to
26  * select the phone account on a multi-SIM device, ask if RTT should be enabled, or rewrite the
27  * number for roaming calls.
28  */
29 public interface PreCallAction {
30 
31   /**
32    * Whether the action requires an activity to operate. This method is called on all actions before
33    * {@link #runWithUi(PreCallCoordinator)} is called. If {@link true} is returned, {@link
34    * #runWithUi(PreCallCoordinator)} will be guaranteed to be called on the execution phase.
35    * Otherwise {@link #runWithoutUi(Context, CallIntentBuilder)} may be called instead and the
36    * action will not be able to show UI, perform async task, or abort the call. This method should
37    * not make any state changes.
38    */
39   @MainThread
requiresUi(Context context, CallIntentBuilder builder)40   boolean requiresUi(Context context, CallIntentBuilder builder);
41 
42   /**
43    * Called when all actions returned {@code false} for {@link #requiresUi(Context,
44    * CallIntentBuilder)}.
45    */
runWithoutUi(Context context, CallIntentBuilder builder)46   void runWithoutUi(Context context, CallIntentBuilder builder);
47 
48   /**
49    * Runs the action. Should block on the main thread until the action is finished. If the action is
50    * not instantaneous, {@link PreCallCoordinator#startPendingAction()} should be called to release
51    * the thread and continue later.
52    */
53   @MainThread
runWithUi(PreCallCoordinator coordinator)54   void runWithUi(PreCallCoordinator coordinator);
55 
56   /**
57    * Called when the UI is being paused when a {@link PreCallCoordinator.PendingAction} is started,
58    * and the action is going to be discarded. If the action is showing a dialog the dialog should be
59    * dismissed. The action should not retain state, a new instance of the action will be re-run when
60    * the UI is resumed.
61    */
62   @MainThread
onDiscard()63   void onDiscard();
64 }
65