summaryrefslogtreecommitdiffstats
path: root/gui
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
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 '')
-rw-r--r--gui/action.cpp49
-rw-r--r--[-rwxr-xr-x]gui/devices/1024x600/res/ui.xml10
-rw-r--r--gui/devices/1024x768/res/ui.xml10
-rw-r--r--gui/devices/1080x1920/res/ui.xml5
-rw-r--r--gui/devices/1200x1920/res/ui.xml5
-rw-r--r--gui/devices/1280x800/res/ui.xml10
-rw-r--r--gui/devices/1920x1200/res/ui.xml10
-rw-r--r--gui/devices/240x240/res/ui.xml5
-rw-r--r--gui/devices/2560x1600/res/ui.xml10
-rw-r--r--gui/devices/320x480/res/ui.xml5
-rw-r--r--gui/devices/480x800/res/ui.xml5
-rw-r--r--gui/devices/480x854/res/ui.xml5
-rw-r--r--gui/devices/540x960/res/ui.xml5
-rw-r--r--gui/devices/720x1280/res/ui.xml5
-rw-r--r--[-rwxr-xr-x]gui/devices/800x1280/res/ui.xml5
-rw-r--r--[-rwxr-xr-x]gui/devices/800x480/res/ui.xml10
16 files changed, 154 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")
diff --git a/gui/devices/1024x600/res/ui.xml b/gui/devices/1024x600/res/ui.xml
index 4795ce0ed..5c9c63b68 100755..100644
--- a/gui/devices/1024x600/res/ui.xml
+++ b/gui/devices/1024x600/res/ui.xml
@@ -277,6 +277,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
@@ -4159,6 +4164,11 @@
<action function="overlay">lock</action>
</object>
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
+
<object type="template" name="keyboardtemplate" />
<object type="action">
diff --git a/gui/devices/1024x768/res/ui.xml b/gui/devices/1024x768/res/ui.xml
index d041c50e0..f3e0a8e14 100644
--- a/gui/devices/1024x768/res/ui.xml
+++ b/gui/devices/1024x768/res/ui.xml
@@ -277,6 +277,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
@@ -4159,6 +4164,11 @@
<action function="overlay">lock</action>
</object>
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
+
<object type="template" name="keyboardtemplate" />
<object type="action">
diff --git a/gui/devices/1080x1920/res/ui.xml b/gui/devices/1080x1920/res/ui.xml
index f95ae090f..5801f20c8 100644
--- a/gui/devices/1080x1920/res/ui.xml
+++ b/gui/devices/1080x1920/res/ui.xml
@@ -266,6 +266,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/1200x1920/res/ui.xml b/gui/devices/1200x1920/res/ui.xml
index 0630e10e1..d0c8b4ed8 100644
--- a/gui/devices/1200x1920/res/ui.xml
+++ b/gui/devices/1200x1920/res/ui.xml
@@ -269,6 +269,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/1280x800/res/ui.xml b/gui/devices/1280x800/res/ui.xml
index fdd205941..b76060ad0 100644
--- a/gui/devices/1280x800/res/ui.xml
+++ b/gui/devices/1280x800/res/ui.xml
@@ -277,6 +277,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
@@ -4159,6 +4164,11 @@
<action function="overlay">lock</action>
</object>
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
+
<object type="template" name="keyboardtemplate" />
<object type="action">
diff --git a/gui/devices/1920x1200/res/ui.xml b/gui/devices/1920x1200/res/ui.xml
index 2622a8878..0841c96ef 100644
--- a/gui/devices/1920x1200/res/ui.xml
+++ b/gui/devices/1920x1200/res/ui.xml
@@ -277,6 +277,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
@@ -4159,6 +4164,11 @@
<action function="overlay">lock</action>
</object>
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
+
<object type="template" name="keyboardtemplate" />
<object type="action">
diff --git a/gui/devices/240x240/res/ui.xml b/gui/devices/240x240/res/ui.xml
index ac98dbad8..da73a99c2 100644
--- a/gui/devices/240x240/res/ui.xml
+++ b/gui/devices/240x240/res/ui.xml
@@ -253,6 +253,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/2560x1600/res/ui.xml b/gui/devices/2560x1600/res/ui.xml
index 06880b22e..28a9b81b3 100644
--- a/gui/devices/2560x1600/res/ui.xml
+++ b/gui/devices/2560x1600/res/ui.xml
@@ -277,6 +277,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
@@ -4159,6 +4164,11 @@
<action function="overlay">lock</action>
</object>
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
+
<object type="template" name="keyboardtemplate" />
<object type="action">
diff --git a/gui/devices/320x480/res/ui.xml b/gui/devices/320x480/res/ui.xml
index fff85334e..82273cee8 100644
--- a/gui/devices/320x480/res/ui.xml
+++ b/gui/devices/320x480/res/ui.xml
@@ -259,6 +259,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/480x800/res/ui.xml b/gui/devices/480x800/res/ui.xml
index 6baa70293..53d630feb 100644
--- a/gui/devices/480x800/res/ui.xml
+++ b/gui/devices/480x800/res/ui.xml
@@ -259,6 +259,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml
index 4f5a7c98a..ce79ebf39 100644
--- a/gui/devices/480x854/res/ui.xml
+++ b/gui/devices/480x854/res/ui.xml
@@ -258,6 +258,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/540x960/res/ui.xml b/gui/devices/540x960/res/ui.xml
index 11c9490a4..5e2807fbd 100644
--- a/gui/devices/540x960/res/ui.xml
+++ b/gui/devices/540x960/res/ui.xml
@@ -259,6 +259,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/720x1280/res/ui.xml b/gui/devices/720x1280/res/ui.xml
index 157548564..4db6e22ae 100644
--- a/gui/devices/720x1280/res/ui.xml
+++ b/gui/devices/720x1280/res/ui.xml
@@ -266,6 +266,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/800x1280/res/ui.xml b/gui/devices/800x1280/res/ui.xml
index abd62de8e..718074e0f 100755..100644
--- a/gui/devices/800x1280/res/ui.xml
+++ b/gui/devices/800x1280/res/ui.xml
@@ -260,6 +260,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
diff --git a/gui/devices/800x480/res/ui.xml b/gui/devices/800x480/res/ui.xml
index 6a2c08fa9..9c56ca381 100755..100644
--- a/gui/devices/800x480/res/ui.xml
+++ b/gui/devices/800x480/res/ui.xml
@@ -279,6 +279,11 @@
<touch key="power" />
<action function="overlay">lock</action>
</object>
+
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
</template>
<template name="progress_bar">
@@ -4167,6 +4172,11 @@
<action function="overlay">lock</action>
</object>
+ <object type="action">
+ <touch key="power+voldown" />
+ <action function="screenshot" />
+ </object>
+
<object type="template" name="keyboardtemplate" />
<object type="action">