summaryrefslogtreecommitdiff
path: root/java/com/android/contacts/common/compat/TelephonyManagerCompat.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/contacts/common/compat/TelephonyManagerCompat.java')
-rw-r--r--java/com/android/contacts/common/compat/TelephonyManagerCompat.java80
1 files changed, 12 insertions, 68 deletions
diff --git a/java/com/android/contacts/common/compat/TelephonyManagerCompat.java b/java/com/android/contacts/common/compat/TelephonyManagerCompat.java
index 7e4803ca5..02113ca55 100644
--- a/java/com/android/contacts/common/compat/TelephonyManagerCompat.java
+++ b/java/com/android/contacts/common/compat/TelephonyManagerCompat.java
@@ -27,7 +27,7 @@ import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
-import com.android.dialer.compat.CompatUtils;
+import com.android.dialer.telecom.TelecomUtil;
import java.lang.reflect.InvocationTargetException;
public class TelephonyManagerCompat {
@@ -40,6 +40,8 @@ public class TelephonyManagerCompat {
public static final String EVENT_CALL_REMOTELY_HELD = "android.telecom.event.CALL_REMOTELY_HELD";
public static final String EVENT_CALL_REMOTELY_UNHELD =
"android.telecom.event.CALL_REMOTELY_UNHELD";
+ public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
+ public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
public static final String EVENT_NOTIFY_INTERNATIONAL_CALL_ON_WFC =
"android.telephony.event.EVENT_NOTIFY_INTERNATIONAL_CALL_ON_WFC";
@@ -49,31 +51,6 @@ public class TelephonyManagerCompat {
private static final String SECRET_CODE_ACTION = "android.provider.Telephony.SECRET_CODE";
/**
- * @param telephonyManager The telephony manager instance to use for method calls.
- * @return true if the current device is "voice capable".
- * <p>"Voice capable" means that this device supports circuit-switched (i.e. voice) phone
- * calls over the telephony network, and is allowed to display the in-call UI while a cellular
- * voice call is active. This will be false on "data only" devices which can't make voice
- * calls and don't support any in-call UI.
- * <p>Note: the meaning of this flag is subtly different from the
- * PackageManager.FEATURE_TELEPHONY system feature, which is available on any device with a
- * telephony radio, even if the device is data-only.
- */
- public static boolean isVoiceCapable(@Nullable TelephonyManager telephonyManager) {
- if (telephonyManager == null) {
- return false;
- }
- if (CompatUtils.isLollipopMr1Compatible()
- || CompatUtils.isMethodAvailable(TELEPHONY_MANAGER_CLASS, "isVoiceCapable")) {
- // isVoiceCapable was unhidden in L-MR1
- return telephonyManager.isVoiceCapable();
- }
- final int phoneType = telephonyManager.getPhoneType();
- return phoneType == TelephonyManager.PHONE_TYPE_CDMA
- || phoneType == TelephonyManager.PHONE_TYPE_GSM;
- }
-
- /**
* Returns the number of phones available. Returns 1 for Single standby mode (Single SIM
* functionality) Returns 2 for Dual standby mode.(Dual SIM functionality)
*
@@ -85,31 +62,7 @@ public class TelephonyManagerCompat {
if (telephonyManager == null) {
return 1;
}
- if (CompatUtils.isMarshmallowCompatible()
- || CompatUtils.isMethodAvailable(TELEPHONY_MANAGER_CLASS, "getPhoneCount")) {
- return telephonyManager.getPhoneCount();
- }
- return 1;
- }
-
- /**
- * Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for
- * CDMA phones. Return null if device ID is not available.
- *
- * <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
- *
- * @param telephonyManager The telephony manager instance to use for method calls.
- * @param slotId of which deviceID is returned
- */
- public static String getDeviceId(@Nullable TelephonyManager telephonyManager, int slotId) {
- if (telephonyManager == null) {
- return null;
- }
- if (CompatUtils.isMarshmallowCompatible()
- || CompatUtils.isMethodAvailable(TELEPHONY_MANAGER_CLASS, "getDeviceId", Integer.class)) {
- return telephonyManager.getDeviceId(slotId);
- }
- return null;
+ return telephonyManager.getPhoneCount();
}
/**
@@ -119,14 +72,7 @@ public class TelephonyManagerCompat {
* @return {@code true} if the device supports TTY mode, and {@code false} otherwise.
*/
public static boolean isTtyModeSupported(@Nullable TelephonyManager telephonyManager) {
- if (telephonyManager == null) {
- return false;
- }
- if (CompatUtils.isMarshmallowCompatible()
- || CompatUtils.isMethodAvailable(TELEPHONY_MANAGER_CLASS, "isTtyModeSupported")) {
- return telephonyManager.isTtyModeSupported();
- }
- return false;
+ return telephonyManager != null && telephonyManager.isTtyModeSupported();
}
/**
@@ -138,15 +84,7 @@ public class TelephonyManagerCompat {
*/
public static boolean isHearingAidCompatibilitySupported(
@Nullable TelephonyManager telephonyManager) {
- if (telephonyManager == null) {
- return false;
- }
- if (CompatUtils.isMarshmallowCompatible()
- || CompatUtils.isMethodAvailable(
- TELEPHONY_MANAGER_CLASS, "isHearingAidCompatibilitySupported")) {
- return telephonyManager.isHearingAidCompatibilitySupported();
- }
- return false;
+ return telephonyManager != null && telephonyManager.isHearingAidCompatibilitySupported();
}
/**
@@ -228,6 +166,12 @@ public class TelephonyManagerCompat {
public static void handleSecretCode(Context context, String secretCode) {
// Must use system service on O+ to avoid using broadcasts, which are not allowed on O+.
if (BuildCompat.isAtLeastO()) {
+ if (!TelecomUtil.isDefaultDialer(context)) {
+ LogUtil.e(
+ "TelephonyManagerCompat.handleSecretCode",
+ "not default dialer, cannot send special code");
+ return;
+ }
context.getSystemService(TelephonyManager.class).sendDialerSpecialCode(secretCode);
} else {
// System service call is not supported pre-O, so must use a broadcast for N-.