MoleMan1024 / audiowagon

AudioWagon will play audio files from an attached USB flash drive in cars equipped with Android Automotive OS
https://moleman1024.github.io/audiowagon/
GNU General Public License v3.0
58 stars 18 forks source link

Allow AudioWagon to access USB DISK 3.0 persistant popup #133

Closed kingstonwa closed 9 months ago

kingstonwa commented 9 months ago

Describe the issue I have a 2023 C40 and connected a USB flash drive to the usb port with the white circle. When I launch Audiowagon, I get this popup persistently repeated every time I start. The developer tells me that this is a Volvo system issue. How can I disable this popup?

To Reproduce

  1. install Audiowagon
  2. insert properly formatted usb drive in the proper usb port
  3. let audiowagon digest the files
  4. turn off system and exit car
  5. enter car and launch audiowagon
  6. see persistent popup requiring OK to Allow AudioWagon to access USB DISK 3.0 and check the box for Always open... perm
  7. exit system, then enter car and launch audiowagon, see repeated issue described in 6. above

Expected behavior No popup after first interaction and OK selected

AudioWagon version <Which version of AudioWagon were you using? (see the settings screen)>

Car version Updated on Nov 4, 2023 from Google Play download

IMG_20231208_095942820_HDR_AE

MoleMan1024 commented 9 months ago

This is already addressed in the FAQ. Must be fixed by Volvo/Polestar in Android Automotive code. 3rd party apps do not have permission to set themselves persistently as default Intent handlers for USB intents, this must be done by the OEM.

Please do not trust what Volvo/Polestar support team tells you, they have not been known to provide correct information in the past (at least regarding the USB connection). You would need to talk to an AAOS software architect/developer directly to get a technically accurate response.

If Volvo/Polestar keeps claiming the issue is on my side, they are welcome to point out the flaw in my code which is open source. Since they don't make their adaptations to AOSP public, I can only work on assumptions and I assume they have either not at all or only partially integrated the car-usb-handler by Google. This car-usb-handler will write discovered Intent handlers to handle USB related intents to a sqlite database, which will be looked up and taken as default handler if chosen by user. This works fine with my implementation on the unmodified AAOS build including car-usb-handler on my development platform. In conclusion, the issue is on their end.

bobybc commented 8 months ago

I just want to say that the same issue occurs on Renault Megane E-TECH

petard commented 5 months ago

Volvo / Polestar released an update to Android 12 from Android 11 recently. Does it make any difference on how to resolve this issue?

micksmothers commented 5 months ago

I think we can only hope - I am running the update on my Polestar 2 right now, I'll test it out once the update is successfully completed.

kingstonwa commented 5 months ago

Just updated to v 3 on my Volvo C40 and no joy, blue popup still comes on

micksmothers commented 5 months ago

Yes, same here with my Polestar unfortunately. I'm used to just tapping the button every time I get in the car. Annoying but not horribly so.

kingstonwa commented 5 months ago

Anyone having this issue, I encourage you to contact Volvo on their Facebook messanger chat and ask that this be fixed. Perhaps some squeeky wheels will motivate them https://www.messenger.com/t/339744344488 image

MoleMan1024 commented 4 months ago

Based on some recent logging changes I made, I found that in certain cars that report themselves as a device called "OpenR Link" (I believe those are Renault cars), the USB permission is granted during boot-up.

Even though @bobybc said above the permission popup also appears in those cars (which can be true, depending on timing), in most cases it should not appear, the permission will be granted automatically (like I would expect in Polestar/Volvo cars also).

Attached is a log file as proof: de.moleman1024.audiowagon_issue_9d4a11dec5864345ec38522d6bb2158b_error_session_6646EB7503D0000137F4D02FF64B80BA_DNE_0_v2.log

In that log file, the AudioBrowserService is first created here at 07:30:30 CEST:

2024-05-17 07:30:30.060 [DEBUG   ][14324-14324][AudioBrowserService     ] onCreate() at: 2024-05-17T07:30:30.059+0200↲

AudioWagon could initialize the filesystem 3.1 minutes after the system was booted, so we know the car was not in sleep mode before, it is a cold boot (the uptimeMillis equals the elapsedRealtime and it is only 187078 milliseconds ~ 3.1 minutes):

2024-05-17 07:30:31.309 [INFO    ][14324-14413][USBDevConn              ] Successfully initialized filesystem at: 2024-05-17T07:30:31.309+0200 (uptimeMillis=187078 elapsedRealtime=187078)↲

In Polestar/Volvo cars, you will always get a USB permission popup when starting from cold boot.

However in this log, as I would expect, the USBDummyActivity is trampolining the permitted USB device to the service, as designed:

2024-05-17 07:30:30.123 [DEBUG   ][14324-14324][AudioBrowserService     ] onStartCommand(intent=Intent { act=de.moleman1024.audiowagon.ACTION_START_SERVICE_WITH_USB_DEVICE dat= cmp=de.moleman1024.audiowagon/.AudioBrowserService (has extras) }, flags=0, startid=1)↲
2024-05-17 07:30:30.123 [DEBUG   ][14324-14324][AudioBrowserService     ] Service was started from USBDummyActivity, forwarding broadcast↲
...
2024-05-17 07:30:30.174 [DEBUG   ][14324-14397][USBIntBCRecv            ] Broadcast with action de.moleman1024.audiowagon.USB_ATTACHED received for USB device: ...
...
2024-05-17 07:30:30.189 [DEBUG   ][14324-14413][USBDevPerm              ] USB device USBMediaDevice{Kingston DT microDuo 3C(2385;5806;/dev/bus/usb/001/004;-888768790)} has permission: GRANTED↲
...
2024-05-17 07:30:31.309 [INFO    ][14324-14413][USBDevConn              ] Successfully initialized filesystem at: 2024-05-17T07:30:31.309+0200 (uptimeMillis=187078 elapsedRealtime=187078)↲

This should also work after unplugging and replugging the USB device and after sleep mode. If someone has a Renault car with AAOS they could try this and show it to Volvo/Polestar users (it is the same AudioWagon app).

In Polestar and Volvo cars you will see these kind of log messages instead and USBDummyActivity will never be called:

Requesting permission to access device
...
Waiting for user to grant permission
kingstonwa commented 4 months ago

I just submitted a support ticket to Volvo USA and here is what they said:

If there is a USB drive being utilized with the vehicle. That message will appear on the screen when the vehicle is started. This message in the vehicle cannot be removed or disabled. We understand that your experience is not to your expectation and we apologize for any inconvenience. Thank you for being part of the Volvo family.

justinschoeman commented 3 months ago

Based on some recent logging changes I made, I found that in certain cars that report themselves as a device called "OpenR Link" (I believe those are Renault cars), the USB permission is granted during boot-up.

Even though @bobybc said above the permission popup also appears in those cars (which can be true, depending on timing), in most cases it should not appear, the permission will be granted automatically (like I would expect in Polestar/Volvo cars also).

It may be worth noting that something similar happens in the Volvo XC40. Sometimes when replugging the USB device audio will start playing without pressing the ACCEPT button.

So, perhaps permission is there, but just not reported? Or is there some race/glitch in Android, which occasionally allows permission without the click through?

MoleMan1024 commented 3 months ago

It may be worth noting that something similar happens in the Volvo XC40. Sometimes when replugging the USB device audio will start playing without pressing the ACCEPT button.

Please provide a log file if you encounter this, I have never seen this happen.

petard commented 3 months ago

Curious what the root cause for the issue of seeing the permission pop-up every time. I'd like to think the app asks for certain Android permissions, which are then stored by Android. Similar to the privacy permission visible under Settings for every app.

Is this supported by stock AAOS but Volvo choose to not correctly implement it in their AAOS version?

MoleMan1024 commented 3 months ago

Is this supported by stock AAOS but Volvo choose to not correctly implement it in their AAOS version?

Indeed, in a unmodified AAOS 10 or 11 or 13 build for emulator (or when installing such a build on a mobile phone) the permission is stored persistently and it works as expected. Depending on timing this is also the behaviour you see in Renault cars. It even works fine when installing on a regular Android tablet.

Volvo/Polestar have either deliberately or by accident broken this functionality. The intended behaviour of the car-usb-handler is shortly described above in my comment and is also mentioned several times in the source code.

I cannot tell exactly what is broken exactly, as AAOS in Polestar/Volvo cars has not been rooted (yet?) so I have no possibility to debug this further, I can only see my own app's logging.