diff options
author | 2020-06-17 10:17:30 +0800 | |
---|---|---|
committer | 2020-07-10 16:13:40 +0000 | |
commit | e70cc6c64870cbfa7a73de89502632b718cfebcc (patch) | |
tree | 0023091cf42d5d0e9537103e163fd94fa44f8789 /services/surfaceflinger/SurfaceFlinger.cpp | |
parent | c6a2f3a47d46c990105d58d6e3707b189605cbc1 (diff) |
SF: update mInputFlinger on main thread
mInputFlinger can be accessed by bootFinished() and updateInputFlinger().
These function can run in different thread at the same time, but
mInputFlinger was not protected.
update mInputFlinger on main thread
Fixes: 157871763
Fixes: 147009853
Test: adb shell stop / start
Test: boot ok
Test: Race was only reproducible in monkey tests
Change-Id: I4d87e90793a88a646aaa1ae5806f118f1ae51e30
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 2564600f6b..e5e3f48732 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -603,13 +603,6 @@ void SurfaceFlinger::bootFinished() 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(); @@ -624,7 +617,15 @@ void SurfaceFlinger::bootFinished() 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; |