Merge pull request #96742 from m4gr3d/check_openxr_automatic_permissions_request
[Android editor] Limit when OpenXR runtime permissions are requested
This commit is contained in:
commit
f33a81977b
|
@ -45,15 +45,13 @@ open class GodotEditor : BaseGodotEditor() {
|
||||||
|
|
||||||
internal val XR_RUN_GAME_INFO = EditorWindowInfo(GodotXRGame::class.java, 1667, ":GodotXRGame")
|
internal val XR_RUN_GAME_INFO = EditorWindowInfo(GodotXRGame::class.java, 1667, ":GodotXRGame")
|
||||||
|
|
||||||
internal const val USE_ANCHOR_API_PERMISSION = "com.oculus.permission.USE_ANCHOR_API"
|
|
||||||
internal const val USE_SCENE_PERMISSION = "com.oculus.permission.USE_SCENE"
|
internal const val USE_SCENE_PERMISSION = "com.oculus.permission.USE_SCENE"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExcludedPermissions(): MutableSet<String> {
|
override fun getExcludedPermissions(): MutableSet<String> {
|
||||||
val excludedPermissions = super.getExcludedPermissions()
|
val excludedPermissions = super.getExcludedPermissions()
|
||||||
// The USE_ANCHOR_API and USE_SCENE permissions are requested when the "xr/openxr/enabled"
|
// The USE_SCENE permission is requested when the "xr/openxr/enabled" project setting
|
||||||
// project setting is enabled.
|
// is enabled.
|
||||||
excludedPermissions.add(USE_ANCHOR_API_PERMISSION)
|
|
||||||
excludedPermissions.add(USE_SCENE_PERMISSION)
|
excludedPermissions.add(USE_SCENE_PERMISSION)
|
||||||
return excludedPermissions
|
return excludedPermissions
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
package org.godotengine.editor
|
package org.godotengine.editor
|
||||||
|
|
||||||
import org.godotengine.godot.GodotLib
|
import org.godotengine.godot.GodotLib
|
||||||
import org.godotengine.godot.utils.PermissionsUtil
|
|
||||||
import org.godotengine.godot.xr.XRMode
|
import org.godotengine.godot.xr.XRMode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,9 +61,17 @@ open class GodotXRGame: GodotGame() {
|
||||||
|
|
||||||
val openxrEnabled = GodotLib.getGlobal("xr/openxr/enabled").toBoolean()
|
val openxrEnabled = GodotLib.getGlobal("xr/openxr/enabled").toBoolean()
|
||||||
if (openxrEnabled) {
|
if (openxrEnabled) {
|
||||||
permissionsToEnable.add(USE_ANCHOR_API_PERMISSION)
|
// We only request permissions when the `automatically_request_runtime_permissions`
|
||||||
|
// project setting is enabled.
|
||||||
|
// If the project setting is not defined, we fall-back to the default behavior which is
|
||||||
|
// to automatically request permissions.
|
||||||
|
val automaticallyRequestPermissionsSetting = GodotLib.getGlobal("xr/openxr/extensions/automatically_request_runtime_permissions")
|
||||||
|
val automaticPermissionsRequestEnabled = automaticallyRequestPermissionsSetting.isNullOrEmpty() ||
|
||||||
|
automaticallyRequestPermissionsSetting.toBoolean()
|
||||||
|
if (automaticPermissionsRequestEnabled) {
|
||||||
permissionsToEnable.add(USE_SCENE_PERMISSION)
|
permissionsToEnable.add(USE_SCENE_PERMISSION)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return permissionsToEnable
|
return permissionsToEnable
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,19 +472,22 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env,
|
||||||
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path) {
|
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path) {
|
||||||
String js = jstring_to_string(path, env);
|
String js = jstring_to_string(path, env);
|
||||||
|
|
||||||
return env->NewStringUTF(GLOBAL_GET(js).operator String().utf8().get_data());
|
Variant setting_with_override = GLOBAL_GET(js);
|
||||||
|
String setting_value = (setting_with_override.get_type() == Variant::NIL) ? "" : setting_with_override;
|
||||||
|
return env->NewStringUTF(setting_value.utf8().get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
|
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
|
||||||
String editor_setting = "";
|
String editor_setting_value = "";
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
String godot_setting_key = jstring_to_string(p_setting_key, env);
|
String godot_setting_key = jstring_to_string(p_setting_key, env);
|
||||||
editor_setting = EDITOR_GET(godot_setting_key).operator String();
|
Variant editor_setting = EDITOR_GET(godot_setting_key);
|
||||||
|
editor_setting_value = (editor_setting.get_type() == Variant::NIL) ? "" : editor_setting;
|
||||||
#else
|
#else
|
||||||
WARN_PRINT("Access to the Editor Settings in only available on Editor builds");
|
WARN_PRINT("Access to the Editor Settings in only available on Editor builds");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return env->NewStringUTF(editor_setting.utf8().get_data());
|
return env->NewStringUTF(editor_setting_value.utf8().get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
|
||||||
|
|
Loading…
Reference in New Issue