Add TelecomManagerCompat method for getSimCallManager
Bug: 25776171
Change-Id: I6dcc1b1aed44dccb283b9b7208327250b8d067e2
diff --git a/src/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java b/src/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java
index 035b1bd..6292b7f 100644
--- a/src/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java
+++ b/src/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java
@@ -21,13 +21,11 @@
import android.net.Uri;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccount;
-
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import android.util.Log;
import com.android.contacts.common.compat.CompatUtils;
@@ -167,7 +165,7 @@
* Return whether a given phone number is the configured voicemail number for a
* particular phone account.
*
- * @param telecomManager the {@link TelecomManager} to use
+ * @param telecomManager the {@link TelecomManager} to use for checking the number.
* @param accountHandle The handle for the account to check the voicemail number against
* @param number The number to look up.
*/
@@ -186,8 +184,8 @@
* resources which can be used in a user interface.
*
* @param telecomManager the {@link TelecomManager} used for method calls, if possible.
- * @param accountHandle The PhoneAccountHandle.
- * @return The PhoneAccount object or null if it doesn't exist.
+ * @param account The {@link PhoneAccountHandle}.
+ * @return The {@link PhoneAccount} object or null if it doesn't exist.
*/
@Nullable
public static PhoneAccount getPhoneAccount(@Nullable TelecomManager telecomManager,
@@ -257,7 +255,7 @@
* Silences the ringer if a ringing call exists. Noop if {@link TelecomManager#silenceRinger()}
* is unavailable.
*
- * @param telecomManager the TelecomManager to use to silence the ringer
+ * @param telecomManager the TelecomManager to use to silence the ringer.
*/
public static void silenceRinger(@Nullable TelecomManager telecomManager) {
if (telecomManager != null && (CompatUtils.isMarshmallowCompatible() || CompatUtils
@@ -265,4 +263,20 @@
telecomManager.silenceRinger();
}
}
+
+ /**
+ * Returns the current SIM call manager. Apps must be prepared for this method to return null,
+ * indicating that there currently exists no registered SIM call manager.
+ *
+ * @param telecomManager the {@link TelecomManager} to use to fetch the SIM call manager.
+ * @return The phone account handle of the current sim call manager.
+ */
+ @Nullable
+ public static PhoneAccountHandle getSimCallManager(TelecomManager telecomManager) {
+ if (telecomManager != null && (CompatUtils.isMarshmallowCompatible() || CompatUtils
+ .isMethodAvailable(TELECOM_MANAGER_CLASS, "getSimCallManager"))) {
+ return telecomManager.getSimCallManager();
+ }
+ return null;
+ }
}