//35.找到了吧,最初的构造数据是number
//35.回到最初的起点
final Intent intent = new CallIntentBuilder(number).
setCallInitiationType(LogState.INITIATION_DIALPAD)
.build();
IntentUtil.CallIntentBuilder
public CallIntentBuilder(String number) {
this(CallUtil.getCallUri(number));
}
public CallIntentBuilder(Uri uri) {
mUri = uri;
}
public CallIntentBuilder setCallInitiationType(int initiationType) {
mCallInitiationType = initiationType;
return this;
}
public Intent build() {
return getCallIntent(
mUri,
mPhoneAccountHandle,
mIsVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY,
mCallInitiationType);
}
/**
* Create a call intent that can be used to place a call.
* 构建intent,uri目标号码,
* @param uri Address to place the call to.
* @param accountHandle {@link PhoneAccountHandle} to place the call with.此处为空
* @param videoState Initial video state of the call.好像是是否是video ?audio only
* 初始化电话的类型,应该是有系统phone拨号和其他调用拨号之类的区分
* @param callIntiationType The UI affordance the call was initiated by.
* @return Call intent with provided extras and data.
*/
public static Intent getCallIntent(
Uri uri, PhoneAccountHandle accountHandle, int videoState, int callIntiationType) {
//String CALL_ACTION = Intent.ACTION_CALL;
final Intent intent = new Intent(CALL_ACTION, uri);
intent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState);
final Bundle b = new Bundle();
b.putInt(EXTRA_CALL_INITIATION_TYPE, callIntiationType);
intent.putExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, b);
if (accountHandle != null) {
intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
}
return intent;
}
CallUtil
public static Uri getCallUri(String number) {
//
if (PhoneNumberHelper.isUriNumber(number)) {
//String SCHEME_SIP = "sip";
return Uri.fromParts(PhoneAccount.SCHEME_SIP, number, null);
}
return Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
}
PhoneNumberHelper
public static boolean isUriNumber(String number) {
// Note we allow either "@" or "%40" to indicate a URI, in case
// the passed-in string is URI-escaped. (Neither "@" nor "%40"
// will ever be found in a legal PSTN number.)
return number != null && (number.contains("@") || number.contains("%40"));
}