Bug 753521 - Use libhardware_legacy to turn off screen, r=jlebar
authorMichael Wu <mwu@mozilla.com>
Wed, 09 May 2012 14:30:22 -0700
changeset 98149 10201e9cf42d953ae87f3b955b67412bf2dfa167
parent 98148 c41ba3a62a6d63395854892ebe379f6091ebfeaf
child 98150 60620b1440d263911e1eef321b0707e61c5ece4c
push id173
push userlsblakk@mozilla.com
push dateFri, 24 Aug 2012 15:39:16 +0000
treeherdermozilla-release@bcc45eb1fb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs753521
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 753521 - Use libhardware_legacy to turn off screen, r=jlebar
hal/gonk/GonkHal.cpp
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -12,16 +12,17 @@
 #include <time.h>
 
 #include "android/log.h"
 #include "cutils/properties.h"
 #include "hardware/hardware.h"
 #include "hardware/lights.h"
 #include "hardware_legacy/uevent.h"
 #include "hardware_legacy/vibrator.h"
+#include "hardware_legacy/power.h"
 
 #include "base/message_loop.h"
 
 #include "Hal.h"
 #include "HalImpl.h"
 #include "mozilla/dom/battery/Constants.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Monitor.h"
@@ -326,17 +327,16 @@ GetCurrentBatteryInformation(hal::Batter
   aBatteryInfo->remainingTime() = dom::battery::kUnknownRemainingTime;
 }
 
 namespace {
 
 /**
  * RAII class to help us remember to close file descriptors.
  */
-const char *screenEnabledFilename = "/sys/power/state";
 const char *wakeLockFilename = "/sys/power/wake_lock";
 const char *wakeUnlockFilename = "/sys/power/wake_unlock";
 
 template<ssize_t n>
 bool ReadFromFile(const char *filename, char (&buf)[n])
 {
   int fd = open(filename, O_RDONLY);
   ScopedClose autoClose(fd);
@@ -387,17 +387,17 @@ bool
 GetScreenEnabled()
 {
   return sScreenEnabled;
 }
 
 void
 SetScreenEnabled(bool enabled)
 {
-  WriteToFile(screenEnabledFilename, enabled ? "on" : "mem");
+  set_screen_state(enabled);
   sScreenEnabled = enabled;
 }
 
 double
 GetScreenBrightness()
 {
   hal::LightConfiguration aConfig;
   hal::LightType light = hal::eHalLightID_Backlight;