More fixes towards the race conditions in AMS

Bug: 142986887
Bug: 140108616
Test: Manual
Change-Id: I6e0bdc8c02bab54f6278096b3a3acadd97c064c6
Merged-In: I6e0bdc8c02bab54f6278096b3a3acadd97c064c6
(cherry picked from commit b2e84f0406139156442984943d8de7dd37d51368)
(cherry picked from commit b581128020acb378d0a941f022151d7e2883e19c)
1 file changed