diff options
author | roldenburg <roldenburg@google.com> | 2018-01-18 12:57:19 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-18 14:04:29 -0800 |
commit | 6bd612f57bcd528283a4f45692908edf75574c60 (patch) | |
tree | 002c5123f2d4d9c0def0391f90e8d625535bdcdb /java | |
parent | c332a5f54c2ea6459f66bd7bed33a5511e8609ac (diff) |
Pass PhoneAccountHandle into VideoTech isAvailable
Bug: 71840382
Test: DuoImplTest, existing tests
PiperOrigin-RevId: 182424150
Change-Id: I25607d43e1915d57134feac99b2c2240ae9559f9
Diffstat (limited to 'java')
8 files changed, 36 insertions, 20 deletions
diff --git a/java/com/android/dialer/duo/Duo.java b/java/com/android/dialer/duo/Duo.java index d9147844f..d471a7adf 100644 --- a/java/com/android/dialer/duo/Duo.java +++ b/java/com/android/dialer/duo/Duo.java @@ -23,6 +23,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.telecom.Call; +import android.telecom.PhoneAccountHandle; import com.google.auto.value.AutoValue; import com.google.common.base.Optional; import java.util.List; @@ -51,7 +52,10 @@ public interface Duo { * null} if result is unknown. */ @MainThread - Optional<Boolean> supportsUpgrade(@NonNull Context context, @Nullable String number); + Optional<Boolean> supportsUpgrade( + @NonNull Context context, + @Nullable String number, + @Nullable PhoneAccountHandle phoneAccountHandle); /** Starts a task to update the reachability of the parameter numbers asynchronously. */ @MainThread diff --git a/java/com/android/dialer/duo/stub/DuoStub.java b/java/com/android/dialer/duo/stub/DuoStub.java index cfa400a7f..9e896cfbd 100644 --- a/java/com/android/dialer/duo/stub/DuoStub.java +++ b/java/com/android/dialer/duo/stub/DuoStub.java @@ -23,6 +23,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.telecom.Call; +import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; import com.android.dialer.duo.Duo; import com.android.dialer.duo.DuoListener; @@ -60,7 +61,10 @@ public class DuoStub implements Duo { @MainThread @Override - public Optional<Boolean> supportsUpgrade(@NonNull Context context, @Nullable String number) { + public Optional<Boolean> supportsUpgrade( + @NonNull Context context, + @Nullable String number, + @Nullable PhoneAccountHandle phoneAccountHandle) { Assert.isMainThread(); Assert.isNotNull(context); return Optional.of(false); diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index 88aeaf581..385464252 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -497,7 +497,7 @@ public class CallButtonPresenter } private boolean hasVideoCallCapabilities(DialerCall call) { - return call.getVideoTech().isAvailable(context); + return call.getVideoTech().isAvailable(context, call.getAccountHandle()); } /** diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index d57271ae9..27243225b 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -525,7 +525,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa Trace.beginSection("DialerCall.updateFromTelecomCall"); LogUtil.v("DialerCall.updateFromTelecomCall", telecomCall.toString()); - videoTechManager.dispatchCallStateChanged(telecomCall.getState()); + videoTechManager.dispatchCallStateChanged(telecomCall.getState(), getAccountHandle()); final int translatedState = translateState(telecomCall.getState()); if (state != State.BLOCKED) { @@ -1258,7 +1258,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa public VideoTech getVideoTech() { if (videoTech == null) { - videoTech = videoTechManager.getVideoTech(); + videoTech = videoTechManager.getVideoTech(getAccountHandle()); // Only store the first video tech type found to be available during the life of the call. if (selectedAvailableVideoTechType == com.android.dialer.logging.VideoTech.Type.NONE) { @@ -1674,16 +1674,17 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } @VisibleForTesting - public VideoTech getVideoTech() { + public VideoTech getVideoTech(PhoneAccountHandle phoneAccountHandle) { if (savedTech == emptyVideoTech) { for (VideoTech tech : videoTechs) { - if (tech.isAvailable(context)) { + if (tech.isAvailable(context, phoneAccountHandle)) { savedTech = tech; savedTech.becomePrimary(); break; } } - } else if (savedTech instanceof DuoVideoTech && rcsVideoShare.isAvailable(context)) { + } else if (savedTech instanceof DuoVideoTech + && rcsVideoShare.isAvailable(context, phoneAccountHandle)) { // RCS Video Share will become available after the capability exchange which is slower than // Duo reading local contacts for reachability. If Video Share becomes available and we are // not in the middle of any session changes, let it take over. @@ -1695,9 +1696,9 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } @VisibleForTesting - public void dispatchCallStateChanged(int newState) { + public void dispatchCallStateChanged(int newState, PhoneAccountHandle phoneAccountHandle) { for (VideoTech videoTech : videoTechs) { - videoTech.onCallStateChanged(context, newState); + videoTech.onCallStateChanged(context, newState, phoneAccountHandle); } } diff --git a/java/com/android/incallui/videotech/VideoTech.java b/java/com/android/incallui/videotech/VideoTech.java index 71087cb2c..98703025c 100644 --- a/java/com/android/incallui/videotech/VideoTech.java +++ b/java/com/android/incallui/videotech/VideoTech.java @@ -19,6 +19,7 @@ package com.android.incallui.videotech; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.telecom.PhoneAccountHandle; import com.android.dialer.logging.DialerImpression; import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.video.protocol.VideoCallScreenDelegate; @@ -27,7 +28,7 @@ import com.android.incallui.videotech.utils.SessionModificationState; /** Video calling interface. */ public interface VideoTech { - boolean isAvailable(Context context); + boolean isAvailable(Context context, PhoneAccountHandle phoneAccountHandle); boolean isTransmittingOrReceiving(); @@ -50,7 +51,7 @@ public interface VideoTech { VideoCallScreenDelegate createVideoCallScreenDelegate( Context context, VideoCallScreen videoCallScreen); - void onCallStateChanged(Context context, int newState); + void onCallStateChanged(Context context, int newState, PhoneAccountHandle phoneAccountHandle); void onRemovedFromCallList(); diff --git a/java/com/android/incallui/videotech/duo/DuoVideoTech.java b/java/com/android/incallui/videotech/duo/DuoVideoTech.java index c858ae1f2..fdaed077b 100644 --- a/java/com/android/incallui/videotech/duo/DuoVideoTech.java +++ b/java/com/android/incallui/videotech/duo/DuoVideoTech.java @@ -20,6 +20,7 @@ import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.telecom.Call; +import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -55,7 +56,7 @@ public class DuoVideoTech implements VideoTech, DuoListener { } @Override - public boolean isAvailable(Context context) { + public boolean isAvailable(Context context, PhoneAccountHandle phoneAccountHandle) { if (!ConfigProviderBindings.get(context) .getBoolean("enable_lightbringer_video_upgrade", true)) { LogUtil.v("DuoVideoTech.isAvailable", "upgrade disabled by flag"); @@ -66,7 +67,7 @@ public class DuoVideoTech implements VideoTech, DuoListener { LogUtil.v("DuoVideoTech.isAvailable", "upgrade unavailable, call must be active"); return false; } - Optional<Boolean> localResult = duo.supportsUpgrade(context, callingNumber); + Optional<Boolean> localResult = duo.supportsUpgrade(context, callingNumber, phoneAccountHandle); if (localResult.isPresent()) { LogUtil.v( "DuoVideoTech.isAvailable", "upgrade supported in local cache: " + localResult.get()); @@ -109,7 +110,8 @@ public class DuoVideoTech implements VideoTech, DuoListener { } @Override - public void onCallStateChanged(Context context, int newState) { + public void onCallStateChanged( + Context context, int newState, PhoneAccountHandle phoneAccountHandle) { if (newState == Call.STATE_DISCONNECTING) { duo.unregisterListener(this); } diff --git a/java/com/android/incallui/videotech/empty/EmptyVideoTech.java b/java/com/android/incallui/videotech/empty/EmptyVideoTech.java index 2e34a6a8a..9f6211de8 100644 --- a/java/com/android/incallui/videotech/empty/EmptyVideoTech.java +++ b/java/com/android/incallui/videotech/empty/EmptyVideoTech.java @@ -19,6 +19,7 @@ package com.android.incallui.videotech.empty; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.video.protocol.VideoCallScreenDelegate; @@ -29,7 +30,7 @@ import com.android.incallui.videotech.utils.SessionModificationState; public class EmptyVideoTech implements VideoTech { @Override - public boolean isAvailable(Context context) { + public boolean isAvailable(Context context, PhoneAccountHandle phoneAccountHandle) { return false; } @@ -60,7 +61,8 @@ public class EmptyVideoTech implements VideoTech { } @Override - public void onCallStateChanged(Context context, int newState) {} + public void onCallStateChanged( + Context context, int newState, PhoneAccountHandle phoneAccountHandle) {} @Override public void onRemovedFromCallList() {} diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java index 17bad5588..a2fb73bd2 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoTech.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoTech.java @@ -23,6 +23,7 @@ import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.telecom.Call; import android.telecom.Call.Details; +import android.telecom.PhoneAccountHandle; import android.telecom.VideoProfile; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; @@ -59,7 +60,7 @@ public class ImsVideoTech implements VideoTech { } @Override - public boolean isAvailable(Context context) { + public boolean isAvailable(Context context, PhoneAccountHandle phoneAccountHandle) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return false; } @@ -121,8 +122,9 @@ public class ImsVideoTech implements VideoTech { } @Override - public void onCallStateChanged(Context context, int newState) { - if (!isAvailable(context)) { + public void onCallStateChanged( + Context context, int newState, PhoneAccountHandle phoneAccountHandle) { + if (!isAvailable(context, phoneAccountHandle)) { return; } |