【Group control】Receive call & send SMS script through adb command

Due to the regulations of the telecommunications bureau, when the mobile phone number is not used for a long time, it will enter the locked state (can receive calls but not make calls, can receive text messages but cannot send text messages), so in order to avoid mobile phone numbers being judged as zombie numbers, it is necessary to make regular calls to each other and Connected script.

Disclaimer: This article is only for technical discussion, technology is not guilty. Do not use this method for illegal activities! ! !

Call operation:

Outgoing calls:

adb shell am start -a android.intent.action.CALL -d tel:{$phone_number}

Answer the phone:

adb shell setprop persist.sys.tel.autoanswer.ms 2000

or

adb shell input keyevent 5

Hang up the phone:

adb shell input keyevent 6

Determine the current phone status:

adb shell dumpsys telephony.registry

mCallState - call state

0: Indicates the standby state

1: Indicates that the incoming call has not been answered

2: Indicates that the phone is busy

mServiceState - service state

0: Indicates normal use status

1: Indicates that the phone is not connected to any telecom operator network

2: Indicates that the phone can only dial emergency numbers

3: Indicates that the phone is turned off

Supplement the script of shell automatic answering and calling:

devices=$(adb devices)
var=${devices//List of devices attached/}
var=${var//    device/}
phone="******"
called_device="d922ad4"

for element in $var
do
    if [ ! -n "$(adb -s $element shell dumpsys telephony.registry | grep "mCallState=1")" ]
    then
        adb -s $element shell am start -a android.intent.action.CALL -d tel:{$phone}
        sleep 15
        if [ ! -n "$(adb -s $called_device shell dumpsys telephony.registry | grep "mCallState=1")" ]
        then
            echo "I have no incoming call, please connect SYSTEM_MANAGER."
        else
            adb -s $called_device shell input keyevent 5
            sleep 15
            adb -s $called_device shell input keyevent 6
        fi
    else
          echo "ERROR!!!!!!"
    fi    
done

Send SMS operation:

Open the SMS sending UI interface:

adb shell am start -a android.intent.action.SENDTO -d sms:$phone

Type in the message content: (Note that only letters can be entered)

adb shell input text xxxxxxxxx

Move the cursor to select:

adb shell input keyevent 22

Execute send:

adb shell input keyevent 66

The effect is as follows:

Guess you like

Origin blog.csdn.net/u013772433/article/details/128789992