diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-05-10 19:56:27 +0300 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2021-05-11 12:35:30 +0000 |
commit | f37944623025f7e1466bbb1f6fbb142e718cfa51 (patch) | |
tree | d65c8ee17bef02961646c14133c0baf2b706f0b1 /src | |
parent | c113c88aa29c47d55dc01d468d88140cbc4848d7 (diff) |
Handle checkPermission() below api 23
Although Qt 6 supports API 23+, it's still not bad to do this fix, it
achieves two things:
* Avoid the use of reflection when checking for permission state
* It works for all api versions
With this we would be sure we don't need to do a check in c++
if (androidSdkVersion < 23)
return true;
The platform api checks if permission is granted or not, irrelevant of
the api version.
Change-Id: I9766dc35bbc8347ad0d60fde54b95710c8866736
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt/android/QtNative.java | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java index f9bb680cb6..5529cbdf62 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java @@ -843,13 +843,8 @@ public class QtNative int perm = PackageManager.PERMISSION_DENIED; synchronized (m_mainActivityMutex) { Context context = getContext(); - try { - if (m_checkSelfPermissionMethod == null) - m_checkSelfPermissionMethod = Context.class.getMethod("checkSelfPermission", String.class); - perm = (Integer)m_checkSelfPermissionMethod.invoke(context, permission); - } catch (Exception e) { - e.printStackTrace(); - } + PackageManager pm = context.getPackageManager(); + perm = pm.checkPermission(permission, context.getPackageName()); } return perm; |