diff options
author | roldenburg <roldenburg@google.com> | 2017-06-22 13:43:59 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-06-22 14:43:23 -0700 |
commit | 590000b9ed674e9244d7561f10b214f6b343cb66 (patch) | |
tree | 5ef7370fb052d15594cae2b43568439f476e5f28 /java/com/android/dialer/app/calllog | |
parent | d1dfa05d59357b9818a8223c91b739cb6169075d (diff) |
Only show video call option in the call log when appropriate
This fixes two bugs we previously had:
1) If video calling was disabled in Settings, we would still show a video call option in the call log (fixed by checking the setting)
2) If a different app from Dialer inserted a video call into the history, we would incorrectly show a video call button in the call log (fixed by checking the account handle matches the default phone account)
PiperOrigin-RevId: 159870114
Change-Id: I19ef6b50db50f9961a486f48996427a1da8f8813
Diffstat (limited to 'java/com/android/dialer/app/calllog')
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java | 13 | ||||
-rw-r--r-- | java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java | 13 |
2 files changed, 10 insertions, 16 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index b8b029f7b..02433f5bb 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -85,6 +85,7 @@ import com.android.dialer.phonenumbercache.CachedNumberLookupService; import com.android.dialer.phonenumbercache.ContactInfo; import com.android.dialer.phonenumbercache.PhoneNumberCache; import com.android.dialer.phonenumberutil.PhoneNumberHelper; +import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.CallUtil; import com.android.dialer.util.DialerUtils; import java.lang.annotation.Retention; @@ -117,6 +118,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public final ImageView primaryActionButtonView; private final Context mContext; + @Nullable private final PhoneAccountHandle mDefaultPhoneAccountHandle; private final CallLogCache mCallLogCache; private final CallLogListItemHelper mCallLogListItemHelper; private final CachedNumberLookupService mCachedNumberLookupService; @@ -255,6 +257,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder mBlockReportListener = blockReportListener; mCachedNumberLookupService = PhoneNumberCache.get(mContext).getCachedNumberLookupService(); + // Cache this to avoid having to look it up each time we bind to a call log entry + mDefaultPhoneAccountHandle = + TelecomUtil.getDefaultOutgoingPhoneAccount(context, PhoneAccount.SCHEME_TEL); + this.rootView = rootView; this.quickContactView = dialerQuickContactView; this.primaryActionView = primaryActionView; @@ -594,7 +600,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder callButtonView.setVisibility(View.VISIBLE); } - if (hasPlacedCarrierVideoCall() || canSupportCarrierVideoCall()) { + if (CallUtil.isVideoEnabled(mContext) + && (hasPlacedCarrierVideoCall() || canSupportCarrierVideoCall())) { videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); } else if (showLightbringerPrimaryButton()) { @@ -709,10 +716,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (accountHandle == null) { return false; } - if (accountHandle.getComponentName().equals(getLightbringer().getPhoneAccountComponentName())) { + if (mDefaultPhoneAccountHandle == null) { return false; } - return true; + return accountHandle.getComponentName().equals(mDefaultPhoneAccountHandle.getComponentName()); } private boolean canSupportCarrierVideoCall() { diff --git a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java index 6728dfb38..514fda57f 100644 --- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java +++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java @@ -60,19 +60,6 @@ public abstract class CallLogCache { public abstract boolean isVoicemailNumber(PhoneAccountHandle accountHandle, CharSequence number); /** - * Returns {@code true} when the current sim supports video calls, regardless of the value in a - * contact's {@link android.provider.ContactsContract.CommonDataKinds.Phone#CARRIER_PRESENCE} - * column. - */ - public boolean isVideoEnabled() { - if (!mHasCheckedForVideoAvailability) { - mVideoAvailability = CallUtil.getVideoCallingAvailability(mContext); - mHasCheckedForVideoAvailability = true; - } - return (mVideoAvailability & CallUtil.VIDEO_CALLING_ENABLED) != 0; - } - - /** * Returns {@code true} when the current sim supports checking video calling capabilities via the * {@link android.provider.ContactsContract.CommonDataKinds.Phone#CARRIER_PRESENCE} column. */ |