Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c97a895e authored by twyen's avatar twyen Committed by Copybara-Service
Browse files

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
parent 3e2c6b8c
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -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<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
+3 −0
Original line number Diff line number Diff line
@@ -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.
 *
 * <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 {

+9 −0
Original line number Diff line number Diff line
@@ -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<PreCallAction> createActions();

  public static PreCallComponent get(Context context) {
    return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component())
        .preCallActionsComponent();
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class PreCallCoordinatorImpl implements PreCallCoordinator {
  }

  void onResume() {
    actions = PreCallComponent.get(activity).getPreCall().getActions();
    actions = PreCallComponent.get(activity).createActions();
    runNextAction();
  }

+0 −5
Original line number Diff line number Diff line
@@ -39,11 +39,6 @@ public class PreCallImpl implements PreCall {
    this.actions = actions;
  }

  @Override
  public ImmutableList<PreCallAction> getActions() {
    return actions;
  }

  @NonNull
  @Override
  public Intent buildIntent(Context context, CallIntentBuilder builder) {
Loading