summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-07-28 11:15:40 +0200
committerGitHub <noreply@github.com>2017-07-28 11:15:40 +0200
commitd9b4969c18b3f5994621bbb06e496dd19c40e300 (patch)
tree9f2b76a35025391ffcbed36ba9e6705ddfcbe3a3
parent3ea3c2d4cbc96a1cc6e969a864bf7a98931c8e73 (diff)
parentc8d1457898b649432a35a0337052f137452ce6b1 (diff)
Merge pull request #9921 from RandomShaper/fix-android-debug
Fix Android debug/run
-rw-r--r--platform/android/export/export.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 97f239c4da..a722cd1b8c 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -2050,6 +2050,7 @@ class EditorExportAndroid : public EditorExportPlatform {
String id;
String name;
String description;
+ int release;
};
struct APKExportData {
@@ -2123,6 +2124,7 @@ class EditorExportAndroid : public EditorExportPlatform {
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;
}
}
@@ -2143,6 +2145,7 @@ class EditorExportAndroid : public EditorExportPlatform {
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];
@@ -2153,7 +2156,9 @@ class EditorExportAndroid : public EditorExportPlatform {
} 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=")) {
@@ -3005,15 +3010,19 @@ public:
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 = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
+ 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(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));
@@ -3021,6 +3030,8 @@ public:
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));
@@ -3036,7 +3047,10 @@ public:
args.push_back("shell");
args.push_back("am");
args.push_back("start");
- args.push_back("--user 0");
+ if ((bool)EditorSettings::get_singleton()->get("export/android/force_system_user") && 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");
@@ -3044,7 +3058,7 @@ public:
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;
}
@@ -3586,6 +3600,7 @@ void register_android_exporter() {
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "keystore"));
EDITOR_DEF("export/android/debug_keystore_user", "androiddebugkey");
EDITOR_DEF("export/android/debug_keystore_pass", "android");
+ EDITOR_DEF("export/android/force_system_user", false);
EDITOR_DEF("export/android/timestamping_authority_url", "");
EDITOR_DEF("export/android/use_remote_debug_over_adb", false);