Add TestRule to enable access to deprecated BC algorithms

Android restricts access to a number of deprecated BouncyCastle
algorithms to APKs that target SDK version <= 27. However, those
algorithms still need testing. Rather than set the target SDK version
to be <= 27 (which could have other side effects) tests use
Providers.setMaximumAllowableApiLevelForBcDeprecation(int) to raise
the level to make them accessible at the current target SDK version
and resets it the default value afterwards.

This change adds a JUnit test rule to implement that behavior and
uses it to replace duplicate setUp() and tearDown() code across a
number of tests. It also insulates the tests from having to access
the internal sun.security.jca.Providers and dalvik.system.VMRuntime
classes.

This is intended to be used by external/conscrypt so that the
conscrypt-tests module can stop depending on core-all-systems-module.

Bug: 141539296
Test: atest CtsLibcoreTestCases
Change-Id: If41b5c221c392e9b6d14d500537115d3380c4999
16 files changed