2

Is it possible to use the android api functions from the adb? If its possible, what is the syntax to do so? For example I'd like to call the "DATA_CONNECTED" function from android.telephony and get its return value. Link: http://developer.android.com/reference/android/telephony/TelephonyManager.html#CALL_STATE_OFFHOOK

1 Answer 1

2

There is no DATA_CONNECTED function in Android TelephonyManager. It is a 0x00000002 constant - one of possible response codes to the getDataState() function.

The way you call getDataState() from adb shell is:

service call phone 32

Update: if your phone runs anything older than jb-mr2, the command should be:

service call phone 31

P.S. just finished my write-up on Calling Android services from ADB shell - it includes a small bash script to look up calling codes for any service/method for a specific device.

Sign up to request clarification or add additional context in comments.

4 Comments

Can I use every API function in that manner? Same question as in the other question, how do you know what int to supply the service?
in theory you can call any service IPC method with adb shell service call. in practice you won't be able to provide all needed parameters for many methods. but it works great for the basic stuff like most getState type of functions.
Thanks, very usefull to know, accepted that as an answer. Comes as close as it can get I guess.
after almost a year I finally remembered to publish my post on how to find out calling codes for services for a specific android version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.