电话接通与未接通,下层上报的状态

原创 2012年03月29日 21:20:58

  

 在

反复拨打电话,电话测试小程序,紧急电话与普通电话分枝判断

中遇到这样一个问题 ,在压力测试电话拨打时,如果没有接通,该如何判断此状态呢,该如何统计拨打成功多少次?

从log日志中发现有:

 01-01 08:26:43.507: DEBUG/InCallScreen(1409):   - mLastDisconnectCause = NORMAL
 01-01 08:27:01.515: DEBUG/InCallScreen(1409):   - mLastDisconnectCause = LOCAL

01-02 17:21:36.304: DEBUG/InCallScreen(1383):   - mLastDisconnectCause = ERROR_UNSPECIFIED

 

其中:    // DisconnectCause values in the most common scenarios:
                // - INCOMING_MISSED: incoming ringing call times out, or the  other end hangs up while still ringing
                // - INCOMING_REJECTED: user rejects the call while ringing
                // - LOCAL: user hung up while a call was active (after answering an incoming call, or after making an  outgoing call)
                // - NORMAL: the other end hung up (after answering an incoming   call, or after making an outgoing call)

如果:mLastDisconnectCause = ERROR_UNSPECIFIED 表示连接不成功--失败。

在代码:InCallScreen.java里得到体现,见如下代码:

  

    private void delayedCleanupAfterDisconnect() {
        if (VDBG) log("delayedCleanupAfterDisconnect()...  Phone state = " + mCM.getState());

        // Clean up any connections in the DISCONNECTED state.
        //
        // [Background: Even after a connection gets disconnected, its
        // Connection object still stays around, in the special
        // DISCONNECTED state.  This is necessary because we we need the
        // caller-id information from that Connection to properly draw the
        // "Call ended" state of the CallCard.
        //   But at this point we truly don't need that connection any
        // more, so tell the Phone that it's now OK to to clean up any
        // connections still in that state.]
        mCM.clearDisconnected();

        if (!phoneIsInUse()) {
            // Phone is idle!  We should exit this screen now.
            if (DBG) log("- delayedCleanupAfterDisconnect: phone is idle...");

            // And (finally!) exit from the in-call screen
            // (but not if we're already in the process of pausing...)
            if (mIsForegroundActivity) {
                if (DBG) log("- delayedCleanupAfterDisconnect: finishing InCallScreen...");

                // In some cases we finish the call by taking the user to the
                // Call Log.  Otherwise, we simply call endInCallScreenSession,
                // which will take us back to wherever we came from.
                //
                // UI note: In eclair and earlier, we went to the Call Log
                // after outgoing calls initiated on the device, but never for
                // incoming calls.  Now we do it for incoming calls too, as
                // long as the call was answered by the user.  (We always go
                // back where you came from after a rejected or missed incoming
                // call.)
                //
                // And in any case, *never* go to the call log if we're in
                // emergency mode (i.e. if the screen is locked and a lock
                // pattern or PIN/password is set.)

                if (VDBG) log("- Post-call behavior:");
                if (VDBG) log("  - mLastDisconnectCause = " + mLastDisconnectCause);
                if (VDBG) log("  - isPhoneStateRestricted() = " + isPhoneStateRestricted());
                
                mNumberAll ++;
                Log.e("mNumber", "mNumberAll==="+mNumberAll);
                
                if(mLastDisconnectCause.toString().equals("ERROR_UNSPECIFIED")){
                	mNumberFail ++;
                	Log.e("mNumber", "Failure number==="+mNumberFail);
                }
                
                Log.e("mNumber", "mNumberFail/mNumberAll==="+mNumberAll +"/"+ mNumberAll);
                

                // DisconnectCause values in the most common scenarios:
                // - INCOMING_MISSED: incoming ringing call times out, or the
                //                    other end hangs up while still ringing
                // - INCOMING_REJECTED: user rejects the call while ringing
                // - LOCAL: user hung up while a call was active (after
                //          answering an incoming call, or after making an
                //          outgoing call)
                // - NORMAL: the other end hung up (after answering an incoming
                //           call, or after making an outgoing call)

				//Mod by kylin 2011.10.21 begin	    //Open by kylin 2012.03.22
                if ((mLastDisconnectCause != Connection.DisconnectCause.INCOMING_MISSED)
                        && (mLastDisconnectCause != Connection.DisconnectCause.INCOMING_REJECTED)
                        && !isPhoneStateRestricted()) {
                    if (VDBG) log("- Show Call Log after disconnect...");
                    final Intent intent = PhoneApp.createCallLogIntent();
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    startActivity(intent);
                    // Even in this case we still call endInCallScreenSession (below),
                    // to make sure we don't stay in the activity history.
                }
			    endInCallScreenSession();
                finish();
                //Mod by kylin 2011.10.21 begin	
            }
        } else {
            // The phone is still in use.  Stay here in this activity, but
            // we don't need to keep the screen on.
            if (DBG) log("- delayedCleanupAfterDisconnect: staying on the InCallScreen...");
            if (DBG) PhoneUtils.dumpCallState();
        }
    }


 

 

相关文章推荐

Swift3.0拨打电话,获取通话状态(接通,挂断...)<CoreTelephony,CallKit.CXCallObserver>

Swift3.0拨打电话,获取通话状态(接通,挂断...) 基于Swift3.0的一个循环拨打电话的小功能的,直到接通为止...

Android底层开发之Linux输入子系统要不要判断系统休眠状态上报键值

Android按键驱动中要不要进行suspend状态的判断来选择性的上报键值,根据Android中的经验所有的状态都要上传的,响应不响应是看上层系统的决定;但是如果对于普通的嵌入式Linux系统就不一...
  • kangear
  • kangear
  • 2014年10月14日 10:07
  • 4614

对android M中Call的概要总结(目录结构/界面组成/call状态转化上报/常见log分析)

主要内容 1. Call涉及的目录结构及框架结构 2. InCallUI层的基本架构(所涉及的Presenter、Fragment及Activity) 3. Call的几种状态(对应phone状态)及...
  • aaa111
  • aaa111
  • 2016年10月20日 20:16
  • 2688

android程序接通和挂断电话

关键代码:【PhoneUtils类】 package com.ebupt.phonerecorddemo.server; import java.lang.reflect.Method; impo...

android4.4 接通电话

使用的是耳机模拟,网上的代码可以接通,但是会出现异常。 新建类PhoneManager public class PhoneManager { ////放开耳机按钮    private stat...

android自动接通电话:部分手机不支持

一  前言 这两天要研究类似白名单黑名单以及手势自动接听的一些功能,所以呢,自然而然的涉及到怎么自动接听/挂断电话的功能了。 对于自动接听这一块,android4.1版本及其以上的版本和之前的版本处...

拨打电话通过蓝牙接通

我配对号蓝牙耳机,然后拨打电话,接通后,声音会从蓝牙耳机里面出来,这个流程是怎么样的呢?今天就来分析。      首先肯定的是在开启蓝牙通话的这个通道是在Phone进程里面。     ...
  • wsb1321
  • wsb1321
  • 2012年08月31日 17:06
  • 3201

android 监听电话去电接通瞬间[非来电]

首先感叹一下android强大,它可以把同一个apk里面得不同Actvity分别运行在不同的进程中,比如我想让自己的应用中Activity运行在Phone进程中,那么我需要做三个事情。 本文包含三个知...

Net CF中电话状态的捕获

  • 2009年04月15日 13:25
  • 13KB
  • 下载

对电话状态进行监听实现录音

  • 2016年01月22日 17:51
  • 768KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:电话接通与未接通,下层上报的状态
举报原因:
原因补充:

(最多只允许输入30个字)