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
Request Android record permission when needed #26756
Conversation
571629b
to
281310e
Compare
281310e
to
a95040d
Compare
Awesome, thanks for the testing! |
@@ -937,6 +945,18 @@ public void setPaymentsManager(PaymentsManager mPaymentsManager) { | |||
*/ | |||
|
|||
// Audio |
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.
By chance this comment is correct now, but I guess in the future we might want to add support for more permissions in the same method, so maybe it should be removed/updated?
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.
I'll remove it
@@ -937,6 +945,18 @@ public void setPaymentsManager(PaymentsManager mPaymentsManager) { | |||
*/ | |||
|
|||
// Audio | |||
public boolean requestPermission(String p_name) { | |||
if (p_name.equals("RECORD_AUDIO")) { | |||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
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.
Similar to above comment, will this check also be relevant for other types of permissions? If so, it should probably be done the other way around?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (p_name.equals("RECORD_AUDIO")) {
or maybe even:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// Not necessary, asked on install already
return true;
}
if (p_name.equals("RECORD_AUDIO")) {
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.
Sound good, I'll change it
@@ -1265,6 +1270,8 @@ void _OS::_bind_methods() { | |||
ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left); | |||
ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left); | |||
|
|||
ClassDB::bind_method(D_METHOD("request_permission", "name"), &_OS::request_permission); |
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.
Could you add documentation for this method too since it's bound? Currently users might try to request all kinds of permissions using it, to find out that it doesn't work as they think.
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.
Alright :D
@BastiaanOlij Should be relevant for your work :) |
a95040d
to
b22cf46
Compare
Thanks! |
Beautiful! I'm going to redo the permissions logic for ARCore so it requests the camera permissions through this. I'll probably do a separate PR for just the camera permissions once I get my head around it. |
@marcelofg55, I'm trying to duplicate this for the camera, if i understand the changes correctly, you now call request permissions from the audio driver. |
@BastiaanOlij check this: https://github.com/godotengine/godot/blob/master/platform/android/java_glue.cpp#L1586 |
Fixes #26506