SetFlagsRule: Check whether read_only flag is optimized

This change introduces a new behavior to SetFlagsRule that it will
verify if a test attempts to modify a read_only flag within an optimized
build. If such scenario occurs, the test will be skipped. The reason for
this behavior is that during optimization, unused code branches will be
stripped away. Attempts to change the flag values in the build won't
trigger the expected behavior.

Bug: 309406391
Test: atest FlagJUnitTests
Change-Id: If327239c2765be80026488c4ea4b3a0f718f660a
3 files changed