diff options
author | Eric Erfanian <erfanian@google.com> | 2018-04-25 19:00:11 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-04-25 19:00:11 +0000 |
commit | 43ed0dc0666e9d2e2837a2019e2765f10f43dff8 (patch) | |
tree | ac6491831c0d331f8582a65eda60143cb0798fd0 /java/com/android/incallui/InCallActivity.java | |
parent | 34ed7da073bbac5b8a4283c495c588ef3b0ea32b (diff) | |
parent | 79a407ee27e6c8f6447f3a8c71ae2c7f6b33f591 (diff) |
Merge changes I5b8ad5ca,I0011019c,I8ee43ce8,I35e0748a,I9e9947ad, ...
* changes:
Show clear frequents option in the toolbar if there are suggested contacts.
Use UI listener for preferred account worker in in call UI
Make SIM Selection hint multi-line
Convert CequintCallerIdContact into an @AutoValue
Newly starred SpeedDialUiItems now have SpeedDialEntry ids set.
Disable entries in CallingAccountSelector that are not selectable
Add "enabled" to SelectPhoneAccountDialogFragment.
Add skeleton for CequintPhoneLookup
Log send button impressions for RTT call.
Show international call on wifi dialog without InCallActivity.
Expose active calls from in call UI
Diffstat (limited to 'java/com/android/incallui/InCallActivity.java')
-rw-r--r-- | java/com/android/incallui/InCallActivity.java | 182 |
1 files changed, 89 insertions, 93 deletions
diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index 91f557bd5..2b6c2b49d 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -55,12 +55,15 @@ import android.view.animation.AnimationUtils; import android.widget.CheckBox; import android.widget.Toast; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment; +import com.android.contacts.common.widget.SelectPhoneAccountDialogOptions; +import com.android.contacts.common.widget.SelectPhoneAccountDialogOptionsUtil; import com.android.dialer.animation.AnimUtils; import com.android.dialer.animation.AnimationListenerAdapter; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.concurrent.ThreadUtil; +import com.android.dialer.common.concurrent.UiListener; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.logging.DialerImpression.Type; import com.android.dialer.logging.Logger; @@ -69,6 +72,7 @@ import com.android.dialer.metrics.Metrics; import com.android.dialer.metrics.MetricsComponent; import com.android.dialer.preferredsim.PreferredAccountRecorder; import com.android.dialer.preferredsim.PreferredAccountWorker; +import com.android.dialer.preferredsim.PreferredAccountWorker.Result; import com.android.dialer.preferredsim.suggestion.SuggestionProvider; import com.android.dialer.util.ViewUtil; import com.android.incallui.answer.bindings.AnswerBindings; @@ -101,6 +105,7 @@ import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.video.protocol.VideoCallScreenDelegate; import com.android.incallui.video.protocol.VideoCallScreenDelegateFactory; import com.google.common.base.Optional; +import com.google.common.util.concurrent.ListenableFuture; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; @@ -129,10 +134,8 @@ public class InCallActivity extends TransactionSafeFragmentActivity private static Optional<Integer> audioRouteForTesting = Optional.absent(); - private final InternationalCallOnWifiCallback internationalCallOnWifiCallback = - new InternationalCallOnWifiCallback(); - private SelectPhoneAccountListener selectPhoneAccountListener; + private UiListener<Result> preferredAccountWorkerResultListener; private Animation dialpadSlideInAnimation; private Animation dialpadSlideOutAnimation; @@ -189,6 +192,10 @@ public class InCallActivity extends TransactionSafeFragmentActivity Trace.beginSection("InCallActivity.onCreate"); super.onCreate(bundle); + preferredAccountWorkerResultListener = + DialerExecutorComponent.get(this) + .createUiListener(getFragmentManager(), "preferredAccountWorkerResultListener"); + selectPhoneAccountListener = new SelectPhoneAccountListener(getApplicationContext()); if (bundle != null) { @@ -245,13 +252,6 @@ public class InCallActivity extends TransactionSafeFragmentActivity } } - InternationalCallOnWifiDialogFragment existingInternationalCallOnWifiDialogFragment = - (InternationalCallOnWifiDialogFragment) - getSupportFragmentManager().findFragmentByTag(Tags.INTERNATIONAL_CALL_ON_WIFI); - if (existingInternationalCallOnWifiDialogFragment != null) { - existingInternationalCallOnWifiDialogFragment.setCallback(internationalCallOnWifiCallback); - } - inCallOrientationEventListener = new InCallOrientationEventListener(this); getWindow() @@ -368,58 +368,84 @@ public class InCallActivity extends TransactionSafeFragmentActivity return false; } - DialerExecutorComponent.get(this) - .dialerExecutorFactory() - .createNonUiTaskBuilder(new PreferredAccountWorker(waitingForAccountCall.getNumber())) - .onSuccess( - (result -> { - if (result.getPhoneAccountHandle().isPresent()) { - Logger.get(this).logImpression(Type.DUAL_SIM_SELECTION_PREFERRED_USED); - selectPhoneAccountListener.onPhoneAccountSelected( - result.getPhoneAccountHandle().get(), false, waitingForAccountCall.getId()); - return; - } - if (result.getSuggestion().isPresent()) { - LogUtil.i( - "CallingAccountSelector.processPreferredAccount", - "SIM suggested: " + result.getSuggestion().get().reason); - if (result.getSuggestion().get().shouldAutoSelect) { - Logger.get(this).logImpression(Type.DUAL_SIM_SELECTION_SUGGESTION_AUTO_SELECTED); - LogUtil.i( - "CallingAccountSelector.processPreferredAccount", "Auto selected suggestion"); - selectPhoneAccountListener.onPhoneAccountSelected( - result.getSuggestion().get().phoneAccountHandle, - false, - waitingForAccountCall.getId()); - return; - } - } - Bundle extras = waitingForAccountCall.getIntentExtras(); - List<PhoneAccountHandle> phoneAccountHandles = - extras == null - ? new ArrayList<>() - : extras.getParcelableArrayList(Call.AVAILABLE_PHONE_ACCOUNTS); - - waitingForAccountCall.setPreferredAccountRecorder( - new PreferredAccountRecorder( - waitingForAccountCall.getNumber(), - result.getSuggestion().orNull(), - result.getDataId().orNull())); - selectPhoneAccountDialogFragment = - SelectPhoneAccountDialogFragment.newInstance( - R.string.select_phone_account_for_calls, - result.getDataId().isPresent() /* canSetDefault */, - R.string.select_phone_account_for_calls_remember /* setDefaultResId */, - phoneAccountHandles, - selectPhoneAccountListener, - waitingForAccountCall.getId(), - SuggestionProvider.buildHint( - this, phoneAccountHandles, result.getSuggestion().orNull() /* hints */)); - selectPhoneAccountDialogFragment.show( - getFragmentManager(), Tags.SELECT_ACCOUNT_FRAGMENT); - })) - .build() - .executeParallel(this); + ListenableFuture<PreferredAccountWorker.Result> preferredAccountFuture = + DialerExecutorComponent.get(this) + .backgroundExecutor() + .submit( + () -> { + try { + return new PreferredAccountWorker(waitingForAccountCall.getNumber()) + .doInBackground(getApplicationContext()); + } catch (Throwable throwable) { + throw new Exception(throwable); + } + }); + + preferredAccountWorkerResultListener.listen( + this, + preferredAccountFuture, + result -> { + if (result.getPhoneAccountHandle().isPresent()) { + Logger.get(this).logImpression(Type.DUAL_SIM_SELECTION_PREFERRED_USED); + selectPhoneAccountListener.onPhoneAccountSelected( + result.getPhoneAccountHandle().get(), false, waitingForAccountCall.getId()); + return; + } + if (result.getSuggestion().isPresent()) { + LogUtil.i( + "CallingAccountSelector.processPreferredAccount", + "SIM suggested: " + result.getSuggestion().get().reason); + if (result.getSuggestion().get().shouldAutoSelect) { + Logger.get(this).logImpression(Type.DUAL_SIM_SELECTION_SUGGESTION_AUTO_SELECTED); + LogUtil.i( + "CallingAccountSelector.processPreferredAccount", "Auto selected suggestion"); + selectPhoneAccountListener.onPhoneAccountSelected( + result.getSuggestion().get().phoneAccountHandle, + false, + waitingForAccountCall.getId()); + return; + } + } + Bundle extras = waitingForAccountCall.getIntentExtras(); + List<PhoneAccountHandle> phoneAccountHandles = + extras == null + ? new ArrayList<>() + : extras.getParcelableArrayList(Call.AVAILABLE_PHONE_ACCOUNTS); + + waitingForAccountCall.setPreferredAccountRecorder( + new PreferredAccountRecorder( + waitingForAccountCall.getNumber(), + result.getSuggestion().orNull(), + result.getDataId().orNull())); + SelectPhoneAccountDialogOptions.Builder optionsBuilder = + SelectPhoneAccountDialogOptions.newBuilder() + .setTitle(R.string.select_phone_account_for_calls) + .setCanSetDefault(result.getDataId().isPresent()) + .setSetDefaultLabel(R.string.select_phone_account_for_calls_remember) + .setCallId(waitingForAccountCall.getId()); + + for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandles) { + SelectPhoneAccountDialogOptions.Entry.Builder entryBuilder = + SelectPhoneAccountDialogOptions.Entry.newBuilder(); + SelectPhoneAccountDialogOptionsUtil.setPhoneAccountHandle( + entryBuilder, phoneAccountHandle); + Optional<String> hint = + SuggestionProvider.getHint( + this, phoneAccountHandle, result.getSuggestion().orNull()); + if (hint.isPresent()) { + entryBuilder.setHint(hint.get()); + } + optionsBuilder.addEntries(entryBuilder); + } + + selectPhoneAccountDialogFragment = + SelectPhoneAccountDialogFragment.newInstance( + optionsBuilder.build(), selectPhoneAccountListener); + selectPhoneAccountDialogFragment.show(getFragmentManager(), Tags.SELECT_ACCOUNT_FRAGMENT); + }, + throwable -> { + throw new RuntimeException(throwable); + }); return true; } @@ -1201,16 +1227,8 @@ public class InCallActivity extends TransactionSafeFragmentActivity } public void showDialogForInternationalCallOnWifi(@NonNull DialerCall call) { - if (!InternationalCallOnWifiDialogFragment.shouldShow(this)) { - LogUtil.i( - "InCallActivity.showDialogForInternationalCallOnWifi", - "InternationalCallOnWifiDialogFragment.shouldShow returned false"); - return; - } - InternationalCallOnWifiDialogFragment fragment = - InternationalCallOnWifiDialogFragment.newInstance( - call.getId(), internationalCallOnWifiCallback); + InternationalCallOnWifiDialogFragment.newInstance(call.getId()); fragment.show(getSupportFragmentManager(), Tags.INTERNATIONAL_CALL_ON_WIFI); } @@ -1785,28 +1803,6 @@ public class InCallActivity extends TransactionSafeFragmentActivity static final String ANSWER_AND_RELEASE_ENABLED = "answer_and_release_enabled"; } - private static final class InternationalCallOnWifiCallback - implements InternationalCallOnWifiDialogFragment.Callback { - private static final String TAG = InternationalCallOnWifiCallback.class.getCanonicalName(); - - @Override - public void continueCall(@NonNull String callId) { - LogUtil.i(TAG, "Continuing call with ID: %s", callId); - } - - @Override - public void cancelCall(@NonNull String callId) { - DialerCall call = CallList.getInstance().getCallById(callId); - if (call == null) { - LogUtil.i(TAG, "Call destroyed before the dialog is closed"); - return; - } - - LogUtil.i(TAG, "Disconnecting international call on WiFi"); - call.disconnect(); - } - } - private static final class SelectPhoneAccountListener extends SelectPhoneAccountDialogFragment.SelectPhoneAccountListener { private static final String TAG = SelectPhoneAccountListener.class.getCanonicalName(); |