Merge "Fix potential race condition due to missing lock" am: 8787386e84 am: af33aac24e am: a8c0e350fe am: 77af314c76

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

Change-Id: I1e7dd8e3f87fb7ebdc31b87131e77a11bd4e6908