Ihad the same kind of problem and I think I've managed to solve it. There's a service that Android uses internally that allows to manage USB devices and accessories.This service is hidden from thrid party developers and is not documented. If you check the source code for UsbPermissionActivity you'll be able to figure out how that service is called.In order to call the service IUsbManager interface and ServiceManager class are employed. These are both hidden too, so you can't use them directly. But what you can do is tocreate their stubs with exactly the same names and in corresponding namespaces (packages). Then you'll be able to compile that code, while the runtime environment will use the real things.
The only requirement is that your application has to be a system one - that is it has to be located in /system/app/ directory. Since your device is rooted that shouldn't be a problem.
Note that interfaces of these classes may change depending on the version of Android. In my case the version is
4.0.3.So if you have another version of Android and this code doesn't work you will have to check the source code for your particular version of OS.
i had the same problem with the popup window and nobody to click on it.But i found a different solution (for rooted devices).The popup gets generated by android in the class UsbPermissionActivity (and that UsbPermissionActivity is started by the UsbSettingsManager). Look at the Android Sourcecode to see whats going on. The good thing here is, we can manipulate the bytecode of the UsbPermissionActivity to accept all UsbDevices. You need the tool Smali/Baksmali to do so.
The solution is to use intent filters and add the android:directBootAware="true" attribute to the associated activity so that the USB_DEVICE_ATTACHED event is correctly received after boot / reboot. It is important not to ask for the USB device permission in code, only using intent filters, like this:
Android is really not designed to support this kind of usage out of the box. Personally, for non-interactive usage, I'd be tempted to consider using the USB serial driver in the linux kernel and skipping the android USB apis. But you'd have to be in a position to seriously modify the android installation - change the kernel configuration and/or load a module, create device files and set their permissions or owners, possibly add a unix group and android permission for apps allowed to access it.
Or you can look through the android source and disable the user confirmation; but if you do not have a from-source android build for the device, this may be trickier than the linux-level idea, since adapting open source android to run on a vendor device can be non-trivial (unless someone already offers a from-source build that is sufficiently functional for the device in question)
Indicentally, root/su access does not apply to applications themselves - it only means that an application which knowns how to run whatever tool your root hack left behind, can start up a helper program that runs as root, but the application itself does not and cannot. Using root to install the app on the system partition might get you some atypical android permissions, but you'd have to check if there are any which would help you with the usb.
I think white-listing the accessory you are using in advance will be the best solution.To do this you need to add the file usb_device_manager.xmlat this location/data/system/users/0
// Note that 0 is user ID, it will probably be 0 if you didn't add more users in Android but if you did change this ID accordingly
According to the documentation on Android Developers you already have permission to the attached USB device when your app gets started trough your manifest intent filter. Perhaps you should try this approach and write a filter to exact match the device you want to use, to prevent that other apps also want to communicate with the device.
One way to achieve this, note that this does not actually get rid of the confirmation, would be to pinpoint the location of the checkbox and use the Android equivalent of the Robot class to select it and then select OK. You could write a application that runs in the background, it could even be called by that startup service that you mentioned, specifically for this purpose.
At the first time, when it needs confirm, you can select "always", then even if the Android device is powered down, and powered up, your app still has permission to access the USB2Serial. Just to say, only one time confirm!
I had the same problem, the permission popup appear everytime i plug the USB cable, to solve it i just added the filter in the manifest and the xml file for VID and PID, just make sure you've setup USB device filtering as suggested in the SO link above or as documented here, and you put the good VID and PID. It was my problem, i didn't put the VID and PID that match to my device
Then it shouldnt have been released. Plenty of hi res apps like USB Audio Pro and Muzecast do it just fine with hi res. By the way, all Galaxy phones have a native hi res app that bypasses Android Audio. Even Android Auto does hi res now.
Roofan there are many good options available and I can recommend the FIIO KAX devices.
I have tried the lots and really like KA1 & KA2, but there is really no best, just best for your use case (it is about 50 in the UK)
The PrePass app gives carriers the option to expand bypass opportunities using tablet or mobile phone devices, and may be used with a PrePass transponder. The PrePass weigh station bypass app provides expanded coverage to enforcement locations without a transponder reader and mobile sites. It also provides expanded functionality including PrePass ALERTS. The application is available on Apple iOS, Android, and select telematics and ELD devices. If you have a transponder, then the PrePass app will default to the transponder message when PrePass transponder infrastructure is present at the weigh station.
Depending on where you operate, the PrePass app will expand bypassing opportunities to weigh stations that are not currently equipped with PrePass transponder technology. This includes lower volume sites and temporary mobile enforcement locations. There is no additional fee for the PrePass app, so there is no reason not to take advantage of this added benefit.
Transponders also provide access to other third-party weigh station locations including Weigh2GoBC, NORPASS and Oregon Green Light. In addition, you can use the same transponder for both electronic toll payment and bypass services.
In the weighing facility, the officer will see the same information they see when you use a transponder such as the DOT number, License Plate, Equipment ID, Vehicle Weight and the Green Light or Red Light decision.
At weigh stations not equipped with transponder technology and offering mobile app bypassing only, your transponder will not signal you, and the PrePass app will provide the appropriate decision on your device screen.
The PrePass App enables drivers to verify the safety, credentials, and weight of a commercial vehicle with upcoming weigh stations. You can pair your dezl OTR device with the Garmin Drive App and the PrePass App to receive upcoming weigh station notifications on your dezl OTR device.
The PrePass app and Garmin are different products, however the two companies collaborated to provide PrePass notifications on Garmin dēzl device models. Motor carriers download the PrePass app and Garmin Drive App to their mobile device (smartphone).
In addition, to weigh station bypass notifications, the PrePass app provides ALERTS, including work zones, traffic incidents, congestion, dangerous slowdowns, weather, truck parking, rest areas, gusty wind areas, steep grades, brake check areas, chain-up areas, runaway truck ramps, and no commercial vehicle roads.
For both push notifications, phone calls and SMS messages, there are steps you can take to ensure you get notified, regardless of what your phone's silent mode and do-not-disturb settings are set up like.
Finally, we'd recommend opening your preferences on the
incident.io dashboard on your computer and clicking the test button next to your phone number whilst your phone is locked to verify the bypass is working. We'd recommend trying:
If you've done the above, and your phone is still in silent, first check that the phone call you received was identified with the
incident.io contact details. If it wasn't, you might need to re-save the
incident.io contact card.
iOS has a concept of Critical notifications, which are push notifications that'll make a noise, regardless of whether your phone is on silent, or if you are in sleep/do-not-disturb. The
incident.io app supports these natively so as long as you agreed to these notifications during set up of the app, you'll receive them. If you did not agree to them, you'll see a warning on the home screen of the app.
Android does not have native support for Critical notifications like iOS, so we instead play a sound to mimic notification sounds using your device's Alarm media stream. This means if you set your alarm volume to 0, then push notifications will not create any noise.
Disable Pause app activity if unused. By default, Android typically will allow the
incident.io app to be paused if the app is unused - which may be typical if you're not on-call very often. You can find this by opening the Settings app, tapping on Applications,
incident.io and then scrolling down to find the toggle at the bottom.
Enabling Unrestricted battery usage. By default, Android will enable "Optimized" battery usage for the
incident.io app. We don't perform any background work that should drain your battery, other than receiving push notifications and updating your volume temporarily, which should have little affect on your battery. You can find this by opening the Settings app, tapping on Applications,
incident.io, App battery usage, and then enabling Unrestricted.
3a8082e126