Show a warning dialog about charges when user starts a video call
The user starts a video call a warning dialog shall be presented.
If the user presses "OK" with the "Do not show again" box selected,
the dialog shall not be presented anymore.
Test: manual - Verified that a warning dialog about charges is shown
when a video call is started if
KEY_SHOW_VIDEO_CALL_CHARGES_ALERT_DIALOG_BOOL is true.
This is an upstream change from:
https://android-review.googlesource.com/c/platform/packages/apps/Dialer/+/518977/8
Bug: 67832837
Test: partner manual test
PiperOrigin-RevId: 188103414
Change-Id: I62628a32557297acaef096db90d2ddf049ef5017
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index d36b00d..30d2bcb 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -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.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 @@
@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;
@@ -464,7 +468,7 @@
/* package-private */ Call getTelecomCall() {
return telecomCall;
}
-
+
public StatusHints getStatusHints() {
return telecomCall.getDetails().getStatusHints();
}
@@ -585,6 +589,9 @@
if (phoneAccount != null) {
isCallSubjectSupported =
phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT);
+ if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
+ cacheCarrierConfiguration(phoneAccountHandle);
+ }
}
}
}
@@ -597,6 +604,26 @@
}
/**
+ * 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
* be thrown and caught by this function.
@@ -712,6 +739,14 @@
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 @@
didShowCameraPermission = didShow;
}
+ public boolean didDismissVideoChargesAlertDialog() {
+ return didDismissVideoChargesAlertDialog;
+ }
+
+ public void setDidDismissVideoChargesAlertDialog(boolean didDismiss) {
+ didDismissVideoChargesAlertDialog = didDismiss;
+ }
+
@Nullable
public Boolean isInGlobalSpamList() {
return isInGlobalSpamList;