Checking the status of a phone call remotely

前端 未结 6 1353
情深已故
情深已故 2020-12-18 13:59

I want to check after starting a phone call what the status of the call is via a connected PC, if possible with the ADB. I\'m starting a call by entering a phone number with

相关标签:
6条回答
  • 2020-12-18 14:31

    The way you find those numbers is by first identifying your AOS version and then go to GrepCode and go to your version. Then follow the links to: /com.android.internal.telephony.ITelephony (*.java) and search the code for CALL_TRANSACTION.

    0 讨论(0)
  • 2020-12-18 14:35

    Run adb logcat|grep -i currentCallState

    You will get the logs:

    D/PhoneUtils( 1242): setAudioMode() currentCallState : DIALING

    D/PhoneUtils( 1242): setAudioMode() currentCallState : DIALING

    D/PhoneUtils( 1242): setAudioMode() currentCallState : DIALING

    D/PhoneUtils( 1242): setAudioMode() currentCallState : DIALING

    D/PhoneUtils( 1242): setAudioMode() currentCallState : ALERTING

    D/PhoneUtils( 1242): setAudioMode() currentCallState : ACTIVE

    D/PhoneUtils( 1242): setAudioMode() currentCallState : DISCONNECTING

    D/PhoneUtils( 1242): setAudioMode() currentCallState : IDLE

    DIALING - Still dialing ALERTING - Ringing DISCONNECTING - Clicked Disconnect IDLE - Back to normal state

    0 讨论(0)
  • 2020-12-18 14:38

    Figuring out if the call is still in progress is pretty straight forward. You can either:

    • Monitor the logcat for the phone state
    • Write a bit of code to poll http://developer.android.com/reference/android/telephony/TelephonyManager.html#getCallState()
    • Write a bit of code to register for phone state http://developer.android.com/reference/android/telephony/PhoneStateListener.html

    Figuring out if the number called is currently busy is a totally different scope since you now have to deal with network specific implementation (cdma is wildly different than gsm). On CDMA it is almost impossible to figure it out.

    0 讨论(0)
  • 2020-12-18 14:46

    adb shell dumpsys telephony.registry | grep mCallState, will return:

    • 0 indicates idle,
    • 1 = ringing and
    • 2 = active call
    0 讨论(0)
  • 2020-12-18 14:46

    To call TelephonyManager.getCallState() from adb shell use:

    adb shell service call phone 30
    

    For proper parsing of the service call command output on the device side and without external dependencies see my answer here

    Also read Calling Android services from ADB shell for more details.

    0 讨论(0)
  • 2020-12-18 14:53

    I just found my own answer. Using "dumpsys telephony.registry" gives me every information I need. It contains the variable "mCallState" which is just what I need.

    Update: ok not 100% what I need, for some reason the callstate does not change when a connection is established. If someone has more ideas I'd love to know.

    Update 2: Apparently this is a security measurement in Android, you can not get the current call status during the call, you only get to know that the user is making one but not if there is already an active connection present or still dialing.

    0 讨论(0)
提交回复
热议问题