Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15c7bcd0 authored by Brett Chabot's avatar Brett Chabot Committed by Jerome Gaillard
Browse files

Build native AssetManager and friends for host linux.

Test: tools/test/simulated_device/ctesque/run_tests_host.sh

Change-Id: I4298502eea67a1676d97f84bf879c363fa926678
parent 5ee1d664
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ cc_library_shared {

    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 @@ cc_library_shared {
        "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 @@ cc_library_shared {
                "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 @@ cc_library_shared {
                "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",
+8 −0
Original line number Diff line number Diff line
@@ -49,6 +49,9 @@ extern int register_android_graphics_Typeface(JNIEnv* env);
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 @@ struct RegJNIRec {
// 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 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
    const char* path = env->GetStringUTFChars(stringPath, 0);
    u_setDataDirectory(path);
    env->ReleaseStringUTFChars(stringPath, path);


    return JNI_VERSION_1_6;
}
+10 −2
Original line number Diff line number Diff line
@@ -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 @@ static jobject NativeGetOverlayableMap(JNIEnv* env, jclass /*clazz*/, jlong ptr,
  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 @@ static jobject ReturnParcelFileDescriptor(JNIEnv* env, std::unique_ptr<Asset> as
  }
  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();
+6 −0
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ android_app {
    // 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