-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Update(android): android 13 camera open Fixed #839
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1312,20 +1312,39 @@ public void onScanCompleted(String path, Uri uri) { | |
} | ||
|
||
public void onRequestPermissionResult(int requestCode, String[] permissions, | ||
int[] grantResults) { | ||
for (int r : grantResults) { | ||
if (r == PackageManager.PERMISSION_DENIED) { | ||
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); | ||
return; | ||
int[] grantResults) throws JSONException { | ||
String version = android.os.Build.VERSION.RELEASE; | ||
if(Integer.parseInt(version) <= 13) | ||
{ | ||
if(PermissionHelper.hasPermission(this, Manifest.permission.CAMERA)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: have you tested this line, because in my test in android 13 hasPermission is every time false, or you call a request to have permission, or remove this line(my android 13 worked without this if) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Normally the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With that being said, the condition seems to be doing |
||
switch (requestCode) { | ||
case TAKE_PIC_SEC: | ||
takePicture(this.destType, this.encodingType); | ||
break; | ||
case SAVE_TO_ALBUM_SEC: | ||
this.getImage(this.srcType, this.destType); | ||
break; | ||
} | ||
} | ||
else { | ||
PermissionHelper.hasPermission(this, Manifest.permission.CAMERA); | ||
} | ||
} | ||
switch (requestCode) { | ||
case TAKE_PIC_SEC: | ||
takePicture(this.destType, this.encodingType); | ||
break; | ||
case SAVE_TO_ALBUM_SEC: | ||
this.getImage(this.srcType, this.destType); | ||
break; | ||
else{ | ||
for (int r : grantResults) { | ||
if (r == PackageManager.PERMISSION_DENIED) { | ||
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); | ||
return; | ||
} | ||
} | ||
switch (requestCode) { | ||
case TAKE_PIC_SEC: | ||
takePicture(this.destType, this.encodingType); | ||
break; | ||
case SAVE_TO_ALBUM_SEC: | ||
this.getImage(this.srcType, this.destType); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
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.
This check may fail, you cannot assume that the user-visible will be number like or an integer.
Instead it should use Build.VERSION.SDK_INT
Which refers to the API level. Android 13 is API 33, which has a constant Build.VERSION_CODES.TIRAMISU
Can you also explain the rationale for adding in a version check for Android 13 and earlier? This is effectively selecting all devies that we support, excluding any newer android versions in the future. So that seems strange to me.