summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2017-08-30 20:25:09 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2017-08-30 20:39:01 +0200
commitd5447a90cc203a0e42d5d091e5675ac38ff3bd1f (patch)
tree878b4fd211fa2156fd3b8d7bf8cd54d72986a232
parenta464659d5beebd3f0356d4a30f0885b222a70be3 (diff)
Fix pre-Lollipop (21) Android debug
Namely, automatically pick debug over Wi-Fi for devices with an older release and debug over USB otherwise. A message is printed both in editor output window and console (uppercase here) to let the user know about what mechanism is being used and why.
-rw-r--r--platform/android/export/export.cpp74
1 files changed, 46 insertions, 28 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 16169c88c2..ef348d8685 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1073,7 +1073,11 @@ public:
//export_temp
ep.step("Exporting APK", 0);
- p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST;
+ const bool use_remote = (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) || (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT);
+ const bool use_reverse = devices[p_device].api_level >= 21;
+
+ if (use_reverse)
+ p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST;
String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk";
Error err = export_project(p_preset, true, export_to, p_debug_flags);
@@ -1119,40 +1123,54 @@ public:
return ERR_CANT_CREATE;
}
- if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) {
+ if (use_remote) {
+ if (use_reverse) {
- args.clear();
- args.push_back("-s");
- args.push_back(devices[p_device].id);
- args.push_back("reverse");
- args.push_back("--remove-all");
- OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ static const char *const msg = "** Device API >= 21; debugging over USB **";
+ EditorNode::get_singleton()->get_log()->add_message(msg);
+ print_line(String(msg).to_upper());
- int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
- args.clear();
- args.push_back("-s");
- args.push_back(devices[p_device].id);
- args.push_back("reverse");
- args.push_back("tcp:" + itos(dbg_port));
- args.push_back("tcp:" + itos(dbg_port));
+ args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
+ args.push_back("reverse");
+ args.push_back("--remove-all");
+ OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
- OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
- print_line("Reverse result: " + itos(rv));
- }
+ if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) {
- if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) {
+ int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
+ args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
+ args.push_back("reverse");
+ args.push_back("tcp:" + itos(dbg_port));
+ args.push_back("tcp:" + itos(dbg_port));
- int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
+ OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ print_line("Reverse result: " + itos(rv));
+ }
- args.clear();
- args.push_back("-s");
- args.push_back(devices[p_device].id);
- args.push_back("reverse");
- args.push_back("tcp:" + itos(fs_port));
- args.push_back("tcp:" + itos(fs_port));
+ if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) {
- err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
- print_line("Reverse result2: " + itos(rv));
+ int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
+
+ args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
+ args.push_back("reverse");
+ args.push_back("tcp:" + itos(fs_port));
+ args.push_back("tcp:" + itos(fs_port));
+
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ print_line("Reverse result2: " + itos(rv));
+ }
+ } else {
+
+ static const char *const msg = "** Device API < 21; debugging over Wi-Fi **";
+ EditorNode::get_singleton()->get_log()->add_message(msg);
+ print_line(String(msg).to_upper());
+ }
}
ep.step("Running on Device..", 3);