NOT_DISCONNECTED, INCOMING_MISSED, NORMAL, LOCAL, BUSY, CONGESTION, MMI, INVALID_NUMBER, LOST_SIGNAL, LIMIT_EXCEEDED, INCOMING_REGECTED, POWER_OFF, OUT_OF_SERVICE, ICC_ERROR, CALL_BARRED, FDN_BLOCKED, CS_RESTRICTED, CS_RESTRICTED_NORMAL, CS_RESTRICTED_EMERGENCY, UNOBTAINABLE_NUMBER, CDMA_LOCKED_UNTIL_POWER_CYCLE, CDMA_DROP, CDMA_INTERCEPT, CDMA_REORDER, CDMA_SO_REJECT, CDMA_RETRY_ORDER, CDMA_ACCESS_FAILURE, CDMA_PREEMPTED, CDMA_NOT_EMERGENCY, CDMA_ACCESS_BLOCKED, ERROR_UNSPECIFIED }
其中枚举了通话断掉的原因,其中有很多原因目前还没有理解。
下面定义了一些抽象方法:
1. public abstract String getAddress(); //获取地址值,例如电话号码
2. public abstract String getCnapName(); //Gets CDMA CNAP name associated with the connection
3. public String getOrigDialString(); //取得原始的号码串
4. public abstract Call getCall(); //取得拥有该Connection的Call
5. public abstract long getCreateTime(); //计算通路建立的时间,ms
6. public abstract long getConnectTime(); //计算通话建立连接的时间,ms
7. public abstract long getDisconnectTime(); //计算断开连接的时间,ms
8. public abstract long getDurationMillis(); //计算通话持续的时间
9. public abstract long getHoldDurationMillis(); //计算通话保持的时间,ms
10. public abstract boolean isIncoming(); //是否是来电
11. public Call.State getState(); //取得Connection的状态,通常与Call的状态一致
12. public boolean isAlive(); / public boolean isRinging(); //都是判断目前电话状态的函数
13. public abstract void hangup() throws CallStateException; //挂断电话的方法
14. public abstract void separate() throws CallStateException; //分离某个Connection的方法
以下是一些处理加长号码(例如含有分机号的号码)的方法。
Call.java 文件位于 frameworks/base/telephony/java/com/android/internal/telephony 目录下,它是一个抽象类,描述了phone 中通话方面信息:刚开始用一个枚举定义了电话的所有状态,为: IDLE, ACTIVE, HOLDING, DIALING, ALERTING, INCOMING, WAITING, DISCONNECTED, DISCONNECTING;并且对这些状态进行了归类,具体为: isActive = !(IDLE || DISCONNECTED || DISCONNECTING); isRinging = (INCOMING || WAITING); isDialing = (DIALING || ALERTING);其中定义的方法有:
1. public abstract ListgetConnection(); //获取Call中所有的Connection
2. public abstract Phone getPhone(); //取得包含Call的Phone
3. public abstract boolean isMultiparty(); //是否有多个通话方
4. public abstract void hangup() throws CallStateException; //挂断通话
5. public boolean hasConnection(Connection c); //判断Call是否包含某个特定的Connection
6. public boolean hasConnections(); //判断Call中是否包含Connection
7. public State getState(); //返回Call的状态
8. public boolean isIdle(); //返回true,如果Call中仅包含disconnected Connection
9. public Connection getEarlistConnection(); //返回最早建立的Connection
10. public long getEarlistCreateTime(); //返回最早的Connection的建立时间
11. public long getEarlistConnectionTime(); //返回最早的Connection的连接时间
12. public boolean isDialingOrAlerting();
13. public boolean isRinging();
14. public Connection getLastestConnection(); //返回最新建立的Connection
15. public void hangupIfAlive(); //Hangup call if it is alive
网友评论