diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/export/export.cpp | 10 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 49 |
3 files changed, 58 insertions, 2 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 6b4d0ff8c4..6d9f0a7e9a 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -301,8 +301,7 @@ class EditorExportAndroid : public EditorExportPlatform { args.push_back("-s"); args.push_back(d.id); args.push_back("shell"); - args.push_back("cat"); - args.push_back("/system/build.prop"); + args.push_back("getprop"); int ec; String dp; @@ -315,7 +314,14 @@ class EditorExportAndroid : public EditorExportPlatform { d.api_level = 0; 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]; + p = p.replace("]: ", "="); + p = p.replace("[", ""); + p = p.replace("]", ""); + if (p.begins_with("ro.product.model=")) { device = p.get_slice("=", 1).strip_edges(); } else if (p.begins_with("ro.product.brand=")) { diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 486d7af1c1..29935f197e 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -195,6 +195,7 @@ public: virtual VideoMode get_video_mode(int p_screen = 0) const; virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const; + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool p_read_stderr); virtual String get_executable_path() const; virtual LatinKeyboardVariant get_latin_keyboard_variant() const; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index a811ff585d..d125ca5a67 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -2045,6 +2045,55 @@ bool OS_OSX::get_borderless_window() { return [window_object styleMask] == NSWindowStyleMaskBorderless; } +Error OS_OSX::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool p_read_stderr) { + + NSTask *task = [[NSTask alloc] init]; + NSPipe *stdout_pipe = nil; + [task setLaunchPath:[NSString stringWithUTF8String:p_path.utf8().get_data()]]; + + NSMutableArray *arguments = [[NSMutableArray alloc] initWithCapacity:p_arguments.size()]; + for (int i = 0; i < p_arguments.size(); i++) { + [arguments addObject:[NSString stringWithUTF8String:p_arguments[i].utf8().get_data()]]; + } + [task setArguments:arguments]; + + if (p_blocking && r_pipe) { + stdout_pipe = [NSPipe pipe]; + [task setStandardOutput:stdout_pipe]; + if (p_read_stderr) [task setStandardError:[task standardOutput]]; + } + + @try { + [task launch]; + if (r_child_id) + *r_child_id = [task processIdentifier]; + + if (p_blocking) { + if (r_pipe) { + NSFileHandle *read_handle = [stdout_pipe fileHandleForReading]; + NSData *data = nil; + while ((data = [read_handle availableData]) && [data length]) { + NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + (*r_pipe) += [string UTF8String]; + [string release]; + } + } else { + [task waitUntilExit]; + } + } + + [arguments release]; + [task release]; + return OK; + } @catch (NSException *exception) { + ERR_PRINTS("NSException: " + String([exception reason].UTF8String) + "; Path: " + p_path); + + [arguments release]; + [task release]; + return ERR_CANT_OPEN; + } +} + String OS_OSX::get_executable_path() const { int ret; |