Suppress androids system message while accessing USB OTG device - android

I'm developing an android app which uses USB OTG devices. The app "connects" to the device via the android USB API and I'm reading some volume information using an external library.
Everything works fine, but there is an user experience issue: The device is mounted by android, but when the connection from my app is established, the device becomes obviously unmounted for the operating system and a message like "USB storage removed unexpectedly" is shown.
I know, this is the right behaviour from androids point of view - but not from my users' :-)
Does anyone know about a possibility either to suppress the system message or doing any kind of workaround? Any ideas are welcome... I've read some SO tickets and don't think that there's a possibility to safely unmount the device programatically befoe connecting from my app.

Related

Android message “Allow <app name> to access <device-name>? (responded OK) continually repeating while app is in use over USB

We have an ultrasound scanner that connects to our app on Android devices via USB or a built-in WiFi mini-router.
When connected over USB, one of our customers randomly gets the message “Allow to access ? [set to OK). Also, an option to “Always open when is connected?” (shouldn’t be related, but tried both on and off). Brand new Samsung Galaxy Android S8 Ultra Tablet.
Unable to duplicate in our offices, even when using the same model ultrasound and same model tablet. As expected, the message only appears on a new Android or after a factory reset. It also runs fine at numerous other customer locations.
Tried (1) Android setting “Allow Notifications” off and on, (2) “Notification Categories” indicates “This app hasn’t sent you any notifications.” (3) WiFi and Bluetooth both off and on, (5) both Android and the app are current, (4) neither Samsung nor Google has had any other suggestions,
Not sure if/how this might factor in. When connecting via the built-in WiFi, any Android or iOS device quickly drops the signal while inside the building, but runs fine in the parking lot or elsewhere. Unfortunately, too many other companies in the building to start shutting off routers, and where this occurred at other locations, changing the WiFi channel in the app, turning off other routers, or resorting to the USB cable always solved it.
Any suggestions much appreciated. Thanks, David

Android Save permission for a USB device across detach, re-attach

Struggling a bit with Android >=10's UsbDevice class and detecting re-attachment of the same USB device. Prior to Android 10, I could use UsbDevice.getSerialNumber to get a unique handle for a USB device (if it had one). UsbDevice.getDeviceName tends to change from attach to attach e.g. /dev/bus/usb/001/002, /dev/bus/usb/001/003. For Android >=10 you need to ask for user USB permission before calling getSerialNumber. Without having a manifest intent filter for the USB device type and saving the App as the preferred client this is now very messy - a new Permission Request dialogue is needed for each re-attach. Has anyone found a workaround for this? USB OTG connectors are not the most secure so yank then re-plug is a reasonable thing to want to do.

Why does Android bond even when asked not to bond?

I have developed an application on an on-board device which allows a smartphone to be able to connect in secure BLE.
Everything works fine but I notice that every time I do a "pairing" via an Android smartphone, that the smartphone "bonds" the device even though I specified in the request that I did not want bondage. I don't have this problem on IOS.
Here are the requests that are sent by my on-board device to the smartphone:
Security request
Pairing response
Is it possible that Android does not support "pairing only"? If it is paired, it does a "boding" automatically even if it has received a request asking it not to do a bond?
Thank you
"Non-bondable mode" is mandatory to support in the Bluetooth Core specification. If Android makes a permanent bond, even though you say to not bond in the "Pairing response", it's a bug in Android. Please file a bug report to Android Open Source Project (AOSP).

Can I launch a specific app when android device get physically connected to a specific usb device?

Can I "register" a (already installed) specific app to be launched when android device get physically connected to a specific usb device ?
Eg.
I connect a keyboard (of a certain brand or with a special USBid/class) and it automatically launch a text editor app
I connect an USB soundcard and it launches an audio app.
And "better", is there an autolaunch on Android ? I plug a keyboard+storage device to my smartphone and Android will ask me if I want to install the apk from the storage (or download it from predefined url)
Obviously for security reasons I understand installing the app from the storage will need confirmation by user. But, once the app has been "registered" would it be possible to launch the app automatically without having a confirmation screen ?
I know I could get USB info with android.hardware.usb.usbdevice. My question is more about how I can tell Android to launch this app rather than another when usb device is connected.
I think you could register your app to receive a system broadcast like USB_ACCESSORY_ATTACHED and make the logic to launch your app when this happens.
Check https://developer.android.com/guide/components/broadcasts
https://developer.android.com/reference/android/hardware/usb/UsbManager.html#ACTION_USB_DEVICE_ATTACHED

Purpose of Telephony Provider

Some background information:
I have a certain yet to be released tablet and sadly the people who designed it seemed to have removed TelephonyProvider.apk
Here's how I've reached that conclusion :
When I go to More... in WIRELESS & NETWORKS there are no options to change APN, VPN or access Mobile networks. (Please note that the table has no facility to lodge a SIM card) However, on my Karbonn ST10 (Android 4.1.1) all these options are found. The certain tablet is currently on Android 4.2.2
When I used an app called APN shortcuts I was able to launch the APN configuration screen, however every time I changed the MCC or MNC number, the APN could not be saved and was deleted.
When I tried to read the contents of content://telephony/carriers I received a NullPointerException.
Questions:
What is the purpose of TelephonyProvider.apk?
Will it be possible to install it without root access? If so, how? (I'm pretty sure this can't be done, but if someone else knows a magical method please enlighten the world)
Can 3G data connections via dongles be established on this device which seems to be missing TelephonyProvider? Or will the ROM have to be edited and TelephonyProvider be installed.
I'm pretty sure this is a programming question, but if it belongs on Android Enthusiasts, please move it.
It's just an apk... you should be able to sideload it with adb without root with adb sideload <your apk>. It would just be removable since its not it /system/app, ie built in with the ROM. If the makers of your device disabled certain features on the device, which would explain possibly why those menus do not display in the Settings app, then TelephonyProvider may not be all that you need to get the connections you want to establish working.
Hope this helps.
Update:
These features are probably disabled on the device you are using. based on what you described.
From the PackageManager documentation.
FEATURE_TELEPHONY Feature for getSystemAvailableFeatures() and hasSystemFeature(String): The device has a telephony radio with data communication support.
FEATURE_WIFI Feature for getSystemAvailableFeatures() and hasSystemFeature(String): The device supports WiFi (802.11) networking.

Categories

Resources