summaryrefslogtreecommitdiffstats
path: root/platform/android/export
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-02-17 15:54:49 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-02-17 15:54:49 +0100
commite697774f61b05f0675a6a2a542ac9395096dc363 (patch)
treeed17cef1571e899d868c6d36a98ff3fbfda1b5c6 /platform/android/export
parent2c5fa95aea28327ea7ce4bf17d863b85fc0c0729 (diff)
parent343bfb112f5a8cda4fdd86b0074bb2f54fd31e4b (diff)
downloadredot-engine-e697774f61b05f0675a6a2a542ac9395096dc363.tar.gz
Merge pull request #87823 from KoBeWi/ban_adb
Don't invoke adb with no runnable Android preset
Diffstat (limited to 'platform/android/export')
-rw-r--r--platform/android/export/export_plugin.cpp31
-rw-r--r--platform/android/export/export_plugin.h6
2 files changed, 35 insertions, 2 deletions
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 52cb366d9f..d0db7b2e6c 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -294,7 +294,7 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
// Check for devices updates
String adb = get_adb_path();
- if (FileAccess::exists(adb)) {
+ if (ea->has_runnable_preset.is_set() && FileAccess::exists(adb)) {
String devices;
List<String> args;
args.push_back("devices");
@@ -426,6 +426,25 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
OS::get_singleton()->execute(adb, args);
}
}
+
+void EditorExportPlatformAndroid::_update_preset_status() {
+ const int preset_count = EditorExport::get_singleton()->get_export_preset_count();
+ bool has_runnable = false;
+
+ for (int i = 0; i < preset_count; i++) {
+ const Ref<EditorExportPreset> &preset = EditorExport::get_singleton()->get_export_preset(i);
+ if (preset->get_platform() == this && preset->is_runnable()) {
+ has_runnable = true;
+ break;
+ }
+ }
+
+ if (has_runnable) {
+ has_runnable_preset.set();
+ } else {
+ has_runnable_preset.clear();
+ }
+}
#endif
String EditorExportPlatformAndroid::get_project_name(const String &p_name) const {
@@ -808,6 +827,15 @@ bool EditorExportPlatformAndroid::_uses_vulkan() {
return uses_vulkan;
}
+void EditorExportPlatformAndroid::_notification(int p_what) {
+#ifndef ANDROID_ENABLED
+ if (p_what == NOTIFICATION_POSTINITIALIZE) {
+ ERR_FAIL_NULL(EditorExport::get_singleton());
+ EditorExport::get_singleton()->connect_presets_runnable_updated(callable_mp(this, &EditorExportPlatformAndroid::_update_preset_status));
+ }
+#endif
+}
+
void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, Vector<String> &r_permissions) {
const char **aperms = android_perms;
while (*aperms) {
@@ -3574,6 +3602,7 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
android_plugins_changed.set();
#endif // DISABLE_DEPRECATED
#ifndef ANDROID_ENABLED
+ _update_preset_status();
check_for_changes_thread.start(_check_for_changes_poll_thread, this);
#endif
}
diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h
index abc462a691..e25655c6cc 100644
--- a/platform/android/export/export_plugin.h
+++ b/platform/android/export/export_plugin.h
@@ -98,8 +98,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
#ifndef ANDROID_ENABLED
Thread check_for_changes_thread;
SafeFlag quit_request;
+ SafeFlag has_runnable_preset;
static void _check_for_changes_poll_thread(void *ud);
+ void _update_preset_status();
#endif
String get_project_name(const String &p_name) const;
@@ -187,10 +189,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
static bool _uses_vulkan();
+protected:
+ void _notification(int p_what);
+
public:
typedef Error (*EditorExportSaveFunction)(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);
-public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override;
virtual void get_export_options(List<ExportOption> *r_options) const override;