Skip to content

Commit 587ae01

Browse files
committed
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
1 parent cf7f0c7 commit 587ae01

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

services/surfaceflinger/DisplayHardware/DisplayHardwareBase.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ DisplayHardwareBase::DisplayEventThread::DisplayEventThread(
4343
DisplayHardwareBase::DisplayEventThread::~DisplayEventThread() {
4444
}
4545

46-
void DisplayHardwareBase::DisplayEventThread::onFirstRef() {
47-
if (initCheck() == NO_ERROR) {
48-
run("DisplayEventThread", PRIORITY_URGENT_DISPLAY);
49-
} else {
50-
ALOGW("/sys/power/wait_for_fb_{wake|sleep} don't exist");
51-
}
52-
}
53-
5446
status_t DisplayHardwareBase::DisplayEventThread::initCheck() const {
5547
return ((access(kSleepFileName, R_OK) == 0 &&
5648
access(kWakeFileName, R_OK) == 0)) ? NO_ERROR : NO_INIT;
@@ -120,6 +112,14 @@ DisplayHardwareBase::DisplayHardwareBase(const sp<SurfaceFlinger>& flinger,
120112
mDisplayEventThread = new DisplayEventThread(flinger);
121113
}
122114

115+
void DisplayHardwareBase::startSleepManagement() const {
116+
if (mDisplayEventThread->initCheck() == NO_ERROR) {
117+
mDisplayEventThread->run("DisplayEventThread", PRIORITY_URGENT_DISPLAY);
118+
} else {
119+
ALOGW("/sys/power/wait_for_fb_{wake|sleep} don't exist");
120+
}
121+
}
122+
123123
DisplayHardwareBase::~DisplayHardwareBase() {
124124
// request exit
125125
mDisplayEventThread->requestExitAndWait();

services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class DisplayHardwareBase
3535

3636
~DisplayHardwareBase();
3737

38+
void startSleepManagement() const;
39+
3840
// console management
3941
void releaseScreen() const;
4042
void acquireScreen() const;
@@ -52,7 +54,6 @@ class DisplayHardwareBase
5254
public:
5355
DisplayEventThread(const sp<SurfaceFlinger>& flinger);
5456
virtual ~DisplayEventThread();
55-
virtual void onFirstRef();
5657
virtual bool threadLoop();
5758
status_t releaseScreen() const;
5859
status_t initCheck() const;

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ status_t SurfaceFlinger::readyToRun()
300300
// start the EventThread
301301
mEventThread = new EventThread(this);
302302
mEventQueue.setEventThread(mEventThread);
303+
hw.startSleepManagement();
303304

304305
/*
305306
* We're now ready to accept clients...

0 commit comments

Comments
 (0)