Compare commits
	
		
			9 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					d9903e7398 | ||
| 
						 | 
					39b69f27ee | ||
| 
						 | 
					31a1d19b4e | ||
| 
						 | 
					f4a923c3dc | ||
| 
						 | 
					171ff7d1e4 | ||
| 
						 | 
					5cfbf22b81 | ||
| 
						 | 
					5a35ed5ea1 | ||
| 
						 | 
					1978359f15 | ||
| 
						 | 
					fef6543f1a | 
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -24,7 +24,7 @@ all: debug release pkgconfig
 | 
			
		||||
 | 
			
		||||
VERSION_MAJOR = 1
 | 
			
		||||
VERSION_MINOR = 0
 | 
			
		||||
VERSION_RELEASE = 15
 | 
			
		||||
VERSION_RELEASE = 17
 | 
			
		||||
 | 
			
		||||
# Version for pkg-config
 | 
			
		||||
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,17 @@
 | 
			
		||||
libgbinder (1.0.17) unstable; urgency=low
 | 
			
		||||
 | 
			
		||||
  * Added gbinder_writer_append_string16_utf16()
 | 
			
		||||
  * Added gbinder_reader_read_nullable_string16_utf16()
 | 
			
		||||
 | 
			
		||||
 -- Slava Monich <slava.monich@jolla.com>  Fri, 07 Dec 2018 02:54:07 +0200
 | 
			
		||||
 | 
			
		||||
libgbinder (1.0.16) unstable; urgency=low
 | 
			
		||||
 | 
			
		||||
  * Added GBinderHidlVec and GBinderHidlString types
 | 
			
		||||
  * Added gbinder_reader_copy()
 | 
			
		||||
 | 
			
		||||
 -- Slava Monich <slava.monich@jolla.com>  Thu, 06 Dec 2018 19:03:32 +0200
 | 
			
		||||
 | 
			
		||||
libgbinder (1.0.15) unstable; urgency=low
 | 
			
		||||
 | 
			
		||||
  * Implemented service polling for old servicemanager
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ struct gbinder_reader {
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
gbinder_reader_at_end(
 | 
			
		||||
    GBinderReader* reader);
 | 
			
		||||
    const GBinderReader* reader);
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
gbinder_reader_read_byte(
 | 
			
		||||
@@ -165,6 +165,12 @@ gbinder_reader_read_nullable_string16(
 | 
			
		||||
    GBinderReader* reader,
 | 
			
		||||
    char** out);
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
gbinder_reader_read_nullable_string16_utf16(
 | 
			
		||||
    GBinderReader* reader,
 | 
			
		||||
    gunichar2** out,
 | 
			
		||||
    gsize* len); /* since 1.0.17 */
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
gbinder_reader_skip_string16(
 | 
			
		||||
    GBinderReader* reader);
 | 
			
		||||
@@ -176,11 +182,16 @@ gbinder_reader_read_byte_array(
 | 
			
		||||
 | 
			
		||||
gsize
 | 
			
		||||
gbinder_reader_bytes_read(
 | 
			
		||||
    GBinderReader* reader);
 | 
			
		||||
    const GBinderReader* reader);
 | 
			
		||||
 | 
			
		||||
gsize
 | 
			
		||||
gbinder_reader_bytes_remaining(
 | 
			
		||||
    GBinderReader* reader);
 | 
			
		||||
    const GBinderReader* reader);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_reader_copy(
 | 
			
		||||
    GBinderReader* dest,
 | 
			
		||||
    const GBinderReader* src); /* Since 1.0.16 */
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -72,6 +72,30 @@ typedef struct gbinder_servicemanager GBinderServiceManager;
 | 
			
		||||
typedef struct gbinder_writer GBinderWriter;
 | 
			
		||||
typedef struct gbinder_parent GBinderParent;
 | 
			
		||||
 | 
			
		||||
/* Basic HIDL types */
 | 
			
		||||
 | 
			
		||||
typedef struct gbinder_hidl_vec {
 | 
			
		||||
    union {
 | 
			
		||||
        guint64 value;
 | 
			
		||||
        const void* ptr;
 | 
			
		||||
    } data;
 | 
			
		||||
    guint32 count;
 | 
			
		||||
    guint32 owns_buffer;
 | 
			
		||||
} GBinderHidlVec;
 | 
			
		||||
 | 
			
		||||
#define GBINDER_HIDL_VEC_BUFFER_OFFSET (0)
 | 
			
		||||
 | 
			
		||||
typedef struct gbinder_hidl_string {
 | 
			
		||||
    union {
 | 
			
		||||
        guint64 value;
 | 
			
		||||
        const char* str;
 | 
			
		||||
    } data;
 | 
			
		||||
    guint32 len;
 | 
			
		||||
    guint32 owns_buffer;
 | 
			
		||||
} GBinderHidlString;
 | 
			
		||||
 | 
			
		||||
#define GBINDER_HIDL_STRING_BUFFER_OFFSET (0)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Each RPC call is identified by the interface name returned
 | 
			
		||||
 * by gbinder_remote_request_interface() the transaction code.
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,12 @@ gbinder_writer_append_string16_len(
 | 
			
		||||
    const char* utf8,
 | 
			
		||||
    gssize num_bytes);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_append_string16_utf16(
 | 
			
		||||
    GBinderWriter* writer,
 | 
			
		||||
    const gunichar2* utf16,
 | 
			
		||||
    gssize length); /* Since 1.0.17 */
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_append_string8(
 | 
			
		||||
    GBinderWriter* writer,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
Name: libgbinder
 | 
			
		||||
Version: 1.0.15
 | 
			
		||||
Version: 1.0.17
 | 
			
		||||
Release: 0
 | 
			
		||||
Summary: Binder client library
 | 
			
		||||
Group: Development/Libraries
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,8 @@ G_STATIC_ASSERT(sizeof(GBinderReader) >= sizeof(GBinderReaderPriv));
 | 
			
		||||
 | 
			
		||||
static inline GBinderReaderPriv* gbinder_reader_cast(GBinderReader* reader)
 | 
			
		||||
    { return (GBinderReaderPriv*)reader; }
 | 
			
		||||
static inline const GBinderReaderPriv* gbinder_reader_cast_c
 | 
			
		||||
    (const GBinderReader* reader)  { return (GBinderReaderPriv*)reader; }
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_reader_init(
 | 
			
		||||
@@ -81,9 +83,9 @@ gbinder_reader_init(
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
gbinder_reader_at_end(
 | 
			
		||||
    GBinderReader* reader)
 | 
			
		||||
    const GBinderReader* reader)
 | 
			
		||||
{
 | 
			
		||||
    GBinderReaderPriv* p = gbinder_reader_cast(reader);
 | 
			
		||||
    const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
 | 
			
		||||
 | 
			
		||||
    return p->ptr >= p->end;
 | 
			
		||||
}
 | 
			
		||||
@@ -333,8 +335,8 @@ gbinder_reader_read_hidl_vec(
 | 
			
		||||
    gsize out_count = 0, out_elemsize = 0;
 | 
			
		||||
    const void* out = NULL;
 | 
			
		||||
 | 
			
		||||
    if (buf && buf->size == sizeof(HidlVec)) {
 | 
			
		||||
        const HidlVec* vec = buf->data;
 | 
			
		||||
    if (buf && buf->size == sizeof(GBinderHidlVec)) {
 | 
			
		||||
        const GBinderHidlVec* vec = buf->data;
 | 
			
		||||
        const void* next = vec->data.ptr;
 | 
			
		||||
 | 
			
		||||
        if (next) {
 | 
			
		||||
@@ -383,8 +385,8 @@ gbinder_reader_read_hidl_string(
 | 
			
		||||
    GBinderBuffer* buf = gbinder_reader_read_buffer(reader);
 | 
			
		||||
    char* str = NULL;
 | 
			
		||||
 | 
			
		||||
    if (buf && buf->size == sizeof(HidlString)) {
 | 
			
		||||
        const HidlString* s = buf->data;
 | 
			
		||||
    if (buf && buf->size == sizeof(GBinderHidlString)) {
 | 
			
		||||
        const GBinderHidlString* s = buf->data;
 | 
			
		||||
        GBinderBuffer* sbuf = gbinder_reader_read_buffer(reader);
 | 
			
		||||
 | 
			
		||||
        if (sbuf && sbuf->size == s->len + 1 &&
 | 
			
		||||
@@ -405,8 +407,8 @@ gbinder_reader_read_hidl_string_vec(
 | 
			
		||||
    GBinderBuffer* buf = gbinder_reader_read_buffer(reader);
 | 
			
		||||
 | 
			
		||||
    /* First buffer contains hidl_vector */
 | 
			
		||||
    if (buf && buf->size == sizeof(HidlVec)) {
 | 
			
		||||
        HidlVec* vec = buf->data;
 | 
			
		||||
    if (buf && buf->size == sizeof(GBinderHidlVec)) {
 | 
			
		||||
        GBinderHidlVec* vec = buf->data;
 | 
			
		||||
        const guint n = vec->count;
 | 
			
		||||
        const void* next = vec->data.ptr;
 | 
			
		||||
 | 
			
		||||
@@ -419,8 +421,9 @@ gbinder_reader_read_hidl_string_vec(
 | 
			
		||||
        } else {
 | 
			
		||||
            /* The second buffer (if any) contains n hidl_string's */
 | 
			
		||||
            buf = gbinder_reader_read_buffer(reader);
 | 
			
		||||
            if (buf && buf->data == next && buf->size == sizeof(HidlString)*n) {
 | 
			
		||||
                const HidlString* strings = buf->data;
 | 
			
		||||
            if (buf && buf->data == next &&
 | 
			
		||||
                buf->size == (sizeof(GBinderHidlString) * n)) {
 | 
			
		||||
                const GBinderHidlString* strings = buf->data;
 | 
			
		||||
                GBinderBuffer* sbuf;
 | 
			
		||||
                GPtrArray* list = g_ptr_array_new();
 | 
			
		||||
                guint i;
 | 
			
		||||
@@ -428,7 +431,7 @@ gbinder_reader_read_hidl_string_vec(
 | 
			
		||||
                /* Now we expect n buffers containing the actual data */
 | 
			
		||||
                for (i=0; i<n &&
 | 
			
		||||
                    (sbuf = gbinder_reader_read_buffer(reader)); i++) {
 | 
			
		||||
                    const HidlString* s = strings + i;
 | 
			
		||||
                    const GBinderHidlString* s = strings + i;
 | 
			
		||||
                    if (sbuf->size == s->len + 1 &&
 | 
			
		||||
                        sbuf->data == s->data.str &&
 | 
			
		||||
                        s->data.str[s->len] == 0) {
 | 
			
		||||
@@ -489,6 +492,24 @@ gboolean
 | 
			
		||||
gbinder_reader_read_nullable_string16(
 | 
			
		||||
    GBinderReader* reader,
 | 
			
		||||
    char** out)
 | 
			
		||||
{
 | 
			
		||||
    gunichar2* str;
 | 
			
		||||
    gsize len;
 | 
			
		||||
 | 
			
		||||
    if (gbinder_reader_read_nullable_string16_utf16(reader, &str, &len)) {
 | 
			
		||||
        if (out) {
 | 
			
		||||
            *out = str ? g_utf16_to_utf8(str, len, NULL, NULL, NULL) : NULL;
 | 
			
		||||
        }
 | 
			
		||||
        return TRUE;
 | 
			
		||||
    }
 | 
			
		||||
    return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
gbinder_reader_read_nullable_string16_utf16(
 | 
			
		||||
    GBinderReader* reader,
 | 
			
		||||
    gunichar2** out,
 | 
			
		||||
    gsize* out_len) /* since 1.0.17 */
 | 
			
		||||
{
 | 
			
		||||
    GBinderReaderPriv* p = gbinder_reader_cast(reader);
 | 
			
		||||
 | 
			
		||||
@@ -502,15 +523,21 @@ gbinder_reader_read_nullable_string16(
 | 
			
		||||
            if (out) {
 | 
			
		||||
                *out = NULL;
 | 
			
		||||
            }
 | 
			
		||||
            if (out_len) {
 | 
			
		||||
                *out_len = 0;
 | 
			
		||||
            }
 | 
			
		||||
            return TRUE;
 | 
			
		||||
        } else if (len >= 0) {
 | 
			
		||||
            const guint32 padded_len = G_ALIGN4((len+1)*2);
 | 
			
		||||
            const gunichar2* utf16 = (const gunichar2*)(p->ptr + 4);
 | 
			
		||||
            const guint32 padded_len = G_ALIGN4((len + 1)*2);
 | 
			
		||||
            gunichar2* utf16 = (gunichar2*)(p->ptr + 4);
 | 
			
		||||
 | 
			
		||||
            if ((p->ptr + padded_len + 4) <= p->end) {
 | 
			
		||||
                p->ptr += padded_len + 4;
 | 
			
		||||
                if (out) {
 | 
			
		||||
                    *out = g_utf16_to_utf8(utf16, len, NULL, NULL, NULL);
 | 
			
		||||
                    *out = utf16;
 | 
			
		||||
                }
 | 
			
		||||
                if (out_len) {
 | 
			
		||||
                    *out_len = len;
 | 
			
		||||
                }
 | 
			
		||||
                return TRUE;
 | 
			
		||||
            }
 | 
			
		||||
@@ -583,22 +610,31 @@ gbinder_reader_read_byte_array(
 | 
			
		||||
 | 
			
		||||
gsize
 | 
			
		||||
gbinder_reader_bytes_read(
 | 
			
		||||
    GBinderReader* reader)
 | 
			
		||||
    const GBinderReader* reader)
 | 
			
		||||
{
 | 
			
		||||
    GBinderReaderPriv* p = gbinder_reader_cast(reader);
 | 
			
		||||
    const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
 | 
			
		||||
 | 
			
		||||
    return p->ptr - p->start;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gsize
 | 
			
		||||
gbinder_reader_bytes_remaining(
 | 
			
		||||
    GBinderReader* reader)
 | 
			
		||||
    const GBinderReader* reader)
 | 
			
		||||
{
 | 
			
		||||
    GBinderReaderPriv* p = gbinder_reader_cast(reader);
 | 
			
		||||
    const GBinderReaderPriv* p = gbinder_reader_cast_c(reader);
 | 
			
		||||
 | 
			
		||||
    return p->end - p->ptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_reader_copy(
 | 
			
		||||
    GBinderReader* dest,
 | 
			
		||||
    const GBinderReader* src)
 | 
			
		||||
{
 | 
			
		||||
    /* It's actually quite simple :) */
 | 
			
		||||
    memcpy(dest, src, sizeof(*dest));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Local Variables:
 | 
			
		||||
 * mode: C
 | 
			
		||||
 
 | 
			
		||||
@@ -46,28 +46,6 @@ typedef struct gbinder_output_data GBinderOutputData;
 | 
			
		||||
typedef struct gbinder_rpc_protocol GBinderRpcProtocol;
 | 
			
		||||
typedef struct gbinder_servicepoll GBinderServicePoll;
 | 
			
		||||
 | 
			
		||||
typedef struct hidl_vec {
 | 
			
		||||
    union {
 | 
			
		||||
        guint64 value;
 | 
			
		||||
        const void* ptr;
 | 
			
		||||
    } data;
 | 
			
		||||
    guint32 count;
 | 
			
		||||
    guint32 owns_buffer;
 | 
			
		||||
} HidlVec;
 | 
			
		||||
 | 
			
		||||
#define HIDL_VEC_BUFFER_OFFSET (0)
 | 
			
		||||
 | 
			
		||||
typedef struct hidl_string {
 | 
			
		||||
    union {
 | 
			
		||||
        guint64 value;
 | 
			
		||||
        const char* str;
 | 
			
		||||
    } data;
 | 
			
		||||
    guint32 len;
 | 
			
		||||
    guint32 owns_buffer;
 | 
			
		||||
} HidlString;
 | 
			
		||||
 | 
			
		||||
#define HIDL_STRING_BUFFER_OFFSET (0)
 | 
			
		||||
 | 
			
		||||
#define GBINDER_INLINE_FUNC static inline
 | 
			
		||||
 | 
			
		||||
#define GBINDER_TRANSACTION(c2,c3,c4)     GBINDER_FOURCC('_',c2,c3,c4)
 | 
			
		||||
 
 | 
			
		||||
@@ -351,15 +351,36 @@ gbinder_writer_data_append_string16(
 | 
			
		||||
    gbinder_writer_data_append_string16_len(data, utf8, utf8? strlen(utf8) : 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_data_append_string16_null(
 | 
			
		||||
    GBinderWriterData* data)
 | 
			
		||||
{
 | 
			
		||||
    /* NULL string */
 | 
			
		||||
    gbinder_writer_data_append_int32(data, -1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_data_append_string16_empty(
 | 
			
		||||
    GBinderWriterData* data)
 | 
			
		||||
{
 | 
			
		||||
    GByteArray* buf = data->bytes;
 | 
			
		||||
    const gsize old_size = buf->len;
 | 
			
		||||
    guint16* ptr16;
 | 
			
		||||
 | 
			
		||||
    /* Empty string */
 | 
			
		||||
    g_byte_array_set_size(buf, old_size + 8);
 | 
			
		||||
    ptr16 = (guint16*)(buf->data + old_size);
 | 
			
		||||
    ptr16[0] = ptr16[1] = ptr16[2] = 0; ptr16[3] = 0xffff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_data_append_string16_len(
 | 
			
		||||
    GBinderWriterData* data,
 | 
			
		||||
    const char* utf8,
 | 
			
		||||
    gssize num_bytes)
 | 
			
		||||
{
 | 
			
		||||
    GByteArray* buf = data->bytes;
 | 
			
		||||
    const gsize old_size = buf->len;
 | 
			
		||||
 | 
			
		||||
    if (utf8) {
 | 
			
		||||
        const char* end = utf8;
 | 
			
		||||
 | 
			
		||||
@@ -370,6 +391,8 @@ gbinder_writer_data_append_string16_len(
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (num_bytes > 0) {
 | 
			
		||||
        GByteArray* buf = data->bytes;
 | 
			
		||||
        const gsize old_size = buf->len;
 | 
			
		||||
        glong len = g_utf8_strlen(utf8, num_bytes);
 | 
			
		||||
        gsize padded_len = G_ALIGN4((len+1)*2);
 | 
			
		||||
        guint32* len_ptr;
 | 
			
		||||
@@ -407,14 +430,69 @@ gbinder_writer_data_append_string16_len(
 | 
			
		||||
        g_byte_array_set_size(buf, old_size + padded_len + 4);
 | 
			
		||||
    } else if (utf8) {
 | 
			
		||||
        /* Empty string */
 | 
			
		||||
        guint16* ptr16;
 | 
			
		||||
 | 
			
		||||
        g_byte_array_set_size(buf, old_size + 8);
 | 
			
		||||
        ptr16 = (guint16*)(buf->data + old_size);
 | 
			
		||||
        ptr16[0] = ptr16[1] = ptr16[2] = 0; ptr16[3] = 0xffff;
 | 
			
		||||
        gbinder_writer_data_append_string16_empty(data);
 | 
			
		||||
    } else {
 | 
			
		||||
        /* NULL string */
 | 
			
		||||
        gbinder_writer_data_append_int32(data, -1);
 | 
			
		||||
        gbinder_writer_data_append_string16_null(data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_data_append_string16_utf16(
 | 
			
		||||
    GBinderWriterData* data,
 | 
			
		||||
    const gunichar2* utf16,
 | 
			
		||||
    gssize length)
 | 
			
		||||
{
 | 
			
		||||
    if (length < 0) {
 | 
			
		||||
        length = 0;
 | 
			
		||||
        if (utf16) {
 | 
			
		||||
            const guint16* ptr;
 | 
			
		||||
 | 
			
		||||
            /* Assume NULL terminated string */
 | 
			
		||||
            for (ptr = utf16; *ptr; ptr++);
 | 
			
		||||
            length = ptr - utf16;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (length > 0) {
 | 
			
		||||
        GByteArray* buf = data->bytes;
 | 
			
		||||
        const gsize old_size = buf->len;
 | 
			
		||||
        const gsize padded_size = G_ALIGN4((length + 1) * 2);
 | 
			
		||||
        guint32* len_ptr;
 | 
			
		||||
        gunichar2* utf16_ptr;
 | 
			
		||||
 | 
			
		||||
        /* Preallocate space */
 | 
			
		||||
        g_byte_array_set_size(buf, old_size + padded_size + 4);
 | 
			
		||||
        len_ptr = (guint32*)(buf->data + old_size);
 | 
			
		||||
        utf16_ptr = (gunichar2*)(len_ptr + 1);
 | 
			
		||||
 | 
			
		||||
        /* Actual length */
 | 
			
		||||
        *len_ptr = length;
 | 
			
		||||
 | 
			
		||||
        /* Characters */
 | 
			
		||||
        memcpy(utf16_ptr, utf16, 2 * length);
 | 
			
		||||
 | 
			
		||||
        /* Zero padding */
 | 
			
		||||
        memset(utf16_ptr + length, 0, padded_size - 2 * length);
 | 
			
		||||
    } else if (utf16) {
 | 
			
		||||
        /* Empty string */
 | 
			
		||||
        gbinder_writer_data_append_string16_empty(data);
 | 
			
		||||
    } else {
 | 
			
		||||
        /* NULL string */
 | 
			
		||||
        gbinder_writer_data_append_string16_null(data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
gbinder_writer_append_string16_utf16(
 | 
			
		||||
    GBinderWriter* self,
 | 
			
		||||
    const gunichar2* utf16,
 | 
			
		||||
    gssize length) /* Since 1.0.17 */
 | 
			
		||||
{
 | 
			
		||||
    GBinderWriterData* data = gbinder_writer_data(self);
 | 
			
		||||
 | 
			
		||||
    if (G_LIKELY(data)) {
 | 
			
		||||
        gbinder_writer_data_append_string16_utf16(data, utf16, length);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -504,13 +582,13 @@ gbinder_writer_data_append_hidl_vec(
 | 
			
		||||
    guint elemsize)
 | 
			
		||||
{
 | 
			
		||||
    GBinderParent vec_parent;
 | 
			
		||||
    HidlVec* vec = g_new0(HidlVec, 1);
 | 
			
		||||
    GBinderHidlVec* vec = g_new0(GBinderHidlVec, 1);
 | 
			
		||||
    const gsize total = count * elemsize;
 | 
			
		||||
    void* buf = g_memdup(base, total);
 | 
			
		||||
 | 
			
		||||
    /* Prepare parent descriptor for the string data */
 | 
			
		||||
    vec_parent.index = gbinder_writer_data_prepare(data);
 | 
			
		||||
    vec_parent.offset = HIDL_VEC_BUFFER_OFFSET;
 | 
			
		||||
    vec_parent.offset = GBINDER_HIDL_VEC_BUFFER_OFFSET;
 | 
			
		||||
 | 
			
		||||
    /* Fill in the vector descriptor */
 | 
			
		||||
    if (buf) {
 | 
			
		||||
@@ -550,12 +628,12 @@ gbinder_writer_data_append_hidl_string(
 | 
			
		||||
    const char* str)
 | 
			
		||||
{
 | 
			
		||||
    GBinderParent str_parent;
 | 
			
		||||
    HidlString* hidl_string = g_new0(HidlString, 1);
 | 
			
		||||
    GBinderHidlString* hidl_string = g_new0(GBinderHidlString, 1);
 | 
			
		||||
    const gsize len = str ? strlen(str) : 0;
 | 
			
		||||
 | 
			
		||||
    /* Prepare parent descriptor for the string data */
 | 
			
		||||
    str_parent.index = gbinder_writer_data_prepare(data);
 | 
			
		||||
    str_parent.offset = HIDL_STRING_BUFFER_OFFSET;
 | 
			
		||||
    str_parent.offset = GBINDER_HIDL_STRING_BUFFER_OFFSET;
 | 
			
		||||
 | 
			
		||||
    /* Fill in the string descriptor and store it */
 | 
			
		||||
    hidl_string->data.str = str;
 | 
			
		||||
@@ -597,8 +675,8 @@ gbinder_writer_data_append_hidl_string_vec(
 | 
			
		||||
    gssize count)
 | 
			
		||||
{
 | 
			
		||||
    GBinderParent vec_parent;
 | 
			
		||||
    HidlVec* vec = g_new0(HidlVec, 1);
 | 
			
		||||
    HidlString* strings = NULL;
 | 
			
		||||
    GBinderHidlVec* vec = g_new0(GBinderHidlVec, 1);
 | 
			
		||||
    GBinderHidlString* strings = NULL;
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    if (count < 0) {
 | 
			
		||||
@@ -608,11 +686,11 @@ gbinder_writer_data_append_hidl_string_vec(
 | 
			
		||||
 | 
			
		||||
    /* Prepare parent descriptor for the vector data */
 | 
			
		||||
    vec_parent.index = gbinder_writer_data_prepare(data);
 | 
			
		||||
    vec_parent.offset = HIDL_VEC_BUFFER_OFFSET;
 | 
			
		||||
    vec_parent.offset = GBINDER_HIDL_VEC_BUFFER_OFFSET;
 | 
			
		||||
 | 
			
		||||
    /* Fill in the vector descriptor */
 | 
			
		||||
    if (count > 0) {
 | 
			
		||||
        strings = g_new0(HidlString, count);
 | 
			
		||||
        strings = g_new0(GBinderHidlString, count);
 | 
			
		||||
        vec->data.ptr = strings;
 | 
			
		||||
        data->cleanup = gbinder_cleanup_add(data->cleanup, g_free, strings);
 | 
			
		||||
    }
 | 
			
		||||
@@ -623,7 +701,7 @@ gbinder_writer_data_append_hidl_string_vec(
 | 
			
		||||
    /* Fill in string descriptors */
 | 
			
		||||
    for (i = 0; i < count; i++) {
 | 
			
		||||
        const char* str = strv[i];
 | 
			
		||||
        HidlString* hidl_str = strings + i;
 | 
			
		||||
        GBinderHidlString* hidl_str = strings + i;
 | 
			
		||||
 | 
			
		||||
        if ((hidl_str->data.str = str) != NULL) {
 | 
			
		||||
            hidl_str->len = strlen(str);
 | 
			
		||||
@@ -638,7 +716,7 @@ gbinder_writer_data_append_hidl_string_vec(
 | 
			
		||||
 | 
			
		||||
        /* Prepare parent descriptor for the string data */
 | 
			
		||||
        str_parent.index = data->offsets->count;
 | 
			
		||||
        str_parent.offset = HIDL_STRING_BUFFER_OFFSET;
 | 
			
		||||
        str_parent.offset = GBINDER_HIDL_STRING_BUFFER_OFFSET;
 | 
			
		||||
 | 
			
		||||
        /* Write the vector data (it's parent for the string data) */
 | 
			
		||||
        gbinder_writer_data_write_buffer_object(data, strings,
 | 
			
		||||
@@ -646,7 +724,7 @@ gbinder_writer_data_append_hidl_string_vec(
 | 
			
		||||
 | 
			
		||||
        /* Write the string data */
 | 
			
		||||
        for (i = 0; i < count; i++) {
 | 
			
		||||
            HidlString* hidl_str = strings + i;
 | 
			
		||||
            GBinderHidlString* hidl_str = strings + i;
 | 
			
		||||
 | 
			
		||||
            if (hidl_str->data.str) {
 | 
			
		||||
                gbinder_writer_data_write_buffer_object(data,
 | 
			
		||||
@@ -655,7 +733,7 @@ gbinder_writer_data_append_hidl_string_vec(
 | 
			
		||||
                    (guint)hidl_str->len, (guint)str_parent.index,
 | 
			
		||||
                    (guint)data->buffers_size);
 | 
			
		||||
            }
 | 
			
		||||
            str_parent.offset += sizeof(HidlString);
 | 
			
		||||
            str_parent.offset += sizeof(GBinderHidlString);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -359,7 +359,7 @@ test_hidl_string(
 | 
			
		||||
    offsets = gbinder_output_data_offsets(data);
 | 
			
		||||
    g_assert(offsets->count == 1);
 | 
			
		||||
    g_assert(offsets->data[0] == 0);
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == sizeof(HidlString));
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data)==sizeof(GBinderHidlString));
 | 
			
		||||
    g_assert(data->bytes->len == BUFFER_OBJECT_SIZE_32);
 | 
			
		||||
    gbinder_local_reply_unref(reply);
 | 
			
		||||
}
 | 
			
		||||
@@ -382,7 +382,7 @@ test_hidl_string_vec(
 | 
			
		||||
    offsets = gbinder_output_data_offsets(data);
 | 
			
		||||
    g_assert(offsets->count == 1);
 | 
			
		||||
    g_assert(offsets->data[0] == 0);
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == sizeof(HidlVec));
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == sizeof(GBinderHidlVec));
 | 
			
		||||
    g_assert(data->bytes->len == BUFFER_OBJECT_SIZE_32);
 | 
			
		||||
    gbinder_local_reply_unref(reply);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -375,7 +375,7 @@ test_hidl_string(
 | 
			
		||||
    offsets = gbinder_output_data_offsets(data);
 | 
			
		||||
    g_assert(offsets->count == 1);
 | 
			
		||||
    g_assert(offsets->data[0] == 0);
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == sizeof(HidlString));
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data)==sizeof(GBinderHidlString));
 | 
			
		||||
    g_assert(data->bytes->len == BUFFER_OBJECT_SIZE_32);
 | 
			
		||||
    gbinder_local_request_unref(req);
 | 
			
		||||
}
 | 
			
		||||
@@ -398,7 +398,7 @@ test_hidl_string_vec(
 | 
			
		||||
    offsets = gbinder_output_data_offsets(data);
 | 
			
		||||
    g_assert(offsets->count == 1);
 | 
			
		||||
    g_assert(offsets->data[0] == 0);
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == sizeof(HidlVec));
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == sizeof(GBinderHidlVec));
 | 
			
		||||
    g_assert(data->bytes->len == BUFFER_OBJECT_SIZE_32);
 | 
			
		||||
    gbinder_local_request_unref(req);
 | 
			
		||||
}
 | 
			
		||||
@@ -525,8 +525,9 @@ test_remote_request_obj_validate_data(
 | 
			
		||||
    g_assert(offsets->data[1] == 4 + BUFFER_OBJECT_SIZE_64);
 | 
			
		||||
    g_assert(offsets->data[2] == 4 + 2*BUFFER_OBJECT_SIZE_64);
 | 
			
		||||
    g_assert(bytes->len == 4 + 2*BUFFER_OBJECT_SIZE_64 + BINDER_OBJECT_SIZE_64);
 | 
			
		||||
    /* HidlString + the contents (2 bytes) aligned at 8-byte boundary */
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == (sizeof(HidlString)+8));
 | 
			
		||||
    /* GBinderHidlString + the contents (2 bytes) aligned at 8-byte boundary */
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) ==
 | 
			
		||||
        (sizeof(GBinderHidlString) + 8));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
 
 | 
			
		||||
@@ -445,6 +445,8 @@ test_string16_null(
 | 
			
		||||
    GBinderDriver* driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER, NULL);
 | 
			
		||||
    GBinderReader reader;
 | 
			
		||||
    GBinderReaderData data;
 | 
			
		||||
    gunichar2* out2 = NULL;
 | 
			
		||||
    gsize len = 0;
 | 
			
		||||
    char dummy;
 | 
			
		||||
    char* out = &dummy;
 | 
			
		||||
 | 
			
		||||
@@ -454,6 +456,16 @@ test_string16_null(
 | 
			
		||||
        g_memdup(TEST_ARRAY_AND_SIZE(test_string16_in_null)),
 | 
			
		||||
        sizeof(test_string16_in_null));
 | 
			
		||||
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, sizeof(test_string16_in_null));
 | 
			
		||||
    g_assert(gbinder_reader_read_nullable_string16_utf16(&reader, NULL, NULL));
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader));
 | 
			
		||||
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, sizeof(test_string16_in_null));
 | 
			
		||||
    g_assert(gbinder_reader_read_nullable_string16_utf16(&reader, &out2, &len));
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader));
 | 
			
		||||
    g_assert(!out2);
 | 
			
		||||
    g_assert(!len);
 | 
			
		||||
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, sizeof(test_string16_in_null));
 | 
			
		||||
    g_assert(gbinder_reader_read_nullable_string16(&reader, NULL));
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader));
 | 
			
		||||
@@ -485,6 +497,8 @@ test_string16(
 | 
			
		||||
    GBinderReader reader;
 | 
			
		||||
    GBinderReaderData data;
 | 
			
		||||
    const gboolean valid = (test->out != NULL);
 | 
			
		||||
    gunichar2* out2 = NULL;
 | 
			
		||||
    gsize len = 0;
 | 
			
		||||
    char* str = NULL;
 | 
			
		||||
 | 
			
		||||
    g_assert(driver);
 | 
			
		||||
@@ -492,6 +506,22 @@ test_string16(
 | 
			
		||||
    data.buffer = gbinder_buffer_new(driver, g_memdup(test->in, test->in_size),
 | 
			
		||||
        test->in_size);
 | 
			
		||||
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, test->in_size);
 | 
			
		||||
    g_assert(gbinder_reader_read_nullable_string16_utf16(&reader, NULL,
 | 
			
		||||
        NULL) == valid);
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader) == (!test->remaining));
 | 
			
		||||
    g_assert(gbinder_reader_bytes_remaining(&reader) == test->remaining);
 | 
			
		||||
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, test->in_size);
 | 
			
		||||
    g_assert(gbinder_reader_read_nullable_string16_utf16(&reader, &out2,
 | 
			
		||||
        &len) == valid);
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader) == (!test->remaining));
 | 
			
		||||
    g_assert(gbinder_reader_bytes_remaining(&reader) == test->remaining);
 | 
			
		||||
    if (valid) {
 | 
			
		||||
        g_assert(out2);
 | 
			
		||||
        g_assert((gsize)len == strlen(test->out));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, test->in_size);
 | 
			
		||||
    g_assert(gbinder_reader_read_nullable_string16(&reader, NULL) == valid);
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader) == (!test->remaining));
 | 
			
		||||
@@ -603,7 +633,7 @@ typedef struct test_hidl_vec {
 | 
			
		||||
 | 
			
		||||
static const guint test_hidl_vec_2offsets [] = { 0, BUFFER_OBJECT_SIZE_64 };
 | 
			
		||||
static const guint8 test_hidl_vec_2bytes_data [] = { 0x01, 0x02 };
 | 
			
		||||
static const HidlVec test_hidl_vec_2bytes = {
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_2bytes = {
 | 
			
		||||
    .data.ptr = test_hidl_vec_2bytes_data,
 | 
			
		||||
    sizeof(test_hidl_vec_2bytes_data),
 | 
			
		||||
    TRUE
 | 
			
		||||
@@ -612,81 +642,81 @@ static const BinderObject64 test_hidl_vec_2bytes_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_2bytes },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    },{
 | 
			
		||||
        BINDER_TYPE_PTR, BINDER_BUFFER_FLAG_HAS_PARENT,
 | 
			
		||||
        { test_hidl_vec_2bytes_data },
 | 
			
		||||
        sizeof(test_hidl_vec_2bytes_data), 0,
 | 
			
		||||
        HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
        GBINDER_HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const HidlVec test_hidl_vec_empty = {
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_empty = {
 | 
			
		||||
    .data.ptr = test_hidl_vec_2bytes_data, 0, TRUE
 | 
			
		||||
};
 | 
			
		||||
static const BinderObject64 test_hidl_vec_empty_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_empty },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    },{
 | 
			
		||||
        BINDER_TYPE_PTR, BINDER_BUFFER_FLAG_HAS_PARENT,
 | 
			
		||||
        { test_hidl_vec_2bytes_data },
 | 
			
		||||
        0, 0, HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
        0, 0, GBINDER_HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const guint test_hidl_vec_1offset [] = {0};
 | 
			
		||||
static const HidlVec test_hidl_vec_null = {{0}, 0, TRUE};
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_null = {{0}, 0, TRUE};
 | 
			
		||||
static const BinderObject64 test_hidl_vec_null_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_null },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Buffer smaller than HidlVec */
 | 
			
		||||
/* Buffer smaller than GBinderHidlVec */
 | 
			
		||||
static const BinderObject64 test_hidl_vec_short_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_empty },
 | 
			
		||||
        sizeof(HidlVec) - 1, 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec) - 1, 0, 0
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* NULL buffer with size 1 */
 | 
			
		||||
static const guint test_hidl_vec_badnull_offsets [] = {0};
 | 
			
		||||
static const HidlVec test_hidl_vec_badnull = {{0}, 1, TRUE};
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_badnull = {{0}, 1, TRUE};
 | 
			
		||||
static const BinderObject64 test_hidl_vec_badnull_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_badnull },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Buffer size not divisible by count */
 | 
			
		||||
static const guint8 test_hidl_vec_badsize_data [] = { 0x01, 0x02, 0x03 };
 | 
			
		||||
static const HidlVec test_hidl_vec_badsize = {
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_badsize = {
 | 
			
		||||
    .data.ptr = test_hidl_vec_badsize_data, 2, TRUE
 | 
			
		||||
};
 | 
			
		||||
static const BinderObject64 test_hidl_vec_badsize_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_badsize },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    },{
 | 
			
		||||
        BINDER_TYPE_PTR, BINDER_BUFFER_FLAG_HAS_PARENT,
 | 
			
		||||
        { test_hidl_vec_badsize_data },
 | 
			
		||||
        sizeof(test_hidl_vec_badsize_data), 0,
 | 
			
		||||
        HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
        GBINDER_HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Bad buffer address */
 | 
			
		||||
static const guint8 test_hidl_vec_badbuf_data [] = { 0x01, 0x02, 0x03 };
 | 
			
		||||
static const HidlVec test_hidl_vec_badbuf = {
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_badbuf = {
 | 
			
		||||
    .data.ptr = test_hidl_vec_badbuf_data,
 | 
			
		||||
    sizeof(test_hidl_vec_badbuf_data), TRUE
 | 
			
		||||
};
 | 
			
		||||
@@ -694,45 +724,45 @@ static const BinderObject64 test_hidl_vec_badbuf_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_badbuf },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    },{
 | 
			
		||||
        BINDER_TYPE_PTR, BINDER_BUFFER_FLAG_HAS_PARENT,
 | 
			
		||||
        { test_hidl_vec_badsize_data },
 | 
			
		||||
        sizeof(test_hidl_vec_badsize_data), 0,
 | 
			
		||||
        HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
        GBINDER_HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Non-zero count and zero size */
 | 
			
		||||
static const HidlVec test_hidl_vec_badcount1 = {
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_badcount1 = {
 | 
			
		||||
    .data.ptr = test_hidl_vec_badsize_data, 1, TRUE
 | 
			
		||||
};
 | 
			
		||||
static const BinderObject64 test_hidl_vec_badcount1_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_badcount1 },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    },{
 | 
			
		||||
        BINDER_TYPE_PTR, BINDER_BUFFER_FLAG_HAS_PARENT,
 | 
			
		||||
        { test_hidl_vec_badsize_data }, 0, 0,
 | 
			
		||||
        HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
        GBINDER_HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Zero count0 and non-zero size */
 | 
			
		||||
static const HidlVec test_hidl_vec_badcount2 = {
 | 
			
		||||
static const GBinderHidlVec test_hidl_vec_badcount2 = {
 | 
			
		||||
    .data.ptr = test_hidl_vec_badsize_data, 0, TRUE
 | 
			
		||||
};
 | 
			
		||||
static const BinderObject64 test_hidl_vec_badcount2_buf [] = {
 | 
			
		||||
    {
 | 
			
		||||
        BINDER_TYPE_PTR, 0,
 | 
			
		||||
        { &test_hidl_vec_badcount2 },
 | 
			
		||||
        sizeof(HidlVec), 0, 0
 | 
			
		||||
        sizeof(GBinderHidlVec), 0, 0
 | 
			
		||||
    },{
 | 
			
		||||
        BINDER_TYPE_PTR, BINDER_BUFFER_FLAG_HAS_PARENT,
 | 
			
		||||
        { test_hidl_vec_badsize_data },
 | 
			
		||||
        sizeof(test_hidl_vec_badsize_data), 0,
 | 
			
		||||
        HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
        GBINDER_HIDL_VEC_BUFFER_OFFSET
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -835,6 +865,14 @@ typedef struct test_hidl_string_err {
 | 
			
		||||
} TestHidlStringErr;
 | 
			
		||||
 | 
			
		||||
static const guint8 test_hidl_string_err_short [] = { 0x00 };
 | 
			
		||||
static const guint8 test_hidl_string_err_bad_obj [] = {
 | 
			
		||||
    TEST_INT32_BYTES(BINDER_TYPE_HANDLE),
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00
 | 
			
		||||
};
 | 
			
		||||
static const guint8 test_hidl_string_err_empty [] = {
 | 
			
		||||
    TEST_INT32_BYTES(BINDER_TYPE_PTR),
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
@@ -849,6 +887,7 @@ static const guint test_hidl_string_err_one_offset [] = { 0 };
 | 
			
		||||
 | 
			
		||||
static const TestHidlStringErr test_hidl_string_err_tests [] = {
 | 
			
		||||
    { "no-data", TEST_ARRAY_AND_SIZE(test_hidl_string_err_short), NULL },
 | 
			
		||||
    { "no-object", TEST_ARRAY_AND_SIZE(test_hidl_string_err_bad_obj), NULL },
 | 
			
		||||
    { "no-offset", TEST_ARRAY_AND_SIZE(test_hidl_string_err_empty), NULL },
 | 
			
		||||
    { "empty-offset", TEST_ARRAY_AND_SIZE(test_hidl_string_err_empty),
 | 
			
		||||
        test_hidl_string_err_one_offset, 0 },
 | 
			
		||||
@@ -1004,7 +1043,7 @@ test_vec(
 | 
			
		||||
    GBinderReaderData data;
 | 
			
		||||
    GBinderReader reader;
 | 
			
		||||
    BinderObject64 obj;
 | 
			
		||||
    HidlVec vec;
 | 
			
		||||
    GBinderHidlVec vec;
 | 
			
		||||
    char** out;
 | 
			
		||||
 | 
			
		||||
    g_assert(ipc);
 | 
			
		||||
@@ -1129,37 +1168,100 @@ test_byte_array(
 | 
			
		||||
    gbinder_driver_unref(driver);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*==========================================================================*
 | 
			
		||||
 * copy
 | 
			
		||||
 *==========================================================================*/
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
void
 | 
			
		||||
test_copy(
 | 
			
		||||
    void)
 | 
			
		||||
{
 | 
			
		||||
    const char in_data1[] = "12345678";
 | 
			
		||||
    const char in_data2[] = "abcdefgh";
 | 
			
		||||
    gint32 in_len1 = sizeof(in_data1) - 1;
 | 
			
		||||
    gint32 in_len2 = sizeof(in_data2) - 1;
 | 
			
		||||
    const void* out_data = NULL;
 | 
			
		||||
    gsize out_len = 0;
 | 
			
		||||
    void* tmp;
 | 
			
		||||
    guint8* ptr;
 | 
			
		||||
    gsize tmp_len = 2 * sizeof(guint32) + in_len1 + in_len2;
 | 
			
		||||
 | 
			
		||||
    GBinderDriver* driver;
 | 
			
		||||
    GBinderReader reader;
 | 
			
		||||
    GBinderReader reader2;
 | 
			
		||||
    GBinderReaderData data;
 | 
			
		||||
 | 
			
		||||
    /* test for data */
 | 
			
		||||
    g_assert((driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER, NULL)));
 | 
			
		||||
    ptr = tmp = g_malloc0(tmp_len);
 | 
			
		||||
    memcpy(ptr, &in_len1, sizeof(in_len1));
 | 
			
		||||
    ptr += sizeof(in_len1);
 | 
			
		||||
    memcpy(ptr, in_data1, in_len1);
 | 
			
		||||
    ptr += in_len1;
 | 
			
		||||
    memcpy(ptr, &in_len2, sizeof(in_len2));
 | 
			
		||||
    ptr += sizeof(in_len2);
 | 
			
		||||
    memcpy(ptr, in_data2, in_len2);
 | 
			
		||||
 | 
			
		||||
    memset(&data, 0, sizeof(data));
 | 
			
		||||
    data.buffer = gbinder_buffer_new(driver, tmp, tmp_len);
 | 
			
		||||
    gbinder_reader_init(&reader, &data, 0, tmp_len);
 | 
			
		||||
 | 
			
		||||
    /* Read the first array */
 | 
			
		||||
    g_assert((out_data = gbinder_reader_read_byte_array(&reader, &out_len)));
 | 
			
		||||
    g_assert((gsize)in_len1 == out_len);
 | 
			
		||||
    g_assert(memcmp(in_data1, out_data, in_len1) == 0);
 | 
			
		||||
 | 
			
		||||
    /* Copy the reader */
 | 
			
		||||
    gbinder_reader_copy(&reader2, &reader);
 | 
			
		||||
 | 
			
		||||
    /* Read both and compare the output */
 | 
			
		||||
    g_assert((out_data = gbinder_reader_read_byte_array(&reader, &out_len)));
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader));
 | 
			
		||||
    g_assert((gsize)in_len2 == out_len);
 | 
			
		||||
    g_assert(memcmp(in_data2, out_data, in_len2) == 0);
 | 
			
		||||
 | 
			
		||||
    g_assert((out_data = gbinder_reader_read_byte_array(&reader2, &out_len)));
 | 
			
		||||
    g_assert(gbinder_reader_at_end(&reader2));
 | 
			
		||||
    g_assert((gsize)in_len2 == out_len);
 | 
			
		||||
    g_assert(memcmp(in_data2, out_data, in_len2) == 0);
 | 
			
		||||
 | 
			
		||||
    gbinder_buffer_free(data.buffer);
 | 
			
		||||
    gbinder_driver_unref(driver);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*==========================================================================*
 | 
			
		||||
 * Common
 | 
			
		||||
 *==========================================================================*/
 | 
			
		||||
 | 
			
		||||
#define TEST_PREFIX "/reader/"
 | 
			
		||||
#define TEST_(t) TEST_PREFIX t
 | 
			
		||||
 | 
			
		||||
int main(int argc, char* argv[])
 | 
			
		||||
{
 | 
			
		||||
    guint i;
 | 
			
		||||
 | 
			
		||||
    g_test_init(&argc, &argv, NULL);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "empty", test_empty);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "byte", test_byte);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "bool", test_bool);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "int32", test_int32);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "int64", test_int64);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "float", test_float);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "double", test_double);
 | 
			
		||||
    g_test_add_func(TEST_("empty"), test_empty);
 | 
			
		||||
    g_test_add_func(TEST_("byte"), test_byte);
 | 
			
		||||
    g_test_add_func(TEST_("bool"), test_bool);
 | 
			
		||||
    g_test_add_func(TEST_("int32"), test_int32);
 | 
			
		||||
    g_test_add_func(TEST_("int64"), test_int64);
 | 
			
		||||
    g_test_add_func(TEST_("float"), test_float);
 | 
			
		||||
    g_test_add_func(TEST_("double"), test_double);
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_string8_tests); i++) {
 | 
			
		||||
        const TestStringData* test = test_string8_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "/string8/", test->name, NULL);
 | 
			
		||||
        char* path = g_strconcat(TEST_("string8/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_string8);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "/string16/null", test_string16_null);
 | 
			
		||||
    g_test_add_func(TEST_("string16/null"), test_string16_null);
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_string16_tests); i++) {
 | 
			
		||||
        const TestStringData* test = test_string16_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "/string16/", test->name, NULL);
 | 
			
		||||
        char* path = g_strconcat(TEST_("string16/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_string16);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
@@ -1167,7 +1269,7 @@ int main(int argc, char* argv[])
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_hidl_struct_tests); i++) {
 | 
			
		||||
        const TestHidlStruct* test = test_hidl_struct_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "/hidl_struct/", test->name,
 | 
			
		||||
        char* path = g_strconcat(TEST_("hidl_struct/"), test->name,
 | 
			
		||||
            NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_hidl_struct);
 | 
			
		||||
@@ -1176,7 +1278,7 @@ int main(int argc, char* argv[])
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_hidl_vec_tests); i++) {
 | 
			
		||||
        const TestHidlVec* test = test_hidl_vec_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "/hidl_vec/", test->name,
 | 
			
		||||
        char* path = g_strconcat(TEST_("hidl_vec/"), test->name,
 | 
			
		||||
            NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_hidl_vec);
 | 
			
		||||
@@ -1185,18 +1287,19 @@ int main(int argc, char* argv[])
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_hidl_string_err_tests); i++) {
 | 
			
		||||
        const TestHidlStringErr* test = test_hidl_string_err_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "/hidl_string/err-", test->name,
 | 
			
		||||
        char* path = g_strconcat(TEST_("hidl_string/err-"), test->name,
 | 
			
		||||
            NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_hidl_string_err);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "/object/object", test_object);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "/object/object/invalid", test_object_invalid);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "/object/object/no_reg", test_object_no_reg);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "/vec", test_vec);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "/byte_array", test_byte_array);
 | 
			
		||||
    g_test_add_func(TEST_("object/valid"), test_object);
 | 
			
		||||
    g_test_add_func(TEST_("object/invalid"), test_object_invalid);
 | 
			
		||||
    g_test_add_func(TEST_("object/no_reg"), test_object_no_reg);
 | 
			
		||||
    g_test_add_func(TEST_("vec"), test_vec);
 | 
			
		||||
    g_test_add_func(TEST_("byte_array"), test_byte_array);
 | 
			
		||||
    g_test_add_func(TEST_("copy"), test_copy);
 | 
			
		||||
    test_init(&test_opt, argc, argv);
 | 
			
		||||
    return g_test_run();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -74,6 +74,7 @@ test_null(
 | 
			
		||||
    gbinder_writer_append_string16(&writer, NULL);
 | 
			
		||||
    gbinder_writer_append_string16_len(NULL, NULL, 0);
 | 
			
		||||
    gbinder_writer_append_string16_len(&writer, NULL, 0);
 | 
			
		||||
    gbinder_writer_append_string16_utf16(NULL, NULL, 0);
 | 
			
		||||
    gbinder_writer_append_bool(NULL, FALSE);
 | 
			
		||||
    gbinder_writer_append_bool(&writer, FALSE);
 | 
			
		||||
    gbinder_writer_append_bytes(NULL, NULL, 0);
 | 
			
		||||
@@ -342,6 +343,75 @@ test_string16(
 | 
			
		||||
    gbinder_local_request_unref(req);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*==========================================================================*
 | 
			
		||||
 * utf16
 | 
			
		||||
 *==========================================================================*/
 | 
			
		||||
 | 
			
		||||
typedef struct test_utf16_data {
 | 
			
		||||
    const char* name;
 | 
			
		||||
    const gunichar2* in;
 | 
			
		||||
    gssize in_len;
 | 
			
		||||
    const guint8* out;
 | 
			
		||||
    gssize out_len;
 | 
			
		||||
} TestUtf16Data;
 | 
			
		||||
 | 
			
		||||
static const guint8 utf16_tests_data_null[] = {
 | 
			
		||||
    TEST_INT32_BYTES(-1)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const guint8 utf16_tests_data_empty[] = {
 | 
			
		||||
    TEST_INT32_BYTES(0),
 | 
			
		||||
    0x00, 0x00, 0xff, 0xff
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const guint8 utf16_tests_data_x[] = {
 | 
			
		||||
    TEST_INT32_BYTES(1),
 | 
			
		||||
    TEST_INT16_BYTES('x'), 0x00, 0x00
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const guint8 utf16_tests_data_xy[] = {
 | 
			
		||||
    TEST_INT32_BYTES(2),
 | 
			
		||||
    TEST_INT16_BYTES('x'), TEST_INT16_BYTES('y'),
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const gunichar2 utf16_tests_input_empty[] = { 0 };
 | 
			
		||||
static const gunichar2 utf16_tests_input_x[] = { 'x', 0 };
 | 
			
		||||
static const gunichar2 utf16_tests_input_xy[] = { 'x', 'y', 0 };
 | 
			
		||||
 | 
			
		||||
static const TestUtf16Data test_utf16_tests[] = {
 | 
			
		||||
    { "null", NULL, -1,
 | 
			
		||||
      TEST_ARRAY_AND_SIZE(utf16_tests_data_null) },
 | 
			
		||||
    { "empty", utf16_tests_input_empty, -1,
 | 
			
		||||
      TEST_ARRAY_AND_SIZE(utf16_tests_data_empty) },
 | 
			
		||||
    { "1", utf16_tests_input_x, -1,
 | 
			
		||||
      TEST_ARRAY_AND_SIZE(utf16_tests_data_x) },
 | 
			
		||||
    { "2", utf16_tests_input_xy, 1,
 | 
			
		||||
      TEST_ARRAY_AND_SIZE(utf16_tests_data_x) },
 | 
			
		||||
    { "3", utf16_tests_input_xy, -1,
 | 
			
		||||
      TEST_ARRAY_AND_SIZE(utf16_tests_data_xy) }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
void
 | 
			
		||||
test_utf16(
 | 
			
		||||
    gconstpointer test_data)
 | 
			
		||||
{
 | 
			
		||||
    const TestUtf16Data* test = test_data;
 | 
			
		||||
    GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
 | 
			
		||||
    GBinderOutputData* data;
 | 
			
		||||
    GBinderWriter writer;
 | 
			
		||||
 | 
			
		||||
    gbinder_local_request_init_writer(req, &writer);
 | 
			
		||||
    gbinder_writer_append_string16_utf16(&writer, test->in, test->in_len);
 | 
			
		||||
    data = gbinder_local_request_data(req);
 | 
			
		||||
    g_assert(!gbinder_output_data_offsets(data));
 | 
			
		||||
    g_assert(!gbinder_output_data_buffers_size(data));
 | 
			
		||||
    g_assert(data->bytes->len == test->out_len);
 | 
			
		||||
    g_assert(!memcmp(data->bytes->data, test->out, test->out_len));
 | 
			
		||||
    gbinder_local_request_unref(req);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*==========================================================================*
 | 
			
		||||
 * hidl_vec
 | 
			
		||||
 *==========================================================================*/
 | 
			
		||||
@@ -366,15 +436,15 @@ static guint test_hidl_vec_offsets_64[] =
 | 
			
		||||
 | 
			
		||||
static const TestHidlVecData test_hidl_vec_tests[] = {
 | 
			
		||||
    { "32/null", &gbinder_io_32, NULL, 0, 0,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_vec_offsets_0), sizeof(HidlVec) },
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_vec_offsets_0), sizeof(GBinderHidlVec) },
 | 
			
		||||
    { "32/2x1", &gbinder_io_32, "xy", 2, 1,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_vec_offsets_32),
 | 
			
		||||
      sizeof(HidlVec) + 8 /* vec data aligned at 8 bytes boundary */ },
 | 
			
		||||
      sizeof(GBinderHidlVec) + 8 /* vec data aligned at 8 bytes boundary */ },
 | 
			
		||||
    { "64/null", &gbinder_io_64, NULL, 0, 0,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_vec_offsets_0), sizeof(HidlVec) },
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_vec_offsets_0), sizeof(GBinderHidlVec) },
 | 
			
		||||
    { "64/2x2", &gbinder_io_64, "xxyy", 2, 2,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_vec_offsets_64),
 | 
			
		||||
      sizeof(HidlVec) + 8 /* vec data aligned at 8 bytes boundary */ }
 | 
			
		||||
      sizeof(GBinderHidlVec) + 8 /* vec data aligned at 8 bytes boundary */ }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
@@ -425,15 +495,17 @@ static guint test_hidl_string_offsets_64[] =
 | 
			
		||||
 | 
			
		||||
static const TestHidlStringData test_hidl_string_tests[] = {
 | 
			
		||||
    { "32/null", &gbinder_io_32, NULL,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_offsets_0), sizeof(HidlString) },
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_offsets_0),
 | 
			
		||||
      sizeof(GBinderHidlString) },
 | 
			
		||||
    { "32/xxx", &gbinder_io_32, "xxx",
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_offsets_32),
 | 
			
		||||
      sizeof(HidlString) + 8 /* string data aligned at 8 bytes boundary */ },
 | 
			
		||||
      sizeof(GBinderHidlString) + 8 /* string data aligned at 8 bytes */ },
 | 
			
		||||
    { "64/null", &gbinder_io_64, NULL,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_offsets_0), sizeof(HidlString) },
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_offsets_0),
 | 
			
		||||
      sizeof(GBinderHidlString) },
 | 
			
		||||
    { "64/xxxxxxx", &gbinder_io_64, "xxxxxxx",
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_offsets_64),
 | 
			
		||||
      sizeof(HidlString) + 8 /* string data aligned at 8 bytes boundary */ }
 | 
			
		||||
      sizeof(GBinderHidlString) + 8 /* string data aligned at 8 bytes */ }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
@@ -481,8 +553,9 @@ test_hidl_string2(
 | 
			
		||||
    g_assert(offsets->data[0] == 0);
 | 
			
		||||
    g_assert(offsets->data[1] == BUFFER_OBJECT_SIZE_32);
 | 
			
		||||
    g_assert(offsets->data[2] == 2*BUFFER_OBJECT_SIZE_32);
 | 
			
		||||
    /* 2 HidlStrings + "foo" aligned at 8 bytes boundary */
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) == 2*sizeof(HidlString)+8);
 | 
			
		||||
    /* 2 GBinderHidlStrings + "foo" aligned at 8 bytes boundary */
 | 
			
		||||
    g_assert(gbinder_output_data_buffers_size(data) ==
 | 
			
		||||
        (2 * sizeof(GBinderHidlString) + 8));
 | 
			
		||||
 | 
			
		||||
    gbinder_local_request_unref(req);
 | 
			
		||||
}
 | 
			
		||||
@@ -513,18 +586,18 @@ static guint test_hidl_string_vec_offsets_1_64[] =
 | 
			
		||||
static const TestHidlStringVecData test_hidl_string_vec_tests[] = {
 | 
			
		||||
    { "32/null", &gbinder_io_32, NULL, -1,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_vec_offsets_empty),
 | 
			
		||||
      sizeof(HidlVec) },
 | 
			
		||||
      sizeof(GBinderHidlVec) },
 | 
			
		||||
    { "32/1", &gbinder_io_32,
 | 
			
		||||
      (const char**)TEST_ARRAY_AND_COUNT(test_hidl_string_vec_data_1),
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_vec_offsets_1_32),
 | 
			
		||||
      sizeof(HidlVec) + sizeof(HidlString) + 8 },
 | 
			
		||||
      sizeof(GBinderHidlVec) + sizeof(GBinderHidlString) + 8 },
 | 
			
		||||
    { "64/null", &gbinder_io_64, NULL, -1,
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_vec_offsets_empty),
 | 
			
		||||
      sizeof(HidlVec) },
 | 
			
		||||
      sizeof(GBinderHidlVec) },
 | 
			
		||||
    { "64/1", &gbinder_io_64,
 | 
			
		||||
      (const char**)TEST_ARRAY_AND_COUNT(test_hidl_string_vec_data_1),
 | 
			
		||||
      TEST_ARRAY_AND_COUNT(test_hidl_string_vec_offsets_1_64),
 | 
			
		||||
      sizeof(HidlVec) + sizeof(HidlString) + 8 },
 | 
			
		||||
      sizeof(GBinderHidlVec) + sizeof(GBinderHidlString) + 8 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
@@ -742,41 +815,50 @@ test_byte_array(
 | 
			
		||||
 *==========================================================================*/
 | 
			
		||||
 | 
			
		||||
#define TEST_PREFIX "/writer/"
 | 
			
		||||
#define TEST_(t) TEST_PREFIX t
 | 
			
		||||
 | 
			
		||||
int main(int argc, char* argv[])
 | 
			
		||||
{
 | 
			
		||||
    guint i;
 | 
			
		||||
 | 
			
		||||
    g_test_init(&argc, &argv, NULL);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "null", test_null);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "int32", test_int32);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "int64", test_int64);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "float", test_float);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "double", test_double);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "bool", test_bool);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "bytes", test_bytes);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "string8", test_string8);
 | 
			
		||||
    g_test_add_func(TEST_("null"), test_null);
 | 
			
		||||
    g_test_add_func(TEST_("int32"), test_int32);
 | 
			
		||||
    g_test_add_func(TEST_("int64"), test_int64);
 | 
			
		||||
    g_test_add_func(TEST_("float"), test_float);
 | 
			
		||||
    g_test_add_func(TEST_("double"), test_double);
 | 
			
		||||
    g_test_add_func(TEST_("bool"), test_bool);
 | 
			
		||||
    g_test_add_func(TEST_("bytes"), test_bytes);
 | 
			
		||||
    g_test_add_func(TEST_("string8"), test_string8);
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_string16_tests); i++) {
 | 
			
		||||
        const TestString16Data* test = test_string16_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "string16/", test->name, NULL);
 | 
			
		||||
        char* path = g_strconcat(TEST_("string16/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_string16);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_utf16_tests); i++) {
 | 
			
		||||
        const TestUtf16Data* test = test_utf16_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_("utf16/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_utf16);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_hidl_vec_tests); i++) {
 | 
			
		||||
        const TestHidlVecData* test = test_hidl_vec_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "hidl_vec/", test->name, NULL);
 | 
			
		||||
        char* path = g_strconcat(TEST_("hidl_vec/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_hidl_vec);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "hidl_string/2strings", test_hidl_string2);
 | 
			
		||||
    g_test_add_func(TEST_("hidl_string/2strings"), test_hidl_string2);
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_hidl_string_tests); i++) {
 | 
			
		||||
        const TestHidlStringData* test = test_hidl_string_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "hidl_string/", test->name, NULL);
 | 
			
		||||
        char* path = g_strconcat(TEST_("hidl_string/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_hidl_string);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
@@ -784,18 +866,17 @@ int main(int argc, char* argv[])
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < G_N_ELEMENTS(test_hidl_string_vec_tests); i++) {
 | 
			
		||||
        const TestHidlStringVecData* test = test_hidl_string_vec_tests + i;
 | 
			
		||||
        char* path = g_strconcat(TEST_PREFIX "hidl_string_vec/",
 | 
			
		||||
            test->name, NULL);
 | 
			
		||||
        char* path = g_strconcat(TEST_("hidl_string_vec/"), test->name, NULL);
 | 
			
		||||
 | 
			
		||||
        g_test_add_data_func(path, test, test_hidl_string_vec);
 | 
			
		||||
        g_free(path);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "buffer", test_buffer);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "parent", test_parent);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "local_object", test_local_object);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "remote_object", test_remote_object);
 | 
			
		||||
    g_test_add_func(TEST_PREFIX "byte_array", test_byte_array);
 | 
			
		||||
    g_test_add_func(TEST_("buffer"), test_buffer);
 | 
			
		||||
    g_test_add_func(TEST_("parent"), test_parent);
 | 
			
		||||
    g_test_add_func(TEST_("local_object"), test_local_object);
 | 
			
		||||
    g_test_add_func(TEST_("remote_object"), test_remote_object);
 | 
			
		||||
    g_test_add_func(TEST_("byte_array"), test_byte_array);
 | 
			
		||||
    test_init(&test_opt, argc, argv);
 | 
			
		||||
    return g_test_run();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user