Fix Android debug/run
Same as _master_'s 0ae3336a329b1fd14b66bb26707c2461b66e5aa8; namely: - Prefix all __adb__ commands with device specification to avoid errors when multiple devices connected. - Include Android release in device data collection. - Force system user:. - Ability to enable/disable. - Apply only if OS release >= 17 (when multiuser was introduced. - Fix argument passing. - Rename local variable `port` to `dbg_port` to better match its partner `fs_port`. - Fix typo in error message. But adds: - Get the debug port from the editor settings, where it lives now. Fixes #8581.
This commit is contained in:
parent
bfa2024313
commit
aea12b56bc
@ -237,6 +237,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
|
||||
String id;
|
||||
String name;
|
||||
String description;
|
||||
int release;
|
||||
};
|
||||
|
||||
Vector<Device> devices;
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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];
|
||||
@ -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=")) {
|
||||
@ -1647,15 +1652,19 @@ 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));
|
||||
@ -1663,6 +1672,8 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
|
||||
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));
|
||||
@ -1678,7 +1689,10 @@ 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");
|
||||
@ -1686,7 +1700,7 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
|
||||
|
||||
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;
|
||||
}
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user