Make environment variable APIs consistent and add tests.
Android allows reading of changed environment variables by
both Os.getenv(String name) and System.getenv(String name),
so make System.getenv() and ProcessBuilder.environment()
consistent with this and enforce with tests.
This change means that the System class no longer caches a
copy of the C environment, so it won't take space unless
used, but does mean that if an app calls System.getenv()
or ProcessBuilder.environment() multiple times then it will
process the environment variables multiple times.
Bug: 182164671
Bug: 201665416
Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest
Change-Id: Iab6c22fd25a145ebd4ef209429e1a8d8adc66e7c
2 files changed