Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open application when device connected #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcusbirkin
Copy link

Updated Manifest to open application when device is attached

@freshollie
Copy link
Owner

freshollie commented Dec 18, 2019

Hey, there is a reason why this isn't implemented:

Older versions of android give a popup which appears everytime the device is plugged in. You can use my other app in order to automatically play monkeyboard on powerup.

https://github.com/freshollie/headunit-controller-android

I won't be merging this for this case :)

@marcusbirkin
Copy link
Author

That's odd, I made a reply that has disappeared now..

So the issue I'm trying to solve is excatly that popup box.
On my device, running Android 8.1, after every reboot I get this dialog:
image
The tick box does nothing

With a2bb10d I get this on the first connection of the radio. The tick box is remembered, and the permission is preserved between reboots:
image

The only remaining issue is if the radio is left plugged in and the device rebooted, then I get the first dialog when opening the application. This is because the connection event never actually happens. My personal workaround for this is to unbind/bind the usb hub via a shell script, this then triggers the connection event, and the application automatically has USB permission.

@freshollie
Copy link
Owner

freshollie commented Dec 18, 2019

Ah, interesting. Seems with 8 they have actually made the tickbox do something? In android 6 the tickbox would not be remembered and the popup would appear every time the device was plugged in again.

Notice I actually have a readme section on that permissions popup. The solution (for rooted devices) is to edit the underlying android system service to accept the popup every time.

I'm wondering if the manifest can be made to only apply to devices over a given version? Because this fix would cause the same level of annoyance for anyone using < android 8.

@marcusbirkin
Copy link
Author

Sorry I don't see that section in the readme.
However if it's what I think it is, that would require access to the android source, not always an option. I've yet not managed to find any pure root, or otherwise, way via google magic...

I had a quick look to see if you can make manifests platform dependent, not found it yet.

Are you able to test this merge on any older hardware to double check it's the case. I didn't fully read the two subtly different popups at first, but they operate for different things. All the offical android documentation I can find leads me to belive that USB_DEVICE_ATTACHED has always worked like this.

@freshollie
Copy link
Owner

Ah, very sorry getting mixed up with another project of mine, see the "Usage" section of here https://github.com/freshollie/usbgps4droid :)

Yeah, I do understand that they are 2 different popups. What I was trying to say is that the first is supressable in rooted android 6.0 and the second is not. There is a bug in Android 6.0 which doesn't save the "remember this" tickbox when the device is disconnected. The problem with the popup is android 6 is that it also forces the app to open when "ok" is clicked which was annoying.

Not sure what the options are here. I understand that for you usage you don't want the popup, but TBH no point in merging it with the main repo if it can't be optional. If it's something you need for your app then you now have the fix.

@marcusbirkin
Copy link
Author

Android is a messed up platform. For my use case I'll take advantage of the benefits of open source and simply roll my own APK.

I don't see a way of making it optional without making two builds: one for older platforms, one for newer.

@freshollie
Copy link
Owner

freshollie commented Dec 19, 2019

It really is, I appreciate the effort though! I understand it seems counter intuitive not to accept fixes like this, but like you said I either create 2 builds with and without the USB manifest or I remove backwards compatibility for my own device :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants