summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/com/android/dialer/calllog/database/contract/number_attributes.proto5
-rw-r--r--java/com/android/dialer/calllog/ui/menu/Modules.java50
-rw-r--r--java/com/android/dialer/calllogutils/NumberAttributesConverter.java3
3 files changed, 51 insertions, 7 deletions
diff --git a/java/com/android/dialer/calllog/database/contract/number_attributes.proto b/java/com/android/dialer/calllog/database/contract/number_attributes.proto
index 2e93291ab..f99693d4e 100644
--- a/java/com/android/dialer/calllog/database/contract/number_attributes.proto
+++ b/java/com/android/dialer/calllog/database/contract/number_attributes.proto
@@ -24,7 +24,7 @@ package com.android.dialer;
import "java/com/android/dialer/logging/contact_source.proto";
// Information related to the phone number of the call.
-// Next ID: 12
+// Next ID: 13
message NumberAttributes {
// The name (which may be a person's name or business name, but not a number)
// formatted exactly as it should appear to the user. If the user's locale or
@@ -67,4 +67,7 @@ message NumberAttributes {
// Source of the contact associated with the number.
optional com.android.dialer.logging.ContactSource.Type contact_source = 11;
+
+ // Whether the number can be reached via a carrier video call.
+ optional bool can_support_carrier_video_call = 12;
} \ No newline at end of file
diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java
index e0a69ca85..dd0b0851e 100644
--- a/java/com/android/dialer/calllog/ui/menu/Modules.java
+++ b/java/com/android/dialer/calllog/ui/menu/Modules.java
@@ -28,6 +28,8 @@ import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.calllogutils.CallLogEntryText;
import com.android.dialer.calllogutils.NumberAttributesConverter;
+import com.android.dialer.duo.Duo;
+import com.android.dialer.duo.DuoComponent;
import com.android.dialer.duo.DuoConstants;
import com.android.dialer.glidephotomanager.PhotoInfo;
import com.android.dialer.historyitemactions.DividerModule;
@@ -38,6 +40,7 @@ import com.android.dialer.historyitemactions.SharedModules;
import com.android.dialer.logging.ReportingLocation;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.telecom.TelecomUtil;
+import com.android.dialer.util.CallUtil;
import com.google.common.base.Optional;
import java.util.ArrayList;
import java.util.Collections;
@@ -145,18 +148,32 @@ final class Modules {
IntentModule.newCallModule(
context, normalizedNumber, phoneAccountHandle, CallInitiationType.Type.CALL_LOG));
- // Add a video item if (1) the call log entry is for a video call, and (2) the call is not spam.
- if ((row.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO
- && !row.getNumberAttributes().getIsSpam()) {
+ // If the call log entry is for a spam call, nothing more to be done.
+ if (row.getNumberAttributes().getIsSpam()) {
+ return modules;
+ }
+
+ // If the call log entry is for a video call, add the corresponding video call options.
+ if ((row.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) {
modules.add(
isDuoCall
? new DuoCallModule(context, normalizedNumber, CallInitiationType.Type.CALL_LOG)
: IntentModule.newCarrierVideoCallModule(
context, normalizedNumber, phoneAccountHandle, CallInitiationType.Type.CALL_LOG));
+ return modules;
}
- // TODO(zachh): Also show video option if the call log entry is for an audio call but video
- // capabilities are present?
+ // At this point, the call log entry is for an audio call. We will also show a video call option
+ // if the video capability is present.
+ //
+ // The carrier video call option takes precedence over Duo.
+ if (canPlaceCarrierVideoCall(context, row)) {
+ modules.add(
+ IntentModule.newCarrierVideoCallModule(
+ context, normalizedNumber, phoneAccountHandle, CallInitiationType.Type.CALL_LOG));
+ } else if (canPlaceDuoCall(context, normalizedNumber)) {
+ modules.add(new DuoCallModule(context, normalizedNumber, CallInitiationType.Type.CALL_LOG));
+ }
return modules;
}
@@ -197,4 +214,27 @@ final class Modules {
.setIsVoicemail(row.getIsVoicemailCall())
.build();
}
+
+ private static boolean canPlaceDuoCall(Context context, String phoneNumber) {
+ Duo duo = DuoComponent.get(context).getDuo();
+
+ return duo.isInstalled(context)
+ && duo.isEnabled(context)
+ && duo.isActivated(context)
+ && duo.isReachable(context, phoneNumber);
+ }
+
+ private static boolean canPlaceCarrierVideoCall(Context context, CoalescedRow row) {
+ int carrierVideoAvailability = CallUtil.getVideoCallingAvailability(context);
+ boolean isCarrierVideoCallingEnabled =
+ ((carrierVideoAvailability & CallUtil.VIDEO_CALLING_ENABLED)
+ == CallUtil.VIDEO_CALLING_ENABLED);
+ boolean canRelyOnCarrierVideoPresence =
+ ((carrierVideoAvailability & CallUtil.VIDEO_CALLING_PRESENCE)
+ == CallUtil.VIDEO_CALLING_PRESENCE);
+
+ return isCarrierVideoCallingEnabled
+ && canRelyOnCarrierVideoPresence
+ && row.getNumberAttributes().getCanSupportCarrierVideoCall();
+ }
}
diff --git a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
index 24567e027..f4fab8405 100644
--- a/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
+++ b/java/com/android/dialer/calllogutils/NumberAttributesConverter.java
@@ -55,6 +55,7 @@ public final class NumberAttributesConverter {
.setIsSpam(phoneLookupInfoConsolidator.isSpam())
.setCanReportAsInvalidNumber(phoneLookupInfoConsolidator.canReportAsInvalidNumber())
.setIsCp2InfoIncomplete(phoneLookupInfoConsolidator.isDefaultCp2InfoIncomplete())
- .setContactSource(phoneLookupInfoConsolidator.getContactSource());
+ .setContactSource(phoneLookupInfoConsolidator.getContactSource())
+ .setCanSupportCarrierVideoCall(phoneLookupInfoConsolidator.canSupportCarrierVideoCall());
}
}