Merge "Remove ICU .dat prebuilt / add new one for APEX"
diff --git a/android_utils/IcuUtils.cpp b/android_utils/IcuUtils.cpp
index 857dde9..8a7ea86 100644
--- a/android_utils/IcuUtils.cpp
+++ b/android_utils/IcuUtils.cpp
@@ -24,11 +24,12 @@
 #include <stdlib.h>
 
 void InitializeIcuOrDie() {
-    const char* systemPathPrefix = getenv("ANDROID_ROOT");
-    LOG_ALWAYS_FATAL_IF(systemPathPrefix == NULL, "ANDROID_ROOT environment variable not set");
+    const char* runtimeModulePathPrefix = getenv("ANDROID_RUNTIME_ROOT");
+    LOG_ALWAYS_FATAL_IF(runtimeModulePathPrefix == NULL,
+            "ANDROID_RUNTIME_ROOT environment variable not set");
 
     char buf[256];
-    const int num_written = snprintf(buf, sizeof(buf), "%s/usr/icu/", systemPathPrefix);
+    const int num_written = snprintf(buf, sizeof(buf), "%s/etc/icu/", runtimeModulePathPrefix);
     LOG_ALWAYS_FATAL_IF((num_written < 0 || static_cast<size_t>(num_written) >= sizeof(buf)),
             "Unable to construct ICU path.");
 
diff --git a/icu4c/source/common/Android.bp b/icu4c/source/common/Android.bp
index 890e0af..34362d4 100644
--- a/icu4c/source/common/Android.bp
+++ b/icu4c/source/common/Android.bp
@@ -45,7 +45,7 @@
 
     rtti: true,
 
-    required: ["icu-data"],
+    required: ["icu-data_host_runtime_apex"],
 
     target: {
         android: {
diff --git a/icu4c/source/stubdata/Android.bp b/icu4c/source/stubdata/Android.bp
new file mode 100644
index 0000000..9f3fd80
--- /dev/null
+++ b/icu4c/source/stubdata/Android.bp
@@ -0,0 +1,22 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+prebuilt_etc {
+    name: "apex_icu.dat",
+    src: "icu*.dat",
+    filename_from_src: true,
+    sub_dir: "icu",
+    installable: false,
+}
+
diff --git a/icu4c/source/stubdata/Android.mk b/icu4c/source/stubdata/Android.mk
index 7c0c95c..62d7679 100644
--- a/icu4c/source/stubdata/Android.mk
+++ b/icu4c/source/stubdata/Android.mk
@@ -24,17 +24,9 @@
 dat_file := $(notdir $(wildcard $(stubdata_path)/*.dat))
 
 include $(CLEAR_VARS)
-LOCAL_MODULE := icu-data
+LOCAL_MODULE := icu-data_host_runtime_apex
 LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/icu
-LOCAL_MODULE_STEM := $(dat_file)
-LOCAL_SRC_FILES := $(dat_file)
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := icu-data
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(HOST_OUT)/usr/icu
+LOCAL_MODULE_PATH := $(HOST_OUT)/com.android.runtime/etc/icu
 LOCAL_MODULE_STEM := $(dat_file)
 LOCAL_SRC_FILES := $(dat_file)
 LOCAL_IS_HOST_MODULE := true
diff --git a/icu4c/source/stubdata/CleanSpec.mk b/icu4c/source/stubdata/CleanSpec.mk
index 20c32b1..adc2409 100644
--- a/icu4c/source/stubdata/CleanSpec.mk
+++ b/icu4c/source/stubdata/CleanSpec.mk
@@ -54,6 +54,10 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/host/linux-x86/com.android.runtime/etc/icu)
 $(call add-clean-step, rm -rf $(OUT_DIR)/host/linux-x86/com.android.runtime/etc/icu)
 
+# Remove the icu .dat file from /system/usr/icu and the host equivalent. 2nd attempt.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/usr/icu/*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/linux-x86/usr/icu/*)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************