Reset System properities between tests

This is to avoid test leakage.

The properties are reset to their initial values with this
change, clearing any of the ones set by tests. Vogar
was already doing something like this.

Some of the existing property setting was rendered
unnecessary / pointless by Narayan's immutable
system property commit
(f63153ac0ec510b0111d01805097bbd08ccf64ab).

Note: This change will cause a merge conflict for the
internal master due to changes in the CTS runner.

Change-Id: I7edfc325857f701ab0c5b9958703b3a592e8eb82
diff --git a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
index 83c339b..96aeb51 100644
--- a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
+++ b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
@@ -75,16 +75,7 @@
     public void onCreate(Bundle arguments) {
         // We might want to move this to /sdcard, if is is mounted/writable.
         File cacheDir = getTargetContext().getCacheDir();
-
-        // Set some properties that the core tests absolutely need.
-        System.setProperty("user.language", "en");
-        System.setProperty("user.region", "US");
-
-        System.setProperty("java.home", cacheDir.getAbsolutePath());
-        System.setProperty("user.home", cacheDir.getAbsolutePath());
         System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath());
-        System.setProperty("user.dir", cacheDir.getAbsolutePath());
-
 
         mEnvironment = new TestEnvironment();
 
@@ -203,7 +194,6 @@
     static class TestEnvironment {
         private final Locale mDefaultLocale;
         private final TimeZone mDefaultTimeZone;
-        private final String mUserHome;
         private final String mJavaIoTmpDir;
         private final HostnameVerifier mHostnameVerifier;
         private final SSLSocketFactory mSslSocketFactory;
@@ -211,17 +201,16 @@
         TestEnvironment() {
             mDefaultLocale = Locale.getDefault();
             mDefaultTimeZone = TimeZone.getDefault();
-            mUserHome = System.getProperty("user.home");
             mJavaIoTmpDir = System.getProperty("java.io.tmpdir");
             mHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
             mSslSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
         }
 
         void reset() {
+            System.setProperties(null);
+            System.setProperty("java.io.tmpdir", mJavaIoTmpDir);
             Locale.setDefault(mDefaultLocale);
             TimeZone.setDefault(mDefaultTimeZone);
-            System.setProperty("user.home", mUserHome);
-            System.setProperty("java.io.tmpdir", mJavaIoTmpDir);
             Authenticator.setDefault(null);
             CookieHandler.setDefault(null);
             ResponseCache.setDefault(null);