Merge cherrypicks of [13237717, 13237455, 13237456, 13237585, 13237718, 13237719, 13237720, 13237725, 13238104, 13237746, 13237586, 13237478, 13237479, 13237691, 13238124, 13238105, 13237747, 13237748, 13237749, 13237750, 13237751, 13238125, 13237587, 13237726, 13238126, 13238127, 13237727, 13237728, 13237729, 13237721, 13237588, 13238106, 13238107, 13237722, 13237723, 13238144, 13238145, 13238146, 13238147, 13238148, 13237589, 13237590, 13237591, 13237692, 13237693, 13238128, 13238129, 13238149, 13238150, 13237592, 13237593, 13237594, 13237595, 13237730, 13237731, 13238151, 13236939, 13236940, 13238130, 13238131, 13236759, 13236761, 13237752, 13237753, 13237754, 13238132, 13238133, 13238134] into rvc-qpr1-c-release

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