Don't invoke adb with no runnable Android preset

This commit is contained in:
kobewi 2024-02-01 16:02:39 +01:00
parent 9adb7c7d13
commit 343bfb112f
7 changed files with 88 additions and 7 deletions

View file

@ -291,7 +291,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");
@ -423,6 +423,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 {
@ -805,6 +824,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) {
@ -3530,6 +3558,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
}