From 509b613c45fb82744efae659318dcaecb8a59380 Mon Sep 17 00:00:00 2001 From: lkorth Date: Fri, 27 May 2016 12:11:10 -0400 Subject: [PATCH] Handle runtime permissions when checking hardware support Return true for CardIOActivity#canReadCardWithCamera when camera cannot be access on API >= 23. Fixes card-io/card.io-Android-SDK#136 --- card.io/src/main/java/io/card/payment/Util.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/card.io/src/main/java/io/card/payment/Util.java b/card.io/src/main/java/io/card/payment/Util.java index da188afe..c0f06d80 100644 --- a/card.io/src/main/java/io/card/payment/Util.java +++ b/card.io/src/main/java/io/card/payment/Util.java @@ -84,8 +84,12 @@ private static boolean hardwareSupportCheck() { try { c = Camera.open(); } catch (RuntimeException e) { - Log.w(PUBLIC_LOG_TAG, "- Error opening camera: " + e); - throw new CameraUnavailableException(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return true; + } else { + Log.w(PUBLIC_LOG_TAG, "- Error opening camera: " + e); + throw new CameraUnavailableException(); + } } if (c == null) { Log.w(PUBLIC_LOG_TAG, "- No camera found");