Skip to content

Commit

Permalink
Merge pull request #49070 from RandomShaper/android_data_backup_3.x
Browse files Browse the repository at this point in the history
[3.x] Allow basic user data backup on Android
  • Loading branch information
akien-mga authored May 25, 2021
2 parents bb53fb0 + 76a4831 commit 998b6b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> perms;
// Write permissions into the perms variable.
_get_permissions(p_preset, p_give_internet, perms);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -1738,6 +1744,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
3 changes: 2 additions & 1 deletion platform/android/export/gradle_export_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_
bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1;
String manifest_application_text = vformat(
" <application android:label=\"@string/godot_project_name_string\"\n"
" android:allowBackup=\"false\" tools:ignore=\"GoogleAppIndexingWarning\"\n"
" android:allowBackup=\"%s\" tools:ignore=\"GoogleAppIndexingWarning\"\n"
" tools:replace=\"android:requestLegacyExternalStorage\" "
" android:requestLegacyExternalStorage=\"%s\"\n"
" android:icon=\"@mipmap/icon\">\n\n"
" <meta-data tools:node=\"remove\" android:name=\"xr_mode_metadata_name\" />\n",
bool_to_string(p_preset->get("user_data_backup/allow")),
bool_to_string(p_has_storage_permission));

if (uses_xr) {
Expand Down

0 comments on commit 998b6b1

Please sign in to comment.