mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-29 04:50:15 +02:00
fix(native): custom emoji font crash
This commit is contained in:
parent
07282e7b48
commit
5d5a067319
@ -16,7 +16,9 @@ fun FileHandleManager.getFileHandleLocalPath(
|
||||
fileUniqueIdentifier: String,
|
||||
): String? {
|
||||
return getFileHandle(scope.key, name)?.open(ParcelFileDescriptor.MODE_READ_ONLY)?.use { pfd ->
|
||||
val cacheFile = context.androidContext.cacheDir.resolve((fileUniqueIdentifier + Build.FINGERPRINT).longHashCode().absoluteValue.toString(16))
|
||||
val cacheFile = context.androidContext.cacheDir.also {
|
||||
it.mkdirs()
|
||||
}.resolve((fileUniqueIdentifier + Build.FINGERPRINT).longHashCode().absoluteValue.toString(16))
|
||||
if (!cacheFile.exists() || pfd.statSize != cacheFile.length()) {
|
||||
FileOutputStream(cacheFile).use { output ->
|
||||
ParcelFileDescriptor.AutoCloseInputStream(pfd).use { input ->
|
||||
|
@ -1,9 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace CustomEmojiFont {
|
||||
HOOK_DEF(int, open_hook, const char *pathname, int flags, mode_t mode) {
|
||||
if (strstr(pathname, "/system/fonts/NotoColorEmoji.ttf") != 0 && common::native_config->custom_emoji_font_path[0] != 0) {
|
||||
pathname = common::native_config->custom_emoji_font_path;
|
||||
auto custom_path = common::native_config->custom_emoji_font_path;
|
||||
if (strstr(pathname, "/system/fonts/NotoColorEmoji.ttf") != 0 && custom_path[0] != 0) {
|
||||
struct stat buffer;
|
||||
if (stat(custom_path, &buffer) == 0) {
|
||||
pathname = custom_path;
|
||||
}
|
||||
}
|
||||
return open_hook_original(pathname, flags, mode);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user