From c97a895e19d09707f54533f8985542caf2b0a17b Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 15 May 2018 11:01:52 -0700 Subject: Use new instances of PreCallAction on activity resume Previously the same action instance is used every time the PreCallActivity is resumed. This causes some state to be retain, for example the isDiscarding state on CallingAccountSelector prevents canceling the next dialog to abort the call. Actions should not retain state between activity life cycles. TEST=TAP Bug: 79692264 Test: TAP PiperOrigin-RevId: 196696224 Change-Id: Ifa604f431563dd1fb123a42e2a64b34c001e897d --- java/com/android/dialer/precall/PreCall.java | 8 -------- java/com/android/dialer/precall/PreCallAction.java | 3 +++ java/com/android/dialer/precall/PreCallComponent.java | 9 +++++++++ java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java | 2 +- java/com/android/dialer/precall/impl/PreCallImpl.java | 5 ----- java/com/android/dialer/precall/impl/PreCallModule.java | 1 - 6 files changed, 13 insertions(+), 15 deletions(-) (limited to 'java/com/android/dialer/precall') diff --git a/java/com/android/dialer/precall/PreCall.java b/java/com/android/dialer/precall/PreCall.java index 4f021f142..bd0aee58d 100644 --- a/java/com/android/dialer/precall/PreCall.java +++ b/java/com/android/dialer/precall/PreCall.java @@ -22,18 +22,10 @@ import android.support.annotation.MainThread; 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 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 diff --git a/java/com/android/dialer/precall/PreCallAction.java b/java/com/android/dialer/precall/PreCallAction.java index 9ddc6f205..298af08ee 100644 --- a/java/com/android/dialer/precall/PreCallAction.java +++ b/java/com/android/dialer/precall/PreCallAction.java @@ -25,6 +25,9 @@ import com.android.dialer.callintent.CallIntentBuilder; * 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. + * + *

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 00adde56d..859eb011a 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 @@ import dagger.Subcomponent; 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 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 240549ca5..314a0a067 100644 --- a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java +++ b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java @@ -82,7 +82,7 @@ public class PreCallCoordinatorImpl implements PreCallCoordinator { } 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 2f9b2784c..f52fa618e 100644 --- a/java/com/android/dialer/precall/impl/PreCallImpl.java +++ b/java/com/android/dialer/precall/impl/PreCallImpl.java @@ -39,11 +39,6 @@ public class PreCallImpl implements PreCall { this.actions = actions; } - @Override - public ImmutableList 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 fa78cba5c..cbdabe33c 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 class PreCallModule { public abstract PreCall to(PreCallImpl impl); @Provides - @Singleton public static ImmutableList provideActions( DuoAction duoAction, CallingAccountSelector callingAccountSelector) { return ImmutableList.of( -- cgit v1.2.3