Support i18n apex in Microdroid environment
The i18n APEX expects the ANDROID_I18N_ROOT and ANDROID_TZDATA_ROOT
variables to be configured.
The ANDROID_I18N_ROOT should be set to /apex/com.android.i18n, since
this is where i18n libs are located. It is no-op if i18n APEX is not
mounted.
For now the ANDROID_TZDATA_ROOT is set to a non-existent path, since
libicu seem to work correctly without it. We might need to also add
tzdata APEX to support APIS that depend on tzdata.
Bug: 390557313
Test: atest MicrodroidTests
Change-Id: Id89bd26a9bcb7b6d0aa0935171be4a4bdf916a20
diff --git a/tests/testapk/src/native/testbinary.cpp b/tests/testapk/src/native/testbinary.cpp
index c3904b7..355cfb1 100644
--- a/tests/testapk/src/native/testbinary.cpp
+++ b/tests/testapk/src/native/testbinary.cpp
@@ -30,6 +30,9 @@
#include <stdio.h>
#include <sys/capability.h>
#include <sys/system_properties.h>
+#ifdef __MICRODROID_TEST_PAYLOAD_USES_LIBICU__
+#include <unicode/uchar.h>
+#endif
#include <unistd.h>
#include <vm_main.h>
#include <vm_payload_restricted.h>
@@ -385,10 +388,13 @@
}
ScopedAStatus checkLibIcuIsAccessible() override {
+#ifdef __MICRODROID_TEST_PAYLOAD_USES_LIBICU__
static constexpr const char* kLibIcuPath = "/apex/com.android.i18n/lib64/libicu.so";
if (access(kLibIcuPath, R_OK) == 0) {
- // TODO(ioffe): call an API provided by libicu.so and check that it returns expected
- // value.
+ if (!u_hasBinaryProperty(U'❤' /* Emoji heart U+2764 */, UCHAR_EMOJI)) {
+ return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
+ "libicu broken!");
+ }
return ScopedAStatus::ok();
} else {
std::string msg = "failed to access " + std::string(kLibIcuPath) + "(" +
@@ -396,6 +402,12 @@
return ScopedAStatus::fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
msg.c_str());
}
+#else
+ return ScopedAStatus::
+ fromExceptionCodeWithMessage(EX_SERVICE_SPECIFIC,
+ "should be only used together with "
+ "MicrodroidTestNativeLibWithLibIcu.so payload");
+#endif
}
ScopedAStatus quit() override { exit(0); }