Path: blob/master/platform/android/export/gradle_export_util.h
10278 views
/**************************************************************************/1/* gradle_export_util.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/crypto/crypto_core.h"33#include "core/io/dir_access.h"34#include "core/io/file_access.h"35#include "core/io/zip_io.h"36#include "core/os/os.h"37#include "editor/export/editor_export.h"38#include "editor/export/editor_export_platform.h"3940const String GODOT_PROJECT_NAME_XML_STRING = R"(<?xml version="1.0" encoding="utf-8"?>41<!--WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME-->42<resources>43<string name="godot_project_name_string">%s</string>44</resources>45)";4647// Application category.48// See https://developer.android.com/guide/topics/manifest/application-element#appCategory for standards49static const int APP_CATEGORY_ACCESSIBILITY = 0;50static const int APP_CATEGORY_AUDIO = 1;51static const int APP_CATEGORY_GAME = 2;52static const int APP_CATEGORY_IMAGE = 3;53static const int APP_CATEGORY_MAPS = 4;54static const int APP_CATEGORY_NEWS = 5;55static const int APP_CATEGORY_PRODUCTIVITY = 6;56static const int APP_CATEGORY_SOCIAL = 7;57static const int APP_CATEGORY_VIDEO = 8;58static const int APP_CATEGORY_UNDEFINED = 9;5960// Supported XR modes.61// This should match the entries in 'platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java'62static const int XR_MODE_REGULAR = 0;63static const int XR_MODE_OPENXR = 1;6465struct CustomExportData {66EditorExportPlatform::PackData pd;67String assets_directory;68String libs_directory;69bool debug;70Vector<String> libs;71};7273struct MetadataInfo {74String name;75String value;76};7778int _get_android_orientation_value(DisplayServer::ScreenOrientation screen_orientation);7980String _get_android_orientation_label(DisplayServer::ScreenOrientation screen_orientation);8182int _get_app_category_value(int category_index);8384String _get_app_category_label(int category_index);8586Error _store_temp_file(const String &p_simplified_path, const Vector<uint8_t> &p_data, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed, Vector<uint8_t> &r_enc_data, EditorExportPlatform::SavedData &r_sd);8788// Utility method used to create a directory.89Error create_directory(const String &p_dir);9091// Writes p_data into a file at p_path, creating directories if necessary.92// Note: this will overwrite the file at p_path if it already exists.93Error store_file_at_path(const String &p_path, const Vector<uint8_t> &p_data);9495// Writes string p_data into a file at p_path, creating directories if necessary.96// Note: this will overwrite the file at p_path if it already exists.97Error store_string_at_path(const String &p_path, const String &p_data);9899// Implementation of EditorExportSaveFunction.100// This method will only be called as an input to export_project_files.101// It is used by the export_project_files method to save all the asset files into the gradle project.102// It's functionality mirrors that of the method save_apk_file.103// This method will be called ONLY when gradle build is enabled.104Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed);105106// Creates strings.xml files inside the gradle project for different locales.107Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &p_project_name, const String &p_gradle_build_dir, const Dictionary &p_appnames);108109String bool_to_string(bool v);110111String _get_gles_tag();112113String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset);114115String _get_activity_tag(const Ref<EditorExportPlatform> &p_export_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug);116117String _get_application_tag(const Ref<EditorExportPlatform> &p_export_platform, const Ref<EditorExportPreset> &p_preset, bool p_has_read_write_storage_permission, bool p_debug, const Vector<MetadataInfo> &p_metadata);118119120