I have a problem in sending touch events to Android (not to a specific application, system-wide touch events) through bluetooth.
I know that there are similar questions, but I still could not find the solution. I will be really happy if somebody helps me on this issue.
You can find details of my problem below :
Requirement :
To send remote touch events to Android (without root) through bluetooth.
Possible options I discovered so far :
1) Use of ADB commands - This is possible via USB cable and over network connection; however it is not allowed via bluetooth. Workaround I thought of :
To write an Android application with a background service which listens for Bluetooth inputs; and once it receives input, it runs ADB commands within the app itself. However, I think this requires rooted Android.
2) MonkeyRunner - I think this is also not possible through bluetooth.
3) Accessibility Service - According to my research, writing an accessibility service may be a solution to simulate touch events only when specific conditions are met (e.g. view clicks). But I need to initiate the touch from an external bluetooth device, without waiting for a specific condition.
4) Connecting the external bluetooth device as a HID (e.g. mouse) and simulate the touch on mouse button click. But in this case, the mouse pointer will always be visible to user. I also could not find a way to hide the mouse pointer. There are some tutorials to customise the pointer (e.g. a bigger one), but as I saw transparent mouse pointer is not supported.
I found an application called AutoInput (a Tasker plugin), which simulates touch events, but I could not get any feedback about how it works actually, I could not find how it simulates touch events.
Thanks in advance for your help.
Regards
Related
I have viewed many unofficial MiBand SDKs in Github. (e.g. https://github.com/Freeyourgadget/Gadgetbridge) None includes detect when button touching, but I have viewed apps to detect this feature.
For example Mi Band 2 Func Button.
Also I have tried sniffing bluetooth data traces, but just show data because mobile device is not rooted and I haven't rooted.
Is there any way I can detect the touch of a miband button?
Thanks a lot!
You can listen if there is any touches event on the Mi Band device.
Assuming that the app authenticated...
Start notification to UUID_CHARACTERISTIC_DEVICEEVENT characteristic (In my case it's "00000010-0000-3512-2118-0009af100700")
and you shall receive '\x04' if the device touched.
I am trying to implement a very simple hack.
Suppose there are 2 android phones which are connected via wifi and I run an app in Phone B which sends events to phone A like a pinch / swipe / turn.
So conceptually I would have to write an app which opens a socket and whenever there is an event sends an ioctl to kernel driver which injects these virtual events into android input subsystem
I just dont know what part in android that I need to push virtual events any help would be welcome
You need an rooted device as Phone A, look on this answers:
How to simulate touch from background service with sendevent or other way?
How to simulate a touch event in Android?
and:
Programmatically Injecting Events on Android – Part 1
How to compile Android Application with system permissions
Instruction for compile here
Update(2013.08.15) : I managed to emulate touch event using 1. adb shell (slow), 2. Monkey tool(fast but not satisfying) and 3. monkeyrunner (best because I can couple it with python)
I'm trying to create an external device (probably using raspberry pi) which acts as input device for android. Specifically, I want the device to create touch event(touch, swipe... etc). The touch event should be created not only when certain app is activated, but also in background.
I have thought several methods of doing it.
Create an app(probably service) which receives data from the input device and emulate the touch event.(Probably monkeyrunner?)
Connect the android device to the external device and use adb to directly create touch event.
Make the device to mimic the behavior of joystick (I heard that this method only applies to several game apps. is it true?)
Which is the most viable method? Or is any of the method possible? (On rooted phone probably)
PS. For solution 1, I saw several apps (Remote desktop-like apps) which creates touch events using S/W. How does it work?(Using Android API, use adb or misc. methods... etc.)
Thank you for reading this question.
Ok, I watched the Google I/O from 2011 presentation on NFC on peer to peer.
The demo was done on Gingerbread and using the application Sticky Notes found
Now in this demo, both device the onNewIntent() was called at the same time so both devices are trying to share information to one another.
On ICS and above, you have Android Beam..
With Android Beam, you have to touch to trigger the onNewIntent() event that will send the NDef message across.
Now the problem with this is that now to trigger the onNewIntent() on both devices, both user on each device has to "Touch To Beam" at the same time.
Is there a way that when you Touch To Beam on one device, both can have the onNewIntent() to be called?
I am trying to develop an app that will exchange data to each other but for it to work in a nice friendly fashion I need the devices to share the data at the same time once the Touch To Beam has been initiated on one device. I do hope this is possible.
Edit: It looks like this might not be possible to do :(
As far as I can tell, the feature you want is not available over NFC itself. The touch-to-beam/SNEP/NPP transfer is one direction only on Android. The user that clicks his screen will push an NDEF message to the other phone.
What I believe they've done in the video is set up a bluetooth connection with the NDEF message to make the transfer (as you saw in the stickynotes demo). Unfortunately there is no nice API for this.
However, the EasyNFC project promises to be able to allow you to create a bluetooth connection and socket between two phones/applications. Check it out here
I had a try and didn't really like the Touch-to-Beam UI that was still required in the set up of the bluetooth connection. It also didnt really suit my needs, as I wanted to transfer phone to computer and didn't really want to implement NFC P2P and a bluetooth connection.
Did you try this:
Use the Touch to Beam on phone-1 to "PUSH" the data, while on the other (phone-2), use the NDEF_DISCOVERED/TECH_DISCOVERED intent to trigger/start the data capture/reception. I vaguely remember one of the above intents were triggered when a PUSH is done. Although, every transmission requires a "Touch" to start the beaming.
When you think in general, Android should not allow the NFC data transfer in both direction at the same time. Lets think of a scenario where I want to send a thing to my friend with NFC. What is actively open on my friend's phone is not important. I should send this thing even the same app is not open on the receiver side. There may be another app in my friends phone that tries to send another thing to me. When we touch our phones, Android Beam (TM) appears and he data is sent from the phone that is touched.
In you case I think you should disable Android Beam (TM) by setting setNdefPushMessage(null) and do sending both ways using the old way.
https://developer.android.com/preview/api-overview.html
I think it will be available in L!!!
NFC enhancements
Your app can invoke the Android Beam on the user’s device to share data by calling android.nfc.NfcAdapter.invokeBeam(). This avoids the need for the user to manually tap the device against another NFC-capable device to complete the data transfer.
I am writing Bluetooth mouse driver app for android. I want to know is that possible to implement mouse cursor in same fashion as on desktop?
What I have done so far is that I have connected my HID mouse to android device via Bluetooth. Mouse is sending reports to device and the Intent service receive it and parse it broadcast x and y coordinates. Now I want to display cursor with same functionality as on desktop.
Is that possible, and if so, how is it done?
Yes, it's been done, and mouse support is included in android from 3.1 up.
Just wait for an update to your device.