Generic linux usb permission rule - java

I am trying to use Java4USB to gather usb devices info on Raspian. My java app runs under its own user, but has no access to usb devices.
I have seen that adding udev rules can do the trick, but...
How can I allow usb access to all usb devices to my app, without changing access rules for other users ?

Related

How to check WiFi hotspot(AP) is enabled an Android app

I am making an Android app that will communicate via Bluetooth with other devices. These devices need to check WiFi hotspot. How can I, from inside the app, check if the phone is an WiFi hotspot?
I don't need to turn hotspot on from the application, just check if it has so I can tell the user to turn it on manually to be able to use the app.
EDIT:
I just realized the question is not really correct.
The phone with the app I am developing connects to internet via wifi. Then it needs to share internet with other devices via Bluetooth. The answers here worked fine to check if WiFi hotspot is on. But I need to check if it can share internet via Bluetooth with other devices.
The phone gets internet via wifi, but the devices have to get internet via Bluetooth.

how to write android program to detect all the Devices connected in a WiFi network? [duplicate]

I am developing an app in which I need to scans WiFi network and display the list of all connected devices.
Allow a use to tap on a device and the app should show all the hardware info of that particular device. Here by hardware I mean - RAM, Storage Media, Storage Capacity, Device Name, Device IP address, etc.
Now this device can be anything like xbox, a laptop with Linux/Windows, mobile phone like iPhone or any Andorid based smart phone or even a printer.
How can I scans WiFi network and query/detect all the devices attached to it?
What are the protocols that I need to use to get list of hardware in a particular device irrespective of the OS running on it?
Check requestPeers of
WifiP2pManager
As per documents it seeks
PeerListListener which returns WifiP2pDeviceList carrying list of WifiP2pDevice which carries deviceAddress, deviceName, primaryDeviceType, secondaryDeviceType, status and other attributes.
Maybe the Network Discovery github project could help you. It lists all users connected to WiFi with IP and MAC addresses and gathers even some information like open ports, device name, ping, etc.
Hope it helps
In my opinion, you can use Wi-Fi Peer-to-Peer
https://developer.android.com/guide/topics/connectivity/wifip2p.html
"Wi-Fi peer-to-peer (P2P) allows Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi without an intermediate access point (Android's Wi-Fi P2P framework complies with the Wi-Fi Alliance's Wi-Fi Directâ„¢ certification program). Using these APIs, you can discover and connect to other devices when each device supports Wi-Fi P2P, then communicate over a speedy connection across distances much longer than a Bluetooth connection. This is useful for applications that share data among users, such as a multiplayer game or a photo sharing application."
Blockquote

Java: Get USB Mass Storage Device Information

is there a possibility to get USB mass storage information like the serial of an USB device in Java on Windows?
I tried to achieve that with USB4Java (low and high-level API) and it works, but the problem is that I have to install a customized driver to get access to the information from my Java app (described in the FAQ at http://usb4java.org/). When that special driver (created with Zadig) is installed I don't have any further access to the device from the Windows explorer (just from my Java app).
I would like to detect when a new USB device is attached and if it was attached, I would like to get some information like the serial number of the device, the device name, the drive letter that was assigned etc.
That app should be used by other users and I couldn't force them to create a customized driver for each device ...
Do you have any hints how to achieve that?
Thanks.
Edit: Is it possible to get the usb-port of a connected device with Java-built-in methods?
I've tried sth with FileSystemView.getFileSystemView().getSystemDisplayName() but there are no such options. Is there another possibility to get vendor id's or sth. similiar with Java?
Or is it possible to get the drive letter with USB4Java?
Thanks.

Connecting usb to uart device to android device >3.1

I know that the latest android device with API>3.1 support USB host mode or USB OTG that allows you to connect a lot of usb devices like flash disks,mouse,keyboard etc. but can you connect any device that does not have common general drivers like USB to uart device,printers,cameras
I have linux drivers for these devices in source codes as .c files, So is there a way that I can build and install those drivers to an android phone and make the usb devices usable on the phone?
To use linux drivers for android you have to compile your own kernel or kernel module. If you expect your app to be used by other people, this is not a feasible way.
For some low bandwidth USB devices it is possible to write user space drivers in java using the Host API. For USB-UARTs there is the usb-serial-for-android project that is implementing a user space driver based on this API.
Never Mind ! I found a standard way for my device here It provides interface through native code and IPC and official library from manufacturer

Android 2.3.4 FTDI D2xx Driver for TTL-232R

I have been trying to get the FTDI D2xx driver working with my Android 2.3.4 tablet for a while now. After solving a number issues relating to actually loading the driver I am now in a situation where the FTDI device is just not seen by the sample application FTDI provides.
There are no errors reported in either LogCat or Java (debug) the device is just simply not found.
Java_com_ftdi_D2xx_getDeviceInfoList() returns zero.
The tablet is rooted, and the permissions for the ueventd.rc file are set to:
/dev/bus/usb/* 0666 root usb
The USB port I have connected my TTL-232R to does work (in that I can read a USB memory stick with it at least...)
Has anyone else experimented with this and/or got it working? If so some pointers would be greatly appreciated!
Many thanks
Does 2.3.4 support USB Host?
http://developer.android.com/sdk/android-2.3.4.html
No USB host support — Android 2.3.4 and the Open Accessory Library do not support USB host mode (for example, through UsbDevice), although USB host mode is supported in Android 3.1. An Android-powered device running Android 2.3.4 can not function as a USB host. The library enables the Android-powered device to function as a peripheral only, with the connected accessory functioning as USB host (through UsbAccessory).
I've got the sample working with ICS.
Well, I must manually switch from USB peripherals to USB host and vice versa in terminal emulator, since stock kernel does not support otg, custom kernel support otg, but not turn it on automaticly.
cmd1="echo host > /d/otg/mode"; // usb otg host on
cmd2="cat /d/otg/info</"; // check usb status, must be usb a_host and otg=1
cmd3="echo peripheral > /d/otg/mode"; // usb oth host off

Categories