Merge "Use new instances of PreCallAction on activity resume"
diff --git a/java/com/android/dialer/precall/PreCall.java b/java/com/android/dialer/precall/PreCall.java
index 4f021f1..bd0aee5 100644
--- a/java/com/android/dialer/precall/PreCall.java
+++ b/java/com/android/dialer/precall/PreCall.java
@@ -22,19 +22,11 @@
 import android.support.annotation.NonNull;
 import com.android.dialer.callintent.CallIntentBuilder;
 import com.android.dialer.util.DialerUtils;
-import com.google.common.collect.ImmutableList;
 
 /** Interface to prepare a {@link CallIntentBuilder} before placing the call with telecom. */
 public interface PreCall {
 
   /**
-   * @return a list of {@link PreCallAction} in execution order for the {@link PreCallCoordinator}
-   *     to run.
-   */
-  @NonNull
-  ImmutableList<PreCallAction> getActions();
-
-  /**
    * @return a intent when started as activity, will perform the pre-call actions and then place a
    *     call. TODO(twyen): if all actions do not require an UI, return a intent that will place the
    *     call directly instead.
diff --git a/java/com/android/dialer/precall/PreCallAction.java b/java/com/android/dialer/precall/PreCallAction.java
index 9ddc6f2..298af08 100644
--- a/java/com/android/dialer/precall/PreCallAction.java
+++ b/java/com/android/dialer/precall/PreCallAction.java
@@ -25,6 +25,9 @@
  * CallIntentBuilder} to generate full information for the call. For example, showing a dialog to
  * select the phone account on a multi-SIM device, ask if RTT should be enabled, or rewrite the
  * number for roaming calls.
+ *
+ * <p>UI actions are discarded when the hosting activity is paused. A new instance of the action
+ * will be created once the activity is resumed again.
  */
 public interface PreCallAction {
 
diff --git a/java/com/android/dialer/precall/PreCallComponent.java b/java/com/android/dialer/precall/PreCallComponent.java
index 00adde5..859eb01 100644
--- a/java/com/android/dialer/precall/PreCallComponent.java
+++ b/java/com/android/dialer/precall/PreCallComponent.java
@@ -17,7 +17,9 @@
 package com.android.dialer.precall;
 
 import android.content.Context;
+import android.support.annotation.NonNull;
 import com.android.dialer.inject.HasRootComponent;
+import com.google.common.collect.ImmutableList;
 import dagger.Subcomponent;
 
 /** Daggaer component for {@link PreCall} */
@@ -25,6 +27,13 @@
 public abstract class PreCallComponent {
   public abstract PreCall getPreCall();
 
+  /**
+   * @return a list of {@link PreCallAction} in execution order for the {@link PreCallCoordinator}
+   *     to run.
+   */
+  @NonNull
+  public abstract ImmutableList<PreCallAction> createActions();
+
   public static PreCallComponent get(Context context) {
     return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component())
         .preCallActionsComponent();
diff --git a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
index 240549c..314a0a0 100644
--- a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
+++ b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
@@ -82,7 +82,7 @@
   }
 
   void onResume() {
-    actions = PreCallComponent.get(activity).getPreCall().getActions();
+    actions = PreCallComponent.get(activity).createActions();
     runNextAction();
   }
 
diff --git a/java/com/android/dialer/precall/impl/PreCallImpl.java b/java/com/android/dialer/precall/impl/PreCallImpl.java
index 2f9b278..f52fa61 100644
--- a/java/com/android/dialer/precall/impl/PreCallImpl.java
+++ b/java/com/android/dialer/precall/impl/PreCallImpl.java
@@ -39,11 +39,6 @@
     this.actions = actions;
   }
 
-  @Override
-  public ImmutableList<PreCallAction> getActions() {
-    return actions;
-  }
-
   @NonNull
   @Override
   public Intent buildIntent(Context context, CallIntentBuilder builder) {
diff --git a/java/com/android/dialer/precall/impl/PreCallModule.java b/java/com/android/dialer/precall/impl/PreCallModule.java
index fa78cba..cbdabe3 100644
--- a/java/com/android/dialer/precall/impl/PreCallModule.java
+++ b/java/com/android/dialer/precall/impl/PreCallModule.java
@@ -38,7 +38,6 @@
   public abstract PreCall to(PreCallImpl impl);
 
   @Provides
-  @Singleton
   public static ImmutableList<PreCallAction> provideActions(
       DuoAction duoAction, CallingAccountSelector callingAccountSelector) {
     return ImmutableList.of(