Android: Add `isGame` application attribute, default to true

It can be turned off in the export preset with `package/classify_as_game`.

Upstream definition: https://developer.android.com/guide/topics/manifest/application-element#isGame

> `android:isGame`
>
> Whether or not the application is a game. The system may group together
> applications classifed as games or display them separately from other
> applications.

Also fixes replacing `android:allowBackup` in custom builds.

(cherry picked from commit 40a594c6ea)
This commit is contained in:
Rémi Verschelde 2021-06-30 18:44:33 +02:00
parent 76c1a0e91d
commit cd64bcdae5
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 13 additions and 5 deletions

View File

@ -903,6 +903,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool focus_awareness = p_preset->get("xr_features/focus_awareness"); bool focus_awareness = p_preset->get("xr_features/focus_awareness");
bool backup_allowed = p_preset->get("user_data_backup/allow"); bool backup_allowed = p_preset->get("user_data_backup/allow");
bool classify_as_game = p_preset->get("package/classify_as_game");
Vector<String> perms; Vector<String> perms;
// Write permissions into the perms variable. // Write permissions into the perms variable.
@ -1006,6 +1007,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
encode_uint32(backup_allowed, &p_manifest.write[iofs + 16]); encode_uint32(backup_allowed, &p_manifest.write[iofs + 16]);
} }
if (tname == "application" && attrname == "isGame") {
encode_uint32(classify_as_game, &p_manifest.write[iofs + 16]);
}
if (tname == "instrumentation" && attrname == "targetPackage") { if (tname == "instrumentation" && attrname == "targetPackage") {
string_table.write[attr_value] = get_package_name(package_name); string_table.write[attr_value] = get_package_name(package_name);
} }
@ -1758,6 +1763,7 @@ public:
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "org.godotengine.$genname")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "org.godotengine.$genname"));
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::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/signed"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/classify_as_game"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icon_option, PROPERTY_HINT_FILE, "*.png"), "")); 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"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), ""));

View File

@ -263,12 +263,14 @@ String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_
bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1; bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1;
String manifest_application_text = vformat( String manifest_application_text = vformat(
" <application android:label=\"@string/godot_project_name_string\"\n" " <application android:label=\"@string/godot_project_name_string\"\n"
" android:allowBackup=\"%s\" tools:ignore=\"GoogleAppIndexingWarning\"\n" " android:allowBackup=\"%s\"\n"
" tools:replace=\"android:requestLegacyExternalStorage\" " " android:icon=\"@mipmap/icon\"\n"
" android:isGame=\"%s\"\n"
" android:requestLegacyExternalStorage=\"%s\"\n" " android:requestLegacyExternalStorage=\"%s\"\n"
" android:icon=\"@mipmap/icon\">\n\n" " tools:replace=\"android:allowBackup,android:isGame,android:requestLegacyExternalStorage\"\n"
" <meta-data tools:node=\"remove\" android:name=\"xr_mode_metadata_name\" />\n", " tools:ignore=\"GoogleAppIndexingWarning\">\n\n",
bool_to_string(p_preset->get("user_data_backup/allow")), bool_to_string(p_preset->get("user_data_backup/allow")),
bool_to_string(p_preset->get("package/classify_as_game")),
bool_to_string(p_has_storage_permission)); bool_to_string(p_has_storage_permission));
if (uses_xr) { if (uses_xr) {

View File

@ -28,7 +28,7 @@
<!-- If you want to add tags manually, do before it. --> <!-- 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. --> <!-- 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 --> <!-- 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" tools:ignore="GoogleAppIndexingWarning" android:requestLegacyExternalStorage="false" android:icon="@mipmap/icon" > <application android:label="@string/godot_project_name_string" android:allowBackup="false" android:icon="@mipmap/icon" android:isGame="true" android:requestLegacyExternalStorage="false" tools:ignore="GoogleAppIndexingWarning" >
<!-- Records the version of the Godot editor used for building --> <!-- Records the version of the Godot editor used for building -->
<meta-data <meta-data