[automerger skipped] Merge "More fixes towards the race conditions in AMS" into pi-dev am: f56666c524 -s ours am: 0295276dfa -s ours am: f400177a95 -s ours

am skip reason: Change-Id I6e0bdc8c02bab54f6278096b3a3acadd97c064c6 with SHA-1 5f647cd3f2 is in history

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

Change-Id: I60e6222ee005ef72da26e093a44c954bd507e8ac