diff options
author | twyen <twyen@google.com> | 2018-05-07 16:36:17 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-09 16:53:51 -0700 |
commit | b2b6365629aed422a006529fe7940612f778baed (patch) | |
tree | ac481d7c67921e64c957dafcd7b553b2be0f7c93 /java/com/android/dialer/historyitemactions | |
parent | d7c058c4e1bfd772e514f6d09deb21d7893d28c8 (diff) |
Place Duo calls with PreCall
This CL consolidates common duo calling operations into precall, including checking reachability, falling back to carrier video call, placing the call to duo with startActivityForResult.
TEST=TAP
Bug: 78783816
Test: TAP
PiperOrigin-RevId: 195742478
Change-Id: I9fea1e4999f604e1f3a153b28079cd0db77b7393
Diffstat (limited to 'java/com/android/dialer/historyitemactions')
-rw-r--r-- | java/com/android/dialer/historyitemactions/DuoCallModule.java | 56 | ||||
-rw-r--r-- | java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java | 18 |
2 files changed, 7 insertions, 67 deletions
diff --git a/java/com/android/dialer/historyitemactions/DuoCallModule.java b/java/com/android/dialer/historyitemactions/DuoCallModule.java deleted file mode 100644 index e6f31e293..000000000 --- a/java/com/android/dialer/historyitemactions/DuoCallModule.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.historyitemactions; - -import android.Manifest.permission; -import android.content.Context; -import android.support.annotation.RequiresPermission; -import com.android.dialer.duo.PlaceDuoCallNotifier; - -/** {@link HistoryItemActionModule} for making a Duo call. */ -public class DuoCallModule implements HistoryItemActionModule { - - private final Context context; - private final String phoneNumber; - - /** - * Creates a module for making a Duo call. - * - * @param phoneNumber The number to start a Duo call. It can be of any format. - */ - public DuoCallModule(Context context, String phoneNumber) { - this.context = context; - this.phoneNumber = phoneNumber; - } - - @Override - public int getStringId() { - return R.string.video_call; - } - - @Override - public int getDrawableId() { - return R.drawable.quantum_ic_videocam_vd_white_24; - } - - @Override - @RequiresPermission(permission.READ_PHONE_STATE) - public boolean onClick() { - PlaceDuoCallNotifier.notify(context, phoneNumber); - return true; // Close the bottom sheet. - } -} diff --git a/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java b/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java index 5da56a127..e1c6c9666 100644 --- a/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java +++ b/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java @@ -149,18 +149,14 @@ public final class HistoryItemActionModulesBuilder { // Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to // place or receive the call should be ignored for carrier video calls. // TODO(a bug): figure out the correct video call behavior - HistoryItemActionModule carrierVideoCallModule = - IntentModule.newCallModule( - context, - new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType()) - .setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing()) - .setIsVideoCall(true)); - HistoryItemActionModule duoVideoCallModule = - new DuoCallModule(context, moduleInfo.getNormalizedNumber()); + CallIntentBuilder callIntentBuilder = + new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType()) + .setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing()) + .setIsVideoCall(true); // If the module info is for a video call, add an appropriate video call module. if ((moduleInfo.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) { - modules.add(isDuoCall() && canPlaceDuoCall() ? duoVideoCallModule : carrierVideoCallModule); + modules.add(IntentModule.newCallModule(context, callIntentBuilder.setIsDuoCall(isDuoCall()))); return this; } @@ -169,9 +165,9 @@ public final class HistoryItemActionModulesBuilder { // // The carrier video call module takes precedence over the Duo module. if (canPlaceCarrierVideoCall()) { - modules.add(carrierVideoCallModule); + modules.add(IntentModule.newCallModule(context, callIntentBuilder)); } else if (canPlaceDuoCall()) { - modules.add(duoVideoCallModule); + modules.add(IntentModule.newCallModule(context, callIntentBuilder.setIsDuoCall(true))); } return this; } |