Merge cherrypicks of [13231586, 13231437, 13231588, 13230397, 13230399, 13231350, 13231351, 13231354, 13231356, 13231439, 13231441, 13231358, 13231443, 13231360, 13231030, 13231457, 13230243, 13231032, 13231725, 13230838, 13231034, 13230840, 13230842, 13231361, 13231363, 13231745, 13231458, 13231747, 13231749, 13231751, 13229580, 13229582, 13231589, 13231591, 13231764, 13230400, 13230402, 13231784, 13231786, 13231788, 13231790] into rvc-qpr1-release

Change-Id: I4dae86d710b87570636240127014b3d4bd8b93e8
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;