Add support for ANDROID_TZDATA_ROOT

Soon, code in the Android Core Library / ICU4C library will depend on the
ANDROID_TZDATA_ROOT environment variable being set. On device this points
to the root of the com.android.tzdata module.

Unlike ANDROID_RUNTIME_ROOT, ANDROID_TZDATA_ROOT it doesn't have to point to
anything that exists because the code will fall back to looking in
ANDROID_RUNTIME_ROOT if it can't find the files it is looking for. Most
of the changes in this commit are plumbing to make sure the environment
variable is set to benign defaults or passed through to the runtime.

This commit has been put together by looking for usages of
ANDROID_RUNTIME_ROOT and duplicating the logic.

Bug: 128422035
Test: build only
Change-Id: I2fd73fe16f5022742aaf634be158765cac8759e6
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 916f072..ed74947 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -158,6 +158,17 @@
       setenv("ANDROID_RUNTIME_ROOT", android_runtime_root.c_str(), 1);
     }
 
+    // Environment variable ANDROID_TZDATA_ROOT is set on the device, but not
+    // necessarily on the host. It needs to be set so that various libraries
+    // like icu4c can find their data files.
+    const char* android_tzdata_root_from_env = getenv("ANDROID_TZDATA_ROOT");
+    if (android_tzdata_root_from_env == nullptr) {
+      // Use ${ANDROID_HOST_OUT}/com.android.tzdata for ANDROID_TZDATA_ROOT.
+      std::string android_tzdata_root = android_host_out_from_env;
+      android_tzdata_root += "/com.android.tzdata";
+      setenv("ANDROID_TZDATA_ROOT", android_tzdata_root.c_str(), 1);
+    }
+
     setenv("LD_LIBRARY_PATH", ":", 0);  // Required by java.lang.System.<clinit>.
   }
 }