From d7490db984a6a84efd7ef58328c2abde4a031aeb Mon Sep 17 00:00:00 2001 From: roldenburg Date: Tue, 9 Jan 2018 13:51:29 -0800 Subject: Let RCS Video Share take over Duo as the active video tech for a call Bug: 67005309 Test: VideoTechManagerTest PiperOrigin-RevId: 181368613 Change-Id: I8a13bd04d3ac342a06febb7437a0e0dd3d25affd --- .../android/dialer/app/res/values-v27/styles.xml | 23 +++++++++++ java/com/android/incallui/call/DialerCall.java | 47 +++++++++++++--------- 2 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 java/com/android/dialer/app/res/values-v27/styles.xml diff --git a/java/com/android/dialer/app/res/values-v27/styles.xml b/java/com/android/dialer/app/res/values-v27/styles.xml new file mode 100644 index 000000000..5a946b6a0 --- /dev/null +++ b/java/com/android/dialer/app/res/values-v27/styles.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 5d71d0aac..dd7535e20 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -1635,13 +1635,17 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } } - private static class VideoTechManager { + /** Coordinates the available VideoTech implementations for a call. */ + @VisibleForTesting + public static class VideoTechManager { private final Context context; private final EmptyVideoTech emptyVideoTech = new EmptyVideoTech(); + private final VideoTech rcsVideoShare; private final List videoTechs; private VideoTech savedTech; - VideoTechManager(DialerCall call) { + @VisibleForTesting + public VideoTechManager(DialerCall call) { this.context = call.context; String phoneNumber = call.getNumber(); @@ -1653,40 +1657,47 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa videoTechs.add(new ImsVideoTech(Logger.get(call.context), call, call.telecomCall)); - VideoTech rcsVideoTech = + rcsVideoShare = EnrichedCallComponent.get(call.context) .getRcsVideoShareFactory() .newRcsVideoShare( EnrichedCallComponent.get(call.context).getEnrichedCallManager(), call, phoneNumber); - if (rcsVideoTech != null) { - videoTechs.add(rcsVideoTech); + if (rcsVideoShare != null) { + videoTechs.add(rcsVideoShare); } videoTechs.add( new DuoVideoTech( DuoComponent.get(call.context).getDuo(), call, call.telecomCall, phoneNumber)); - } - VideoTech getVideoTech() { - if (savedTech != null) { - return savedTech; - } + savedTech = emptyVideoTech; + } - for (VideoTech tech : videoTechs) { - if (tech.isAvailable(context)) { - // Remember the first VideoTech that becomes available and always use it - savedTech = tech; - savedTech.becomePrimary(); - return savedTech; + @VisibleForTesting + public VideoTech getVideoTech() { + if (savedTech == emptyVideoTech) { + for (VideoTech tech : videoTechs) { + if (tech.isAvailable(context)) { + savedTech = tech; + savedTech.becomePrimary(); + break; + } } + } else if (savedTech instanceof DuoVideoTech && rcsVideoShare.isAvailable(context)) { + // 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. + savedTech = rcsVideoShare; + rcsVideoShare.becomePrimary(); } - return emptyVideoTech; + return savedTech; } - void dispatchCallStateChanged(int newState) { + @VisibleForTesting + public void dispatchCallStateChanged(int newState) { for (VideoTech videoTech : videoTechs) { videoTech.onCallStateChanged(context, newState); } -- cgit v1.2.3