From e7833312d746ca1e89e9fa66d66e109af32e5a22 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Tue, 7 May 2019 10:55:55 -0700 Subject: [PATCH] Make getSimCallManager msim aware When there are multiple subscriptions available, the SIM call manager is currently resolved based on what the default voice subscription is. Add the ability for TelecomManager to get the SIM call manager for a Telephony subscription ID. Test: Manual; atest TelecomUnitTests Bug: 131627085 Change-Id: I748fcebb44f07fbc9deef0c6a07d2f15a44b22d3 --- .../java/android/telecom/TelecomManager.java | 45 +++++++++++++++---- .../internal/telecom/ITelecomService.aidl | 2 +- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index db63198715406..dc6cf18cc5f41 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -33,6 +33,7 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; @@ -849,15 +850,18 @@ public class TelecomManager { /** * Returns the current SIM call manager. Apps must be prepared for this method to return - * {@code null}, indicating that there currently exists no user-chosen default - * {@code PhoneAccount}. + * {@code null}, indicating that there currently exists no SIM call manager {@link PhoneAccount} + * for the default voice subscription. * - * @return The phone account handle of the current sim call manager. + * @return The phone account handle of the current sim call manager for the default voice + * subscription. + * @see SubscriptionManager#getDefaultVoiceSubscriptionId() */ public PhoneAccountHandle getSimCallManager() { try { if (isServiceConnected()) { - return getTelecomService().getSimCallManager(); + return getTelecomService().getSimCallManager( + SubscriptionManager.getDefaultSubscriptionId()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); @@ -866,9 +870,32 @@ public class TelecomManager { } /** - * Returns the current SIM call manager for the specified user. Apps must be prepared for this - * method to return {@code null}, indicating that there currently exists no user-chosen default - * {@code PhoneAccount}. + * Returns current SIM call manager for the Telephony Subscription ID specified. Apps must be + * prepared for this method to return {@code null}, indicating that there currently exists no + * SIM call manager {@link PhoneAccount} for the subscription specified. + * + * @param subscriptionId The Telephony Subscription ID that the SIM call manager should be + * queried for. + * @return The phone account handle of the current sim call manager. + * @see SubscriptionManager#getActiveSubscriptionInfoList() + * @hide + */ + public PhoneAccountHandle getSimCallManagerForSubscription(int subscriptionId) { + try { + if (isServiceConnected()) { + return getTelecomService().getSimCallManager(subscriptionId); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecomService#getSimCallManager"); + } + return null; + } + + /** + * Returns the current SIM call manager for the user-chosen default Telephony Subscription ID + * (see {@link SubscriptionManager#getDefaultSubscriptionId()}) and the specified user. Apps + * must be prepared for this method to return {@code null}, indicating that there currently + * exists no SIM call manager {@link PhoneAccount} for the default voice subscription. * * @return The phone account handle of the current sim call manager. * @@ -889,8 +916,8 @@ public class TelecomManager { /** * Returns the current connection manager. Apps must be prepared for this method to return - * {@code null}, indicating that there currently exists no user-chosen default - * {@code PhoneAccount}. + * {@code null}, indicating that there currently exists no Connection Manager + * {@link PhoneAccount} for the default voice subscription. * * @return The phone account handle of the current connection manager. * @hide diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index 5cd46ca936a73..4fcda4d008839 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -97,7 +97,7 @@ interface ITelecomService { /** * @see TelecomServiceImpl#getSimCallManager */ - PhoneAccountHandle getSimCallManager(); + PhoneAccountHandle getSimCallManager(int subId); /** * @see TelecomServiceImpl#getSimCallManagerForUser