Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28b252f6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Show a warning dialog about charges when user starts a video call"

parents d554f435 da410d32
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -77,6 +77,13 @@ public class TelephonyManagerCompat {
   */
  public static final Integer FEATURES_ASSISTED_DIALING = 1 << 4;

  /**
   * Flag specifying whether to show an alert dialog for video call charges. By default this value
   * is {@code false}. TODO(a bug): Replace with public API for these constants when available.
   */
  public static final String CARRIER_CONFIG_KEY_SHOW_VIDEO_CALL_CHARGES_ALERT_DIALOG_BOOL =
      "show_video_call_charges_alert_dialog_bool";

  /**
   * Returns the number of phones available. Returns 1 for Single standby mode (Single SIM
   * functionality) Returns 2 for Dual standby mode.(Dual SIM functionality)
+35 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.telecom.InCallService.VideoCall;
import android.telecom.VideoProfile;
@@ -80,7 +81,8 @@ public class VideoCallPresenter
        InCallDetailsListener,
        SurfaceChangeListener,
        InCallPresenter.InCallEventListener,
        VideoCallScreenDelegate {
        VideoCallScreenDelegate,
        CallList.Listener {

  private static boolean isVideoMode = false;

@@ -325,6 +327,8 @@ public class VideoCallPresenter
    InCallPresenter.getInstance().getLocalVideoSurfaceTexture().setDelegate(new LocalDelegate());
    InCallPresenter.getInstance().getRemoteVideoSurfaceTexture().setDelegate(new RemoteDelegate());

    CallList.getInstance().addListener(this);

    // Register for surface and video events from {@link InCallVideoCallListener}s.
    InCallVideoCallCallbackNotifier.getInstance().addSurfaceChangeListener(this);
    currentVideoState = VideoProfile.STATE_AUDIO_ONLY;
@@ -354,6 +358,8 @@ public class VideoCallPresenter
    InCallPresenter.getInstance().removeInCallEventListener(this);
    InCallPresenter.getInstance().getLocalVideoSurfaceTexture().setDelegate(null);

    CallList.getInstance().removeListener(this);

    InCallVideoCallCallbackNotifier.getInstance().removeSurfaceChangeListener(this);

    // Ensure that the call's camera direction is updated (most likely to UNKNOWN). Normally this
@@ -1126,6 +1132,34 @@ public class VideoCallPresenter
        || VideoUtils.hasReceivedVideoUpgradeRequest(state);
  }

  @Override
  public void onIncomingCall(DialerCall call) {}

  @Override
  public void onUpgradeToVideo(DialerCall call) {}

  @Override
  public void onSessionModificationStateChange(DialerCall call) {}

  @Override
  public void onCallListChange(CallList callList) {}

  @Override
  public void onDisconnect(DialerCall call) {}

  @Override
  public void onWiFiToLteHandover(DialerCall call) {
    if (call.isVideoCall() || call.hasSentVideoUpgradeRequest()) {
      videoCallScreen.onHandoverFromWiFiToLte();
    }
  }

  @Override
  public void onHandoverToWifiFailed(DialerCall call) {}

  @Override
  public void onInternationalCallOnWifi(@NonNull DialerCall call) {}

  private class LocalDelegate implements VideoSurfaceDelegate {
    @Override
    public void onSurfaceCreated(VideoSurfaceTexture videoCallSurface) {
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@ public class AnswerVideoCallScreen implements VideoCallScreen {
    return callId;
  }

  @Override
  public void onHandoverFromWiFiToLte() {}

  private void updatePreviewVideoScaling() {
    if (textureView.getWidth() == 0 || textureView.getHeight() == 0) {
      LogUtil.i(
+3 −0
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ public class SelfManagedAnswerVideoCallScreen extends StateCallback implements V
    return callId;
  }

  @Override
  public void onHandoverFromWiFiToLte() {}

  /**
   * Opens the first front facing camera on the device into a {@link SurfaceView} while preserving
   * aspect ratio.
+44 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.incallui.call;

import android.Manifest.permission;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
@@ -25,6 +26,7 @@ import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.Trace;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
@@ -156,6 +158,8 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa

  @Nullable private Boolean isInGlobalSpamList;
  private boolean didShowCameraPermission;
  private boolean didDismissVideoChargesAlertDialog;
  private PersistableBundle carrierConfig;
  private String callProviderLabel;
  private String callbackNumber;
  private int cameraDirection = CameraDirection.CAMERA_DIRECTION_UNKNOWN;
@@ -585,6 +589,9 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
        if (phoneAccount != null) {
          isCallSubjectSupported =
              phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT);
          if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
            cacheCarrierConfiguration(phoneAccountHandle);
          }
        }
      }
    }
@@ -596,6 +603,26 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
    Trace.endSection();
  }

  /**
   * Caches frequently used carrier configuration locally.
   *
   * @param accountHandle The PhoneAccount handle.
   */
  @SuppressLint("MissingPermission")
  private void cacheCarrierConfiguration(PhoneAccountHandle accountHandle) {
    if (!PermissionsUtil.hasPermission(context, permission.READ_PHONE_STATE)) {
      return;
    }
    if (VERSION.SDK_INT < VERSION_CODES.O) {
      return;
    }
    // TODO(a bug): This may take several seconds to complete, revisit it to move it to worker
    // thread.
    carrierConfig =
        TelephonyManagerCompat.getTelephonyManagerForPhoneAccountHandle(context, accountHandle)
            .getCarrierConfig();
  }

  /**
   * Tests corruption of the {@code callExtras} bundle by calling {@link
   * Bundle#containsKey(String)}. If the bundle is corrupted a {@link IllegalArgumentException} will
@@ -712,6 +739,14 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
    doNotShowDialogForHandoffToWifiFailure = bool;
  }

  public boolean showVideoChargesAlertDialog() {
    if (carrierConfig == null) {
      return false;
    }
    return carrierConfig.getBoolean(
        TelephonyManagerCompat.CARRIER_CONFIG_KEY_SHOW_VIDEO_CALL_CHARGES_ALERT_DIALOG_BOOL);
  }

  public long getTimeAddedMs() {
    return timeAddedMs;
  }
@@ -1071,6 +1106,14 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
    didShowCameraPermission = didShow;
  }

  public boolean didDismissVideoChargesAlertDialog() {
    return didDismissVideoChargesAlertDialog;
  }

  public void setDidDismissVideoChargesAlertDialog(boolean didDismiss) {
    didDismissVideoChargesAlertDialog = didDismiss;
  }

  @Nullable
  public Boolean isInGlobalSpamList() {
    return isInGlobalSpamList;
Loading