From 1f339ff3875afad128a8e16ee6395c5fad295826 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 1 Jul 2011 17:08:43 -0700 Subject: [PATCH] don't kill surfaceflinger when system process dies Change-Id: I2d3ed87b590f9ccea3fa4af41d92911de070b315 --- .../DisplayHardware/DisplayHardware.cpp | 5 ++++ services/surfaceflinger/SurfaceFlinger.cpp | 25 +++++++++++++++++++ services/surfaceflinger/SurfaceFlinger.h | 5 ++++ 3 files changed, 35 insertions(+) diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp index a774841dd..33125c487 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -103,6 +103,11 @@ void DisplayHardware::init(uint32_t dpy) { mNativeWindow = new FramebufferNativeWindow(); framebuffer_device_t const * fbDev = mNativeWindow->getDevice(); + if (!fbDev) { + LOGE("Display subsystem failed to initialize. check logs. exiting..."); + exit(0); + } + mDpiX = mNativeWindow->xdpi; mDpiY = mNativeWindow->ydpi; mRefreshRate = fbDev->fps; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 685613efe..d69bff213 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -163,9 +163,34 @@ void SurfaceFlinger::bootFinished() const nsecs_t duration = now - mBootTime; LOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) ); mBootFinished = true; + + // wait patiently for the window manager death + const String16 name("window"); + sp window(defaultServiceManager()->getService(name)); + if (window != 0) { + window->linkToDeath(this); + } + + // stop boot animation property_set("ctl.stop", "bootanim"); } +void SurfaceFlinger::binderDied(const wp& who) +{ + // the window manager died on us. prepare its eulogy. + + // unfreeze the screen in case it was... frozen + mFreezeDisplayTime = 0; + mFreezeCount = 0; + mFreezeDisplay = false; + + // reset screen orientation + setOrientation(0, eOrientationDefault, 0); + + // restart the boot-animation + property_set("ctl.start", "bootanim"); +} + void SurfaceFlinger::onFirstRef() { run("SurfaceFlinger", PRIORITY_URGENT_DISPLAY); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index b49fa363e..471226175 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -147,6 +147,7 @@ enum { class SurfaceFlinger : public BinderService, public BnSurfaceComposer, + public IBinder::DeathRecipient, protected Thread { public: @@ -192,6 +193,10 @@ public: sp getLayer(const sp& sur) const; +private: + // DeathRecipient interface + virtual void binderDied(const wp& who); + private: friend class Client; friend class LayerBase;