tulip: Update CNE and DPM blobs from ddv_sprout

Signed-off-by: Vivekachooz <vivekachooz@gmail.com>
Change-Id: I163776edfd9bfcb41d742ae13c124dd83a68dde1
This commit is contained in:
Vivekachooz
2022-02-28 22:06:07 +05:30
committed by Le Hong Duc
parent 9407cb22cd
commit effac2a959
9 changed files with 60 additions and 447 deletions

View File

@@ -396,7 +396,6 @@ PRODUCT_PACKAGES += \
# Shims
PRODUCT_PACKAGES += \
libcamera_sdm660_shim \
libshim_dpmframework \
libpiex_shim
# Tetheroffload

View File

@@ -76,11 +76,6 @@ function blob_fixup() {
system_ext/etc/permissions/qcrilhook.xml)
sed -i 's|/product/framework/qcrilhook.jar|/system_ext/framework/qcrilhook.jar|g' "${2}"
;;
system_ext/lib64/libdpmframework.so)
for LIBSHIM_DPMFRAMEWORK in $(grep -L "libshim_dpmframework.so" "${2}"); do
"${PATCHELF}" --add-needed "libshim_dpmframework.so" "$LIBSHIM_DPMFRAMEWORK"
done
;;
vendor/bin/mlipayd@1.1)
"${PATCHELF}" --remove-needed vendor.xiaomi.hardware.mtdservice@1.0.so "${2}"
;;

View File

@@ -157,7 +157,7 @@
<hal format="hidl">
<name>vendor.qti.data.factory</name>
<transport>hwbinder</transport>
<fqname>@2.1::IFactory/default</fqname>
<fqname>@2.2::IFactory/default</fqname>
</hal>
<hal format="hidl">
<name>vendor.qti.esepowermanager</name>

View File

@@ -684,13 +684,10 @@ vendor/lib/libft2vendor.so|1332ed2141660b9372c959ca1155575c25a73751
# Charger - from jasmine
vendor/bin/hvdcp_opti|120837d6d44abfd86515731dd26183be9cdd5596
# CNE - from jasmine
etc/cne/Nexus/ATT/ATT_profiles.xml|33e568627fd3f94dc45bca1c01ad10e6d8fb5b52
etc/cne/Nexus/ROW/ROW_profiles.xml|238e785e9674b27c4b2365958d127533d7293132
etc/cne/Nexus/VZW/VZW_profiles.xml|0f63b632e3a3f114def7aeadaabd13851c8ceec5
-vendor/app/CneApp/CneApp.apk|2356a0335ab8e0106832a9325f972467654fd1f0
-vendor/app/IWlanService/IWlanService.apk|450aa6da382446125d06f328f8c1a0e2e33e52bb
vendor/bin/cnd|ca653a8064fe83a12a12798a73c9cc8c1fecf758
# CNE - from m690-user 11 RKQ1.210607.001 00WW_3_440 release-keys
-vendor/app/CneApp/CneApp.apk|13bdf6ba5637d3df3d6d9fb0017f9f56ddc620e7
-vendor/app/IWlanService/IWlanService.apk|a189d8879b4cf5026db2d6a80abb3a1319e38f0c
vendor/bin/cnd|07829b294562037b779a6e7244972d7c24e758a5
vendor/etc/cne/wqeclient/ATT/ATT_profile1.xml|578f3f8f56059bfdbef926bcc68d01c15e06951f
vendor/etc/cne/wqeclient/ATT/ATT_profile2.xml|1fb42c672a12b6660bdce3ea94e0c43719dd9de8
vendor/etc/cne/wqeclient/ATT/ATT_profile3.xml|f88e13f1dd7b82388c90358f71813026370c9ed8
@@ -698,45 +695,53 @@ vendor/etc/cne/wqeclient/ATT/ATT_profile4.xml|fb08e04f57797c5684bf734f7ce4bb4968
vendor/etc/cne/wqeclient/ATT/ATT_profile5.xml|eb726ad1a42b9b78b9ee3b821fc108611bc9eeac
vendor/etc/cne/wqeclient/ATT/ATT_profile6.xml|be97b46b0d07ee2f6ebcc677d8099ed2140d5d85
vendor/etc/cne/wqeclient/ROW/ROW_profile1.xml|e7ca213d0998cb3a6a603ad3eca7bda69830ff55
vendor/etc/cne/wqeclient/ROW/ROW_profile2.xml|169a5209000e357a1a3183e8e5bfdf6fd07c2787
vendor/etc/cne/wqeclient/ROW/ROW_profile3.xml|4be4060e8ac2d9fcea490feec7938cadcff46e1f
vendor/etc/cne/wqeclient/ROW/ROW_profile4.xml|f88e13f1dd7b82388c90358f71813026370c9ed8
vendor/etc/cne/wqeclient/ROW/ROW_profile5.xml|96101f6b01436a02572c67a469ff67ccfb738874
vendor/etc/cne/wqeclient/ROW/ROW_profile6.xml|cef14ff8a160c7ad719b85d024a4b3301c3638d0
vendor/etc/cne/wqeclient/ROW/ROW_profile7.xml|8d6773a4c418d0dcc4dc9096017d2681c7a1defe
vendor/etc/cne/wqeclient/ROW/ROW_profile15.xml|0130dfd8326ee710bf4e15718ede87c49a85b763
vendor/etc/cne/wqeclient/ROW/ROW_profile16.xml|e05b935d7ccf48d306b71c719b2e4df83187d9c0
vendor/etc/cne/wqeclient/ROW/ROW_profile17.xml|f1b33204799268eda78dd8314f26abf2e37431e2
vendor/etc/cne/wqeclient/ROW/ROW_profile18.xml|19db16f62dabb806a62f192858a9d52b5bc2a064
vendor/etc/cne/wqeclient/ROW/ROW_profile19.xml|1fcc57b1fa4dbbc7d250e8dd92acf1527d447eb3
vendor/etc/cne/wqeclient/ROW/ROW_profile2.xml|169a5209000e357a1a3183e8e5bfdf6fd07c2787
vendor/etc/cne/wqeclient/ROW/ROW_profile20.xml|7be0614cf0116c39b736c58fe5eca36838aeb3db
vendor/etc/cne/wqeclient/ROW/ROW_profile21.xml|cc62517e6c37e12ee1ebebbb27f9c22878749be3
vendor/etc/cne/wqeclient/ROW/ROW_profile3.xml|4be4060e8ac2d9fcea490feec7938cadcff46e1f
vendor/etc/cne/wqeclient/ROW/ROW_profile32.xml|b87542b9284efe4c2bd0ae868bb9a765c2c3dbc5
vendor/etc/cne/wqeclient/ROW/ROW_profile4.xml|f88e13f1dd7b82388c90358f71813026370c9ed8
vendor/etc/cne/wqeclient/ROW/ROW_profile5.xml|96101f6b01436a02572c67a469ff67ccfb738874
vendor/etc/cne/wqeclient/ROW/ROW_profile6.xml|cef14ff8a160c7ad719b85d024a4b3301c3638d0
vendor/etc/cne/wqeclient/ROW/ROW_profile7.xml|8d6773a4c418d0dcc4dc9096017d2681c7a1defe
vendor/etc/cne/wqeclient/VZW/VZW_profile1.xml|c89d3c062790b442cbe941cafc641a4e322f2d59
vendor/etc/cne/wqeclient/VZW/VZW_profile2.xml|ba14a9df975cf872ed0cbe28bee8fac63cd848d4
vendor/etc/cne/wqeclient/VZW/VZW_profile3.xml|9b123d81c9b8991499cda33b0706810e0c8fb974
vendor/etc/cne/wqeclient/VZW/VZW_profile4.xml|ff91feb5060a6df07e3e4d9bc99ae58bccad7649
vendor/etc/cne/wqeclient/VZW/VZW_profile5.xml|f76c894f3c6d5b6ed35113a088dc3174c900501b
vendor/etc/cne/wqeclient/VZW/VZW_profile6.xml|14d136e7fcc682311757d3edc0b9d3eaeba11815
vendor/etc/init/cnd.rc|ff205cff8e00ec6805fd1e19f3ca6ff86700cbb6
vendor/lib64/libcne.so|1344c4749026a55eee9e3a814c7a71b6733e08fb
vendor/lib64/libcneapiclient.so|a99c0ebb180bca17ed05c2ac348ee8e16227a5a3
vendor/lib64/libcneoplookup.so|99dbc1b2ae37181ae49a72d581fe53abe8207c42
vendor/lib64/libcneqmiutils.so|f2fc09230fdf877020f734451c13a6adb749838d
vendor/lib64/libwms.so|19a39c776120515292dc821599cf504a5fd600b3
vendor/lib64/libwqe.so|e762bb803cdb4fa55224df58e06c3a5bca5f36a7
vendor/lib64/libxml.so|9fa23668a2ab5fb0aff7e694fe44fb050b20f83d
vendor/lib64/vendor.qti.data.factory@2.0.so|428b56ac165ba30c450a1e191db9b386752f653b
vendor/lib64/vendor.qti.hardware.data.cne.internal.api@1.0.so|fc8634f7cf90524c24c45d8771eec888d652db92
vendor/lib64/vendor.qti.hardware.data.cne.internal.constants@1.0.so|ffa8e4013bc1bd8bd44e3d64c278be0d36274f6e
vendor/lib64/vendor.qti.hardware.data.cne.internal.server@1.0.so|f4e1e9991fa90546dfe0d4f9c7da8441b6a0af35
vendor/lib64/vendor.qti.hardware.data.connection@1.0.so|e2f77b104fbc3abe7423fc24743051b69cc887be
vendor/lib64/vendor.qti.hardware.data.connection@1.1.so|7b2e00bfbc40280a520dffc3eb99c68c1832761d
vendor/lib64/vendor.qti.hardware.data.dynamicdds@1.0.so|bf7766fbd49a3aa3426a93ab82bcd825cc72334a
vendor/lib64/vendor.qti.hardware.data.iwlan@1.0.so|c471659fc3fb56dcdcda183e080397a737e4708b
vendor/lib64/vendor.qti.hardware.data.latency@1.0.so|ff7a319e51ddd4de14af28a84f7bca5e82547f6e
vendor/lib64/vendor.qti.hardware.data.qmi@1.0.so|90f1106f7462a9e01721e1159ed3301579adee07
vendor/lib64/vendor.qti.latency@2.0.so|91a8b05b20485057ee9f42c55ce70207ef6af761
vendor/etc/init/cnd.rc|3a5183df3479500fb729493bc56c71166fc10bce
vendor/lib64/libcne.so|1e0ea712d0c62168e527780bc525be99cf24da64
vendor/lib64/libcneapiclient.so|b6479678e5b0e8b46d8df5eb8bd610aa17be00d0
vendor/lib64/libcneoplookup.so|60d6abe85061de4fa75e5e4f69d477f37f1f8f64
vendor/lib64/libcneqmiutils.so|c2e2658698eb8b312ca6b28c1a1088a331bb28b9
vendor/lib64/libwms.so|1b23b338937081f2f911680d5c9021951f93439d
vendor/lib64/libwqe.so|5a955d19151ad220446df0c49825714dd71a5d8b
vendor/lib64/libxml.so|11c11c2fb6b713855532a3709f78935f8c98a766
vendor/lib64/vendor.qti.data.factory@2.0.so|748bfbaa57a409b8962e2b1725e1415e423a7315
vendor/lib64/vendor.qti.data.factory@2.1.so|bb1f3fa22563282ee24bf03ca681fdc45551feef
vendor/lib64/vendor.qti.data.factory@2.2.so|6951ff98d20902678e8af584c7b4cf89e360f31b
vendor/lib64/vendor.qti.data.factory@2.3.so|e9992039c400ef5fb57db62e108873a219348b4c
vendor/lib64/vendor.qti.data.mwqem@1.0.so|cde93c45f93a82091513d31535f188569dda89fe
vendor/lib64/vendor.qti.data.slm@1.0.so|0b5e88dfdb4fd0fb3c890f0aa3405ef268814da9
vendor/lib64/vendor.qti.hardware.data.cne.internal.api@1.0.so|e4d002e61b2d6a4d3826e0563ee16cac74696833
vendor/lib64/vendor.qti.hardware.data.cne.internal.constants@1.0.so|f87a303f7a092c4d18b7db91d5162a777c920817
vendor/lib64/vendor.qti.hardware.data.cne.internal.server@1.0.so|7d80cd3bda9fd34dd1629116124579e5a4a787f5
vendor/lib64/vendor.qti.hardware.data.connection@1.0.so|39bf1d748c3bb90d38be5d031dcd0024b1f2bb2f
vendor/lib64/vendor.qti.hardware.data.connection@1.1.so|702dd62c50c91446de473f32e31da3a85ba0aea9
vendor/lib64/vendor.qti.hardware.data.dynamicdds@1.0.so|4494ebdbbcfa79a0ed5ac3445cf0e2e417742bc1
vendor/lib64/vendor.qti.hardware.data.iwlan@1.0.so|e67ecee0938f81d3241a5acf140d7fc7d24db469
vendor/lib64/vendor.qti.hardware.data.latency@1.0.so|c433c73b5469b787cb7fb70b05b83190b319edd6
vendor/lib64/vendor.qti.hardware.data.lce@1.0.so|80d8502e6458ecf0883a029c2777c24574d29485
vendor/lib64/vendor.qti.hardware.data.qmi@1.0.so|851db5940d5e9e4330e16221be114aef14f52325
vendor/lib64/vendor.qti.latency@2.0.so|60ab3143325e855f8c72e3f603c28efe2e7227b9
vendor/lib64/vendor.qti.latency@2.1.so|47f0d25338274af94764be9d39eabef8cf5ca790
vendor/lib64/vendor.qti.hardware.mwqemadapter@1.0.so|c041dbfc99643e791e52c4e7f3a87050a8cd6c93
# ConsumerIR (lirc) - from jason V12.0.1.0.PCHCNXM
vendor/lib64/hw/consumerir.default.so:vendor/lib64/hw/consumerir.lirc.sdm660.so|8c614f98e2a42b5ba9e148c01b3d69e7fb59ce1d
@@ -744,24 +749,25 @@ vendor/lib64/hw/consumerir.default.so:vendor/lib64/hw/consumerir.lirc.sdm660.so|
# ConsumerIR (spi) - from jasmine V11.0.28.0.QDIMIXM
vendor/lib64/hw/consumerir.default.so:vendor/lib64/hw/consumerir.spi.sdm660.so|d1f275a91557dfab52e82906986c5094fe078722
# DPM - from jasmine
product/bin/dpmd:system_ext/bin/dpmd|49caa8e7d8af8055efdd7ebc0d7f7d67bc600041
product/etc/dpm/dpm.conf:system_ext/etc/dpm/dpm.conf|95e27da8c989e96c6faea6f0697bce11955b62a5
product/etc/init/dpmd.rc:system_ext/etc/init/dpmd.rc|f061bb76ae844f6df04c1d78caf00cf29a41b112
product/etc/permissions/com.qti.dpmframework.xml:system_ext/etc/permissions/com.qti.dpmframework.xml|ab94e634782b7a2e833ce129eda74cb9333ed3f7
product/etc/permissions/dpmapi.xml:system_ext/etc/permissions/dpmapi.xml|697c88d7ebef6232ef214b17b4023bbb3ff4e625
product/framework/com.qti.dpmframework.jar:system_ext/framework/com.qti.dpmframework.jar|e39a7e06af2d1e95a3724c19c36b8716277f53a1
product/framework/dpmapi.jar:system_ext/framework/dpmapi.jar|4696df9793ad676b305d53b5d7ce65ecf74771ad
product/lib64/com.qualcomm.qti.dpm.api@1.0.so:system_ext/lib64/com.qualcomm.qti.dpm.api@1.0.so|a763bb1bbeecb84723bff6f547a3b23fab68dee3
product/lib64/libdpmctmgr.so:system_ext/lib64/libdpmctmgr.so|3d4b87a4937caf3a8d276f48a4f0dc2cad246c5b
product/lib64/libdpmfdmgr.so:system_ext/lib64/libdpmfdmgr.so|e809155312a05d83b323ab0be64cb393d936e52a
product/lib64/libdpmframework.so:system_ext/lib64/libdpmframework.so|8fd037eb8740a468a67c78e7fa01c69b1ba3fd2a|dad2493b5d4f42078713066130b0703af449c82f
product/lib64/libdpmtcm.so:system_ext/lib64/libdpmtcm.so|71a3d624602807f6fa6cbdb3a489efe9e93de634
-product/priv-app/dpmserviceapp/dpmserviceapp.apk:system_ext/priv-app/dpmserviceapp/dpmserviceapp.apk|9fd873c5330c03c62dfdeb6540b5984588295319
vendor/bin/dpmQmiMgr|d536096b310a2d3f30a683c1bdcad8658db1ba52
vendor/etc/init/dpmQmiMgr.rc|67569302d3a8828a9118c835e5b69c51b0c8ac68
vendor/lib64/com.qualcomm.qti.dpm.api@1.0.so|fbff6357ee46dd6d62f490a942ff567b6ce955d1
vendor/lib64/libdpmqmihal.so|30a170684219dd589d05ce5b446e73b7501f13e3
# DPM - from m690-user 11 RKQ1.210607.001 00WW_3_440 release-keys
system_ext/bin/dpmd|4662a11c5331919cc08d541a298444ffce18cc1b
system_ext/etc/dpm/dpm.conf|95e27da8c989e96c6faea6f0697bce11955b62a5
system_ext/etc/init/dpmd.rc|738b638ff04cda368e22c03e16baf90ba157a6fc
system_ext/etc/permissions/com.qti.dpmframework.xml|c4b7ad0879d00c1eba4f3fe3a88ddb8aa153629a
system_ext/etc/permissions/dpmapi.xml|9158c9789cc7135a685b3fb27f8cc27108b51fef
system_ext/framework/com.qti.dpmframework.jar|96a29e28b3abffb9223daadd67459e3f5a3271df
system_ext/framework/dpmapi.jar|2e2fbe2257a697b96a644c774136da0554430d3f
system_ext/lib64/com.qualcomm.qti.dpm.api@1.0.so|b992e1f565f7b8b814eac0c88517543e6d0de603
system_ext/lib64/libdpmctmgr.so|8a687fce30df9483a96065e6cc4154f03562dfa9
system_ext/lib64/libdpmfdmgr.so|bf3666db17e77da3a303c10579baec0bd018089f
system_ext/lib64/libdpmframework.so|235fbb48b47baebd48dbe56f72c77d97ca12c07c
system_ext/lib64/libdpmtcm.so|dff3d3dbacd18ed55b5758a174f5016ef9e7a896
system_ext/lib64/vendor.qti.diaghal@1.0.so|abe51fdbdcbf3449012395cf0ade8aa8d267dbe6
-system_ext/priv-app/dpmserviceapp/dpmserviceapp.apk|61a4e791ebd5c3bc4025fd0242b029b388530b98
vendor/bin/dpmQmiMgr|3c553042d4257161adb75c0979c829b0cb050639
vendor/etc/init/dpmQmiMgr.rc|1538743661a5c48c15cd105beaad20f72953885a
vendor/lib64/com.qualcomm.qti.dpm.api@1.0.so|d9f1aa7f93b928f42499d613d20ccbc60f279097
vendor/lib64/libdpmqmihal.so|41eb89e66ba065c43a5eb79cd3c72cef0ee167aa
# DRM - from jasmine
vendor/bin/qseecomd|0c5e6d088e4d5600ce08915e7ef6ef28a99a2611

View File

@@ -15,3 +15,6 @@ bluetooth.profile.pan.nap.enabled=true
bluetooth.profile.pan.panu.enabled=true
bluetooth.profile.pbap.server.enabled=true
bluetooth.profile.sap.server.enabled=true
# DPM
persist.vendor.dpm.feature=11

View File

@@ -13,12 +13,3 @@ cc_library_shared {
],
vendor: true,
}
cc_library {
name: "libshim_dpmframework",
srcs: [
"libshim_dpmframework/strdup16to8.cpp",
"libshim_dpmframework/strdup8to16.cpp",
],
product_specific: true,
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <stddef.h>
extern "C" {
#if __STDC_VERSION__ < 201112L && __cplusplus < 201103L
typedef uint16_t char16_t;
#endif
extern char * strndup16to8 (const char16_t* s, size_t n);
extern size_t strnlen16to8 (const char16_t* s, size_t n);
extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n);
extern char16_t * strdup8to16 (const char* s, size_t *out_len);
extern size_t strlen8to16 (const char* utf8Str);
extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len);
}

View File

@@ -1,167 +0,0 @@
/* libs/cutils/strdup16to8.c
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include "jstring.h"
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
/**
* Convert a UTF-16 string to UTF-8.
*
*/
char * strndup16to8 (const char16_t* s, size_t n)
{
if (s == NULL) {
return NULL;
}
size_t len = strnlen16to8(s, n);
/* We are paranoid, and we check for SIZE_MAX-1
* too since it is an overflow value for our
* strnlen16to8 implementation.
*/
if (len >= SIZE_MAX-1)
return NULL;
char* ret = static_cast<char*>(malloc(len + 1));
if (ret == NULL)
return NULL;
strncpy16to8 (ret, s, n);
return ret;
}
/**
* Given a UTF-16 string, compute the length of the corresponding UTF-8
* string in bytes.
*/
extern size_t strnlen16to8(const char16_t* utf16Str, size_t len)
{
size_t utf8Len = 0;
/* A small note on integer overflow. The result can
* potentially be as big as 3*len, which will overflow
* for len > SIZE_MAX/3.
*
* Moreover, the result of a strnlen16to8 is typically used
* to allocate a destination buffer to strncpy16to8 which
* requires one more byte to terminate the UTF-8 copy, and
* this is generally done by careless users by incrementing
* the result without checking for integer overflows, e.g.:
*
* dst = malloc(strnlen16to8(utf16,len)+1)
*
* Due to this, the following code will try to detect
* overflows, and never return more than (SIZE_MAX-1)
* when it detects one. A careless user will try to malloc
* SIZE_MAX bytes, which will return NULL which can at least
* be detected appropriately.
*
* As far as I know, this function is only used by strndup16(),
* but better be safe than sorry.
*/
/* Fast path for the usual case where 3*len is < SIZE_MAX-1.
*/
if (len < (SIZE_MAX-1)/3) {
while (len != 0) {
len--;
unsigned int uic = *utf16Str++;
if (uic > 0x07ff)
utf8Len += 3;
else if (uic > 0x7f || uic == 0)
utf8Len += 2;
else
utf8Len++;
}
return utf8Len;
}
/* The slower but paranoid version */
while (len != 0) {
len--;
unsigned int uic = *utf16Str++;
size_t utf8Cur = utf8Len;
if (uic > 0x07ff)
utf8Len += 3;
else if (uic > 0x7f || uic == 0)
utf8Len += 2;
else
utf8Len++;
if (utf8Len < utf8Cur) /* overflow detected */
return SIZE_MAX-1;
}
/* don't return SIZE_MAX to avoid common user bug */
if (utf8Len == SIZE_MAX)
utf8Len = SIZE_MAX-1;
return utf8Len;
}
/**
* Convert a Java-Style UTF-16 string + length to a JNI-Style UTF-8 string.
*
* This basically means: embedded \0's in the UTF-16 string are encoded
* as "0xc0 0x80"
*
* Make sure you allocate "utf8Str" with the result of strlen16to8() + 1,
* not just "len".
*
* Please note, a terminated \0 is always added, so your result will always
* be "strlen16to8() + 1" bytes long.
*/
extern char* strncpy16to8(char* utf8Str, const char16_t* utf16Str, size_t len)
{
char* utf8cur = utf8Str;
/* Note on overflows: We assume the user did check the result of
* strnlen16to8() properly or at a minimum checked the result of
* its malloc(SIZE_MAX) in case of overflow.
*/
while (len != 0) {
len--;
unsigned int uic = *utf16Str++;
if (uic > 0x07ff) {
*utf8cur++ = (uic >> 12) | 0xe0;
*utf8cur++ = ((uic >> 6) & 0x3f) | 0x80;
*utf8cur++ = (uic & 0x3f) | 0x80;
} else if (uic > 0x7f || uic == 0) {
*utf8cur++ = (uic >> 6) | 0xc0;
*utf8cur++ = (uic & 0x3f) | 0x80;
} else {
*utf8cur++ = uic;
if (uic == 0) {
break;
}
}
}
*utf8cur = '\0';
return utf8Str;
}

View File

@@ -1,178 +0,0 @@
/* libs/cutils/strdup8to16.c
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include "jstring.h"
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
/* See http://www.unicode.org/reports/tr22/ for discussion
* on invalid sequences
*/
#define UTF16_REPLACEMENT_CHAR 0xfffd
/* Clever trick from Dianne that returns 1-4 depending on leading bit sequence*/
#define UTF8_SEQ_LENGTH(ch) (((0xe5000000 >> (((ch) >> 3) & 0x1e)) & 3) + 1)
/* note: macro expands to multiple lines */
#define UTF8_SHIFT_AND_MASK(unicode, byte) \
(unicode)<<=6; (unicode) |= (0x3f & (byte));
#define UNICODE_UPPER_LIMIT 0x10fffd
/**
* out_len is an out parameter (which may not be null) containing the
* length of the UTF-16 string (which may contain embedded \0's)
*/
extern char16_t * strdup8to16 (const char* s, size_t *out_len)
{
char16_t *ret;
size_t len;
if (s == NULL) return NULL;
len = strlen8to16(s);
// fail on overflow
if (len && SIZE_MAX/len < sizeof(char16_t))
return NULL;
// no plus-one here. UTF-16 strings are not null terminated
ret = (char16_t *) malloc (sizeof(char16_t) * len);
return strcpy8to16 (ret, s, out_len);
}
/**
* Like "strlen", but for strings encoded with Java's modified UTF-8.
*
* The value returned is the number of UTF-16 characters required
* to represent this string.
*/
extern size_t strlen8to16 (const char* utf8Str)
{
size_t len = 0;
int ic;
int expected = 0;
while ((ic = *utf8Str++) != '\0') {
/* bytes that start 0? or 11 are lead bytes and count as characters.*/
/* bytes that start 10 are extention bytes and are not counted */
if ((ic & 0xc0) == 0x80) {
/* count the 0x80 extention bytes. if we have more than
* expected, then start counting them because strcpy8to16
* will insert UTF16_REPLACEMENT_CHAR's
*/
expected--;
if (expected < 0) {
len++;
}
} else {
len++;
expected = UTF8_SEQ_LENGTH(ic) - 1;
/* this will result in a surrogate pair */
if (expected == 3) {
len++;
}
}
}
return len;
}
/*
* Retrieve the next UTF-32 character from a UTF-8 string.
*
* Stops at inner \0's
*
* Returns UTF16_REPLACEMENT_CHAR if an invalid sequence is encountered
*
* Advances "*pUtf8Ptr" to the start of the next character.
*/
static inline uint32_t getUtf32FromUtf8(const char** pUtf8Ptr)
{
uint32_t ret;
int seq_len;
int i;
/* Mask for leader byte for lengths 1, 2, 3, and 4 respectively*/
static const unsigned char leaderMask[4] = {0xff, 0x1f, 0x0f, 0x07};
/* Bytes that start with bits "10" are not leading characters. */
if (((**pUtf8Ptr) & 0xc0) == 0x80) {
(*pUtf8Ptr)++;
return UTF16_REPLACEMENT_CHAR;
}
/* note we tolerate invalid leader 11111xxx here */
seq_len = UTF8_SEQ_LENGTH(**pUtf8Ptr);
ret = (**pUtf8Ptr) & leaderMask [seq_len - 1];
if (**pUtf8Ptr == '\0') return ret;
(*pUtf8Ptr)++;
for (i = 1; i < seq_len ; i++, (*pUtf8Ptr)++) {
if ((**pUtf8Ptr) == '\0') return UTF16_REPLACEMENT_CHAR;
if (((**pUtf8Ptr) & 0xc0) != 0x80) return UTF16_REPLACEMENT_CHAR;
UTF8_SHIFT_AND_MASK(ret, **pUtf8Ptr);
}
return ret;
}
/**
* out_len is an out parameter (which may not be null) containing the
* length of the UTF-16 string (which may contain embedded \0's)
*/
extern char16_t * strcpy8to16 (char16_t *utf16Str, const char*utf8Str,
size_t *out_len)
{
char16_t *dest = utf16Str;
while (*utf8Str != '\0') {
uint32_t ret;
ret = getUtf32FromUtf8(&utf8Str);
if (ret <= 0xffff) {
*dest++ = (char16_t) ret;
} else if (ret <= UNICODE_UPPER_LIMIT) {
/* Create surrogate pairs */
/* See http://en.wikipedia.org/wiki/UTF-16/UCS-2#Method_for_code_points_in_Plane_1.2C_Plane_2 */
*dest++ = 0xd800 | ((ret - 0x10000) >> 10);
*dest++ = 0xdc00 | ((ret - 0x10000) & 0x3ff);
} else {
*dest++ = UTF16_REPLACEMENT_CHAR;
}
}
*out_len = dest - utf16Str;
return utf16Str;
}