Merge cherrypicks of [13231585, 13231436, 13231587, 13230396, 13230398, 13231349, 13231352, 13231353, 13231355, 13231438, 13231440, 13231357, 13231442, 13231359, 13231031, 13231456, 13230694, 13231724, 13231033, 13230839, 13231035, 13230841, 13230843, 13231362, 13231744, 13231746, 13231459, 13231748, 13231750, 13231752, 13229581, 13229583, 13231590, 13231592, 13231765, 13230401, 13230403, 13231785, 13231787, 13231789, 13231791] into rvc-qpr1-d-release

Change-Id: I879efe5ae91b5b675ccbb733a503ae52278c5e39
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index c9e595a..79f99cc 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -600,13 +600,6 @@
     if (mWindowManager != 0) {
         mWindowManager->linkToDeath(static_cast<IBinder::DeathRecipient*>(this));
     }
-    sp<IBinder> input(defaultServiceManager()->getService(
-            String16("inputflinger")));
-    if (input == nullptr) {
-        ALOGE("Failed to link to input service");
-    } else {
-        mInputFlinger = interface_cast<IInputFlinger>(input);
-    }
 
     if (mVrFlinger) {
       mVrFlinger->OnBootFinished();
@@ -621,7 +614,15 @@
     LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM,
                    ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
 
-    static_cast<void>(schedule([this] {
+    sp<IBinder> input(defaultServiceManager()->getService(String16("inputflinger")));
+
+    static_cast<void>(schedule([=] {
+        if (input == nullptr) {
+            ALOGE("Failed to link to input service");
+        } else {
+            mInputFlinger = interface_cast<IInputFlinger>(input);
+        }
+
         readPersistentProperties();
         mPowerAdvisor.onBootFinished();
         mBootStage = BootStage::FINISHED;