Closed ilinchunjie closed 1 year ago
你可能需要重新包装一下 patch_decompress_with_cache或patch_single_stream (根据你的diff选择) 它们的函数接口需要输入输出数据为流,可以借鉴我对文件访问的包装方式。
patch_decompress_with_cache
patch_single_stream
推荐做法: 如果你的assets中的old数据没有压缩,那就实现起来很简单,用现有的文件流包装器应该就能支持:获取old数据在apk文件中的起始位置和长度,通过jni函数patch传入 本apk文件、old在apk中位置和长度(后两项为新增参数),在现有代码打开apk流后,添加设置流的偏移位置(hpatch_TFileStreamInput_setOffset)和流大小。 整个过程代码改动很小就能兼容。
hpatch_TFileStreamInput_setOffset
如果 assets中的old数据有压缩,那就不能直接使用了,因为hpatch时要求old数据支持随机访问,所以建议将old数据解压另存为文件或者解压在内存中抽象成流来使用(mem_as_hStreamInput)。
mem_as_hStreamInput
好滴,我尝试一下,感谢回复 @sisong
你可能需要重新包装一下
patch_decompress_with_cache
或patch_single_stream
(根据你的diff选择)它们的函数接口需要输入输出数据为流,可以借鉴我对文件访问的包装方式。
推荐做法:
如果你的assets中的old数据没有压缩,那就实现起来很简单,用现有的文件流包装器应该就能支持:获取old数据在apk文件中的起始位置和长度,通过jni函数patch传入 本apk文件、old在apk中位置和长度(后两项为新增参数),在现有代码打开apk流后,添加设置流的偏移位置(
hpatch_TFileStreamInput_setOffset
)和流大小。 整个过程代码改动很小就能兼容。如果 assets中的old数据有压缩,那就不能直接使用了,因为hpatch时要求old数据支持随机访问,所以建议将old数据解压另存为文件或者解压在内存中抽象成流来使用(
mem_as_hStreamInput
)。