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.
This commit is contained in:
parent
a464659d5b
commit
d5447a90cc
1 changed files with 46 additions and 28 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue