diff options
-rw-r--r-- | java/com/android/dialer/telecom/TelecomUtil.java | 10 | ||||
-rw-r--r-- | java/com/android/incallui/NewReturnToCallController.java | 43 |
2 files changed, 28 insertions, 25 deletions
diff --git a/java/com/android/dialer/telecom/TelecomUtil.java b/java/com/android/dialer/telecom/TelecomUtil.java index 22f3727e6..c64a50231 100644 --- a/java/com/android/dialer/telecom/TelecomUtil.java +++ b/java/com/android/dialer/telecom/TelecomUtil.java @@ -178,6 +178,10 @@ public abstract class TelecomUtil { * are not included. */ public static boolean isInManagedCall(Context context) { + return instance.isInManagedCall(context); + } + + public static boolean isInCall(Context context) { return instance.isInCall(context); } @@ -289,7 +293,7 @@ public abstract class TelecomUtil { @VisibleForTesting() public static class TelecomUtilImpl { - public boolean isInCall(Context context) { + public boolean isInManagedCall(Context context) { if (hasReadPhoneStatePermission(context)) { // The TelecomManager#isInCall method returns true anytime the user is in a call. // Starting in O, the APIs include support for self-managed ConnectionServices so that other @@ -308,6 +312,10 @@ public abstract class TelecomUtil { return false; } + public boolean isInCall(Context context) { + return hasReadPhoneStatePermission(context) && getTelecomManager(context).isInCall(); + } + public boolean hasPermission(Context context, String permission) { return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED; diff --git a/java/com/android/incallui/NewReturnToCallController.java b/java/com/android/incallui/NewReturnToCallController.java index ad49d6828..ca60a52c1 100644 --- a/java/com/android/incallui/NewReturnToCallController.java +++ b/java/com/android/incallui/NewReturnToCallController.java @@ -101,7 +101,7 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au if (showing) { hide(); } else { - if (TelecomUtil.isInManagedCall(context)) { + if (getCall() != null) { show(); } } @@ -157,22 +157,15 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au @Override public void onDisconnect(DialerCall call) { - if (call.wasParentCall()) { - // It's disconnected after the last child call is disconnected, and we already did everything - // for the last child. - LogUtil.i( - "ReturnToCallController.onDisconnect", "being called for a parent call and do nothing"); - return; - } - if (bubble != null - && bubble.isVisible() - && (!TelecomUtil.isInManagedCall(context) - || CallList.getInstance().getActiveOrBackgroundCall() != null)) { - bubble.showText(context.getText(R.string.incall_call_ended)); - } - // For conference call, we should hideAndReset for the last disconnected child call while the - // parent call is still there. - if (!CallList.getInstance().hasNonParentActiveOrBackgroundCall()) { + LogUtil.enterBlock("ReturnToCallController.onDisconnect"); + if (bubble != null && bubble.isVisible() && (getCall() == null)) { + // Show "Call ended" and hide bubble when there is no outgoing, active or background call + LogUtil.i("ReturnToCallController.onDisconnect", "show call ended and hide bubble"); + // Don't show text if it's Duo upgrade + // It doesn't work for Duo fallback upgrade since we're not considered in call + if (!TelecomUtil.isInCall(context) || CallList.getInstance().getIncomingCall() != null) { + bubble.showText(context.getText(R.string.incall_call_ended)); + } hideAndReset(); } else { startContactInfoSearch(); @@ -197,19 +190,21 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au } private void startContactInfoSearch() { - DialerCall dialerCall = CallList.getInstance().getIncomingCall(); - if (dialerCall == null) { - dialerCall = CallList.getInstance().getOutgoingCall(); - } - if (dialerCall == null) { - dialerCall = CallList.getInstance().getActiveOrBackgroundCall(); - } + DialerCall dialerCall = getCall(); if (dialerCall != null) { contactInfoCache.findInfo( dialerCall, false /* isIncoming */, new ReturnToCallContactInfoCacheCallback(this)); } } + private DialerCall getCall() { + DialerCall dialerCall = CallList.getInstance().getOutgoingCall(); + if (dialerCall == null) { + dialerCall = CallList.getInstance().getActiveOrBackgroundCall(); + } + return dialerCall; + } + private void onPhotoAvatarReceived(@NonNull Drawable photo) { if (bubble != null) { bubble.updatePhotoAvatar(photo); |