Merge pull request #17646 from volzhs/android-device-info-2.1

Fix getting Android device information (2.1)
This commit is contained in:
Rémi Verschelde 2018-03-20 11:28:46 +01:00 committed by GitHub
commit 940bab2734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -1505,8 +1505,7 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
args.push_back("-s"); args.push_back("-s");
args.push_back(d.id); args.push_back(d.id);
args.push_back("shell"); args.push_back("shell");
args.push_back("cat"); args.push_back("getprop");
args.push_back("/system/build.prop");
int ec; int ec;
String dp; String dp;
@ -1519,7 +1518,14 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
d.api_level = 0; d.api_level = 0;
for (int j = 0; j < props.size(); j++) { for (int j = 0; j < props.size(); j++) {
// got information by `shell cat /system/build.prop` before and its format is "property=value"
// it's now changed to use `shell getporp` because of permission issue with Android 8.0 and above
// its format is "[property]: [value]" so changed it as like build.prop
String p = props[j]; String p = props[j];
p = p.replace("]: ", "=");
p = p.replace("[", "");
p = p.replace("]", "");
if (p.begins_with("ro.product.model=")) { if (p.begins_with("ro.product.model=")) {
device = p.get_slice("=", 1).strip_edges(); device = p.get_slice("=", 1).strip_edges();
} else if (p.begins_with("ro.product.brand=")) { } else if (p.begins_with("ro.product.brand=")) {