Reapply "Handle corrupted read/write pointers in read funcitons"

This reverts commit 11165074cdd90594e1935ee2b9edceb822a2957f.

Fixed beginRead() check to only apply to kSynchronizedReadWrite flavors.
The other unsync flavor is expected to have overflows when the readers
are too slow to keep with the writer.

Also added tests for beginRead() specifically and tests for the unsync
overflow behavior.

Test: atest fmq_unit_tests
Bug: 504768739
Bug: 514861024
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:c4412ddafd204b5acbf2fbbdafe3ce694bc0a364
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:d4ebcba36d271ea456188a258eee9a0bb59f2fb1
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:92cf2be8cb402c8c324eed46d20bddc4bee6bb58
Merged-In: Icd31feb0855c7d64bd68f7d0a8da690c75341b76
Change-Id: Icd31feb0855c7d64bd68f7d0a8da690c75341b76
1 file changed