diff options
author | Dees_Troy <dees_troy@teamw.in> | 2013-03-01 02:37:36 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@5.9.244.119> | 2013-03-01 02:37:36 +0100 |
commit | 07712b22265ec199487eeaa5c34be70266ae039c (patch) | |
tree | 5b3efe9d075c2d267370d5b2259ad7d0e4677c96 | |
parent | Fix file selector crash (diff) | |
parent | Add 2 second pre-dim and bugfix blank timer (diff) | |
download | android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.tar android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.tar.gz android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.tar.bz2 android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.tar.lz android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.tar.xz android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.tar.zst android_bootable_recovery-07712b22265ec199487eeaa5c34be70266ae039c.zip |
Diffstat (limited to '')
-rw-r--r-- | gui/blanktimer.cpp | 54 | ||||
-rw-r--r-- | gui/blanktimer.hpp | 6 | ||||
-rw-r--r-- | minuitwrp/graphics.c | 3 | ||||
-rw-r--r-- | minuitwrp/minui.h | 2 |
4 files changed, 36 insertions, 29 deletions
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp index cf35f6544..d7a6ffffc 100644 --- a/gui/blanktimer.cpp +++ b/gui/blanktimer.cpp @@ -46,7 +46,8 @@ extern "C" { #include "../variables.h" blanktimer::blanktimer(void) { - blanked = 0; + setTime(0); + setConBlank(0); orig_brightness = getBrightness(); } @@ -62,14 +63,10 @@ int blanktimer::setTimerThread(void) { return 0; } -void blanktimer::setBlank(int blank) { - pthread_mutex_lock(&blankmutex); +void blanktimer::setConBlank(int blank) { + pthread_mutex_lock(&conblankmutex); conblank = blank; - pthread_mutex_unlock(&blankmutex); -} - -int blanktimer::getBlank(void) { - return conblank; + pthread_mutex_unlock(&conblankmutex); } void blanktimer::setTimer(void) { @@ -84,22 +81,25 @@ timespec blanktimer::getTimer(void) { int blanktimer::setClockTimer(void) { timespec curTime, diff; - while(1) { - usleep(1000); + for(;;) { + usleep(1000000); clock_gettime(CLOCK_MONOTONIC, &curTime); diff = TWFunc::timespec_diff(btimer, curTime); - if (sleepTimer && diff.tv_sec > sleepTimer && conblank != 1) { + if (sleepTimer > 2 && diff.tv_sec > (sleepTimer - 2) && conblank == 0) { orig_brightness = getBrightness(); - setBlank(1); - PageManager::ChangeOverlay("lock"); + setConBlank(1); + setBrightness(5); } - if (conblank == 1 && blanked != 1) { - blanked = 1; - gr_fb_blank(conblank); + if (sleepTimer && diff.tv_sec > sleepTimer && conblank < 2) { + setConBlank(2); setBrightness(0); + PageManager::ChangeOverlay("lock"); + } + if (conblank == 2 && gr_fb_blank(1) >= 0) { + setConBlank(3); } } - return -1; + return -1; //shouldn't get here } int blanktimer::getBrightness(void) { @@ -124,11 +124,19 @@ int blanktimer::setBrightness(int brightness) { void blanktimer::resetTimerAndUnblank(void) { setTimer(); - if (blanked) { - setBrightness(orig_brightness); - blanked = 0; - setBlank(0); - gr_fb_blank(conblank); - gui_forceRender(); + switch (conblank) { + case 3: + if (gr_fb_blank(0) < 0) { + LOGI("blanktimer::resetTimerAndUnblank failed to gr_fb_blank(0)\n"); + break; + } + // No break here, we want to keep going + case 2: + gui_forceRender(); + // No break here, we want to keep going + case 1: + setBrightness(orig_brightness); + setConBlank(0); + break; } } diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp index 4135635f8..2d83c4dae 100644 --- a/gui/blanktimer.hpp +++ b/gui/blanktimer.hpp @@ -32,8 +32,7 @@ class blanktimer { void setTime(int newtime); private: - void setBlank(int blank); - int getBlank(void); + void setConBlank(int blank); void setTimer(void); timespec getTimer(void); int getBrightness(void); @@ -42,13 +41,12 @@ class blanktimer { int setClockTimer(void); typedef int (blanktimer::*ThreadPtr)(void); typedef void* (*PThreadPtr)(void*); - pthread_mutex_t blankmutex; + pthread_mutex_t conblankmutex; pthread_mutex_t timermutex; int conblank; timespec btimer; unsigned long long sleepTimer; int orig_brightness; - int blanked; }; extern blanktimer blankTimer; diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c index dc79db881..61a98c3f7 100644 --- a/minuitwrp/graphics.c +++ b/minuitwrp/graphics.c @@ -685,13 +685,14 @@ gr_pixel *gr_fb_data(void) return (unsigned short *) gr_mem_surface.data; } -void gr_fb_blank(int blank) +int gr_fb_blank(int blank) { int ret; ret = ioctl(gr_fb_fd, FBIOBLANK, blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK); if (ret < 0) perror("ioctl(): blank"); + return ret; } int gr_get_surface(gr_surface* surface) diff --git a/minuitwrp/minui.h b/minuitwrp/minui.h index d66807cbb..03e15bb81 100644 --- a/minuitwrp/minui.h +++ b/minuitwrp/minui.h @@ -27,7 +27,7 @@ int gr_fb_width(void); int gr_fb_height(void); gr_pixel *gr_fb_data(void); void gr_flip(void); -void gr_fb_blank(int blank); +int gr_fb_blank(int blank); void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); void gr_fill(int x, int y, int w, int h); |