diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml index 23e3f4139ca..bc18304c30e 100644 --- a/doc/classes/EditorExportPlugin.xml +++ b/doc/classes/EditorExportPlugin.xml @@ -241,6 +241,14 @@ Return [code]true[/code] if the plugin supports the given [param platform]. + + + + + + Provide access to the Android prebuilt manifest and allows the plugin to modify it if needed. + + diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp index ddc340ee77f..dea7c45a7f8 100644 --- a/editor/export/editor_export_plugin.cpp +++ b/editor/export/editor_export_plugin.cpp @@ -264,6 +264,12 @@ String EditorExportPlugin::get_android_manifest_element_contents(const Ref &p_export_platform, const PackedByteArray &p_manifest_data) const { + PackedByteArray ret; + GDVIRTUAL_CALL(_update_android_prebuilt_manifest, p_export_platform, p_manifest_data, ret); + return ret; +} + PackedStringArray EditorExportPlugin::_get_export_features(const Ref &p_platform, bool p_debug) const { PackedStringArray ret; GDVIRTUAL_CALL(_get_export_features, p_platform, p_debug, ret); @@ -369,4 +375,5 @@ void EditorExportPlugin::_bind_methods() { GDVIRTUAL_BIND(_get_android_manifest_activity_element_contents, "platform", "debug"); GDVIRTUAL_BIND(_get_android_manifest_application_element_contents, "platform", "debug"); GDVIRTUAL_BIND(_get_android_manifest_element_contents, "platform", "debug"); + GDVIRTUAL_BIND(_update_android_prebuilt_manifest, "platform", "manifest_data"); } diff --git a/editor/export/editor_export_plugin.h b/editor/export/editor_export_plugin.h index e991a9a5e87..8f9be8d8ae4 100644 --- a/editor/export/editor_export_plugin.h +++ b/editor/export/editor_export_plugin.h @@ -144,6 +144,7 @@ protected: GDVIRTUAL2RC(String, _get_android_manifest_activity_element_contents, const Ref &, bool); GDVIRTUAL2RC(String, _get_android_manifest_application_element_contents, const Ref &, bool); GDVIRTUAL2RC(String, _get_android_manifest_element_contents, const Ref &, bool); + GDVIRTUAL2RC(PackedByteArray, _update_android_prebuilt_manifest, const Ref &, const PackedByteArray &); virtual bool _begin_customize_resources(const Ref &p_platform, const Vector &p_features); // Return true if this plugin does property export customization virtual Ref _customize_resource(const Ref &p_resource, const String &p_path); // If nothing is returned, it means do not touch (nothing changed). If something is returned (either the same or a different resource) it means changes are made. @@ -175,6 +176,7 @@ public: virtual String get_android_manifest_activity_element_contents(const Ref &p_export_platform, bool p_debug) const; virtual String get_android_manifest_application_element_contents(const Ref &p_export_platform, bool p_debug) const; virtual String get_android_manifest_element_contents(const Ref &p_export_platform, bool p_debug) const; + virtual PackedByteArray update_android_prebuilt_manifest(const Ref &p_export_platform, const PackedByteArray &p_manifest_data) const; Vector get_ios_frameworks() const; Vector get_ios_embedded_frameworks() const; diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 13d721da5db..78ca4ca96f8 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1484,7 +1484,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p ofs += size; } - //create new andriodmanifest binary + // Create new android manifest binary. Vector ret; ret.resize(string_table_begins + string_table.size() * 4); @@ -1864,16 +1864,10 @@ String EditorExportPlatformAndroid::get_export_option_warning(const EditorExport } } else if (p_name == "gradle_build/use_gradle_build") { bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); - String enabled_plugins_names = _get_plugins_names(Ref(p_preset)); - if (!enabled_plugins_names.is_empty() && !gradle_build_enabled) { + String enabled_deprecated_plugins_names = _get_deprecated_plugins_names(Ref(p_preset)); + if (!enabled_deprecated_plugins_names.is_empty() && !gradle_build_enabled) { return TTR("\"Use Gradle Build\" must be enabled to use the plugins."); } - } else if (p_name == "xr_features/xr_mode") { - bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); - int xr_mode_index = p_preset->get("xr_features/xr_mode"); - if (xr_mode_index == XR_MODE_OPENXR && !gradle_build_enabled) { - return TTR("OpenXR requires \"Use Gradle Build\" to be enabled"); - } } else if (p_name == "gradle_build/compress_native_libraries") { bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); if (bool(p_preset->get("gradle_build/compress_native_libraries")) && !gradle_build_enabled) { @@ -2599,6 +2593,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref &p_preset) const { + Vector names; + +#ifndef DISABLE_DEPRECATED + PluginConfigAndroid::get_plugins_names(get_enabled_plugins(p_preset), names); +#endif // DISABLE_DEPRECATED + + String plugins_names = String("|").join(names); + return plugins_names; +} + String EditorExportPlatformAndroid::_get_plugins_names(const Ref &p_preset) const { Vector names; @@ -3655,6 +3662,17 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref> export_plugins = EditorExport::get_singleton()->get_export_plugins(); + for (int i = 0; i < export_plugins.size(); i++) { + if (export_plugins[i]->supports_platform(Ref(this))) { + PackedByteArray export_plugin_data = export_plugins[i]->update_android_prebuilt_manifest(Ref(this), data); + if (!export_plugin_data.is_empty()) { + data = export_plugin_data; + } + } + } } if (file == "resources.arsc") { _fix_resources(p_preset, data); diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index cae5e87e668..1e1f073f44f 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -236,6 +236,8 @@ public: virtual List get_binary_extensions(const Ref &p_preset) const override; + String _get_deprecated_plugins_names(const Ref &p_preset) const; + String _get_plugins_names(const Ref &p_preset) const; String _resolve_export_plugin_android_library_path(const String &p_android_library_path) const; diff --git a/platform/android/java/editor/src/horizonos/AndroidManifest.xml b/platform/android/java/editor/src/horizonos/AndroidManifest.xml index 3f2b87e0485..3db83340aa1 100644 --- a/platform/android/java/editor/src/horizonos/AndroidManifest.xml +++ b/platform/android/java/editor/src/horizonos/AndroidManifest.xml @@ -90,6 +90,8 @@ + +