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

Android 12 support #887

Closed
SebaDro opened this issue Mar 3, 2022 · 4 comments
Closed

Android 12 support #887

SebaDro opened this issue Mar 3, 2022 · 4 comments

Comments

@SebaDro
Copy link
Contributor

SebaDro commented Mar 3, 2022

Description
Up to now, the app does not support Android 12 very well. Several issues have been reported regarding the Bluetooth permission management and OBDII connections.

As stated in the official Android documentation, Bluetooth permission management has changed for Android 12 devices. This has already been addressed by a5b531e. However, the solution does not work perfectly, so that abrupt app crashes still occur.

In addition, these crashes are not logged and therefore do not appear inthe crash report which makes it hard to retrace the failure.

Branches
master, develop

How to reproduce
If you have had the enviroCar app already in use on a device with Android version <12 and upgrade to Android 12, you will notice the first crash when trying to open the Bluetooth selection screen. A helpful workaround for this issue is a clean installation (remove app from your deivce and install again from Google Playstore) in combination with manually revoking enviroCar app permissions from you device settings. By doing so, new permissions will be queried the first time you will visit the Bluetooth selection screen. However, when you try to start recording, the app still crashes abrupt.

How to fix
Refine Bluetooth permission management according to Android 12 requirements and add a more sensible logging that takes into account abrupt crashes caused by permission issues.

Special thanks to @ChrissW-R1 who extensively tested the behavior on an Android 12 device and reported the issues.

@cdhiraj40
Copy link
Contributor

cdhiraj40 commented Mar 12, 2022

Hello @SebaDro sir, I checked on this bug researched it, and did some coding.

you will notice the first crash when trying to open the Bluetooth selection screen.

The request permission code was in the OBDSelectionFragment, After seeing the code I just thought as the OBDSelectionActivity is getting initialized first so we should ask for permission in the activity and then move to the fragment. and it worked. It stopped crashing. so it does not need any more manually revoking permissions.

However, when you try to start recording, the app still crashes abruptly.

I researched about it too, and after getting done with the permission issues, it was crashing because of not specifying the mutability of each pending intent that is being used. This results in a crash.

If your app targets Android 12, you must [specify the mutability](https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent) of each [PendingIntent](https://developer.android.com/reference/android/app/PendingIntent) object that your app creates. This additional requirement improves your app's security.

more info here

I did add some code to handle this issue but I was still facing some issues, I would talk about it more when I have proper information about it.
This is all I gathered by checking on this.
Do tell me your thoughts on this sir @SebaDro

@SebaDro
Copy link
Contributor Author

SebaDro commented Mar 14, 2022

Hey @cdhiraj40. Thanks for your elaborations on this issue. It sounds like you are on the right track. Could you please create a work in progress pull request with the coding you have done so far? Then we can use the pull request to discuss further about possible approaches for fixing the issue.

@cdhiraj40
Copy link
Contributor

Sure @SebaDro sir, I will create a PR soon for this.

@SebaDro
Copy link
Contributor Author

SebaDro commented May 17, 2022

Has been fixed with #910 and proofed as working.

@SebaDro SebaDro closed this as completed May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants