Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Handle runtime permissions when checking hardware support #81

Merged
merged 1 commit into from
Jun 14, 2016

Conversation

lkorth
Copy link
Member

@lkorth lkorth commented May 27, 2016

Return true for CardIOActivity#canReadCardWithCamera when camera cannot be access on API >= 23.

Fixes card-io/card.io-Android-SDK#136

Return true for CardIOActivity#canReadCardWithCamera when camera cannot be access on API >= 23.

Fixes card-io/card.io-Android-SDK#136
Log.w(PUBLIC_LOG_TAG, "- Error opening camera: " + e);
throw new CameraUnavailableException();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return true;
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure there isn't another error path that should be considered?

@braebot
Copy link
Member

braebot commented Jun 1, 2016

Thanks for the PR! Did you happen to look if the camera2 APIs would help, or is it just another way of getting the same information?

@lkorth
Copy link
Member Author

lkorth commented Jun 1, 2016

I'd have to try it out, it looks like CameraManager#getCameraCharacteristics would provide the information needed, but it's unclear if it will work before obtaining permission.

@lkorth
Copy link
Member Author

lkorth commented Jun 2, 2016

Checking camera characteristics does work without permission, however it requires a Context. This would require a breaking change to CardIOActivity#canReadCardWithCamera to take a Context.

@braebot
Copy link
Member

braebot commented Jun 14, 2016

Thanks @lkorth! We'd have to add a new method to take the context, while leaving the old one with this hack.

That being the case, I'll merge this, and leave the new method as a future enhancement.

@braebot braebot merged commit f8a2223 into card-io:master Jun 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants