summaryrefslogtreecommitdiffstats
path: root/gui/action.cpp
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2014-03-13 18:46:34 +0100
committerGerrit Code Review <gerrit2@gerrit>2014-07-09 17:35:36 +0200
commit03fd6c56fe57dcd7cc4a7f7166a00ece42491558 (patch)
tree7b273e894f5ed7d2ed97c78813d48088c7884d1a /gui/action.cpp
parentCheck the crash counter instead of date in TWFunc::Fixup_Time_On_Boot() (diff)
downloadandroid_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.gz
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.bz2
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.lz
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.xz
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.zst
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.zip
Diffstat (limited to 'gui/action.cpp')
-rw-r--r--gui/action.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index 3c5584d4a..b77e7e751 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <dirent.h>
+#include <pwd.h>
#include <string>
#include <sstream>
@@ -775,6 +776,54 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
return 0;
}
+ if (function == "screenshot")
+ {
+ time_t tm;
+ char path[256];
+ int path_len;
+ uid_t uid = -1;
+ gid_t gid = -1;
+
+ struct passwd *pwd = getpwnam("media_rw");
+ if(pwd) {
+ uid = pwd->pw_uid;
+ gid = pwd->pw_gid;
+ }
+
+ const std::string storage = DataManager::GetCurrentStoragePath();
+ if(PartitionManager.Is_Mounted_By_Path(storage)) {
+ snprintf(path, sizeof(path), "%s/Pictures/Screenshots/", storage.c_str());
+ } else {
+ strcpy(path, "/tmp/");
+ }
+
+ if(!TWFunc::Create_Dir_Recursive(path, 0666, uid, gid))
+ return 0;
+
+ tm = time(NULL);
+ path_len = strlen(path);
+
+ // Screenshot_2014-01-01-18-21-38.png
+ strftime(path+path_len, sizeof(path)-path_len, "Screenshot_%Y-%m-%d-%H-%M-%S.png", localtime(&tm));
+
+ int res = gr_save_screenshot(path);
+ if(res == 0) {
+ chmod(path, 0666);
+ chown(path, uid, gid);
+
+ gui_print("Screenshot was saved to %s\n", path);
+
+ // blink to notify that the screenshow was taken
+ gr_color(255, 255, 255, 255);
+ gr_fill(0, 0, gr_fb_width(), gr_fb_height());
+ gr_flip();
+ gui_forceRender();
+ } else {
+ LOGERR("Failed to take a screenshot!\n");
+ }
+ return 0;
+ }
+
if (isThreaded)
{
if (function == "fileexists")