SurfaceFlinger: Avoid overlapping calls to BOOT_FINISHED

Handling BOOT_FINISHED we write to mInputFlinger and mWindowManager.
This could trigger crashes if we write from multiple concurrent threads
or if we try and use it from the main thread while decing the strong
pointer. The easiest way to work around this seems to just to only
be willing to handle BOOT_FINISHED once, until the WM dies.

Bug: 150227563
Bug: 150225569
Test: Existing tests pass
Change-Id: I10f4b9359a5f3dc49e3360f28fbe808f0fc2afc8
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index e892faf..e6b91e6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1129,6 +1129,10 @@
 
     // to linkToDeath
     sp<IBinder> mWindowManager;
+    // We want to avoid multiple calls to BOOT_FINISHED as they come in on
+    // different threads without a lock and could trigger unsynchronized writes to
+    // to mWindowManager or mInputFlinger
+    std::atomic<bool> mBootFinished = false;
 
     std::unique_ptr<dvr::VrFlinger> mVrFlinger;
     std::atomic<bool> mVrFlingerRequestsDisplay = false;