upgrade/downgrade 升降级,其实就是ModifyCall
流程图
界面入手
packages/apps/InCallUI
packages/apps/InCallUI/src/com/android/incallui/CallButtonFragment.Java
CallButtonFragment.java onClick()
case R.id.changeToVideoButton: if (call == null) { Log.i(this, "Call was null"); return; } if (getResources().getBoolean(R.bool.config_regional_number_patterns_video_call) && //默认为false !CallUtil.isVideoCallNumValid(call.getNumber())) { Toast.makeText(this.getActivity(), R.string.toast_change_video_call_failed, Toast.LENGTH_LONG).show(); return; } getPresenter().changeToVideoClicked();//切换为视频通话,实际是ModifyCall 后面可以看到调用 break;
packages/apps/InCallUI/src/com/android/incallui/CallButtonPresenter.java
changeToVideoClicked()
本来还有一个changeToVoiceClick()的,不过没有使用。
public void changeToVideoClicked() { final Context context = getUi().getContext(); if (QtiCallUtils.useExt(context)) { //为true,可以看下面的代码断 QtiCallUtils.displayModifyCallOptions(mCall, context);//这里 return; } VideoCall videoCall = mCall.getVideoCall(); if (videoCall == null) { return; } int currVideoState = mCall.getVideoState(); int currUnpausedVideoState = CallUtils.getUnPausedVideoState(currVideoState); currUnpausedVideoState |= VideoProfile.STATE_BIDIRECTIONAL; VideoProfile videoProfile = new VideoProfile(currUnpausedVideoState); videoCall.sendSessionModifyRequest(videoProfile); mCall.setSessionModificationState(Call.SessionModificationState.WAITING_FOR_RESPONSE); }
packages/apps/InCallUI/src/com/android/incallui/QtiCallUtils.java
QtiCallUtils.java
/** * Checks the boolean flag in config file to figure out if we are going to use Qti extension or * not */ public static boolean useExt(Context context) { if (context == null) { Log.w(context, "Context is null..."); } return context != null && context.getResources().getBoolean(R.bool.video_call_use_ext); //默认为true }
displayModifyCallOptions() 显示选项(早先是在overflow menu中有个modify call选项,点击后弹出4个选项供选择)
/** * The function is called when Modify Call button gets pressed. The function creates and * displays modify call options. */ public static void displayModifyCallOptions(final Call call, final Context context) { if (call == null) { Log.d(LOG_TAG, "Can't display modify call options. Call is null"); return; } if (isTtyEnabled(context)) { Log.w(LOG_TAG, "Call session modification is allo