From 791f820f5108b3ea914690145ef261d6c01bf41a Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 19 Sep 2017 12:45:46 -0700 Subject: Perform remote reachability query if caller is not in contacts Lightbringer.supportsUpgrade() is changed to return absent optional when it does not have data for the number. Seeing this LightbringerTech will use Lightbringer.updateReachability() to retrieve it from the remote package, which will store it in the reachability cache. Bug: 63601277 Test: RemoteReachabillityQueryHandlerTest, LightbringerTechTest PiperOrigin-RevId: 169283953 Change-Id: I3f26d9158fc6cfed196fd533da2aad598c8e6a7a --- .../videotech/lightbringer/LightbringerTech.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'java/com/android/incallui') diff --git a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java index a807759db..4b6f5ec5a 100644 --- a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java +++ b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java @@ -31,6 +31,8 @@ import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.video.protocol.VideoCallScreenDelegate; import com.android.incallui.videotech.VideoTech; import com.android.incallui.videotech.utils.SessionModificationState; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; public class LightbringerTech implements VideoTech, LightbringerListener { private final Lightbringer lightbringer; @@ -38,6 +40,7 @@ public class LightbringerTech implements VideoTech, LightbringerListener { private final Call call; private final String callingNumber; private int callState = Call.STATE_NEW; + private boolean isRemoteUpgradeAvailabilityQueried; public LightbringerTech( @NonNull Lightbringer lightbringer, @@ -69,13 +72,20 @@ public class LightbringerTech implements VideoTech, LightbringerListener { LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, call must be active"); return false; } + Optional localResult = lightbringer.supportsUpgrade(context, callingNumber); + if (localResult.isPresent()) { + LogUtil.v( + "LightbringerTech.isAvailable", "upgrade supported in local cache: " + localResult.get()); + return localResult.get(); + } - if (!lightbringer.supportsUpgrade(context, callingNumber)) { - LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, number does not support it"); - return false; + if (!isRemoteUpgradeAvailabilityQueried) { + LogUtil.v("LightbringerTech.isAvailable", "reachability unknown, starting remote query"); + isRemoteUpgradeAvailabilityQueried = true; + lightbringer.updateReachability(context, ImmutableList.of(callingNumber)); } - return true; + return false; } @Override -- cgit v1.2.3