diff options
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/display_server_android.cpp | 9 | ||||
-rw-r--r-- | platform/android/display_server_android.h | 2 | ||||
-rw-r--r-- | platform/android/export/export.cpp | 61 | ||||
-rw-r--r-- | platform/android/java/app/gradle.properties | 25 | ||||
-rw-r--r-- | platform/android/java/build.gradle | 2 | ||||
-rw-r--r-- | platform/android/java/gradle.properties | 6 | ||||
-rw-r--r-- | platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java | 2 | ||||
-rw-r--r-- | platform/android/java_class_wrapper.cpp | 16 | ||||
-rw-r--r-- | platform/android/java_godot_lib_jni.cpp | 4 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 7 | ||||
-rw-r--r-- | platform/android/os_android.h | 2 |
11 files changed, 84 insertions, 52 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 1fcc3d4a5c..af8829324b 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -334,13 +334,6 @@ bool DisplayServerAndroid::can_any_window_draw() const { return true; } -void DisplayServerAndroid::alert(const String &p_alert, const String &p_title) { - GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); - ERR_FAIL_COND(!godot_java); - - godot_java->alert(p_alert, p_title); -} - void DisplayServerAndroid::process_events() { Input::get_singleton()->flush_accumulated_events(); } @@ -361,7 +354,7 @@ Vector<String> DisplayServerAndroid::get_rendering_drivers_func() { DisplayServer *DisplayServerAndroid::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerAndroid(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver"); + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver"); } return ds; } diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h index 46745f8030..9b9f5e99f6 100644 --- a/platform/android/display_server_android.h +++ b/platform/android/display_server_android.h @@ -204,8 +204,6 @@ public: virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; - virtual void alert(const String &p_alert, const String &p_title) override; - virtual void process_events() override; void process_accelerometer(const Vector3 &p_accelerometer); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 956b59ce80..1795bbe523 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1817,12 +1817,12 @@ public: MutexLock lock(device_lock); - EditorProgress ep("run", "Running on " + devices[p_device].name, 3); + EditorProgress ep("run", vformat(TTR("Running on %s"), devices[p_device].name), 3); String adb = get_adb_path(); // Export_temp APK. - if (ep.step("Exporting APK...", 0)) { + if (ep.step(TTR("Exporting APK..."), 0)) { return ERR_SKIP; } @@ -1857,7 +1857,7 @@ public: String package_name = p_preset->get("package/unique_name"); if (remove_prev) { - if (ep.step("Uninstalling...", 1)) { + if (ep.step(TTR("Uninstalling..."), 1)) { CLEANUP_AND_RETURN(ERR_SKIP); } @@ -1874,7 +1874,7 @@ public: } print_line("Installing to device (please wait...): " + devices[p_device].name); - if (ep.step("Installing to device, please wait...", 2)) { + if (ep.step(TTR("Installing to device, please wait..."), 2)) { CLEANUP_AND_RETURN(ERR_SKIP); } @@ -1889,7 +1889,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not install to device: " + output); + EditorNode::add_io_error(vformat(TTR("Could not install to device: %s"), output)); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } @@ -1945,7 +1945,7 @@ public: } } - if (ep.step("Running on device...", 3)) { + if (ep.step(TTR("Running on device..."), 3)) { CLEANUP_AND_RETURN(ERR_SKIP); } args.clear(); @@ -1967,7 +1967,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not execute on device."); + EditorNode::add_io_error(TTR("Could not execute on device.")); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } @@ -2068,6 +2068,8 @@ public: if (!installed_android_build_template) { r_missing_templates = !exists_export_template("android_source.zip", &err); err += TTR("Android build template not installed in the project. Install it from the Project menu.") + "\n"; + } else { + r_missing_templates = false; } valid = installed_android_build_template && !r_missing_templates; @@ -2324,7 +2326,7 @@ public: String apksigner = get_apksigner_path(); print_verbose("Starting signing of the " + export_label + " binary using " + apksigner); if (!FileAccess::exists(apksigner)) { - EditorNode::add_io_error("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting " + export_label + " is unsigned."); + EditorNode::add_io_error(vformat(TTR("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting %s is unsigned."), export_label)); return OK; } @@ -2342,7 +2344,7 @@ public: user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user"); } - if (ep.step("Signing debug " + export_label + "...", 104)) { + if (ep.step(vformat(TTR("Signing debug %s..."), export_label), 104)) { return ERR_SKIP; } @@ -2351,13 +2353,13 @@ public: password = release_password; user = release_username; - if (ep.step("Signing release " + export_label + "...", 104)) { + if (ep.step(vformat(TTR("Signing release %s..."), export_label), 104)) { return ERR_SKIP; } } if (!FileAccess::exists(keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); + EditorNode::add_io_error(TTR("Could not find keystore, unable to export.")); return ERR_FILE_CANT_OPEN; } @@ -2381,11 +2383,11 @@ public: OS::get_singleton()->execute(apksigner, args, &output, &retval, true); print_verbose(output); if (retval) { - EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval)); + EditorNode::add_io_error(vformat(TTR("'apksigner' returned with error #%d"), retval)); return ERR_CANT_CREATE; } - if (ep.step("Verifying " + export_label + "...", 105)) { + if (ep.step(vformat(TTR("Verifying %s..."), export_label), 105)) { return ERR_SKIP; } @@ -2401,7 +2403,7 @@ public: OS::get_singleton()->execute(apksigner, args, &output, &retval, true); print_verbose(output); if (retval) { - EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed."); + EditorNode::add_io_error(vformat(TTR("'apksigner' verification of %s failed."), export_label)); return ERR_CANT_CREATE; } @@ -2464,7 +2466,7 @@ public: String src_apk; Error err; - EditorProgress ep("export", "Exporting for Android", 105, true); + EditorProgress ep("export", TTR("Exporting for Android"), 105, true); bool use_custom_build = bool(p_preset->get("custom_template/use_custom_build")); bool p_give_internet = p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG); @@ -2513,7 +2515,7 @@ public: return ERR_UNCONFIGURED; } if (export_format > EXPORT_FORMAT_AAB || export_format < EXPORT_FORMAT_APK) { - EditorNode::add_io_error("Unsupported export format!\n"); + EditorNode::add_io_error(TTR("Unsupported export format!\n")); return ERR_UNCONFIGURED; //TODO: is this the right error? } @@ -2543,7 +2545,7 @@ public: String project_name = get_project_name(p_preset->get("package/name")); err = _create_project_name_strings_files(p_preset, project_name); //project name localization. if (err != OK) { - EditorNode::add_io_error("Unable to overwrite res://android/build/res/*.xml files with project name"); + EditorNode::add_io_error(TTR("Unable to overwrite res://android/build/res/*.xml files with project name")); } // Copies the project icon files into the appropriate Gradle project directory. _copy_icons_to_gradle_project(p_preset, processed_splash_config_xml, splash_image, splash_bg_color_image, main_image, foreground, background); @@ -2559,7 +2561,7 @@ public: user_data.debug = p_debug; err = export_project_files(p_preset, rename_and_store_file_in_gradle_project, &user_data, copy_gradle_so); if (err != OK) { - EditorNode::add_io_error("Could not export project files to gradle project\n"); + EditorNode::add_io_error(TTR("Could not export project files to gradle project\n")); return err; } if (user_data.libs.size() > 0) { @@ -2572,7 +2574,7 @@ public: print_verbose("Saving apk expansion file.."); err = save_apk_expansion_file(p_preset, p_path); if (err != OK) { - EditorNode::add_io_error("Could not write expansion package file!"); + EditorNode::add_io_error(TTR("Could not write expansion package file!")); return err; } } @@ -2659,7 +2661,7 @@ public: String release_username = p_preset->get("keystore/release_user"); String release_password = p_preset->get("keystore/release_password"); if (!FileAccess::exists(release_keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); + EditorNode::add_io_error(TTR("Could not find keystore, unable to export.")); return ERR_FILE_CANT_OPEN; } @@ -2723,7 +2725,7 @@ public: src_apk = find_export_template("android_release.apk"); } if (src_apk == "") { - EditorNode::add_io_error("Package not found: " + src_apk); + EditorNode::add_io_error(vformat(TTR("Package not found: %s"), src_apk)); return ERR_FILE_NOT_FOUND; } } @@ -2735,13 +2737,13 @@ public: FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - if (ep.step("Creating APK...", 0)) { + if (ep.step(TTR("Creating APK..."), 0)) { return ERR_SKIP; } unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io); if (!pkg) { - EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk); + EditorNode::add_io_error(vformat(TTR("Could not find template APK to export:\n%s"), src_apk)); return ERR_FILE_NOT_FOUND; } @@ -2869,12 +2871,11 @@ public: if (!invalid_abis.is_empty()) { String unsupported_arch = String(", ").join(invalid_abis); - EditorNode::add_io_error("Missing libraries in the export template for the selected architectures: " + unsupported_arch + ".\n" + - "Please build a template with all required libraries, or uncheck the missing architectures in the export preset."); + EditorNode::add_io_error(vformat(TTR("Missing libraries in the export template for the selected architectures: %s.\nPlease build a template with all required libraries, or uncheck the missing architectures in the export preset."), unsupported_arch)); CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); } - if (ep.step("Adding files...", 1)) { + if (ep.step(TTR("Adding files..."), 1)) { CLEANUP_AND_RETURN(ERR_SKIP); } err = OK; @@ -2888,7 +2889,7 @@ public: if (apk_expansion) { err = save_apk_expansion_file(p_preset, p_path); if (err != OK) { - EditorNode::add_io_error("Could not write expansion package file!"); + EditorNode::add_io_error(TTR("Could not write expansion package file!")); return err; } } else { @@ -2901,7 +2902,7 @@ public: if (err != OK) { unzClose(pkg); - EditorNode::add_io_error("Could not export project files"); + EditorNode::add_io_error(TTR("Could not export project files")); CLEANUP_AND_RETURN(ERR_SKIP); } @@ -2931,13 +2932,13 @@ public: // If we're not signing the apk, then the next step should be the last. const int next_step = should_sign ? 103 : 105; - if (ep.step("Aligning APK...", next_step)) { + if (ep.step(TTR("Aligning APK..."), next_step)) { CLEANUP_AND_RETURN(ERR_SKIP); } unzFile tmp_unaligned = unzOpen2(tmp_unaligned_path.utf8().get_data(), &io); if (!tmp_unaligned) { - EditorNode::add_io_error("Could not unzip temporary unaligned APK."); + EditorNode::add_io_error(TTR("Could not unzip temporary unaligned APK.")); CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); } diff --git a/platform/android/java/app/gradle.properties b/platform/android/java/app/gradle.properties new file mode 100644 index 0000000000..19587bd81f --- /dev/null +++ b/platform/android/java/app/gradle.properties @@ -0,0 +1,25 @@ +# Godot custom build Gradle settings. +# These properties apply when running custom build from the Godot editor. +# NOTE: This should be kept in sync with 'godot/platform/android/java/gradle.properties' except +# where otherwise specified. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +android.enableJetifier=true +android.useAndroidX=true + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +org.gradle.warning.mode=all + +# Enable resource optimizations for release build. +# NOTE: This is turned off for template release build in order to support the build legacy process. +android.enableResourceOptimizations=true diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle index ee24a46d9f..87bb2ea218 100644 --- a/platform/android/java/build.gradle +++ b/platform/android/java/build.gradle @@ -115,7 +115,7 @@ task zipCustomBuild(type: Zip) { doFirst { logger.lifecycle("Generating Godot custom build template") } - from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradle.properties', 'gradlew', 'gradlew.bat', 'gradle/**'])) + from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradlew', 'gradlew.bat', 'gradle/**'])) include '**/*' archiveFileName = 'android_source.zip' destinationDirectory = file(binDir) diff --git a/platform/android/java/gradle.properties b/platform/android/java/gradle.properties index 6b3b62a9da..b51a19a005 100644 --- a/platform/android/java/gradle.properties +++ b/platform/android/java/gradle.properties @@ -1,4 +1,6 @@ # Project-wide Gradle settings. +# NOTE: This should be kept in sync with 'godot/platform/android/java/app/gradle.properties' except +# where otherwise specified. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* @@ -20,3 +22,7 @@ org.gradle.jvmargs=-Xmx4536m # org.gradle.parallel=true org.gradle.warning.mode=all + +# Disable resource optimizations for template release build. +# NOTE: This is turned on for custom build in order to improve the release build. +android.enableResourceOptimizations=false diff --git a/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java b/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java index 008c150a8e..05b452d0c1 100644 --- a/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java +++ b/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java @@ -20,7 +20,7 @@ package com.google.android.vending.licensing; * Interface used as part of a {@link Policy} to allow application authors to obfuscate * licensing data that will be stored into a SharedPreferences file. * <p> - * Any transformation scheme must be reversable. Implementing classes may optionally implement an + * Any transformation scheme must be reversible. Implementing classes may optionally implement an * integrity check to further prevent modification to preference data. Implementing classes * should use device-specific information as a key in the obfuscation algorithm to prevent * obfuscated preferences from being shared among devices. diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index ed6b5c3e14..49891cd739 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -41,13 +41,13 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, ERR_FAIL_COND_V(env == nullptr, false); MethodInfo *method = nullptr; - for (List<MethodInfo>::Element *E = M->get().front(); E; E = E->next()) { - if (!p_instance && !E->get()._static) { + for (MethodInfo &E : M->get()) { + if (!p_instance && !E._static) { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; continue; } - int pc = E->get().param_types.size(); + int pc = E.param_types.size(); if (pc > p_argcount) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = pc; @@ -58,7 +58,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, r_error.argument = pc; continue; } - uint32_t *ptypes = E->get().param_types.ptrw(); + uint32_t *ptypes = E.param_types.ptrw(); bool valid = true; for (int i = 0; i < pc; i++) { @@ -107,7 +107,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (Object::cast_to<JavaObject>(ref.ptr())) { Ref<JavaObject> jo = ref; //could be faster - jclass c = env->FindClass(E->get().param_sigs[i].operator String().utf8().get_data()); + jclass c = env->FindClass(E.param_sigs[i].operator String().utf8().get_data()); if (!c || !env->IsInstanceOf(jo->instance, c)) { arg_expected = Variant::OBJECT; } else { @@ -138,7 +138,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (!valid) continue; - method = &E->get(); + method = &E; break; } @@ -474,8 +474,8 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } break; } - for (List<jobject>::Element *E = to_free.front(); E; E = E->next()) { - env->DeleteLocalRef(E->get()); + for (jobject &E : to_free) { + env->DeleteLocalRef(E); } return success; diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 583d3342a0..ce7a49e53c 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -438,8 +438,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env->DeleteLocalRef(obj); }; - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); // something env->PopLocalFrame(nullptr); } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 222976d948..792a390e36 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -71,6 +71,13 @@ public: virtual ~AndroidLogger() {} }; +void OS_Android::alert(const String &p_alert, const String &p_title) { + GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); + ERR_FAIL_COND(!godot_java); + + godot_java->alert(p_alert, p_title); +} + void OS_Android::initialize_core() { OS_Unix::initialize_core(); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 1e89e9211d..38f0f3edc7 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -86,6 +86,8 @@ public: virtual bool request_permissions() override; virtual Vector<String> get_granted_permissions() const override; + virtual void alert(const String &p_alert, const String &p_title) override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual String get_name() const override; |