From 76a4831cd3a56282b649705fc25d77d076ed2b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 25 May 2021 17:37:24 +0200 Subject: [PATCH] Allow basic user data backup on Android --- platform/android/export/export.cpp | 8 ++++++++ platform/android/export/gradle_export_util.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 070ead20024..6d8808fbc05 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -867,6 +867,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { int xr_mode_index = p_preset->get("xr_features/xr_mode"); bool focus_awareness = p_preset->get("xr_features/focus_awareness"); + bool backup_allowed = p_preset->get("user_data_backup/allow"); + Vector perms; // Write permissions into the perms variable. _get_permissions(p_preset, p_give_internet, perms); @@ -965,6 +967,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { encode_uint32(has_storage_permission ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); } + if (tname == "application" && attrname == "allowBackup") { + encode_uint32(backup_allowed, &p_manifest.write[iofs + 16]); + } + if (tname == "instrumentation" && attrname == "targetPackage") { string_table.write[attr_value] = get_package_name(package_name); } @@ -1738,6 +1744,8 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_large"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data_backup/allow"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "apk_expansion/enable"), false)); diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index 82c3ac7a9f6..727d2369112 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -292,11 +292,12 @@ String _get_application_tag(const Ref &p_preset, bool p_has_ bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1; String manifest_application_text = vformat( " \n\n" " \n", + bool_to_string(p_preset->get("user_data_backup/allow")), bool_to_string(p_has_storage_permission)); if (uses_xr) {