summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnamalai Lakshmanan <annamalai.lakshmanan@linaro.org>2012-03-22 20:26:25 +0530
committerBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-03-29 09:52:18 +0200
commitcbf3a1074b36ef3c0ad0eb66698a22710cc3649d (patch)
tree560b511b23dff0135cdd40d77479a1d3a8568727
parent19d62121275dc9f382ec0f741a4ba7e8017bba1d (diff)
downloadcore-cbf3a1074b36ef3c0ad0eb66698a22710cc3649d.tar.gz
origen: Added command to signal surfaceflinger
Added command to signal surfaceflinger for IPC Change-Id: I60847d6e36e7c29a8e09e96c8d166ae1d321f396 Signed-off-by: Annamalai Lakshmanan <annamalai.lakshmanan@linaro.org>
-rw-r--r--toolbox/Android.mk3
-rw-r--r--toolbox/refreshSurfaceFlinger.c42
2 files changed, 44 insertions, 1 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index d7a675a70..49725ce24 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -55,7 +55,8 @@ TOOLS := \
nandread \
ionice \
touch \
- lsof
+ lsof \
+ refreshSurfaceFlinger
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
TOOLS += r
diff --git a/toolbox/refreshSurfaceFlinger.c b/toolbox/refreshSurfaceFlinger.c
new file mode 100644
index 000000000..e6aef8102
--- /dev/null
+++ b/toolbox/refreshSurfaceFlinger.c
@@ -0,0 +1,42 @@
+/*
+ * Send a signal to surfaceflinger, causing it to reconfigure
+ * itself based on properties set elsewhere.
+ *
+ * This program is released under the Apache Software License 2.0.
+ *
+ * (C) 2012 Bernhard "Bero" Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <string.h>
+#include <dirent.h>
+#include <assert.h>
+
+int refreshSurfaceFlinger_main(int argc, char **argv) {
+ struct dirent *de;
+ DIR *d=opendir("/proc");
+ assert(d);
+ while(de=readdir(d)) {
+ pid_t p=atoi(de->d_name);
+ if(!p) // Not /proc/<PID>
+ continue;
+ char fn[strlen(de->d_name)+11];
+ char executable[NAME_MAX];
+ struct stat st;
+ fn[sizeof(fn)-1]=0;
+ strcpy(fn, "/proc/");
+ strcat(fn, de->d_name);
+ strcat(fn, "/exe");
+ ssize_t s=readlink(fn, executable, sizeof(executable));
+ if(s<0) // Not what we're looking for [probably an in-kernel process]
+ continue;
+ executable[s]=0;
+ if(!strcmp(executable, "/system/bin/surfaceflinger")) {
+ kill(p, SIGUSR1);
+ break;
+ }
+ }
+ closedir(d);
+ return 0;
+}