From 4a4918041f753438719652320158fff80a4d3482 Mon Sep 17 00:00:00 2001 From: Richard MacGregor Date: Tue, 8 Mar 2016 09:04:26 -0800 Subject: [1/2] MultiSIM: Call using specified SIM Call using specified SIM from: - T9 Dialpad phone number entry - T9 Dialpad speed dial - T9 Dialpad search quick action (non-contact - 'Call ') - Contact search results (T9 and regular) Ticket CD-426 Change-Id: I7495da58df8787a5a9c8caebac51842ee6747498 --- src-ambient/incall/CallMethodInfo.java | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src-ambient/incall/CallMethodInfo.java b/src-ambient/incall/CallMethodInfo.java index 5751f8a..29352c6 100644 --- a/src-ambient/incall/CallMethodInfo.java +++ b/src-ambient/incall/CallMethodInfo.java @@ -23,7 +23,10 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.provider.ContactsContract; +import android.telecom.PhoneAccountHandle; +import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionManager; +import android.text.TextUtils; import android.util.Log; import com.android.phone.common.ambient.AmbientConnection; import com.android.phone.common.R; @@ -211,8 +214,7 @@ public class CallMethodInfo { /** * return empty mock call method that represents emergency call only mode */ - public static CallMethodInfo getEmergencyCallMethod(Context context) { - Context ctx = context.getApplicationContext(); + public static CallMethodInfo getEmergencyCallMethod(Context ctx) { if (sEmergencyCallMethod == null) { sEmergencyCallMethod = new CallMethodInfo(); sEmergencyCallMethod.mName = @@ -227,6 +229,25 @@ public class CallMethodInfo { return sEmergencyCallMethod; } + public static PhoneAccountHandle getPhoneAccountHandleFromCallMethodInfo(Context ctx, + CallMethodInfo callMethodInfo, String number) { + CallMethodInfo emergencyCallMethod = getEmergencyCallMethod(ctx); + // If no sim is selected, or emergency callmethod selected, or number is + // an emergency number, phone account handle should be null, and will use the + // default account. + // Else, create PhoneAccountHandle from selected callmethod components and + // initial call using that account. + PhoneAccountHandle handle = null; + if (callMethodInfo != null && !callMethodInfo.mIsInCallProvider && + !callMethodInfo.equals(emergencyCallMethod) && + (number == null || !PhoneNumberUtils.isEmergencyNumber(number))) { + handle = new PhoneAccountHandle(callMethodInfo.mComponent, + callMethodInfo.mId, + callMethodInfo.mUserHandle); + } + return handle; + } + public void placeCall(String origin, String number, Context c) { placeCall(origin, number, c, false); } -- cgit v1.2.3