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

Added Permission Checks #993

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

Conversation

javaman97
Copy link

I have added the permission checks to resolve issue #971

@javaman97
Copy link
Author

@SebaDro Please have a look and let me know if further changes are required.

@SebaDro SebaDro self-requested a review July 26, 2023 06:14
Copy link
Contributor

@SebaDro SebaDro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for your contribution @javaman97 . However, I've checked your bluetooth permission request implementation and noticed that you only auto-generated, what your IDE suggests for just fixing missing permission requests. There is no proper permission request handling, which makes the simulator unusable.

Please, have a look into https://developer.android.com/training/permissions/requesting for how permission handling is done right. You also find some implementations of permission requests in the enviroCar-app: check the DashboardFragment or OBDSelectionFragment. The latter uses EasyPermissions.

Comment on lines +104 to +107
if (checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {

return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what else then, if permissions are not granted? Shouldn't they be requested? Just doing nothing, will make the simulator unusable.

Comment on lines +176 to +184
if (checkSelfPermission(Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// Activity#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for Activity#requestPermissions for more details.
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. The recent implementation requests permissions and closes the app, if permissions are declined. But your implementation just do nothing then. Your IDE even suggests you, what to do: call requestPermissions and overwrite onRequestPermissionsResult to handle permission grant or decline. And this is the way to go.

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