Skip to content

Commit

Permalink
Merge pull request #9922 from RandomShaper/fix-android-debug-2.1
Browse files Browse the repository at this point in the history
Fix Android debug/run (2.1)
  • Loading branch information
akien-mga authored Jul 28, 2017
2 parents 93e06fa + aea12b5 commit 0838a1c
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String id;
String name;
String description;
int release;
};

Vector<Device> devices;
Expand Down Expand Up @@ -1494,6 +1495,7 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
if (ea->devices[j].id == ldevices[i]) {
d.description = ea->devices[j].description;
d.name = ea->devices[j].name;
d.release = ea->devices[j].release;
}
}

Expand All @@ -1514,6 +1516,7 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
String vendor;
String device;
d.description + "Device ID: " + d.id + "\n";
d.release = 0;
for (int j = 0; j < props.size(); j++) {

String p = props[j];
Expand All @@ -1524,7 +1527,9 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
} else if (p.begins_with("ro.build.display.id=")) {
d.description += "Build: " + p.get_slice("=", 1).strip_edges() + "\n";
} else if (p.begins_with("ro.build.version.release=")) {
d.description += "Release: " + p.get_slice("=", 1).strip_edges() + "\n";
const String release_str = p.get_slice("=", 1).strip_edges();
d.description += "Release: " + release_str + "\n";
d.release = release_str.to_int();
} else if (p.begins_with("ro.product.cpu.abi=")) {
d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n";
} else if (p.begins_with("ro.product.manufacturer=")) {
Expand Down Expand Up @@ -1647,22 +1652,28 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
if (use_adb_over_usb) {

args.clear();
args.push_back("-s");
args.push_back(devices[p_device].id);
args.push_back("reverse");
args.push_back("--remove-all");
err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);

int port = Globals::get_singleton()->get("network/debug_port");
int dbg_port = (int)EditorSettings::get_singleton()->get("network/debug_port");
args.clear();
args.push_back("-s");
args.push_back(devices[p_device].id);
args.push_back("reverse");
args.push_back("tcp:" + itos(port));
args.push_back("tcp:" + itos(port));
args.push_back("tcp:" + itos(dbg_port));
args.push_back("tcp:" + itos(dbg_port));

err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
print_line("Reverse result: " + itos(rv));

int fs_port = EditorSettings::get_singleton()->get("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));
Expand All @@ -1678,15 +1689,18 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
args.push_back("shell");
args.push_back("am");
args.push_back("start");
args.push_back("--user 0");
if (bool(EDITOR_DEF("android/force_system_user", false)) && devices[p_device].release >= 17) { // Multi-user introduced in Android 17
args.push_back("--user");
args.push_back("0");
}
args.push_back("-a");
args.push_back("android.intent.action.MAIN");
args.push_back("-n");
args.push_back(get_package_name() + "/org.godotengine.godot.Godot");

err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
if (err || rv != 0) {
EditorNode::add_io_error("Could not execute ondevice.");
EditorNode::add_io_error("Could not execute on device.");
device_lock->unlock();
return ERR_CANT_CREATE;
}
Expand Down Expand Up @@ -1831,6 +1845,7 @@ void register_android_exporter() {
//EDITOR_DEF("android/release_keystore","");
//EDITOR_DEF("android/release_username","");
//EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/release_keystore",PROPERTY_HINT_GLOBAL_FILE,"*.keystore"));
EDITOR_DEF("android/force_system_user", false);
EDITOR_DEF("android/timestamping_authority_url", "");
EDITOR_DEF("android/use_remote_debug_over_adb", false);
EDITOR_DEF("android/shutdown_adb_on_exit", true);
Expand Down

0 comments on commit 0838a1c

Please sign in to comment.