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

Commit 726a5508 authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Support building libjnigraphics on the host

Bug: 169137236
Test: SANITIZE_HOST=address make imagedecoder_fuzzer

Along with a change in frameworks/base
(I0ffc4e90b4083db79fbb12012e2e1284206b43e3), this will make it possible
to run imagedecoder_fuzzer on the host, for faster fuzzing.

imagedecoder.h:
- define __ANDROID_API__ and __INTRODUCED_IN on non-Android systems, so
  methods can be called on those systems.

bitmap.h:
- define __ANDROID_API__ and __INTRODUCED_IN on non-Android systems, so
  methods can be called on those systems.
- include <stddef.h>, which is needed on non-Android systems for size_t.
- on Android, unguard types and enums for easier opportunistic usage via
  dlsym.

nativewindow/Android.bp
- make libnativewindow_headers host_supported, so that libjnigraphics
  can access android/data_space.h

Change-Id: Iefdb4132d6f10f9164be85f4dc6e11883f6fd37e
parent 78859b42
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -28,8 +28,23 @@

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <jni.h>

#ifndef __ANDROID__
    // Value copied from 'bionic/libc/include/android/api-level.h' which is not available on
    // non Android systems. It is set to 10000 which is same as __ANDROID_API_FUTURE__ value.
    #ifndef __ANDROID_API__
        #define __ANDROID_API__ 10000
    #endif

    // Value copied from 'bionic/libc/include/android/versioning.h' which is not available on
    // non Android systems
    #ifndef __INTRODUCED_IN
        #define __INTRODUCED_IN(api_level)
    #endif
#endif

#ifdef __cplusplus
extern "C" {
#endif
@@ -152,8 +167,6 @@ int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr);
 */
int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap);

#if __ANDROID_API__ >= 30

// Note: these values match android.graphics.Bitmap#compressFormat.

/**
@@ -203,6 +216,8 @@ typedef bool (*AndroidBitmap_CompressWriteFunc)(void* userContext,
                                                const void* data,
                                                size_t size) __INTRODUCED_IN(30);

#if __ANDROID_API__ >= 30

/**
 *  Compress |pixels| as described by |info|.
 *
+14 −0
Original line number Diff line number Diff line
@@ -51,6 +51,20 @@
#include <android/rect.h>
#include <stdint.h>

#ifndef __ANDROID__
    // Value copied from 'bionic/libc/include/android/api-level.h' which is not available on
    // non Android systems. It is set to 10000 which is same as __ANDROID_API_FUTURE__ value.
    #ifndef __ANDROID_API__
        #define __ANDROID_API__ 10000
    #endif

    // Value copied from 'bionic/libc/include/android/versioning.h' which is not available on
    // non Android systems
    #ifndef __INTRODUCED_IN
        #define __INTRODUCED_IN(api_level)
    #endif
#endif

#ifdef __cplusplus
extern "C" {
#endif
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ cc_library_headers {
    // TODO(b/153609531): remove when no longer needed.
    native_bridge_supported: true,
    min_sdk_version: "29",
    host_supported: true,
}

ndk_library {