3

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 the adb command service call phone 2 s16 "some phone number" and then sending input keyevent 5 to press the call button.

Now I'm struggeling to find a way to determine the status of the call. I need to know if the the number getting called is currently busy, if the call got cancelled or if the call was successfull/that I have an open voice connection to the called number. Is there any way of monitoring that?

The phone model really doesn't matter nor the android service/app I use to call the number nor the android version. The phone will be/is rooted. I will use whatever works.

timonsku
  • 1,249
  • 2
  • 21
  • 45

8 Answers8

7

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

  • 0 indicates idle,
  • 1 = ringing and
  • 2 = active call
mustaccio
  • 18,234
  • 16
  • 48
  • 57
diaBlo35
  • 131
  • 2
  • 3
1

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

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.

ak112358
  • 713
  • 2
  • 13
  • 25
Phuong Nguyen
  • 909
  • 7
  • 20
  • 2
    Thanks for this answer, thats quite usefull. Though I found a bit easier way of doing it with the adb shell command `dumpsys telephony.registry` which gives very detailed information – timonsku Oct 30 '13 at 00:53
1

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.

timonsku
  • 1,249
  • 2
  • 21
  • 45
1

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.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • How do you know what int to supply for the corresponding api function? though suppling `30` gives me always `00000000 00000001` no matter if the phone is idle or dialing. – timonsku Oct 30 '13 at 16:47
  • what android version does your phone have? `getCallState`=30 for jb-mr2. For ics and jb before mr2 it's 29. – Alex P. Oct 31 '13 at 07:34
  • Though again, where do you get these numbers from? I can't find any reference for that. – timonsku Nov 01 '13 at 19:20
1

try adb shell dumpsys telecom | grep mForegroundCall

I've found it useful on my YQ601

qki
  • 1,769
  • 11
  • 25
esc ca
  • 11
  • 1
0

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.

not2qubit
  • 14,531
  • 8
  • 95
  • 135
  • Issue is that I needed to do this over the ADB/scripting interface. Writing an application is out of question. – timonsku Jul 20 '14 at 23:13
0

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

Thejus Krishna
  • 1,755
  • 1
  • 19
  • 28
0
adb shell dumpsys notification --noredact|grep "things like the following patterns"

(Incoming voice call)
(Ongoing voice call)
( Incoming video call)
(Ongoing video call)

here the func i use to get notifications as pair of title,text:

function anotifs(){
    notifsregex1='^          android.title='
    notifsregex2='^          android.text='
    adb shell dumpsys notification --noredact | grep -e "${notifsregex1}" -e "${notifsregex2}"|sed -e "s:${notifsregex1}::g" -e "s:${notifsregex2}::g"
}

you can use like so:

function acallstate(){
    case "$(anotifs)" in
        *'(Incoming voice call)'*)
            echo 1
        ;;
        *'(Ongoing voice call)'*)
            echo 2
        ;;
        *'( Incoming video call)'*)
            echo 3
        ;;
        *'(Ongoing video call)'*)
            echo 4
        ;;
        *)
            echo 0 # none
        ;;
    esac
}
Yunus
  • 181
  • 6