-
Notifications
You must be signed in to change notification settings - Fork 158
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
base: develop
Are you sure you want to change the base?
Conversation
@SebaDro Please have a look and let me know if further changes are required. |
There was a problem hiding this 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.
if (checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) { | ||
|
||
return; | ||
} |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
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.
I have added the permission checks to resolve issue #971