Use /twres instead of /res for theme resources
AOSP and other ROM trees now do a rm -rf of the res folder during
the ramdisk creation process that removes the TWRP resources.
Using /twres instead of /res works around this issue making TWRP
more compatible with AOSP and other build trees.
Change-Id: I0d4c7e06ca381ac5aa0069b6f2b8c47f7dec49e7
diff --git a/minuitwrp/Android.mk b/minuitwrp/Android.mk
index c4380aa..cff5321 100644
--- a/minuitwrp/Android.mk
+++ b/minuitwrp/Android.mk
@@ -123,6 +123,7 @@
LOCAL_SRC_FILES += truetype.c
endif
+LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\"
LOCAL_SHARED_LIBRARIES += libz libc libcutils libjpeg libpng
LOCAL_STATIC_LIBRARIES += libpixelflinger_static
LOCAL_MODULE_TAGS := eng
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index d08e743..512a957 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -626,7 +626,7 @@
{
char tmp[128];
- sprintf(tmp, "/res/fonts/%s.dat", fontName);
+ sprintf(tmp, TWRES "fonts/%s.dat", fontName);
fd = open(tmp, O_RDONLY);
if (fd == -1)
return NULL;
diff --git a/minuitwrp/resources.c b/minuitwrp/resources.c
index bb30147..2e58311 100644
--- a/minuitwrp/resources.c
+++ b/minuitwrp/resources.c
@@ -59,7 +59,8 @@
unsigned char header[8];
int result = 0;
- snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name);
+ snprintf(resPath, sizeof(resPath)-1, TWRES "images/%s.png", name);
+ printf("open_png %s\n", resPath);
resPath[sizeof(resPath)-1] = '\0';
FILE* fp = fopen(resPath, "rb");
if (fp == NULL) {
@@ -261,7 +262,7 @@
if (fp == NULL) {
char resPath[256];
- snprintf(resPath, sizeof(resPath)-1, "/res/images/%s", name);
+ snprintf(resPath, sizeof(resPath)-1, TWRES "images/%s", name);
resPath[sizeof(resPath)-1] = '\0';
fp = fopen(resPath, "rb");
if (fp == NULL) {