How to recognize a newly inserted android USB device using C++/Windows? - android

I am trying to implement a function like this: when an android device is inserted to USB, get its pid and vid and then use them to do some processing.
Now I use WMI to detect USB insertion and deletion. But everytime the device is inserted, my program receives more than one event. That's because the other devices like usb mass-storage card is also detected.
So from what infomation can I recognize if a newly inserted USB device is an android phone?

I think i find a method to solve this problem.
I listen to the event of win32_PnPEntity creation and the Service property of Win32_pnpEntity can be used to identify the device.

Related

Side effects of Settings.Secure.putInt

I want to disable USB access to an android device.
If the device is connected to a computer it should only charge and prevent any data transmission. So no one can access the data on this device.
I read here, that I can change the usb settings by changing entries in the settings database.
I want to do this programmatically, because I want to turn usb access on and off (the button for this will be secured by a password).
My app runs as system app and has the permission to executute the following function.
Settings.Secure.putInt
After changing "mount_play_not_snd" with above function, I looked into the database using adb shell.
The entry
5|mount_play_not_snd|1
was gone.
But I found a new entry:
37|mount_play_not_snd|0
So I think the old entry was deleted and the new one was inserted at the end of the table instead of altering the existing entry.
Are there any side effects of the changed _ID?
Or is there a way to manipulate this database programmatically without changing the _IDs of its entries?
My device runs Android 4.4.4. Maybe the bahavior is different on other systems.

Android app to send and receive a file automatically when get connected via bluetooth

I am new to android world.I want to design an android app in which all connections will be through bluetooth. It will works as follows
as I click some button like start it will connect to one of the paired devices(mobile) and get a file, store it somewhere and eventually disconnect with that device.Then it will connect to the second device, get a file, store it and then disconnect with that device and so on. It will repeat the same procedure for all the paired devices.
And later on I will replace those paired mobiles with sensors and will collect the the data.The whole process should be automatic without user's intervention.
Guys please help me. Is it possible for a mobile to send a file automatically as it connects to a particular mobile.

Not able to pair device to Android Bluetooth

I am trying to pair TI CC2564 module with Android (5.0) and Android (6.0).
5.0: It never connects through the device settings. But I can use it from my app with call to function createRfcommSocket. Issue here is that I need to connect the device manually every time I reopen the app.
6.0: I am able to pair the device through device settings occasionally and it is hit and miss. Once I pair the device it works flawlessly in the app. But if I remove the pairing and try to pair again it doesn't allow me to pair with the following error in Logcat
Device is not allowed because it is either insecure or of unknown security and needs user confirmation
Any suggestion regarding how to get the device pair?
I was able to resolve the issue. The Bluetooth module's broadcast name is null by default, giving it a proper name allows the connection to succeed flawlessly. I am guessing there is some issue with either Android or CC2564 BT stack, which might be causing a crash and hence disconnecting.

Capture RRC state log in android

I am trying to capture RRC state logs which change time to time in mobile devices based on network usage .As of now the only way possible is to run special codes E.g "*#0011#" from dialer which is an inbuilt feature of device and cannot be run as a service in background.
Assuming i know the code to turn RCC state capture on, how can i log this in background in a file ?
Also is there anyway to capture and store logs that come up in adb logcat even when device is not connected to a computer ? assuming device keeps generating similar logs even when not connected to android adb shell.

How can i create new virtual mouse device on my android device?

I know, I can listen input devices from /dev/input/eventx on Android/Linux. If you are superuser, you can also send events to the device through that.
I would like to send mouse events to my Android device as superuser. However, in order to do this, a mouse must be connected to the device via USB or bluetooth connection. Without it, I get error as Could not open /dev/input/event8, No such device when execute this command on adb sendevent /dev/input/event8 xxxx xxxx xxxxxxxx. In this case, the node was attempted to be created using the mknod /dev/input/event8 c 13 71 command.
The problem is solved when I connect a bluetooth or USB mouse to the device. The device is created automatically under /sys/devices/platform/tegra_uart.2/tty/ttyHS2/hci0 named hci0:11 also create input event /dev/input/event7 (major 13 minor 71). After that I can send events to that node and control Android mouse cursor. But I want to do this without connecting a mouse to the device.
Could anyone suggest how can I create a mouse input device (like when a mouse is connected) on my android device virtually?
From what i see you should create your own virtual device with your own driver , Fortunately there is an easy way to do so using uinput
There is an easy guide for getting started here , and this question can be a good guide to write your own virtual driver.
I thought this can only be done if you have access to kernel , and create your own ( i dont think modifying user rom is a good solution ) , but after reading this , it is clear that Uinput can run in user mode.
Note :
I agree with recommendition to use touch events ; as this solution is more common and makes sense , check second suggestion is this answer

Categories

Resources