|
| 1 | +/**************************************************************************/ |
| 2 | +/* android_sdk_manager.h */ |
| 3 | +/**************************************************************************/ |
| 4 | +/* This file is part of: */ |
| 5 | +/* GODOT ENGINE */ |
| 6 | +/* https://godotengine.org */ |
| 7 | +/**************************************************************************/ |
| 8 | +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | +/* */ |
| 11 | +/* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | +/* a copy of this software and associated documentation files (the */ |
| 13 | +/* "Software"), to deal in the Software without restriction, including */ |
| 14 | +/* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | +/* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | +/* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | +/* the following conditions: */ |
| 18 | +/* */ |
| 19 | +/* The above copyright notice and this permission notice shall be */ |
| 20 | +/* included in all copies or substantial portions of the Software. */ |
| 21 | +/* */ |
| 22 | +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | +/**************************************************************************/ |
| 30 | + |
| 31 | +#pragma once |
| 32 | + |
| 33 | +#include "scene/gui/dialogs.h" |
| 34 | +#include "scene/main/http_request.h" |
| 35 | + |
| 36 | +class Label; |
| 37 | +class ProgressBar; |
| 38 | +class RichTextLabel; |
| 39 | + |
| 40 | +class AndroidSdkManager : public AcceptDialog { |
| 41 | + GDCLASS(AndroidSdkManager, AcceptDialog) |
| 42 | + |
| 43 | + enum SetupStatus { |
| 44 | + IDLE, |
| 45 | + DOWNLOADING_ANDROID_SDK, |
| 46 | + DOWNLOADING_JAVA_SDK, |
| 47 | + INSTALLING_ANDROID_SDK, |
| 48 | + INSTALLING_JAVA_SDK, |
| 49 | + }; |
| 50 | + |
| 51 | + void _cancel_setup(); |
| 52 | + void _on_download_completed(int p_result, int p_code, const PackedStringArray &p_headers, const PackedByteArray &p_body); |
| 53 | + |
| 54 | + void _setup_android_sdk(); |
| 55 | + void _download_android_cli(); |
| 56 | + void _android_cli_downloaded(const PackedByteArray &p_body); |
| 57 | + void _install_android_sdk_packages(); |
| 58 | + void _android_sdk_installed(int p_exit_code); |
| 59 | + |
| 60 | + void _setup_java_sdk(); |
| 61 | + void _download_java_sdk(); |
| 62 | + void _java_sdk_downloaded(const PackedByteArray &p_body); |
| 63 | + Error _extract_java_sdk(const String &p_file, const String &p_target_path); |
| 64 | + |
| 65 | + void _show_setup_dialog(SetupStatus p_status); |
| 66 | + void _hide_setup_dialog(SetupStatus p_status); |
| 67 | + |
| 68 | + static String get_android_cli_path(); |
| 69 | + static bool is_java_sdk_setup(String *r_error = nullptr); |
| 70 | + |
| 71 | + Callable on_setup_completed; |
| 72 | + Dictionary setup_process_data; |
| 73 | + Label *setup_label = nullptr; |
| 74 | + RichTextLabel *execute_outputs = nullptr; |
| 75 | + ProgressBar *setup_progress_bar = nullptr; |
| 76 | + HTTPRequest *downloader = nullptr; |
| 77 | + SetupStatus current_setup_status = IDLE; |
| 78 | + |
| 79 | +protected: |
| 80 | + void _notification(int p_what); |
| 81 | + static void _bind_methods(); |
| 82 | + |
| 83 | +public: |
| 84 | + constexpr static const int DEFAULT_MIN_SDK_VERSION = 24; // Should match the value in 'platform/android/java/app/config.gradle#minSdk' |
| 85 | + constexpr static const int VULKAN_MIN_SDK_VERSION = 29; // Minimum recommended sdk version for Vulkan 1.1 support. See https://developer.android.com/games/develop/vulkan/native-engine-support#recommendations |
| 86 | + constexpr static const int DEFAULT_TARGET_SDK_VERSION = 36; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk' |
| 87 | + |
| 88 | + void run_setup(); |
| 89 | + |
| 90 | + /// Returns true if the Android SDK (and its dependencies) are set up. |
| 91 | + static bool is_android_sdk_setup(String *r_error = nullptr); |
| 92 | + |
| 93 | + static String get_java_path(); |
| 94 | + static String get_adb_path(); |
| 95 | + static String get_apksigner_path(int p_target_sdk = -1, bool p_check_executes = false); |
| 96 | + |
| 97 | + AndroidSdkManager(); |
| 98 | + ~AndroidSdkManager(); |
| 99 | +}; |
0 commit comments