How to to end an incoming call using monkeyrunner? - android

I have monkeyrunner up and running: I install my .apk using monkeyrunner and have a device object ready. In other words
device.press('KEYCODE_MENU', 'DOWN_AND_UP')
works perfectly.
I use expect to telnet to an android emulator of mine and do gsm call SOME_NUMBER to simulate and incoming call.
I try to reject this call in the following manner:
device.press('KEYCODE_ENDCALL', 'DOWN_AND_UP')
But it does nothing... What do i do wrong ?

If you are using
gsm call SOME_NUMBER
to start the call.
you can use either
gsm cancel SOME_NUMBER
to reject the call or
gsm accept SOME_NUMBER
to accept it.

As far as I can tell, there is no reliable way way to end calls using MonkeyRunner. I'm not sure why this is the case.
The question here offers some solutions.
You could also try doing:
device.press('KEYCODE_HEADSETHOOK', 'DOWN_AND_UP')
Using the headset hook keycode has worked for me on some devices but not others.
The most reliable method that I've found for ending calls using MonkeyRunner is to use menu button. This is talked about in the answers to the question that I linked to above.

Related

Android, Bluetooth, catching special commands from BT device

How can we listen for special BT device commands like redial from our app? For now, I'm only able to listen to the only one - play/pause/start/end call button (KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE).
Using common BroadcastReceiver for "android.intent.action.MEDIA_BUTTON" doesn't help.
Solution with BluetoothSocket, BluetoothServerSocket won't help too since it requires our code to be invoked on BT device side.
During my redial button tests I see the next line in the logs:
01-20 05:52:30.486 942-1060/com.android.bluetooth E/bt-rfcomm: PORT_DataInd, p_port:0x5526c200, p_data_co_callback is null
It looks like there is something sending an event from BT device to the android device. But how can we catch it on app side, what should we use? I work on some system app by the way and theoretically can do very specific, low-level and system things, so maybe there could be some solution.
afaik, this isn't possible, sadly...
I've been working on custom handling BT headset keys, like VOL UP, DOWN, eventually ANSWER/DISCONNECT/REDIAL. Even made rich question, but without single answer or comment...
After some research (days, weeks...) and digging into Android source I've found that these buttons are sending some AT commands. I've also found methods which are checking these AT commands and if system is able to respond/handle them then it TRY to do it and further won't pass any event to any app/socket/rfcomm/anything... E.g. under VOL UP button we have some well-known AT command, system can handle it, so try to do so, even when we already have volume set to max. Any app won't be noticed that this happened...
btw. I don't think this logcat line posted in question is strictly relevant to button press (but may be indirectly), but you have bt-rfcomm keyword in there, so you may try to establish some RFCOMM connection with Bluetooth device, maybe you will get some luck on this topic... (personally I gave up...)

How to check VoLTE enabled programmatically [duplicate]

I have a very minimal knowledge about VoLTE service in android which is provided by the LTE operator.
Is there any API's are available to detect VoLTE call in android?
The API's such as
Call Connected
Call Disconnected
Latency
Call Status
Any link/API reference is much appreciated.
TelephonyManager.java have a function to check isVolteAvailable(). You can call that function to know the status of voLTE.
You can check the source here.. https://github.com/android/platform_frameworks_base/blob/master/telephony/java/android/telephony/TelephonyManager.java
If you can connect to at port then by using standard at commands, this can be verified.
at+cops? => this will give information about the current latched cell. check if the mobile is currently on LTE(7) cell.
make volte call and shoot the at+cops? again. If the call is connected and mobile is still in LTE(7) cell, then its for sure VoLTE call.

Android/Bluetooth programmatically pairing options

I have a list of BluetoothDevice and I want to pair programmatically with one of them that has a PIN.
I have read several posts here in which the subject is discussed, but I've found two very different approachs.
FIRST OPTION: You call the device.createBond() method. Then, on a BroadcastReceiver, you listen the BluetoothDevice.ACTION_PAIRING_REQUEST action and there you call
device.setPin(PIN_BYTES);
device.setPinConfirmation(true);
You can see the complete example & post here: How to pair Bluetooth device programmatically Android
SECOND OPTION: What if you call device.setPin(PIN_BYTES) and device.setPinConfirmation(true) first, and then device.createBond()? Eg:
if(connConfig!=null && connConfig.bluetooth!=null){
device.setPin(connConfig.bluetooth.pass);
device.setPairingConfirmation(true);
device.createBond();
}
And then you forget about listening the BluetoothDevice.ACTION_PAIRING_REQUEST action on your BroadcastReceiver and only pay attention to BluetoothDevice.ACTION_BOND_STATE_CHANGED events? Android + Pair devices via bluetooth programmatically
See in the first answer the code. As far as I get it, that dude isn't using any PIN for pairing, so I also need to use the setPin method.
Which of both you find better?
Am I missing something? BTW: I'm not using reflection because Im not targeting older platforms.

Use Android API functions with ADB

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
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.

Is there a way for monkeyrunner to look at call and sms history on a device?

Is there a way for me to have monkeyrunner be able to look at call and sms history without using sqlite3? Before, I was using Popen with adb shell "sqlite3 /data/data/com.android.providers.contacts/databases/contacts*.db 'select * from calls'" and while that works on emulators it does not work on non rooted devices.
Is there a way to do something similar without rooting the device?
Did you try using monkeyrunner startActivity, broadcastIntent. I believe using broadcastIntent you can actually call a activity like launching com.android.contacts/.DialtactsActivity

Categories

Resources