Skip to content

Commit

Permalink
Handle checkPermission() below api 23
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Issam-b authored and ablasche committed May 11, 2021
1 parent c113c88 commit f379446
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/android/jar/src/org/qtproject/qt/android/QtNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,8 @@ public static int checkSelfPermission(String permission)
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;
Expand Down

0 comments on commit f379446

Please sign in to comment.