diff --git a/Android.bp b/Android.bp index a494c8a..adf427b 100644 --- a/Android.bp +++ b/Android.bp @@ -335,6 +335,14 @@ cc_library_shared { vendor_available: true, } +cc_library_shared { + name: "libutils_shim", + shared_libs: ["libutils"], + srcs: ["libutils/String16.cpp"], + system_ext_specific: true, + vendor_available: true, +} + cc_library { name: "libip_checksum_shim", whole_static_libs: [ diff --git a/libutils/String16.cpp b/libutils/String16.cpp new file mode 100644 index 0000000..ef0e3bd --- /dev/null +++ b/libutils/String16.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +extern "C" { +char16_t* strncpy16(char16_t* dst, const char16_t* src, size_t n) { + char16_t* q = dst; + const char16_t* p = src; + char ch; + while (n) { + n--; + *q++ = ch = *p++; + if (!ch) break; + } + *q = 0; + return dst; +} +}