hiddenapi: Fail if encoding S+ flags on R/Q libraries

The Q and R runtimes can handle Q/R flags but not S flags. Previously,
the hiddenapi encode command supported the --max-hiddenapi-level option
to allow the build to specify a maximum release flag that could be
encoded and to clamp the flags to that level but that option was not
actually used by the build. So, the option has been repurposed for this
change.

This change causes the encode command to fail if the option is supplied
and a flag to be encoded exceeds the maximum allowable level set by the
option.

Bug: 172453495
Test: m test-art-host-gtest-art_hiddenapi_tests
      m droid && launch_cvd
      Cherry pick changes in https://r.android.com/q/topic:max-target-s
      Add @UnsupportedAppUsage maxTargetSdk=S in classes in framework-permission (for r/q)
      and framework-permission-s (nominally for S+). I had to incresed the min_sdk_version
      in the latter to 31 (S) as it was still set at 30 (R).
Merged-In: Ifd18e0bcf578d6d77b0ba7eee5770854d525a2b3
Change-Id: Ifd18e0bcf578d6d77b0ba7eee5770854d525a2b3
(cherry picked from commit eafb76f2f48997df0be1ab029b36118efa6bdfd2)
3 files changed