fix a crasher when starting SF with the screen off
SF could end-up in an infinite crash-loop during startup if it
was stopped while the screen was off. This happened because
the thread that manages screen blanking was started before
other important pieces of SF were initialized.
Change-Id: I0dded11dbf2395fdd57b673859a7aa0fa9eb32b6
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
index 09f1906..69f1aca 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp
@@ -43,14 +43,6 @@
DisplayHardwareBase::DisplayEventThread::~DisplayEventThread() {
}
-void DisplayHardwareBase::DisplayEventThread::onFirstRef() {
- if (initCheck() == NO_ERROR) {
- run("DisplayEventThread", PRIORITY_URGENT_DISPLAY);
- } else {
- ALOGW("/sys/power/wait_for_fb_{wake|sleep} don't exist");
- }
-}
-
status_t DisplayHardwareBase::DisplayEventThread::initCheck() const {
return ((access(kSleepFileName, R_OK) == 0 &&
access(kWakeFileName, R_OK) == 0)) ? NO_ERROR : NO_INIT;
@@ -120,6 +112,14 @@
mDisplayEventThread = new DisplayEventThread(flinger);
}
+void DisplayHardwareBase::startSleepManagement() const {
+ if (mDisplayEventThread->initCheck() == NO_ERROR) {
+ mDisplayEventThread->run("DisplayEventThread", PRIORITY_URGENT_DISPLAY);
+ } else {
+ ALOGW("/sys/power/wait_for_fb_{wake|sleep} don't exist");
+ }
+}
+
DisplayHardwareBase::~DisplayHardwareBase() {
// request exit
mDisplayEventThread->requestExitAndWait();