android CallCard.java/updateState(Phone phone)分析
CallCard.java----->void updateState(Phone phone)----->根据当点电话的状态选择执行下列更新函数,1,updateRingCall(phone)/ 2,updateForegroundCall(phone)/ 3, updateNoCallphone()
1,
updateRingCall(phone)----->a, displayMainCallStatus(phone, ringingCall) && b, displayOnholdingCallStatus(phone, bgCall) && c, displayOngoingCallStatus(phone, fgoingCall)
a, displayMainCallStatus(phone ringingCall)----->{假如无来电,返回, 确定是否横屏状态,蓝牙状态, 如果当前电话已经接通,根据横屏状态和蓝牙状态拿到当前CallCard背景图片资>源,即callCardBackgroundResid, 更新时钟信息,就是打电话的时候屏幕下方计时的时钟, 而如果是保持状态,挂断状态(DISCONNECTED),拨打等待(DIALING)状态,警告状态(ALERTING),来电状态(INCOMING),等待状态(WAITING),也拿到对应的callCardBackgroundResid, 取消计时,空闲状态下,什么也不做 }, 设置好callCardBackgroundResid(就是装头像的那个背景)后,然后进入updat
eCallCardTitleWidgets(Phone phone, Call call), 设置一些widget, getTitleForCallCard(call), 给当前状态找一个条题目,比如“正在拨号”“来电”“当前通话”等等, {如果当前是的Call是激活的也就是接通的,根据蓝牙状态给当前通话找一个图标,设置文字颜色,如果是挂断状态,也配置好图标和字串显示在屏幕上,然后根据挂断与否,显示时钟},到这里为止,显示的都是背景阿,文字什>么的, 当前通话人的信息,比如头像名字还没找出来,接写来就干这个了, 如果当前是会议通话,更新会议界面,否则查找个人信息,如相片,电话号码,名字等,显示在界面上不详细解释.
b,c 不详细解释
2,
updateForgroundCall(phone), 如果当前电话空闲,且有新连接,则displayMainCallStatus(), 然后执行1里面的动作
3,
updateNoCallPhone, 也是执行,1里面的三个更新函数,只不过,不同状态下,参数不一样,比如电话在完全空闲状态下,没有新来电,也没有挂起的电话,也没有去电,则参数,ringCall, bgCall, ongoingCall 都为null.
源代码如下:
void updateState(Phone phone) {
if (DBG) log("updateState(" + phone + ")...");
// Update some internal state based on the current state of the phone.
// TODO: This code, and updateForegroundCall() / updateRingingCall(),
// can probably still be simplified some more.
Phone.State state = phone.getState(); // IDLE, RINGING, or OFFHOOK
if (state == Phone.State.RINGING) {
// A phone call is ringing *or* call waiting
// (ie. another call may also be active as well.)
updateRingingCall(phone);
} else if (state == Phone.State.OFFHOOK) {
// The phone is off hook. At least one call exists that is
// dialing, active, or holding, and no calls are ringing or waiting.
updateForegroundCall(phone);
} else {
// The phone state is IDLE!
//
// The most common reason for this is if a call just
// ended: the phone will be idle, but we *will* still
// have a call in the DISCONNECTED state:
Call fgCall = phone.getForegroundCall();
Call bgCall = phone.getBackgroundCall();
if ((fgCall.getState() == Call.State.DISCONNECTED)
|| (bgCall.getState() == Call.State.DISCONNECTED)) {
// In this case, we want the main CallCard to display
// the "Call ended" state. The normal "foreground call"
// code path handles that.
updateForegroundCall(phone);
} else {
updateNoCall(phone);
}
}
}
更多相关文章
- android实时监听网络状态并在断网的情况下打开网络设置
- Android状态栏微技巧(推荐)
- android解决FragmentStatePagerAdapter 造成重新绘制fragment状
- android 自定义 radiobutton 文字颜色随选中状态而改变
- Android透明状态栏(沉浸式状态栏)
- Android开发 使用XML文件设置背景变化
- 曾经的笔记——android的学习笔记(布局和电话、短信权限)
- Android开发中ConnectivityManager应用
- android去除标题栏及状态栏