本文主要是介绍安卓挂电话解析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在app/phone里的PhoneUtils.java里还有一个hangup函数
static boolean hangup(CallManager cm) {boolean hungup = false;Call ringing = cm.getFirstActiveRingingCall();Call fg = cm.getActiveFgCall();Call bg = cm.getFirstActiveBgCall();if (!ringing.isIdle()) {log("hangup(): hanging up ringing call");hungup = hangupRingingCall(ringing);} else if (!fg.isIdle()) {log("hangup(): hanging up foreground call");hungup = hangup(fg);} else if (!bg.isIdle()) {log("hangup(): hanging up background call");hungup = hangup(bg);} else {// No call to hang up! This is unlikely in normal usage,// since the UI shouldn't be providing an "End call" button in// the first place. (But it *can* happen, rarely, if an// active call happens to disconnect on its own right when the// user is trying to hang up..)log("hangup(): no active call to hang up");}if (DBG) log("==> hungup = " + hungup);return hungup;}
这里的hungup = hangup(fg);
在同文件里定义
static boolean hangup(Call call) {try {CallManager cm = getCallManager();if (call.getState() == Call.State.ACTIVE && cm.hasActiveBgCall()) {// handle foreground call hangup while there is background calllog("- hangup(Call): hangupForegroundResumeBackground...");cm.hangupForegroundResumeBackground(cm.getFirstActiveBgCall());} else {log("- hangup(Call): regular hangup()...");call.hangup();}return true;} catch (CallStateException ex) {Log.e(LOG_TAG, "Call hangup: caught " + ex, ex);}return false;}
这里的 cm.hangupForegroundResumeBackground(cm.getFirstActiveBgCall());
<span style="font-size:18px;">public void hangupForegroundResumeBackground(Call heldCall) throws CallStateException {Phone foregroundPhone = null;Phone backgroundPhone = null;if (VDBG) {Rlog.d(LOG_TAG, "hangupForegroundResumeBackground(" +heldCall + ")");Rlog.d(LOG_TAG, toString());}if (hasActiveFgCall()) {foregroundPhone = getFgPhone();if (heldCall != null) {backgroundPhone = heldCall.getPhone();if (foregroundPhone == backgroundPhone) {getActiveFgCall().hangup();} else {// the call to be hangup and resumed belongs to different phonesgetActiveFgCall().hangup();switchHoldingAndActive(heldCall);}}}if (VDBG) {Rlog.d(LOG_TAG, "End hangupForegroundResumeBackground(" +heldCall + ")");Rlog.d(LOG_TAG, toString());}}</span>
这里的getActiveFgCall().hangup();在两种情况下都被使用了
这篇关于安卓挂电话解析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!