diff options
author | twyen <twyen@google.com> | 2017-11-15 18:24:45 -0800 |
---|---|---|
committer | zachh <zachh@google.com> | 2017-11-18 07:32:30 +0000 |
commit | 5c7524f3354e5121bbea1064a9f13f19e94c276d (patch) | |
tree | ddb121b16963f3a2cf1eb307bb87a45cf32cc3f6 /java/com/android/dialer/telecom | |
parent | ad01e74802f7ee0c5971b65bd686db5e566e3d12 (diff) |
Send SUB_ID_EXTRA to VoicemailSettingsActivity in Telephony
EXTRA_PHONE_ACCOUNT_HANDLE is not implemented in O. subId is required to determine which SIM the settings is for.
Bug: 67669006
Test: VoicemailSettingsFragmentTest, TelecomUtilTest
PiperOrigin-RevId: 175913331
Change-Id: I84f9e19b711c5baa275d934cfdfd5b7a2d4b6f6d
Diffstat (limited to 'java/com/android/dialer/telecom')
-rw-r--r-- | java/com/android/dialer/telecom/TelecomUtil.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/java/com/android/dialer/telecom/TelecomUtil.java b/java/com/android/dialer/telecom/TelecomUtil.java index 3bf9b4666..c79d9013d 100644 --- a/java/com/android/dialer/telecom/TelecomUtil.java +++ b/java/com/android/dialer/telecom/TelecomUtil.java @@ -33,9 +33,12 @@ import android.support.v4.content.ContextCompat; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; +import android.telephony.SubscriptionInfo; +import android.telephony.SubscriptionManager; import android.text.TextUtils; import android.util.Pair; import com.android.dialer.common.LogUtil; +import com.google.common.base.Optional; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -146,6 +149,24 @@ public abstract class TelecomUtil { } /** + * @return the {@link SubscriptionInfo} of the SIM if {@code phoneAccountHandle} corresponds to a + * valid SIM. Absent otherwise. + */ + public static Optional<SubscriptionInfo> getSubscriptionInfo( + @NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) { + if (TextUtils.isEmpty(phoneAccountHandle.getId())) { + return Optional.absent(); + } + SubscriptionManager subscriptionManager = context.getSystemService(SubscriptionManager.class); + for (SubscriptionInfo info : subscriptionManager.getActiveSubscriptionInfoList()) { + if (phoneAccountHandle.getId().startsWith(info.getIccId())) { + return Optional.of(info); + } + } + return Optional.absent(); + } + + /** * Returns true if there is a dialer managed call in progress. Self managed calls starting from O * are not included. */ |