Skip to content
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

Allow basic user data backup on Android #49069

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

int xr_mode_index = p_preset->get("xr_features/xr_mode");

bool backup_allowed = p_preset->get("user_data_backup/allow");

Vector<String> perms;
// Write permissions into the perms variable.
_get_permissions(p_preset, p_give_internet, perms);
Expand Down Expand Up @@ -949,6 +951,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}

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);
}
Expand Down Expand Up @@ -1684,6 +1690,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
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));
Expand Down
7 changes: 4 additions & 3 deletions platform/android/export/gradle_export_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ String _get_activity_tag(const Ref<EditorExportPreset> &p_preset) {
}

String _get_application_tag(const Ref<EditorExportPreset> &p_preset) {
String manifest_application_text =
String manifest_application_text = vformat(
" <application android:label=\"@string/godot_project_name_string\"\n"
" android:allowBackup=\"false\" tools:ignore=\"GoogleAppIndexingWarning\"\n"
" android:icon=\"@mipmap/icon\">\n\n";
" android:allowBackup=\"%s\" tools:ignore=\"GoogleAppIndexingWarning\"\n"
" android:icon=\"@mipmap/icon\">\n\n",
bool_to_string(p_preset->get("user_data_backup/allow")));

manifest_application_text += _get_activity_tag(p_preset);
manifest_application_text += " </application>\n";
Expand Down