1.通话状态
State {
IDLE,//待机,没有连接
ACTIVE,//通话
HOLDING,//挂断通话
DIALING,//响铃
ALERTING,//提醒
INCOMING,//来电
WAITING,//等待接通
DISCONNECTED,//连接断开后
DISCONNECTING;//连接断开工程中
}
在GSMCallTracker中维护着通话列表:connections。顺序记录了正连接上的通话,这些通话包括:ACTIVE,DIALING,ALERTING,HOLDING,INCOMING,WAITING等状态的连接。GSMCallTracker将这些连接分为了三类别进行管理:
RingingCall: INCOMING ,WAITING
ForegourndCall: ACTIVE, DIALING ,ALERTING
BackgroundCall: HOLDING
2.通话失败的原因
CallFailCause {
// Unassigned/Unobtainable number未分配的号码
static final int UNOBTAINABLE_NUMBER = 1;
static final int NORMAL_CLEARING = 16;
// Busy Tone对方正在通话
static final int USER_BUSY = 17;
// No Tone
static final int NUMBER_CHANGED = 22;
static final int STATUS_ENQUIRY = 30;
static final int NORMAL_UNSPECIFIED = 31;
// Congestion Tone
static final int NO_CIRCUIT_AVAIL = 34;
static final int TEMPORARY_FAILURE = 41;
static final int SWITCHING_CONGESTION = 42;
static final int CHANNEL_NOT_AVAIL = 44;
static final int QOS_NOT_AVAIL = 49;
static final int BEARER_NOT_AVAIL = 58;
// others
static final int ACM_LIMIT_EXCEEDED = 68;
static final int CALL_BARRED = 240;
static final int FDN_BLOCKED = 241;
static final int ERROR_UNSPECIFIED = 0xffff;
static final int IMSI_UNKNOWN_IN_VLR = 242;
static final int IMEI_NOT_ACCEPTED = 243;
}
3.连接取消的原因
DisconnectCause {
NOT_DISCONNECTED,/* has not yet disconnected 连接失败*/
INCOMING_MISSED,/* an incoming call that was missed and never answered 错过了来电*/
NORMAL,/* normal; remote 对方挂断电话*/
LOCAL,/* normal; local hangup 自己挂断电话*/
BUSY,/* outgoing call to busy line 拨打的号码正在通话*/
CONGESTION,/* outgoing call to congested network 网络拥挤*/
MMI,/*not presently used; dial()returns null拨号的号码未被使用*/
INVALID_NUMBER,/* invalid dial string 无效的号码串*/
LOST_SIGNAL,
LIMIT_EXCEEDED,/* eg GSM ACM limit exceeded 超出限额的GSM ACM。ACM(Association for Computing Machinery )中文:美国计算机协会是一个世界性的计算机从业员专业组织*/
INCOMING_REJECTED,/* an incoming call that was rejected 来电被拒绝*/
POWER_OFF,/* radio is turned off explicitly 无线网络被关闭*/
OUT_OF_SERVICE,/* out of service 服务区外*/
ICC_ERROR,/* No ICC, ICC locked, or other ICC error */
CALL_BARRED,/* call was blocked by call barrring 被“呼叫限制”拦截*/
FDN_BLOCKED,/* call was blocked by fixed dial number 被“固定拨号”拦截*/
CS_RESTRICTED,/* call was blocked by restricted all voice access 被“拒绝语音接入”拦截*/
CS_RESTRICTED_NORMAL,/* call was blocked by restricted normal voice access 被“拒绝通话”拦截*/
CS_RESTRICTED_EMERGENCY,/* call was blocked by restricted emergency voice access */
UNOBTAINABLE_NUMBER,/* Unassigned number (3GPP TS 24.008 table 10.5.123) 未分配的号码*/
IMSI_UNKNOWN_IN_VLR,/* IMSI is not known at the VLR VLR不能识别IMSI。国际移动用户识别码(IMSI:International Mobile Subscriber Identification Number)是区别移动用户的标志,储存在SIM卡中,可用于区别移动用户的有效信息。其总长度不超过15位,同样使用0~9的数字。其中MCC是移动用户所属国家代号,占3位数字,中国的MCC规定为460;MNC是移动网号码,最多由两位数字组成,用于识别移动用户所归属的移动通信网;MSIN是移动用户识别码,用以识别某一移动通信网中的移动用户。VLR (Visitor Location Register):拜访位置寄存器。是一个数据库,是存储所管辖区域中MS(统称拜访客户)的来话、去话呼叫所需检索的信息以及用户签约业务和附加业务的信息,例如客户的号码,所处位置区域的识别,向客户提供的服务等参数。*/
IMEI_NOT_ACCEPTED,/* network does not accept emergency call establishment using an IMEI 网络不接受使用紧急呼叫建立一个IMEI。IMEI(International Mobile Equipment Identity)是国际移动设备身份码的缩写,国际移动装备辨识码,是由15位数字组成的"电子串号",它与每台手机一一对应,而且该码是全世界唯一的。每一只手机在组装完成后都将被赋予一个全球唯一的一组号码,这个号码从生产到交付使用都将被制造生产的厂商所记录。*/
CDMA_LOCKED_UNTIL_POWER_CYCLE,/* MS is locked until next power cycle 直到下一个电话周期,MS被关闭。MS:Mobile station 的缩写,移动台*/
CDMA_DROP,
CDMA_INTERCEPT,/* INTERCEPT order received, MS state idle entered 接到拦截命令,MS进入闲置状态*/
CDMA_REORDER,/* MS has been redirected, call is cancelled呼叫被取消 */
CDMA_SO_REJECT,/* service option rejection 拒绝服务选项*/
CDMA_RETRY_ORDER,/* requeseted service is rejected, retry delay is set 请求被拒绝,设置延时重试*/
CDMA_ACCESS_FAILURE,
CDMA_PREEMPTED,
CDMA_NOT_EMERGENCY,/* not an emergency call 不是紧急号码*/
CDMA_ACCESS_BLOCKED,/* Access Blocked by CDMA network 被CDMA网络拦截*/
ERROR_UNSPECIFIED
}
4.电话号码字符串的状态
PostDialState {
NOT_STARTED,/* The post dial string playback hasn't been started, or this call is not yet connected, or this is an incoming call 号码字符未被发送出去,或者此呼叫尚未连接,或者这只是一个来电*/
STARTED,/* The post dial string playback has begun 号码字符发送启动*/
WAIT,/* The post dial string playback is waiting for a call to proceedAfterWaitChar()号码字符等待调用proceedAfterWaitChar函数,如果postDialState为PostDialState.WAIT时,设置postDialState为PostDialState.STARTED,并且调用函数processNextPostDialChar开始另一个电话号码的字符串发送*/
WILD,/* The post dial string playback is waiting for a call to proceedAfterWildChar() 号码字符等待调用proceedAfterWildChar函数,如果postDialState为PostDialState.WILD时,设置postDialState为PostDialState.STARTED,并且如果已经发出去的字符串的最后一个字符不在“0-9,*,#”中,则调用函数processNextPostDialChar开始另一个电话号码的字符串发送*/
COMPLETE,/* The post dial string playback is complete 所有号码字符都完成发送*/
CANCELLED,/* The post dial string playback was cancelled with cancelPostDial() 号码字符取消发送*/
PAUSE/* The post dial string playback is pausing for a call to processNextPostDialChar号码字符为调用processNextPostDialChar函数而暂停发送*/
}
5.GSMCall
一个通话可以有多个连接,其中还包含了一些伪连接,最多能有5个连接。
当所有连接都断开后,通话状态断开。
当本地挂断电话后,会设置连接取消的原因为本地挂断。
1)拨号
注册一个广播接收机“android.intent.action.NEW_OUTGOING_CALL”,
但要求使用许可android.permission.PROCESS_OUTGOING_CALLS。你可以通过“BroadcastReceiver.onReceive();String strPhoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);”拨出电话号码;
2)来电
使用TelephonyManager和PhoneStateListener来管理。
6.GSMConnection
1)获取连接创建的时间,连接的时间,断开连接的时间;通话的时间,通话被保持的时间。
2)得到连接断开的原因。
3)通话挂断与连接取消之间的关系:
DisconnectCause disconnectCauseFromCode(int causeCode) {
switch (causeCode) {
case CallFailCause.USER_BUSY:
return DisconnectCause.BUSY;
case CallFailCause.NO_CIRCUIT_AVAIL:
case CallFailCause.TEMPORARY_FAILURE:
case CallFailCause.SWITCHING_CONGESTION:
case CallFailCause.CHANNEL_NOT_AVAIL:
case CallFailCause.QOS_NOT_AVAIL:
case CallFailCause.BEARER_NOT_AVAIL:
return DisconnectCause.CONGESTION;
case CallFailCause.ACM_LIMIT_EXCEEDED:
return DisconnectCause.LIMIT_EXCEEDED;
case CallFailCause.CALL_BARRED:
return DisconnectCause.CALL_BARRED;
case CallFailCause.FDN_BLOCKED:
return DisconnectCause.FDN_BLOCKED;
case CallFailCause.UNOBTAINABLE_NUMBER:
return DisconnectCause.UNOBTAINABLE_NUMBER;
/*Display the following call fail cause only when Adapt feature is enabled.只有在适应功能已启用才显示下面的调用失败。*/
case CallFailCause.IMSI_UNKNOWN_IN_VLR:
if (SystemProperties.getBoolean("persist.cust.tel.adapt", false)) {
return DisconnectCause.IMSI_UNKNOWN_IN_VLR;
}
case CallFailCause.IMEI_NOT_ACCEPTED:
if (SystemProperties.getBoolean("persist.cust.tel.adapt", false)) {
return DisconnectCause.IMEI_NOT_ACCEPTED;
}
case CallFailCause.ERROR_UNSPECIFIED:
case CallFailCause.NORMAL_CLEARING:
default:
GSMPhone phone = owner.phone;
int serviceState = phone.getServiceState().getState();
if (serviceState == ServiceState.STATE_POWER_OFF) {
return DisconnectCause.POWER_OFF;
} else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
|| serviceState == ServiceState.STATE_EMERGENCY_ONLY ) {
return DisconnectCause.OUT_OF_SERVICE;
} else if (phone.getIccCard().getState() != SimCard.State.READY) {
return DisconnectCause.ICC_ERROR;
} else if (causeCode == CallFailCause.ERROR_UNSPECIFIED) {
if (phone.mSST.rs.isCsRestricted()) {
return DisconnectCause.CS_RESTRICTED;
} else if (phone.mSST.rs.isCsEmergencyRestricted()) {
return DisconnectCause.CS_RESTRICTED_EMERGENCY;
} else if (phone.mSST.rs.isCsNormalRestricted()) {
return DisconnectCause.CS_RESTRICTED_NORMAL;
} else {
return DisconnectCause.ERROR_UNSPECIFIED;
}
} else if (causeCode == CallFailCause.NORMAL_CLEARING) {
return DisconnectCause.NORMAL;
} else {
/*If nothing else matches, report unknown call drop reason to app, not NORMAL call end.没有匹配的通话失败原因则报告未知的应用程序错误使得通话非正常结束*/
return DisconnectCause.ERROR_UNSPECIFIED;
}
}
}
4)获取通话的状态。
5)对号码各个字符发送状态做处理。
6)processPostDialChar为号码字符执行适当的行动,但不通知应用程序。如果字符是无效的,返回false,并且被忽略。
7.GsmServiceStateTracker
与漫游设置有关,与网络时间同步有关,与运营商有关...
8.GsmCallTracker
是android的通话管理层,建立了ConnectionList来管理现行的通话连接,并向上层提供电话调用接口。
在GSMCallTracker中维护着通话列表:connections。顺序记录了正连接上的通话,这些通话包括:ACTIVE,DIALING,ALERTING,HOLDING,INCOMING,WAITING等状态的连接。GSMCallTracker将这些连接分为了三类别进行管理:
RingingCall: INCOMING ,WAITING
ForegourndCall: ACTIVE, DIALING ,ALERTING
BackgroundCall: HOLDING
|