ev-map / EVMap

Android app to find electric vehicle charging stations - compatible with community databases such as GoingElectric.de and OpenChargeMap.org.
https://ev-map.app/
MIT License
192 stars 52 forks source link

Android Automotive: Various issues since update 1.4.x / Car App Library 1.3 #254

Closed johan12345 closed 1 year ago

johan12345 commented 1 year ago

Compass is not working I thought I had fixed this before, but a user reports it is not working in version 1.4.0. I cannot reproduce it on the Emulator, it only occurs on a real car (Polestar 2 and Volvo XC40).

Refresh button does not appear, "disabled" row state not working Also cannot reproduce this on the emulator. Update: workarounds for these have been added with update 1.4.3, see below

mb-software commented 1 year ago

I can confirm that compass does not work in a polestar. Other sensor values are correct but direction only shows unknown.

johan12345 commented 1 year ago

My current theory is that the car might report an outdated Car App API level to the app and thus it doesn't try to access the compass (API level 3 is required for compass, and 5 for some other features that users also reported as not working on a Polestar 2). @Ixam97 will help me debug this once he has picked up his Polestar.

See also: https://issuetracker.google.com/issues/260112181

Ixam97 commented 1 year ago

I've now had some time to look at the debug data. On the real hardware API level 4 is reported, on the emulator however it is API level 6. Both Template Hosts are up to date.

Would this be an issue Google is responsible for, or would it more likely be Polestar themselves?

image image

johan12345 commented 1 year ago

Thanks for testing! Okay, then the reported API level is definitely the reason why the refresh button is not appearing and the highlighting of own plans in the price comparison is not working. I would expect the issue to be on Google's side as the Template Host app is provided directly by them - so I've added this information in the bug report in the Google Issue Tracker.

On the other hand, the compass (on the vehicle data page, and for the "only show chargers in driving direction" feature) should still work even when the car reports API level 4... could you confirm that it is not working for you? I can try to add some more debugging info for that.

Ixam97 commented 1 year ago

could you confirm that it is not working for you?

It indeed is not shown, but I couldn't test it while driving yet.

image

Oh and I also documented the actual version of the Template Host installed on the Car:

image

One thing I noticed: On the emulator, the app background ist filled with gray stripes. This is not the case in the car. The car uses Android 11, the emulator Android 10, so this might just be a visual adjustment. But maybe Polestar has implemented some template featuers differently in the emulator compared to the actual car.

Edit: The direction is indeed not shown even while driving.

johan12345 commented 1 year ago

@Ixam97 and I figured out that this workaround (i.e. simply ignoring the lower API level) re-enables the refresh button. This should be fixed with update 1.4.3, which is on its way to the Play Store now.

To work around the disabled row state issue, I now switched to an alternative UI using SectionedList.

No success regarding the compass issue so far, apparently SensorManager reports that no magnetic field sensor is available on the Polestar (not sure if this has always been the case or only since a specific update). Apparently, only the following sensors are supported:

TYPE_ACCELEROMETER TYPE_GYROSCOPE TYPE_GYROSCOPE_UNCALIBRATED TYPE_GAME_ROTATION_VECTOR TYPE_GRAVITY TYPE_LINEAR_ACCELERATION TYPE_ACCELEROMETER_UNCALIBRATED

GAME_ROTATION_VECTOR could be used to detect rotation, however the documentation states that its values are not aligned with the geomagnetic field, so it would not be suitable for a compass... But maybe we can test it to make sure it's actually not aligned. The accelerometer might also be interesting to display on the vehicle data screen. But without a magnetic field sensor, it's not helpful for the compass...

johan12345 commented 1 year ago

Tests with GAME_ROTATION_VECTOR were not successful so far - in https://github.com/johan12345/EVMap/commit/2166ac076a47a5cd6e0306d48b3665df158fbc2c I implemented a fallback to GPS-based direction detection instead (which will of course only work while moving). If that works okay on @Ixam97's car I will release it in the next update.

Ixam97 commented 1 year ago

I now had the ability to look at the GPS-based direction. It gives back an angle, starting north going clockwise. I've tested it on this relatively straight road and got readings from 222° to 223°:

image

johan12345 commented 1 year ago

That sounds pretty good! So you were driving southwest on that road? Then 222-223° is correct, yes.

Ixam97 commented 1 year ago

So you were driving southwest on that road? Then 222-223° is correct, yes.

Yes, indeed.

johan12345 commented 1 year ago

Okay, thanks for testing! Then this should be fixed for now. Update 1.4.4 is on the way to all users now (after review from Google).