summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllog
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-04-10 10:04:15 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-10 10:05:07 -0700
commitfc1026477ecd034b73289bde11902bd1196a42cb (patch)
tree3d9e708a235b7e23f3658bf2fcaddbc7c1b4b185 /java/com/android/dialer/calllog
parenta5cefeb5cf93f2e6256eced1302f4187f5450c93 (diff)
For an audio call log entry, add a video call option in the bottom sheet if the capability is present.
Bug: 70989603 Test: ModulesTest PiperOrigin-RevId: 192302145 Change-Id: I3162e7d22223aa02709d0d401c70c6fc37a00e3b
Diffstat (limited to 'java/com/android/dialer/calllog')
-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
2 files changed, 49 insertions, 6 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();
+ }
}