[automerger skipped] Merge "More fixes towards the race conditions in AMS" into pi-dev am: f56666c524 -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: I686dd592f9d37b5a365473d0db3ece81e935bba6