diff options
author | twyen <twyen@google.com> | 2018-03-23 17:39:25 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-26 22:20:45 -0700 |
commit | efc3de47fd8394fd7f929f12bf7cbe0feb3a74cc (patch) | |
tree | 82f29a4bee02b6366d2bdaed79a081c0128b0d9b /java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java | |
parent | 36c8b53f677db00b28ab54ae0d4eb690d563528d (diff) |
Forward extras from pre call external receivers to placeCall().
All extras that CallIntentBuilder handles will be stripped and read into the builder. Other entries will be send to telecom when the intent is build.
Renamed CallIntentBuilder.outGoingCallExtras for clarity.
Bug: 72877810
Test: Unit tests
PiperOrigin-RevId: 190301333
Change-Id: I9a8bf6664b270078d91dbfb3398f8990d243b9f8
Diffstat (limited to 'java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java')
-rw-r--r-- | java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java b/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java index 6096d5192..bf7995a0c 100644 --- a/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java +++ b/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java @@ -23,13 +23,16 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; +import android.telecom.VideoProfile; import com.android.dialer.callintent.CallInitiationType.Type; import com.android.dialer.callintent.CallIntentBuilder; +import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProvider; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.precall.PreCall; +import com.google.common.collect.ImmutableList; /** * Activity that forwards to {@link PreCall#start(Context, CallIntentBuilder)} so the pre-call flow @@ -50,6 +53,17 @@ public class LaunchPreCallActivity extends Activity { public static final String EXTRA_ALLOW_ASSISTED_DIAL = "allow_assisted_dial"; + private static final ImmutableList<String> HANDLED_INTENT_EXTRAS = + ImmutableList.of( + TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, + TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, + TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, + TelecomManager.EXTRA_CALL_SUBJECT, + EXTRA_PHONE_ACCOUNT_HANDLE, + EXTRA_IS_VIDEO_CALL, + EXTRA_CALL_SUBJECT, + EXTRA_ALLOW_ASSISTED_DIAL); + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -72,7 +86,62 @@ public class LaunchPreCallActivity extends Activity { intent.getBooleanExtra( EXTRA_ALLOW_ASSISTED_DIAL, configProvider.getBoolean("assisted_dialing_default_precall_state", false))); + filterExtras(intent.getExtras(), builder); PreCall.start(this, builder); finish(); } + + /** + * Move key-value pairs that {@link CallIntentBuilder} can handle from {@code intentExtras} to + * {@code builder} + */ + private void filterExtras(@Nullable Bundle intentExtras, CallIntentBuilder builder) { + if (intentExtras == null) { + return; + } + Bundle bundle = new Bundle(); + bundle.putAll(intentExtras); + + if (intentExtras.containsKey(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE)) { + int videoState = intentExtras.getInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE); + switch (videoState) { + case VideoProfile.STATE_BIDIRECTIONAL: + builder.setIsVideoCall(true); + break; + case VideoProfile.STATE_AUDIO_ONLY: + builder.setIsVideoCall(false); + break; + case VideoProfile.STATE_RX_ENABLED: + case VideoProfile.STATE_TX_ENABLED: + LogUtil.w( + "LaunchPreCallActivity.filterExtras", + "unsupported video state " + videoState + ", overriding to STATE_BIDIRECTIONAL"); + builder.setIsVideoCall(true); + break; + default: + LogUtil.w("LaunchPreCallActivity.filterExtras", "unknown video state " + videoState); + builder.setIsVideoCall(false); + } + } + + if (intentExtras.containsKey(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS)) { + builder + .getInCallUiIntentExtras() + .putAll(intentExtras.getBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS)); + } + + if (intentExtras.containsKey(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)) { + builder.setPhoneAccountHandle( + intentExtras.getParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)); + } + + if (intentExtras.containsKey(TelecomManager.EXTRA_CALL_SUBJECT)) { + builder.setCallSubject(intentExtras.getString(TelecomManager.EXTRA_CALL_SUBJECT)); + } + + for (String handledKey : HANDLED_INTENT_EXTRAS) { + bundle.remove(handledKey); + } + builder.getPlaceCallExtras().putAll(bundle); + } } |