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
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.
4 Comments
timonsku
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?
Alex P.
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.timonsku
Thanks, very usefull to know, accepted that as an answer. Comes as close as it can get I guess.
Alex P.
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