Build native AssetManager and friends for host linux.
Test: tools/test/simulated_device/ctesque/run_tests_host.sh
Change-Id: I4298502eea67a1676d97f84bf879c363fa926678
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index 94970cf..a6794dd 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -33,6 +33,7 @@
srcs: [
"android_animation_PropertyValuesHolder.cpp",
+ "android_content_res_ApkAssets.cpp",
"android_graphics_Canvas.cpp",
"android_graphics_ColorSpace.cpp",
"android_graphics_drawable_AnimatedVectorDrawable.cpp",
@@ -74,6 +75,8 @@
"android/graphics/fonts/FontFamily.cpp",
"android/graphics/text/LineBreaker.cpp",
"android/graphics/text/MeasuredText.cpp",
+ "android_util_AssetManager.cpp",
+ "android_util_StringBlock.cpp",
"com_android_internal_util_VirtualRefBasePtr.cpp",
"com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp",
],
@@ -179,13 +182,11 @@
"android_os_VintfRuntimeInfo.cpp",
"android_net_LocalSocketImpl.cpp",
"android_net_NetUtils.cpp",
- "android_util_AssetManager.cpp",
"android_util_Binder.cpp",
"android_util_EventLog.cpp",
"android_util_StatsLog.cpp",
"android_util_MemoryIntArray.cpp",
"android_util_Process.cpp",
- "android_util_StringBlock.cpp",
"android_util_XmlBlock.cpp",
"android_util_jar_StrictJarFile.cpp",
"android/graphics/AnimatedImageDrawable.cpp",
@@ -242,7 +243,6 @@
"android_backup_FileBackupHelperBase.cpp",
"android_backup_BackupHelperDispatcher.cpp",
"android_app_backup_FullBackup.cpp",
- "android_content_res_ApkAssets.cpp",
"android_content_res_ObbScanner.cpp",
"android_content_res_Configuration.cpp",
"android_security_Scrypt.cpp",
diff --git a/core/jni/LayoutlibLoader.cpp b/core/jni/LayoutlibLoader.cpp
index 3316f2d..f451f4e 100644
--- a/core/jni/LayoutlibLoader.cpp
+++ b/core/jni/LayoutlibLoader.cpp
@@ -49,6 +49,9 @@
namespace android {
extern int register_android_animation_PropertyValuesHolder(JNIEnv *env);
+extern int register_android_content_AssetManager(JNIEnv* env);
+extern int register_android_content_StringBlock(JNIEnv* env);
+extern int register_android_content_res_ApkAssets(JNIEnv* env);
extern int register_android_graphics_Canvas(JNIEnv* env);
extern int register_android_graphics_ColorFilter(JNIEnv* env);
extern int register_android_graphics_ColorSpace(JNIEnv* env);
@@ -86,6 +89,9 @@
// The actual list of registered classes will be determined at runtime via the 'native_classes' System property
static const std::unordered_map<std::string, RegJNIRec> gRegJNIMap = {
{"android.animation.PropertyValuesHolder", REG_JNI(register_android_animation_PropertyValuesHolder)},
+ {"android.content.AssetManager", REG_JNI(register_android_content_AssetManager)},
+ {"android.content.StringBlock", REG_JNI(register_android_content_StringBlock)},
+ {"android.content.res.ApkAssets", REG_JNI(register_android_content_res_ApkAssets)},
{"android.graphics.Bitmap", REG_JNI(register_android_graphics_Bitmap)},
{"android.graphics.BitmapFactory", REG_JNI(register_android_graphics_BitmapFactory)},
{"android.graphics.ByteBufferStreamAdaptor", REG_JNI(register_android_graphics_ByteBufferStreamAdaptor)},
@@ -241,6 +247,8 @@
const char* path = env->GetStringUTFChars(stringPath, 0);
u_setDataDirectory(path);
env->ReleaseStringUTFChars(stringPath, path);
+
+
return JNI_VERSION_1_6;
}
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 2b471fe..d6d9391 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -18,10 +18,8 @@
#define LOG_TAG "asset"
#include <inttypes.h>
-#include <linux/capability.h>
#include <stdio.h>
#include <sys/stat.h>
-#include <sys/system_properties.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -399,6 +397,7 @@
return array_map;
}
+#ifdef __ANDROID__ // Layoutlib does not support parcel
static jobject ReturnParcelFileDescriptor(JNIEnv* env, std::unique_ptr<Asset> asset,
jlongArray out_offsets) {
off64_t start_offset, length;
@@ -430,6 +429,15 @@
}
return newParcelFileDescriptor(env, file_desc);
}
+#else
+static jobject ReturnParcelFileDescriptor(JNIEnv* env, std::unique_ptr<Asset> asset,
+ jlongArray out_offsets) {
+ jniThrowException(env, "java/lang/UnsupportedOperationException",
+ "Implement me");
+ // never reached
+ return nullptr;
+}
+#endif
static jint NativeGetGlobalAssetCount(JNIEnv* /*env*/, jobject /*clazz*/) {
return Asset::getGlobalCount();
diff --git a/core/res/Android.bp b/core/res/Android.bp
index 3402033..3dc74f8 100644
--- a/core/res/Android.bp
+++ b/core/res/Android.bp
@@ -38,6 +38,12 @@
// Create package-export.apk, which other packages can use to get
// PRODUCT-agnostic resource data like IDs and type definitions.
export_package_resources: true,
+
+ dist: {
+ targets: [
+ "simulated_device_launcher",
+ ],
+ },
}
// This logic can be removed once robolectric's transition to binary resources is complete