Merge pull request #51605 from m4gr3d/expose_fragile_user_data_config_3_x

[3.x] Add support for prompting the user to retain app data on uninstall.
This commit is contained in:
Rémi Verschelde 2021-08-13 08:41:46 +02:00 committed by GitHub
commit 537077fffa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

@ -904,6 +904,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool backup_allowed = p_preset->get("user_data_backup/allow");
bool classify_as_game = p_preset->get("package/classify_as_game");
bool retain_data_on_uninstall = p_preset->get("package/retain_data_on_uninstall");
Vector<String> perms;
// Write permissions into the perms variable.
@ -1011,6 +1012,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
encode_uint32(classify_as_game, &p_manifest.write[iofs + 16]);
}
if (tname == "application" && attrname == "hasFragileUserData") {
encode_uint32(retain_data_on_uninstall, &p_manifest.write[iofs + 16]);
}
if (tname == "instrumentation" && attrname == "targetPackage") {
string_table.write[attr_value] = get_package_name(package_name);
}
@ -1764,6 +1769,7 @@ public:
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name [default if blank]"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/classify_as_game"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/retain_data_on_uninstall"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icon_option, PROPERTY_HINT_FILE, "*.png"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), ""));

View file

@ -265,13 +265,15 @@ String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_
" <application android:label=\"@string/godot_project_name_string\"\n"
" android:allowBackup=\"%s\"\n"
" android:isGame=\"%s\"\n"
" android:hasFragileUserData=\"%s\"\n"
" android:requestLegacyExternalStorage=\"%s\"\n"
" tools:replace=\"android:allowBackup,android:isGame,android:requestLegacyExternalStorage\"\n"
" tools:replace=\"android:allowBackup,android:isGame,android:hasFragileUserData,android:requestLegacyExternalStorage\"\n"
" tools:ignore=\"GoogleAppIndexingWarning\"\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_preset->get("package/classify_as_game")),
bool_to_string(p_preset->get("package/retain_data_on_uninstall")),
bool_to_string(p_has_storage_permission));
if (uses_xr) {

View file

@ -28,7 +28,7 @@
<!-- If you want to add tags manually, do before it. -->
<!-- WARNING: This should stay on a single line until the parsing code is improved. See GH-32414. -->
<!-- TODO: Remove the 'requestLegacyExternalStorage' attribute when https://github.com/godotengine/godot/issues/38913 is resolved -->
<application android:label="@string/godot_project_name_string" android:allowBackup="false" android:isGame="true" android:requestLegacyExternalStorage="false" tools:ignore="GoogleAppIndexingWarning" android:icon="@mipmap/icon" >
<application android:label="@string/godot_project_name_string" android:allowBackup="false" android:isGame="true" android:hasFragileUserData="false" android:requestLegacyExternalStorage="false" tools:ignore="GoogleAppIndexingWarning" android:icon="@mipmap/icon" >
<!-- Records the version of the Godot editor used for building -->
<meta-data