Merge "Fix potential race condition due to missing lock" am: 8787386e84

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1864979

Change-Id: I8ec769f756e043e5fb35e18ac7e85bd195bf56ac