From 7db8f346972c054a18c72e942bad09d8bbad7389 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Mon, 16 Feb 2015 21:01:06 +0100 Subject: [PATCH] Move drawing, input and utils code into separate library --- Android.mk | 218 +----------------- device_defines.mk | 111 +++++++++ fw_mounter/Android.mk | 7 +- fw_mounter/fw_mounter.c | 8 +- kexec.c | 6 +- lib/Android.mk | 141 +++++++++++ animation.c => lib/animation.c | 6 +- animation.h => lib/animation.h | 0 atomics.h => lib/atomics.h | 0 button.c => lib/button.c | 4 +- button.h => lib/button.h | 0 lib/colors.c | 155 +++++++++++++ lib/colors.h | 59 +++++ containers.c => lib/containers.c | 0 containers.h => lib/containers.h | 0 framebuffer.c => lib/framebuffer.c | 8 +- framebuffer.h => lib/framebuffer.h | 0 .../framebuffer_generic.c | 0 framebuffer_png.c => lib/framebuffer_png.c | 5 - .../framebuffer_qcom_overlay.c | 0 .../framebuffer_truetype.c | 6 +- fstab.c => lib/fstab.c | 0 fstab.h => lib/fstab.h | 0 input.c => lib/input.c | 0 input.h => lib/input.h | 0 input_priv.h => lib/input_priv.h | 0 input_type_a.c => lib/input_type_a.c | 0 input_type_b.c => lib/input_type_b.c | 0 listview.c => lib/listview.c | 4 +- listview.h => lib/listview.h | 0 log.h => lib/log.h | 12 +- lib/mrom_data.c | 44 ++++ lib/mrom_data.h | 27 +++ .../notification_card.c | 2 +- .../notification_card.h | 0 progressdots.c => lib/progressdots.c | 3 +- progressdots.h => lib/progressdots.h | 1 - tabview.c => lib/tabview.c | 0 tabview.h => lib/tabview.h | 0 touch_tracker.c => lib/touch_tracker.c | 0 touch_tracker.h => lib/touch_tracker.h | 0 util.c => lib/util.c | 0 util.h => lib/util.h | 0 lib/velocity_tracker.c | 72 ++++++ workers.c => lib/workers.c | 0 workers.h => lib/workers.h | 0 main.c | 11 +- multirom.c | 56 ++--- multirom.h | 8 +- multirom_ui.c | 38 +-- multirom_ui.h | 4 +- ..._ui_landscape.c => multirom_ui_landscape.c | 29 +-- ...om_ui_portrait.c => multirom_ui_portrait.c | 29 +-- multirom_ui_themes.c | 141 +---------- multirom_ui_themes.h | 50 +--- pong.c | 8 +- pong.h | 2 +- rom_quirks.c | 4 +- trampoline/Android.mk | 9 +- trampoline/adb.c | 4 +- trampoline/devices.c | 6 +- trampoline/trampoline.c | 7 +- trampoline_encmnt/Android.mk | 7 +- trampoline_encmnt/encmnt.c | 4 +- 64 files changed, 772 insertions(+), 544 deletions(-) create mode 100644 device_defines.mk create mode 100644 lib/Android.mk rename animation.c => lib/animation.c (99%) rename animation.h => lib/animation.h (100%) rename atomics.h => lib/atomics.h (100%) rename button.c => lib/button.c (98%) rename button.h => lib/button.h (100%) create mode 100644 lib/colors.c create mode 100644 lib/colors.h rename containers.c => lib/containers.c (100%) rename containers.h => lib/containers.h (100%) rename framebuffer.c => lib/framebuffer.c (99%) rename framebuffer.h => lib/framebuffer.h (100%) rename framebuffer_generic.c => lib/framebuffer_generic.c (100%) rename framebuffer_png.c => lib/framebuffer_png.c (99%) rename framebuffer_qcom_overlay.c => lib/framebuffer_qcom_overlay.c (100%) rename framebuffer_truetype.c => lib/framebuffer_truetype.c (99%) rename fstab.c => lib/fstab.c (100%) rename fstab.h => lib/fstab.h (100%) rename input.c => lib/input.c (100%) rename input.h => lib/input.h (100%) rename input_priv.h => lib/input_priv.h (100%) rename input_type_a.c => lib/input_type_a.c (100%) rename input_type_b.c => lib/input_type_b.c (100%) rename listview.c => lib/listview.c (99%) rename listview.h => lib/listview.h (100%) rename log.h => lib/log.h (66%) create mode 100644 lib/mrom_data.c create mode 100644 lib/mrom_data.h rename notification_card.c => lib/notification_card.c (99%) rename notification_card.h => lib/notification_card.h (100%) rename progressdots.c => lib/progressdots.c (96%) rename progressdots.h => lib/progressdots.h (97%) rename tabview.c => lib/tabview.c (100%) rename tabview.h => lib/tabview.h (100%) rename touch_tracker.c => lib/touch_tracker.c (100%) rename touch_tracker.h => lib/touch_tracker.h (100%) rename util.c => lib/util.c (100%) rename util.h => lib/util.h (100%) create mode 100644 lib/velocity_tracker.c rename workers.c => lib/workers.c (100%) rename workers.h => lib/workers.h (100%) rename themes/multirom_ui_landscape.c => multirom_ui_landscape.c (94%) rename themes/multirom_ui_portrait.c => multirom_ui_portrait.c (94%) diff --git a/Android.mk b/Android.mk index ee59ed6..172a740 100644 --- a/Android.mk +++ b/Android.mk @@ -7,34 +7,19 @@ multirom_local_path := $(LOCAL_PATH) LOCAL_C_INCLUDES += $(multirom_local_path) \ external/libpng \ external/zlib \ - external/freetype/include + external/freetype/include \ + $(multirom_local_path)/lib LOCAL_SRC_FILES:= \ - animation.c \ - button.c \ - containers.c \ - framebuffer.c \ - framebuffer_generic.c \ - framebuffer_png.c \ - framebuffer_truetype.c \ - fstab.c \ - input.c \ kexec.c \ - listview.c \ main.c \ multirom.c \ multirom_ui.c \ + multirom_ui_landscape.c \ + multirom_ui_portrait.c \ multirom_ui_themes.c \ - themes/multirom_ui_landscape.c \ - themes/multirom_ui_portrait.c \ - notification_card.c \ pong.c \ - progressdots.c \ rom_quirks.c \ - tabview.c \ - touch_tracker.c \ - util.c \ - workers.c # With these, GCC optimizes aggressively enough so full-screen alpha blending # is quick enough to be done in an animation @@ -49,122 +34,15 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) -LOCAL_STATIC_LIBRARIES := libcutils libc libm libpng libz libft2_mrom_static +LOCAL_STATIC_LIBRARIES := libcutils libc libmultirom_static +LOCAL_WHOLE_STATIC_LIBRARIES := libm libcutils libpng libz libft2_mrom_static # clone libbootimg to /system/extras/ from # https://github.com/Tasssadar/libbootimg.git LOCAL_STATIC_LIBRARIES += libbootimg LOCAL_C_INCLUDES += system/extras/libbootimg/include -# Defines from device files -# Init default define values -MULTIROM_DEFAULT_ROTATION := 0 - -LOCAL_CFLAGS += -DMR_LOG_TAG=\"multirom\" - -# This value is used to have different folders on USB drives -# for different devices. Grouper didn't have that, hence the hack -LOCAL_CFLAGS += -DTARGET_DEVICE="\"$(TARGET_DEVICE)\"" -ifeq ($(TARGET_DEVICE),grouper) - LOCAL_CFLAGS += -DMR_MOVE_USB_DIR -endif - -# Flo's bootloader removes first 26 characters from boot.img's cmdline -# because of reasons. On unmodified boot.img, those 26 characters are -# "console=ttyHSL0,115200,n8 " -ifeq ($(TARGET_DEVICE),flo) - LOCAL_CFLAGS += -DFLO_CMDLINE_HACK -endif - -ifeq ($(MR_INPUT_TYPE),) - MR_INPUT_TYPE := type_b -endif -LOCAL_SRC_FILES += input_$(MR_INPUT_TYPE).c - -ifeq ($(DEVICE_RESOLUTION),) - $(info DEVICE_RESOLUTION was not specified) -else ifneq ($(wildcard $(multirom_local_path)/themes/multirom_ui_$(DEVICE_RESOLUTION).c),) - LOCAL_SRC_FILES += themes/multirom_ui_$(DEVICE_RESOLUTION).c - LOCAL_CFLAGS += -DMULTIROM_THEME_$(DEVICE_RESOLUTION) -endif - -ifneq ($(LANDSCAPE_RESOLUTION),) -ifneq ($(wildcard $(multirom_local_path)/themes/multirom_ui_$(LANDSCAPE_RESOLUTION).c),) - LOCAL_SRC_FILES += themes/multirom_ui_$(LANDSCAPE_RESOLUTION).c - LOCAL_CFLAGS += -DMULTIROM_THEME_$(LANDSCAPE_RESOLUTION) -endif -endif -ifneq ($(TW_DEFAULT_ROTATION),) - MULTIROM_DEFAULT_ROTATION := $(TW_DEFAULT_ROTATION) -endif -LOCAL_CFLAGS += -DMULTIROM_DEFAULT_ROTATION=$(MULTIROM_DEFAULT_ROTATION) - -# TWRP framebuffer flags -ifeq ($(RECOVERY_GRAPHICS_USE_LINELENGTH), true) - LOCAL_CFLAGS += -DRECOVERY_GRAPHICS_USE_LINELENGTH -endif - -ifeq ($(MR_PIXEL_FORMAT),) - MR_PIXEL_FORMAT := $(TARGET_RECOVERY_PIXEL_FORMAT) -endif - -ifeq ($(MR_PIXEL_FORMAT),"RGBX_8888") - LOCAL_CFLAGS += -DRECOVERY_RGBX -else ifeq ($(MR_PIXEL_FORMAT),"BGRA_8888") - LOCAL_CFLAGS += -DRECOVERY_BGRA -else ifeq ($(MR_PIXEL_FORMAT),"RGB_565") - LOCAL_CFLAGS += -DRECOVERY_RGB_565 -else - $(info TARGET_RECOVERY_PIXEL_FORMAT or MR_PIXEL_FORMAT not set or have invalid value) -endif - -ifeq ($(MR_DPI),) - $(info MR_DPI not defined in device files) -else ifeq ($(MR_DPI),hdpi) -ifeq ($(MR_DPI_MUL),) - MR_DPI_MUL := 1 -endif -else ifeq ($(MR_DPI),xhdpi) -ifeq ($(MR_DPI_MUL),) - MR_DPI_MUL := 1.5 -endif -endif - -ifeq ($(MR_DPI_FONT),) - MR_DPI_FONT := 96 -endif - -LOCAL_CFLAGS += -DMR_DPI_FONT=$(MR_DPI_FONT) - -ifneq ($(MR_DPI_MUL),) - LOCAL_CFLAGS += -DDPI_MUL=$(MR_DPI_MUL) -else - $(info MR_DPI_MUL not defined!) -endif - -ifeq ($(MR_DISABLE_ALPHA),true) - LOCAL_CFLAGS += -DMR_DISABLE_ALPHA -endif - -ifneq ($(TW_BRIGHTNESS_PATH),) - LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=\"$(TW_BRIGHTNESS_PATH)\" -endif - -ifneq ($(MR_DEFAULT_BRIGHTNESS),) - LOCAL_CFLAGS += -DMULTIROM_DEFAULT_BRIGHTNESS=\"$(MR_DEFAULT_BRIGHTNESS)\" -else - LOCAL_CFLAGS += -DMULTIROM_DEFAULT_BRIGHTNESS=40 -endif - -ifneq ($(MR_KEXEC_MEM_MIN),) - LOCAL_CFLAGS += -DMR_KEXEC_MEM_MIN=\"$(MR_KEXEC_MEM_MIN)\" -else - $(info MR_KEXEC_MEM_MIN was not defined in device files!) -endif - -ifeq ($(MR_KEXEC_DTB),true) - LOCAL_CFLAGS += -DMR_KEXEC_DTB -endif +include $(multirom_local_path)/device_defines.mk ifneq ($(MR_DEVICE_HOOKS),) ifeq ($(MR_DEVICE_HOOKS_VER),) @@ -175,30 +53,10 @@ else endif endif -ifeq ($(MR_USE_QCOM_OVERLAY),true) - LOCAL_CFLAGS += -DMR_USE_QCOM_OVERLAY - LOCAL_SRC_FILES += framebuffer_qcom_overlay.c -ifneq ($(MR_QCOM_OVERLAY_HEADER),) - LOCAL_CFLAGS += -DMR_QCOM_OVERLAY_HEADER=\"../../../$(MR_QCOM_OVERLAY_HEADER)\" -else - $(error MR_USE_QCOM_OVERLAY is true but MR_QCOM_OVERLAY_HEADER was not specified!) -endif -ifneq ($(MR_QCOM_OVERLAY_CUSTOM_PIXEL_FORMAT),) - LOCAL_CFLAGS += -DMR_QCOM_OVERLAY_CUSTOM_PIXEL_FORMAT=$(MR_QCOM_OVERLAY_CUSTOM_PIXEL_FORMAT) -endif -ifeq ($(MR_QCOM_OVERLAY_USE_VSYNC),true) - LOCAL_CFLAGS += -DMR_QCOM_OVERLAY_USE_VSYNC -endif -endif - -ifeq ($(MR_CONTINUOUS_FB_UPDATE),true) - LOCAL_CFLAGS += -DMR_CONTINUOUS_FB_UPDATE -endif - -LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) - include $(BUILD_EXECUTABLE) + + # Trampoline include $(multirom_local_path)/trampoline/Android.mk @@ -219,59 +77,5 @@ ifeq ($(MR_ENCRYPTION),true) include $(multirom_local_path)/trampoline_encmnt/Android.mk endif -# We need static libtruetype but it isn't in standard android makefile :( -LOCAL_PATH := external/freetype/ -include $(CLEAR_VARS) - -# compile in ARM mode, since the glyph loader/renderer is a hotspot -# when loading complex pages in the browser -# -LOCAL_ARM_MODE := arm - -LOCAL_SRC_FILES:= \ - src/base/ftbbox.c \ - src/base/ftbitmap.c \ - src/base/ftfstype.c \ - src/base/ftglyph.c \ - src/base/ftlcdfil.c \ - src/base/ftstroke.c \ - src/base/fttype1.c \ - src/base/ftxf86.c \ - src/base/ftbase.c \ - src/base/ftsystem.c \ - src/base/ftinit.c \ - src/base/ftgasp.c \ - src/raster/raster.c \ - src/sfnt/sfnt.c \ - src/smooth/smooth.c \ - src/autofit/autofit.c \ - src/truetype/truetype.c \ - src/cff/cff.c \ - src/psnames/psnames.c \ - src/pshinter/pshinter.c - -ifeq ($(shell if [ -e "$(ANDROID_BUILD_TOP)/external/freetype/src/gzip/ftgzip.c" ]; then echo "hasgzip"; fi),hasgzip) -LOCAL_SRC_FILES += src/gzip/ftgzip.c -endif - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/builds \ - $(LOCAL_PATH)/include \ - external/libpng \ - external/zlib - -LOCAL_CFLAGS += -W -Wall -LOCAL_CFLAGS += -fPIC -DPIC -LOCAL_CFLAGS += "-DDARWIN_NO_CARBON" -LOCAL_CFLAGS += "-DFT2_BUILD_LIBRARY" - -LOCAL_STATIC_LIBRARIES += libpng libz - -# the following is for testing only, and should not be used in final builds -# of the product -#LOCAL_CFLAGS += "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER" - -LOCAL_CFLAGS += -O2 - -LOCAL_MODULE:= libft2_mrom_static -include $(BUILD_STATIC_LIBRARY) +# libmultirom +include $(multirom_local_path)/lib/Android.mk diff --git a/device_defines.mk b/device_defines.mk new file mode 100644 index 0000000..80f8475 --- /dev/null +++ b/device_defines.mk @@ -0,0 +1,111 @@ +# Defines from device files +# Init default define values +MULTIROM_DEFAULT_ROTATION := 0 + +# This value is used to have different folders on USB drives +# for different devices. Grouper didn't have that, hence the hack +LOCAL_CFLAGS += -DTARGET_DEVICE="\"$(TARGET_DEVICE)\"" +ifeq ($(TARGET_DEVICE),grouper) + LOCAL_CFLAGS += -DMR_MOVE_USB_DIR +endif + +# Flo's bootloader removes first 26 characters from boot.img's cmdline +# because of reasons. On unmodified boot.img, those 26 characters are +# "console=ttyHSL0,115200,n8 " +ifeq ($(TARGET_DEVICE),flo) + LOCAL_CFLAGS += -DFLO_CMDLINE_HACK +endif + +ifeq ($(DEVICE_RESOLUTION),) + $(info DEVICE_RESOLUTION was not specified) +# FIXME +#else ifneq ($(wildcard $(multirom_local_path)/themes/multirom_ui_$(DEVICE_RESOLUTION).c),) +# LOCAL_SRC_FILES += themes/multirom_ui_$(DEVICE_RESOLUTION).c +# LOCAL_CFLAGS += -DMULTIROM_THEME_$(DEVICE_RESOLUTION) +endif + +ifneq ($(LANDSCAPE_RESOLUTION),) +# FIXME +#ifneq ($(wildcard $(multirom_local_path)/themes/multirom_ui_$(LANDSCAPE_RESOLUTION).c),) +# LOCAL_SRC_FILES += themes/multirom_ui_$(LANDSCAPE_RESOLUTION).c +# LOCAL_CFLAGS += -DMULTIROM_THEME_$(LANDSCAPE_RESOLUTION) +#endif +endif + +ifneq ($(TW_DEFAULT_ROTATION),) + MULTIROM_DEFAULT_ROTATION := $(TW_DEFAULT_ROTATION) +endif +LOCAL_CFLAGS += -DMULTIROM_DEFAULT_ROTATION=$(MULTIROM_DEFAULT_ROTATION) + +# TWRP framebuffer flags +ifeq ($(RECOVERY_GRAPHICS_USE_LINELENGTH), true) + LOCAL_CFLAGS += -DRECOVERY_GRAPHICS_USE_LINELENGTH +endif + +ifeq ($(MR_PIXEL_FORMAT),) + MR_PIXEL_FORMAT := $(TARGET_RECOVERY_PIXEL_FORMAT) +endif + +ifeq ($(MR_PIXEL_FORMAT),"RGBX_8888") + LOCAL_CFLAGS += -DRECOVERY_RGBX +else ifeq ($(MR_PIXEL_FORMAT),"BGRA_8888") + LOCAL_CFLAGS += -DRECOVERY_BGRA +else ifeq ($(MR_PIXEL_FORMAT),"RGB_565") + LOCAL_CFLAGS += -DRECOVERY_RGB_565 +else + $(info TARGET_RECOVERY_PIXEL_FORMAT or MR_PIXEL_FORMAT not set or have invalid value) +endif + +ifeq ($(MR_DPI),) + $(info MR_DPI not defined in device files) +else ifeq ($(MR_DPI),hdpi) +ifeq ($(MR_DPI_MUL),) + MR_DPI_MUL := 1 +endif +else ifeq ($(MR_DPI),xhdpi) +ifeq ($(MR_DPI_MUL),) + MR_DPI_MUL := 1.5 +endif +endif + +ifeq ($(MR_DPI_FONT),) + MR_DPI_FONT := 96 +endif + +LOCAL_CFLAGS += -DMR_DPI_FONT=$(MR_DPI_FONT) + +ifneq ($(MR_DPI_MUL),) + LOCAL_CFLAGS += -DDPI_MUL=$(MR_DPI_MUL) +else + $(info MR_DPI_MUL not defined!) +endif + +ifeq ($(MR_DISABLE_ALPHA),true) + LOCAL_CFLAGS += -DMR_DISABLE_ALPHA +endif + +ifneq ($(TW_BRIGHTNESS_PATH),) + LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=\"$(TW_BRIGHTNESS_PATH)\" +endif + +ifneq ($(MR_DEFAULT_BRIGHTNESS),) + LOCAL_CFLAGS += -DMULTIROM_DEFAULT_BRIGHTNESS=\"$(MR_DEFAULT_BRIGHTNESS)\" +else + LOCAL_CFLAGS += -DMULTIROM_DEFAULT_BRIGHTNESS=40 +endif + +ifneq ($(MR_KEXEC_MEM_MIN),) + LOCAL_CFLAGS += -DMR_KEXEC_MEM_MIN=\"$(MR_KEXEC_MEM_MIN)\" +else + $(info MR_KEXEC_MEM_MIN was not defined in device files!) +endif + +ifeq ($(MR_KEXEC_DTB),true) + LOCAL_CFLAGS += -DMR_KEXEC_DTB +endif + +ifeq ($(MR_CONTINUOUS_FB_UPDATE),true) + LOCAL_CFLAGS += -DMR_CONTINUOUS_FB_UPDATE +endif + +LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) diff --git a/fw_mounter/Android.mk b/fw_mounter/Android.mk index f875bd9..a53e22c 100644 --- a/fw_mounter/Android.mk +++ b/fw_mounter/Android.mk @@ -4,9 +4,6 @@ include $(CLEAR_VARS) LOCAL_C_INCLUDES += $(multirom_local_path) LOCAL_SRC_FILES:= \ fw_mounter.c \ - ../util.c \ - ../fstab.c \ - ../containers.c LOCAL_MODULE := fw_mounter LOCAL_MODULE_TAGS := eng @@ -15,8 +12,6 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) -LOCAL_STATIC_LIBRARIES := libcutils libc - -LOCAL_CFLAGS += -DMR_LOG_TAG=\"fw_mounter\" +LOCAL_STATIC_LIBRARIES := libcutils libc libmultirom_static include $(BUILD_EXECUTABLE) diff --git a/fw_mounter/fw_mounter.c b/fw_mounter/fw_mounter.c index ecf1dd7..259648d 100644 --- a/fw_mounter/fw_mounter.c +++ b/fw_mounter/fw_mounter.c @@ -19,13 +19,15 @@ #include #include -#include "../log.h" -#include "../util.h" -#include "../fstab.h" +#include "../lib/log.h" +#include "../lib/util.h" +#include "../lib/fstab.h" #include "fw_mounter_defines.h" int main(int argc, char *argv[]) { + mrom_set_log_tag("fw_mounter"); + struct fstab *f = fstab_load(FW_MOUNTER_FSTAB, 0); if(!f) { diff --git a/kexec.c b/kexec.c index bfbd17c..64afdc3 100644 --- a/kexec.c +++ b/kexec.c @@ -20,9 +20,9 @@ #include #include "kexec.h" -#include "containers.h" -#include "log.h" -#include "util.h" +#include "lib/containers.h" +#include "lib/log.h" +#include "lib/util.h" // kexec --load-hardboot ./zImage --command-line="$(cat /proc/cmdline)" --mem-min=0xA0000000 --initrd=./rd.img // --mem-min should be somewhere in System RAM (see /proc/iomem). Location just above kernel seems to work fine. diff --git a/lib/Android.mk b/lib/Android.mk new file mode 100644 index 0000000..ee914b5 --- /dev/null +++ b/lib/Android.mk @@ -0,0 +1,141 @@ +LOCAL_PATH:= $(call my-dir) + +common_SRC_FILES := \ + animation.c \ + button.c \ + colors.c \ + containers.c \ + framebuffer.c \ + framebuffer_generic.c \ + framebuffer_png.c \ + framebuffer_truetype.c \ + fstab.c \ + input.c \ + listview.c \ + mrom_data.c \ + notification_card.c \ + progressdots.c \ + tabview.c \ + touch_tracker.c \ + util.c \ + workers.c \ + +common_C_INCLUDES := $(multirom_local_path)/lib \ + external/libpng \ + external/zlib \ + external/freetype/include + +# With these, GCC optimizes aggressively enough so full-screen alpha blending +# is quick enough to be done in an animation +common_C_FLAGS := -O3 -funsafe-math-optimizations + +ifeq ($(MR_INPUT_TYPE),) + MR_INPUT_TYPE := type_b +endif +common_SRC_FILES += input_$(MR_INPUT_TYPE).c + +ifeq ($(MR_USE_QCOM_OVERLAY),true) + common_CFLAGS += -DMR_USE_QCOM_OVERLAY + common_SRC_FILES += framebuffer_qcom_overlay.c +ifneq ($(MR_QCOM_OVERLAY_HEADER),) + common_CFLAGS += -DMR_QCOM_OVERLAY_HEADER=\"../../../../$(MR_QCOM_OVERLAY_HEADER)\" +else + $(error MR_USE_QCOM_OVERLAY is true but MR_QCOM_OVERLAY_HEADER was not specified!) +endif +ifneq ($(MR_QCOM_OVERLAY_CUSTOM_PIXEL_FORMAT),) + common_CFLAGS += -DMR_QCOM_OVERLAY_CUSTOM_PIXEL_FORMAT=$(MR_QCOM_OVERLAY_CUSTOM_PIXEL_FORMAT) +endif +ifeq ($(MR_QCOM_OVERLAY_USE_VSYNC),true) + common_CFLAGS += -DMR_QCOM_OVERLAY_USE_VSYNC +endif +endif + + + +include $(CLEAR_VARS) + +LOCAL_MODULE := libmultirom_static +LOCAL_MODULE_TAGS := eng +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) +LOCAL_CFLAGS += $(common_C_FLAGS) +LOCAL_C_INCLUDES += $(common_C_INCLUDES) +LOCAL_SRC_FILES := $(common_SRC_FILES) + +include $(multirom_local_path)/device_defines.mk + +include $(BUILD_STATIC_LIBRARY) + + + +include $(CLEAR_VARS) + +LOCAL_MODULE := libmultirom +LOCAL_MODULE_TAGS := eng +LOCAL_SHARED_LIBRARIES := libcutils libc libm libpng libz libft2 +LOCAL_CFLAGS += $(common_C_FLAGS) +LOCAL_SRC_FILES := $(common_SRC_FILES) +LOCAL_C_INCLUDES += $(common_C_INCLUDES) + +include $(multirom_local_path)/device_defines.mk + +include $(BUILD_SHARED_LIBRARY) + + + +# We need static libtruetype but it isn't in standard android makefile :( +LOCAL_PATH := external/freetype/ +include $(CLEAR_VARS) + +# compile in ARM mode, since the glyph loader/renderer is a hotspot +# when loading complex pages in the browser +# +LOCAL_ARM_MODE := arm + +LOCAL_SRC_FILES:= \ + src/base/ftbbox.c \ + src/base/ftbitmap.c \ + src/base/ftfstype.c \ + src/base/ftglyph.c \ + src/base/ftlcdfil.c \ + src/base/ftstroke.c \ + src/base/fttype1.c \ + src/base/ftxf86.c \ + src/base/ftbase.c \ + src/base/ftsystem.c \ + src/base/ftinit.c \ + src/base/ftgasp.c \ + src/raster/raster.c \ + src/sfnt/sfnt.c \ + src/smooth/smooth.c \ + src/autofit/autofit.c \ + src/truetype/truetype.c \ + src/cff/cff.c \ + src/psnames/psnames.c \ + src/pshinter/pshinter.c + +ifeq ($(shell if [ -e "$(ANDROID_BUILD_TOP)/external/freetype/src/gzip/ftgzip.c" ]; then echo "hasgzip"; fi),hasgzip) +LOCAL_SRC_FILES += src/gzip/ftgzip.c +endif + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/builds \ + $(LOCAL_PATH)/include \ + external/libpng \ + external/zlib + +LOCAL_CFLAGS += -W -Wall +LOCAL_CFLAGS += -fPIC -DPIC +LOCAL_CFLAGS += "-DDARWIN_NO_CARBON" +LOCAL_CFLAGS += "-DFT2_BUILD_LIBRARY" + +LOCAL_STATIC_LIBRARIES += libpng libz + +# the following is for testing only, and should not be used in final builds +# of the product +#LOCAL_CFLAGS += "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER" + +LOCAL_CFLAGS += -O2 + +LOCAL_MODULE:= libft2_mrom_static +include $(BUILD_STATIC_LIBRARY) diff --git a/animation.c b/lib/animation.c similarity index 99% rename from animation.c rename to lib/animation.c index af26300..01ae262 100644 --- a/animation.c +++ b/lib/animation.c @@ -140,8 +140,8 @@ static inline void anim_int_step(int *prop, int *start, int *last, int *target, static inline int item_anim_is_on_screen(item_anim *anim) { fb_item_header *it = anim->item; - return it->x + it->w > 0 && it->x < fb_width && - it->y + it->h > 0 && it->y < fb_height; + return it->x + it->w > 0 && it->x < (int)fb_width && + it->y + it->h > 0 && it->y < (int)fb_height; } static void item_anim_step(item_anim *anim, float interpolated, int *need_draw) @@ -198,7 +198,7 @@ static void anim_update(uint32_t diff, void *data) pthread_mutex_lock(&list->mutex); list->in_update_loop = 1; - + for(it = list->first; it; ) { anim = it->anim; diff --git a/animation.h b/lib/animation.h similarity index 100% rename from animation.h rename to lib/animation.h diff --git a/atomics.h b/lib/atomics.h similarity index 100% rename from atomics.h rename to lib/atomics.h diff --git a/button.c b/lib/button.c similarity index 98% rename from button.c rename to lib/button.c index f869349..c81cfda 100644 --- a/button.c +++ b/lib/button.c @@ -20,9 +20,9 @@ #include "button.h" #include "input.h" #include "util.h" -#include "multirom_ui.h" -#include "multirom_ui_themes.h" +#include "colors.h" #include "log.h" +#include "containers.h" void button_init_ui(button *b, const char *text, int size) { diff --git a/button.h b/lib/button.h similarity index 100% rename from button.h rename to lib/button.h diff --git a/lib/colors.c b/lib/colors.c new file mode 100644 index 0000000..eb2fd3e --- /dev/null +++ b/lib/colors.c @@ -0,0 +1,155 @@ +/* + * This file is part of MultiROM. + * + * MultiROM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MultiROM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MultiROM. If not, see . + */ + +#include "colors.h" +#include "util.h" + +static const struct mrom_color_theme color_themes[] = { + // 0 - red/white, default + { + .background = 0xFFDCDCDC, + .highlight_bg = 0xFFF72F2F, + .highlight_hover = 0xFFF85555, + .highlight_text = 0xFFFFFFFF, + .text = 0xFF000000, + .text_secondary = 0xFF4D4D4D, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54000000, + .rom_highlight = 0xFFFFFFFF, + .rom_highlight_shadow = 0x54000000, + .keyaction_frame = 0xFF0000FF, + }, + // 1 - orange/white + { + .background = 0xFFDCDCDC, + .highlight_bg = 0xFFFF5722, + .highlight_hover = 0xFFFF8A65, + .highlight_text = 0xFFFFFFFF, + .text = 0xFF000000, + .text_secondary = 0xFF4D4D4D, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54000000, + .rom_highlight = 0xFFFFFFFF, + .rom_highlight_shadow = 0x54000000, + .keyaction_frame = 0xFFFF0000, + }, + // 2 - blue/white + { + .background = 0xFFDCDCDC, + .highlight_bg = 0xFF5677FC, + .highlight_hover = 0xFF91A7FF, + .highlight_text = 0xFFFFFFFF, + .text = 0xFF000000, + .text_secondary = 0xFF4D4D4D, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54000000, + .rom_highlight = 0xFFFFFFFF, + .rom_highlight_shadow = 0x54000000, + .keyaction_frame = 0xFFFF0000, + }, + // 3 - purple/white + { + .background = 0xFFDCDCDC, + .highlight_bg = 0xFF673AB7, + .highlight_hover = 0xFF9575CD, + .highlight_text = 0xFFFFFFFF, + .text = 0xFF000000, + .text_secondary = 0xFF4D4D4D, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54000000, + .rom_highlight = 0xFFFFFFFF, + .rom_highlight_shadow = 0x54000000, + .keyaction_frame = 0xFFFF0000, + }, + // 4 - green/white + { + .background = 0xFFDCDCDC, + .highlight_bg = 0xFF259B24, + .highlight_hover = 0xFF72D572, + .highlight_text = 0xFFFFFFFF, + .text = 0xFF000000, + .text_secondary = 0xFF4D4D4D, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54000000, + .rom_highlight = 0xFFFFFFFF, + .rom_highlight_shadow = 0x54000000, + .keyaction_frame = 0xFFFF0000, + }, + // 5 - dark blue + { + .background = 0xFF263238, + .highlight_bg = 0xFF607D8B, + .highlight_hover = 0xFF90A4AE, + .highlight_text = 0xFFFFFFFF, + .text = 0xFFFFFFFF, + .text_secondary = 0xFFE6E6E6, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54000000, + .rom_highlight = 0xFF607D8B, + .rom_highlight_shadow = 0x54000000, + .keyaction_frame = 0xFFFF0000, + }, + // 6 - dark blue/black + { + .background = 0xFF000000, + .highlight_bg = 0xFF263238, + .highlight_hover = 0xFF607D8B, + .highlight_text = 0xFFFFFFFF, + .text = 0xFFFFFFFF, + .text_secondary = 0xFFE6E6E6, + .ncard_bg = 0xFF37474F, + .ncard_text = 0xFFFFFFFF, + .ncard_text_secondary = 0xFFE6E6E6, + .ncard_shadow = 0x54424242, + .rom_highlight = 0xFF263238, + .rom_highlight_shadow = 0x54424242, + .keyaction_frame = 0xFFFF0000, + }, +}; + +const struct mrom_color_theme *color_theme = &color_themes[0]; + +void colors_select(size_t color_theme_idx) +{ + if(color_theme_idx >= ARRAY_SIZE(color_themes)) + return; + color_theme = &color_themes[color_theme_idx]; +} + +const struct mrom_color_theme *colors_get(size_t color_theme_idx) +{ + if(color_theme_idx >= ARRAY_SIZE(color_themes)) + return NULL; + return &color_themes[color_theme_idx]; +} + +int colors_count(void) +{ + return ARRAY_SIZE(color_themes); +} diff --git a/lib/colors.h b/lib/colors.h new file mode 100644 index 0000000..e58a284 --- /dev/null +++ b/lib/colors.h @@ -0,0 +1,59 @@ +/* + * This file is part of MultiROM. + * + * MultiROM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MultiROM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MultiROM. If not, see . + */ + +#ifndef MROM_COLORS_H +#define MROM_COLORS_H + +#include + +struct mrom_color_theme +{ + uint32_t background; + uint32_t highlight_bg; + uint32_t highlight_hover; + uint32_t highlight_text; + uint32_t text; + uint32_t text_secondary; + uint32_t ncard_bg; + uint32_t ncard_text; + uint32_t ncard_text_secondary; + uint32_t ncard_shadow; + uint32_t rom_highlight; + uint32_t rom_highlight_shadow; + uint32_t keyaction_frame; +}; + +extern const struct mrom_color_theme *color_theme; +#define C_BACKGROUND (color_theme->background) +#define C_HIGHLIGHT_BG (color_theme->highlight_bg) +#define C_HIGHLIGHT_HOVER (color_theme->highlight_hover) +#define C_HIGHLIGHT_TEXT (color_theme->highlight_text) +#define C_TEXT (color_theme->text) +#define C_TEXT_SECONDARY (color_theme->text_secondary) +#define C_NCARD_BG (color_theme->ncard_bg) +#define C_NCARD_TEXT (color_theme->ncard_text) +#define C_NCARD_TEXT_SECONDARY (color_theme->ncard_text_secondary) +#define C_NCARD_SHADOW (color_theme->ncard_shadow) +#define C_ROM_HIGHLIGHT (color_theme->rom_highlight) +#define C_ROM_HIGHLIGHT_SHADOW (color_theme->rom_highlight_shadow) +#define C_KEYACT_FRAME (color_theme->keyaction_frame) + +void colors_select(size_t color_theme_idx); +const struct mrom_color_theme *colors_get(size_t color_theme_idx); +int colors_count(void); + +#endif diff --git a/containers.c b/lib/containers.c similarity index 100% rename from containers.c rename to lib/containers.c diff --git a/containers.h b/lib/containers.h similarity index 100% rename from containers.h rename to lib/containers.h diff --git a/framebuffer.c b/lib/framebuffer.c similarity index 99% rename from framebuffer.c rename to lib/framebuffer.c index 550fce2..78a4f24 100644 --- a/framebuffer.c +++ b/lib/framebuffer.c @@ -38,9 +38,9 @@ #include "util.h" #include "containers.h" #include "animation.h" -#include "multirom.h" #include "listview.h" #include "atomics.h" +#include "mrom_data.h" #if PIXEL_SIZE == 4 #define fb_memset(dst, what, len) android_memset32(dst, what, len) @@ -799,9 +799,9 @@ fb_img* fb_add_png_img_lvl(int level, int x, int y, int w, int h, const char *pa px_type *data = NULL; if(strncmp(path, ":/", 2) == 0) { - const int full_path_len = strlen(path) + strlen(multirom_dir) + 4; + const int full_path_len = strlen(path) + strlen(mrom_dir()) + 4; char *full_path = malloc(full_path_len); - snprintf(full_path, full_path_len, "%s/res%s", multirom_dir, path+1); + snprintf(full_path, full_path_len, "%s/res%s", mrom_dir(), path+1); data = fb_png_get(full_path, w, h); free(full_path); } @@ -1003,7 +1003,7 @@ int fb_save_screenshot(void) char dir[256]; char path[256]; - strcpy(dir, multirom_dir); + strcpy(dir, mrom_dir()); r = strrchr(dir, '/'); if(!r) { diff --git a/framebuffer.h b/lib/framebuffer.h similarity index 100% rename from framebuffer.h rename to lib/framebuffer.h diff --git a/framebuffer_generic.c b/lib/framebuffer_generic.c similarity index 100% rename from framebuffer_generic.c rename to lib/framebuffer_generic.c diff --git a/framebuffer_png.c b/lib/framebuffer_png.c similarity index 99% rename from framebuffer_png.c rename to lib/framebuffer_png.c index 2e13bc5..06a0558 100644 --- a/framebuffer_png.c +++ b/lib/framebuffer_png.c @@ -95,11 +95,6 @@ static px_type *scale_png_img(px_type *fi_data, int orig_w, int orig_h, int new_ return (px_type*)out; } -// Kanged from TWRP -double pow(double x, double y) { - return x; -} - static px_type *load_png(const char *path, int destW, int destH) { FILE *fp; diff --git a/framebuffer_qcom_overlay.c b/lib/framebuffer_qcom_overlay.c similarity index 100% rename from framebuffer_qcom_overlay.c rename to lib/framebuffer_qcom_overlay.c diff --git a/framebuffer_truetype.c b/lib/framebuffer_truetype.c similarity index 99% rename from framebuffer_truetype.c rename to lib/framebuffer_truetype.c index a947d30..a3f32d5 100644 --- a/framebuffer_truetype.c +++ b/lib/framebuffer_truetype.c @@ -31,7 +31,7 @@ #include "framebuffer.h" #include "util.h" #include "containers.h" -#include "multirom.h" +#include "mrom_data.h" #define LINE_SPACING 1.15 @@ -88,7 +88,7 @@ struct text_line FT_Vector *pos; }; -typedef struct +typedef struct { char *text; px_type color; @@ -157,7 +157,7 @@ static struct glyphs_entry *get_cache_for_size(const int style, const int size) { char buff[128]; res = mzalloc(sizeof(struct glyphs_entry)); - snprintf(buff, sizeof(buff), "%s/res/%s", multirom_dir, FONT_FILES[style]); + snprintf(buff, sizeof(buff), "%s/res/%s", mrom_dir(), FONT_FILES[style]); error = FT_New_Face(cache.ft_lib, buff, 0, &res->face); if(error) { diff --git a/fstab.c b/lib/fstab.c similarity index 100% rename from fstab.c rename to lib/fstab.c diff --git a/fstab.h b/lib/fstab.h similarity index 100% rename from fstab.h rename to lib/fstab.h diff --git a/input.c b/lib/input.c similarity index 100% rename from input.c rename to lib/input.c diff --git a/input.h b/lib/input.h similarity index 100% rename from input.h rename to lib/input.h diff --git a/input_priv.h b/lib/input_priv.h similarity index 100% rename from input_priv.h rename to lib/input_priv.h diff --git a/input_type_a.c b/lib/input_type_a.c similarity index 100% rename from input_type_a.c rename to lib/input_type_a.c diff --git a/input_type_b.c b/lib/input_type_b.c similarity index 100% rename from input_type_b.c rename to lib/input_type_b.c diff --git a/listview.c b/lib/listview.c similarity index 99% rename from listview.c rename to lib/listview.c index ae54817..405a701 100644 --- a/listview.c +++ b/lib/listview.c @@ -21,12 +21,12 @@ #include "framebuffer.h" #include "util.h" #include "log.h" -#include "multirom_ui.h" -#include "multirom_ui_themes.h" +#include "colors.h" #include "workers.h" #include "input.h" #include "animation.h" #include "notification_card.h" +#include "containers.h" #define MARK_W (10*DPI_MUL) #define MARK_H (50*DPI_MUL) diff --git a/listview.h b/lib/listview.h similarity index 100% rename from listview.h rename to lib/listview.h diff --git a/log.h b/lib/log.h similarity index 66% rename from log.h rename to lib/log.h index bbfa389..3686b37 100644 --- a/log.h +++ b/lib/log.h @@ -17,17 +17,17 @@ #ifndef _INIT_LOG_H_ #define _INIT_LOG_H_ +#include "mrom_data.h" + #ifdef LOG_TO_STDOUT #include - #define ERROR(fmt, ...) fprintf(stderr, MR_LOG_TAG ": " fmt "\n", ##__VA_ARGS__) - #define NOTICE(fmt, ...) printf(MR_LOG_TAG ": " fmt "\n", ##__VA_ARGS__) - #define INFO(fmt, ...) printf(MR_LOG_TAG ": " fmt "\n", ##__VA_ARGS__) + #define ERROR(fmt, ...) fprintf(stderr, "%s: " fmt "\n", mrom_log_tag(), ##__VA_ARGS__) + #define INFO(fmt, ...) printf("%s: " fmt "\n", mrom_log_tag(), ##__VA_ARGS__) #else #include - #define ERROR(x...) KLOG_ERROR(MR_LOG_TAG, x) - #define NOTICE(x...) KLOG_NOTICE(MR_LOG_TAG, x) - #define INFO(x...) KLOG_INFO(MR_LOG_TAG, x) + #define ERROR(fmt, ...) klog_write(3, "<3>%s: " fmt, mrom_log_tag(), ##__VA_ARGS__) + #define INFO(fmt, ...) klog_write(6, "<6>%s: " fmt, mrom_log_tag(), ##__VA_ARGS__) #endif #endif diff --git a/lib/mrom_data.c b/lib/mrom_data.c new file mode 100644 index 0000000..05c2ab8 --- /dev/null +++ b/lib/mrom_data.c @@ -0,0 +1,44 @@ +/* + * This file is part of MultiROM. + * + * MultiROM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MultiROM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MultiROM. If not, see . + */ + +#include +#include + +#include "mrom_data.h" + +static char multirom_dir[128] = { 0 }; +static char log_tag[64] = { 0 }; + +void mrom_set_dir(const char *mrom_dir) +{ + snprintf(multirom_dir, sizeof(multirom_dir), "%s", mrom_dir); +} + +void mrom_set_log_tag(const char *tag) +{ + snprintf(log_tag, sizeof(log_tag), "%s", tag); +} + +const char *mrom_log_tag(void) +{ + return log_tag; +} + +const char *mrom_dir(void) +{ + return multirom_dir; +} diff --git a/lib/mrom_data.h b/lib/mrom_data.h new file mode 100644 index 0000000..d1e2a45 --- /dev/null +++ b/lib/mrom_data.h @@ -0,0 +1,27 @@ +/* + * This file is part of MultiROM. + * + * MultiROM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MultiROM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MultiROM. If not, see . + */ + +#ifndef MROM_DATA_H +#define MROM_DATA_H + +void mrom_set_dir(const char *mrom_dir); +void mrom_set_log_tag(const char *tag); + +const char *mrom_log_tag(void); +const char *mrom_dir(void); + +#endif diff --git a/notification_card.c b/lib/notification_card.c similarity index 99% rename from notification_card.c rename to lib/notification_card.c index e042c89..6400025 100644 --- a/notification_card.c +++ b/lib/notification_card.c @@ -26,7 +26,7 @@ #include "containers.h" #include "log.h" #include "input.h" -#include "multirom_ui_themes.h" +#include "colors.h" enum { diff --git a/notification_card.h b/lib/notification_card.h similarity index 100% rename from notification_card.h rename to lib/notification_card.h diff --git a/progressdots.c b/lib/progressdots.c similarity index 96% rename from progressdots.c rename to lib/progressdots.c index a854f80..220939e 100644 --- a/progressdots.c +++ b/lib/progressdots.c @@ -18,8 +18,7 @@ #include #include "progressdots.h" -#include "multirom_ui.h" -#include "multirom_ui_themes.h" +#include "colors.h" #include "workers.h" #include "util.h" #include "animation.h" diff --git a/progressdots.h b/lib/progressdots.h similarity index 97% rename from progressdots.h rename to lib/progressdots.h index 271cb1a..f485115 100644 --- a/progressdots.h +++ b/lib/progressdots.h @@ -18,7 +18,6 @@ #ifndef PROGRESSDOTS_H #define PROGRESSDOTS_H -#include #include "framebuffer.h" #define PROGDOTS_W (400*DPI_MUL) diff --git a/tabview.c b/lib/tabview.c similarity index 100% rename from tabview.c rename to lib/tabview.c diff --git a/tabview.h b/lib/tabview.h similarity index 100% rename from tabview.h rename to lib/tabview.h diff --git a/touch_tracker.c b/lib/touch_tracker.c similarity index 100% rename from touch_tracker.c rename to lib/touch_tracker.c diff --git a/touch_tracker.h b/lib/touch_tracker.h similarity index 100% rename from touch_tracker.h rename to lib/touch_tracker.h diff --git a/util.c b/lib/util.c similarity index 100% rename from util.c rename to lib/util.c diff --git a/util.h b/lib/util.h similarity index 100% rename from util.h rename to lib/util.h diff --git a/lib/velocity_tracker.c b/lib/velocity_tracker.c new file mode 100644 index 0000000..6341553 --- /dev/null +++ b/lib/velocity_tracker.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010 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 + +#include "touch_tracker.h" +#include "util.h" + +touch_tracker *touch_tracker_create(void) +{ + touch_tracker *t = mzalloc(sizeof(touch_tracker)); + return t; +} + +void touch_tracker_destroy(touch_tracker *t) +{ + free(t); +} + +void touch_tracker_start(touch_tracker *t, touch_event *ev) +{ + t->distance_abs_x = t->distance_abs_y = 0; + t->start_x = ev->x; + t->start_y = ev->y; + t->last_x = ev->x; + t->last_y = ev->y; + memcpy(&v->time_start, &ev->time, sizeof(struct timeval)); +} + +void touch_tracker_finish(touch_tracker *t, touch_event *ev) +{ + t->distance_x = ev->x - t->start_x; + t->distance_y = ev->y - t->start_y; + t->period = timeval_us_diff(ev->time, t->time_start); +} + +void touch_tracker_add(touch_tracker *t, touch_event *ev) +{ + t->distance_abs_x += iabs(ev->x - t->last_x); + t->distance_abs_y += iabs(ev->y - t->last_y); + t->last_x = ev->x; + t->last_y = ev->y; +} + +float touch_tracker_get_velocity(touch_tracker *t, int axis) +{ + if(axis == TRACKER_X) + return ((((float)t->distance_x) / t->period) * 1000000) / DPI_MUL; + else + return ((((float)t->distance_y) / t->period) * 1000000) / DPI_MUL; +} + +float touch_tracker_get_velocity_abs(touch_tracker *t, int axis) +{ + if(axis == TRACKER_X) + return ((((float)t->distance_abs_x) / t->period) * 1000000) / DPI_MUL; + else + return ((((float)t->distance_abs_y) / t->period) * 1000000) / DPI_MUL; +} diff --git a/workers.c b/lib/workers.c similarity index 100% rename from workers.c rename to lib/workers.c diff --git a/workers.h b/lib/workers.h similarity index 100% rename from workers.h rename to lib/workers.h diff --git a/main.c b/main.c index d1db104..36392da 100644 --- a/main.c +++ b/main.c @@ -26,10 +26,11 @@ #include #include "multirom.h" -#include "framebuffer.h" -#include "log.h" +#include "lib/framebuffer.h" +#include "lib/log.h" #include "version.h" -#include "util.h" +#include "lib/util.h" +#include "lib/mrom_data.h" #define EXEC_MASK (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) #define KEEP_REALDATA "/dev/.keep_realdata" @@ -84,6 +85,8 @@ int main(int argc, const char *argv[]) // but it is possible to filter out INFO messages klog_set_level(6); + mrom_set_log_tag("multirom"); + ERROR("Running MultiROM v%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX); // root is mounted read only in android and MultiROM uses @@ -119,4 +122,4 @@ int main(int argc, const char *argv[]) vt_set_mode(0); return 0; -} \ No newline at end of file +} diff --git a/multirom.c b/multirom.c index 89a7538..5b52c97 100644 --- a/multirom.c +++ b/multirom.c @@ -37,15 +37,16 @@ #error "libbootimg version 0.2.0 or higher is required. Please update libbootimg." #endif +#include "lib/containers.h" +#include "lib/framebuffer.h" +#include "lib/input.h" +#include "lib/log.h" +#include "lib/util.h" +#include "lib/mrom_data.h" #include "multirom.h" #include "multirom_ui.h" -#include "framebuffer.h" -#include "input.h" -#include "log.h" -#include "util.h" #include "version.h" #include "hooks.h" -#include "containers.h" #include "rom_quirks.h" #include "kexec.h" #include "fw_mounter/fw_mounter_defines.h" @@ -62,7 +63,6 @@ #define BATTERY_CAP "/sys/class/power_supply/battery/capacity" -char multirom_dir[64] = { 0 }; static char busybox_path[64] = { 0 }; static char kexec_path[64] = { 0 }; static char ntfs_path[64] = { 0 }; @@ -92,7 +92,7 @@ int multirom_find_base_dir(void) if(stat(paths[i], &info) < 0) continue; - strcpy(multirom_dir, paths[i]); + mrom_set_dir(paths[i]); strncpy(partition_dir, paths[i], strchr(paths[i]+1, '/') - paths[i]); @@ -385,7 +385,7 @@ int multirom_default_status(struct multirom_status *s) return -1; char roms_path[256]; - sprintf(roms_path, "%s/roms/"INTERNAL_ROM_NAME, multirom_dir); + sprintf(roms_path, "%s/roms/"INTERNAL_ROM_NAME, mrom_dir()); DIR *d = opendir(roms_path); if(!d) { @@ -395,7 +395,7 @@ int multirom_default_status(struct multirom_status *s) else closedir(d); - sprintf(roms_path, "%s/roms", multirom_dir); + sprintf(roms_path, "%s/roms", mrom_dir()); d = opendir(roms_path); if(!d) { @@ -473,7 +473,7 @@ int multirom_load_status(struct multirom_status *s) multirom_default_status(s); char arg[256]; - sprintf(arg, "%s/multirom.ini", multirom_dir); + sprintf(arg, "%s/multirom.ini", mrom_dir()); FILE *f = fopen(arg, "r"); if(!f) @@ -609,7 +609,7 @@ int multirom_save_status(struct multirom_status *s) char auto_boot_name[MAX_ROM_NAME_LEN+1]; char current_name[MAX_ROM_NAME_LEN+1]; - snprintf(path, sizeof(path), "%s/multirom.ini", multirom_dir); + snprintf(path, sizeof(path), "%s/multirom.ini", mrom_dir()); FILE *f = fopen(path, "w"); if(!f) @@ -853,7 +853,7 @@ int multirom_get_rom_type(struct multirom_rom *rom) // try to copy rom_info.txt in there, ubuntu is deprecated ERROR("Found deprecated Ubuntu 13.04, trying to copy rom_info.txt...\n"); char *cmd[] = { busybox_path, "cp", malloc(256), malloc(256), NULL }; - sprintf(cmd[2], "%s/infos/ubuntu.txt", multirom_dir); + sprintf(cmd[2], "%s/infos/ubuntu.txt", mrom_dir()); sprintf(cmd[3], "%s/rom_info.txt", b); int res = run_cmd(cmd); @@ -889,18 +889,18 @@ void multirom_import_internal(void) char path[256]; // multirom - mkdir(multirom_dir, 0777); + mkdir(mrom_dir(), 0777); // roms - snprintf(path, sizeof(path), "%s/roms", multirom_dir); + snprintf(path, sizeof(path), "%s/roms", mrom_dir()); mkdir(path, 0777); // internal rom - snprintf(path, sizeof(path), "%s/roms/%s", multirom_dir, INTERNAL_ROM_NAME); + snprintf(path, sizeof(path), "%s/roms/%s", mrom_dir(), INTERNAL_ROM_NAME); mkdir(path, 0777); // set default icon if it doesn't exist yet - snprintf(path, sizeof(path), "%s/roms/%s/.icon_data", multirom_dir, INTERNAL_ROM_NAME); + snprintf(path, sizeof(path), "%s/roms/%s/.icon_data", mrom_dir(), INTERNAL_ROM_NAME); if(access(path, F_OK) < 0) { FILE *f = fopen(path, "w"); @@ -1111,7 +1111,7 @@ static int multirom_inject_fw_mounter(char *rc_with_mount_all, struct fstab_part fclose(f); // copy fw_mounter to /sbin - snprintf(line, sizeof(line), "%s/%s", multirom_dir, FW_MOUNTER_BIN); + snprintf(line, sizeof(line), "%s/%s", mrom_dir(), FW_MOUNTER_BIN); copy_file(line, FW_MOUNTER_PATH); chmod(FW_MOUNTER_PATH, 0755); @@ -1440,7 +1440,7 @@ int multirom_get_trampoline_ver(void) { ver = -1; - char buff[sizeof(multirom_dir) + 16]; + char buff[128]; char *cmd[] = { buff, "-v", NULL }; // If we are booting into another ROM from already running system, @@ -1449,7 +1449,7 @@ int multirom_get_trampoline_ver(void) if(access("/main_init", F_OK) >= 0) snprintf(buff, sizeof(buff), "/init"); else - snprintf(buff, sizeof(buff), "%s/trampoline", multirom_dir); + snprintf(buff, sizeof(buff), "%s/trampoline", mrom_dir()); char *res = run_get_stdout(cmd); if(res) @@ -2415,7 +2415,7 @@ int multirom_copy_log(char *klog, const char *dest_path_relative) if(klog) { char path[256]; - snprintf(path, sizeof(path), "%s/%s", multirom_dir, dest_path_relative); + snprintf(path, sizeof(path), "%s/%s", mrom_dir(), dest_path_relative); FILE *f = fopen(path, "w"); if(f) @@ -2556,7 +2556,7 @@ int multirom_update_rd_trampoline(const char *path) else if(magic == 0x184C2102) { type = RD_LZ4; - snprintf(buff, sizeof(buff), "cd /mrom_rd; \"%s/lz4\" -d \"%s\" stdout | \"%s\" cpio -i", multirom_dir, path, busybox_path); + snprintf(buff, sizeof(buff), "cd /mrom_rd; \"%s/lz4\" -d \"%s\" stdout | \"%s\" cpio -i", mrom_dir(), path, busybox_path); } else { @@ -2614,7 +2614,7 @@ int multirom_update_rd_trampoline(const char *path) snprintf(buff, sizeof(buff), "B=\"%s\"; cd /mrom_rd; \"$B\" find . | \"$B\" cpio -o -H newc | \"$B\" gzip > \"%s\"", busybox_path, path); break; case RD_LZ4: - snprintf(buff, sizeof(buff), "B=\"%s\"; cd /mrom_rd; \"$B\" find . | \"$B\" cpio -o -H newc | \"%s/lz4\" stdin \"%s\"", busybox_path, multirom_dir, path); + snprintf(buff, sizeof(buff), "B=\"%s\"; cd /mrom_rd; \"$B\" find . | \"$B\" cpio -o -H newc | \"%s/lz4\" stdin \"%s\"", busybox_path, mrom_dir(), path); break; } @@ -2680,16 +2680,16 @@ void multirom_find_rom_icon(struct multirom_rom *rom) if(!ic_name) goto fail; - len = strlen(multirom_dir) + 6 + strlen(ic_name)+4+1; // + /icons + .png + \0 + len = strlen(mrom_dir()) + 6 + strlen(ic_name)+4+1; // + /icons + .png + \0 rom->icon_path = malloc(len); - snprintf(rom->icon_path, len, "%s/icons%s.png", multirom_dir, ic_name); + snprintf(rom->icon_path, len, "%s/icons%s.png", mrom_dir(), ic_name); break; } case IC_TYPE_USER: { - len = strlen(multirom_dir) + 1 + USER_IC_PATH_LEN + 1 + len + 4 + 1; // + / + / + .png + \0 + len = strlen(mrom_dir()) + 1 + USER_IC_PATH_LEN + 1 + len + 4 + 1; // + / + / + .png + \0 rom->icon_path = malloc(len); - snprintf(rom->icon_path, len, "%s/%s/%s.png", multirom_dir, USER_IC_PATH, buff); + snprintf(rom->icon_path, len, "%s/%s/%s.png", mrom_dir(), USER_IC_PATH, buff); break; } } @@ -2702,7 +2702,7 @@ fail: if(f) fclose(f); - len = strlen(multirom_dir) + DEFAULT_ICON_LEN + 1; + len = strlen(mrom_dir()) + DEFAULT_ICON_LEN + 1; rom->icon_path = realloc(rom->icon_path, len); - snprintf(rom->icon_path, len, "%s%s", multirom_dir, DEFAULT_ICON); + snprintf(rom->icon_path, len, "%s%s", mrom_dir(), DEFAULT_ICON); } diff --git a/multirom.h b/multirom.h index 0e21a99..f5e672f 100644 --- a/multirom.h +++ b/multirom.h @@ -21,8 +21,8 @@ #include #include -#include "fstab.h" -#include "containers.h" +#include "lib/fstab.h" +#include "lib/containers.h" #include "kexec.h" enum @@ -49,7 +49,7 @@ enum #define MASK_LINUX (M(ROM_LINUX_INTERNAL) | M(ROM_LINUX_USB)) #define MASK_KEXEC (MASK_LINUX) -enum +enum { EXIT_REBOOT = 0x01, EXIT_UMOUNT = 0x02, @@ -115,8 +115,6 @@ struct multirom_status struct fstab *fstab; }; -extern char multirom_dir[64]; - int multirom(const char *rom_to_boot); int multirom_find_base_dir(void); void multirom_emergency_reboot(void); diff --git a/multirom_ui.c b/multirom_ui.c index 4d2f2b5..8705515 100644 --- a/multirom_ui.c +++ b/multirom_ui.c @@ -23,23 +23,25 @@ #include #include +#include "lib/framebuffer.h" +#include "lib/input.h" +#include "lib/log.h" +#include "lib/listview.h" +#include "lib/util.h" +#include "lib/button.h" +#include "lib/progressdots.h" +#include "lib/workers.h" +#include "lib/containers.h" +#include "lib/animation.h" +#include "lib/notification_card.h" +#include "lib/tabview.h" +#include "lib/colors.h" + #include "multirom_ui.h" -#include "framebuffer.h" -#include "input.h" -#include "log.h" -#include "listview.h" -#include "util.h" -#include "button.h" +#include "multirom_ui_themes.h" +#include "hooks.h" #include "version.h" #include "pong.h" -#include "progressdots.h" -#include "multirom_ui_themes.h" -#include "workers.h" -#include "hooks.h" -#include "containers.h" -#include "animation.h" -#include "notification_card.h" -#include "tabview.h" static struct multirom_status *mrom_status = NULL; static struct multirom_rom *selected_rom = NULL; @@ -132,7 +134,7 @@ int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot) exit_ui_code = -1; selected_rom = NULL; - multirom_ui_select_color(s->colors); + colors_select(s->colors); themes_info = multirom_ui_init_themes(); if((cur_theme = multirom_ui_select_theme(themes_info, fb_width, fb_height)) == NULL) { @@ -214,7 +216,7 @@ int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot) fb_freeze(1); multirom_ui_destroy_theme(); - multirom_ui_select_color(s->colors); + colors_select(s->colors); multirom_ui_init_theme(TAB_MISC); fb_freeze(0); @@ -272,7 +274,7 @@ int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot) stop_input_thread(); workers_stop(); - + #if MR_DEVICE_HOOKS >= 2 mrom_hook_before_fb_close(); #endif @@ -509,6 +511,8 @@ void *multirom_ui_tab_rom_init(int tab_type) if(tab_type == TAB_INTERNAL) multirom_ui_fill_rom_list(t->list, MASK_INTERNAL); + else + multirom_ui_fill_rom_list(t->list, MASK_USB_ROMS); listview_update_ui(t->list); diff --git a/multirom_ui.h b/multirom_ui.h index 4e99fc5..2a1a25b 100644 --- a/multirom_ui.h +++ b/multirom_ui.h @@ -19,8 +19,8 @@ #define MULTIROM_UI_H #include "multirom.h" -#include "input.h" -#include "listview.h" +#include "lib/input.h" +#include "lib/listview.h" enum { diff --git a/themes/multirom_ui_landscape.c b/multirom_ui_landscape.c similarity index 94% rename from themes/multirom_ui_landscape.c rename to multirom_ui_landscape.c index 2213a0a..533c8a8 100644 --- a/themes/multirom_ui_landscape.c +++ b/multirom_ui_landscape.c @@ -15,18 +15,19 @@ * along with MultiROM. If not, see . */ -#include "../multirom_ui.h" -#include "../multirom_ui_themes.h" -#include "../multirom.h" -#include "../framebuffer.h" -#include "../util.h" -#include "../button.h" -#include "../version.h" -#include "../input.h" -#include "../log.h" -#include "../animation.h" -#include "../notification_card.h" -#include "../tabview.h" +#include "multirom_ui.h" +#include "multirom_ui_themes.h" +#include "multirom.h" +#include "version.h" +#include "lib/framebuffer.h" +#include "lib/util.h" +#include "lib/button.h" +#include "lib/input.h" +#include "lib/log.h" +#include "lib/animation.h" +#include "lib/notification_card.h" +#include "lib/tabview.h" +#include "lib/colors.h" #define HEADER_HEIGHT (80*DPI_MUL) #define TABS_HEIGHT (HEADER_HEIGHT - STATUS_HEIGHT) @@ -152,13 +153,13 @@ static void tab_misc_init(multirom_theme_data *t, tab_data_misc *d, int color_sc tabview_add_item(t->tabs, TAB_MISC, b->rect); tabview_add_item(t->tabs, TAB_MISC, b); - const int max_colors = multirom_ui_get_color_theme_count(); + const int max_colors = colors_count(); x += (MISCBTN_W/2 - (max_colors*(CLRBTN_TOTAL+CLRBTN_MARGIN))/2); y += MISCBTN_H+30*DPI_MUL + (MISCBTN_H/2 - CLRBTN_TOTAL/2); fb_rect *r; for(i = 0; i < max_colors; ++i) { - const struct multirom_color_theme *th = multirom_ui_get_color_theme(i); + const struct mrom_color_theme *th = colors_get(i); r = fb_add_rect(x, y, CLRBTN_TOTAL, CLRBTN_TOTAL, i == color_scheme ? 0xFFFFCC00 : WHITE); list_add(&d->ui_elements, r); diff --git a/themes/multirom_ui_portrait.c b/multirom_ui_portrait.c similarity index 94% rename from themes/multirom_ui_portrait.c rename to multirom_ui_portrait.c index 0f7fcd2..62ffecc 100644 --- a/themes/multirom_ui_portrait.c +++ b/multirom_ui_portrait.c @@ -15,18 +15,19 @@ * along with MultiROM. If not, see . */ -#include "../multirom_ui.h" -#include "../multirom_ui_themes.h" -#include "../multirom.h" -#include "../framebuffer.h" -#include "../util.h" -#include "../button.h" -#include "../version.h" -#include "../input.h" -#include "../log.h" -#include "../animation.h" -#include "../notification_card.h" -#include "../tabview.h" +#include "multirom_ui.h" +#include "multirom_ui_themes.h" +#include "multirom.h" +#include "version.h" +#include "lib/framebuffer.h" +#include "lib/util.h" +#include "lib/button.h" +#include "lib/input.h" +#include "lib/log.h" +#include "lib/animation.h" +#include "lib/notification_card.h" +#include "lib/tabview.h" +#include "lib/colors.h" #define HEADER_HEIGHT (110*DPI_MUL) #define TABS_HEIGHT (HEADER_HEIGHT - STATUS_HEIGHT) @@ -212,12 +213,12 @@ static void tab_misc_init(multirom_theme_data *t, tab_data_misc *d, int color_sc text->y = fb_height - text->h; list_add(&d->ui_elements, text); - const int max_colors = multirom_ui_get_color_theme_count(); + const int max_colors = colors_count(); x = fb_width/2 - (max_colors*(CLRBTN_TOTAL+CLRBTN_MARGIN))/2; fb_rect *r; for(i = 0; i < max_colors; ++i) { - const struct multirom_color_theme *th = multirom_ui_get_color_theme(i); + const struct mrom_color_theme *th = colors_get(i); r = fb_add_rect(x, CLRBTN_Y, CLRBTN_TOTAL, CLRBTN_TOTAL, i == color_scheme ? 0xFFFFCC00 : WHITE); list_add(&d->ui_elements, r); diff --git a/multirom_ui_themes.c b/multirom_ui_themes.c index d9d02bf..fbd38fa 100644 --- a/multirom_ui_themes.c +++ b/multirom_ui_themes.c @@ -18,8 +18,8 @@ #include "multirom_ui.h" #include "multirom_ui_themes.h" #include "multirom.h" -#include "util.h" -#include "log.h" +#include "lib/util.h" +#include "lib/log.h" multirom_themes_info *multirom_ui_init_themes(void) { @@ -67,140 +67,3 @@ multirom_theme *multirom_ui_select_theme(multirom_themes_info *i, int w, int h) return universal; } - - -static const struct multirom_color_theme color_themes[] = { - // 0 - red/white, default - { - .background = 0xFFDCDCDC, - .highlight_bg = 0xFFF72F2F, - .highlight_hover = 0xFFF85555, - .highlight_text = 0xFFFFFFFF, - .text = 0xFF000000, - .text_secondary = 0xFF4D4D4D, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54000000, - .rom_highlight = 0xFFFFFFFF, - .rom_highlight_shadow = 0x54000000, - .keyaction_frame = 0xFF0000FF, - }, - // 1 - orange/white - { - .background = 0xFFDCDCDC, - .highlight_bg = 0xFFFF5722, - .highlight_hover = 0xFFFF8A65, - .highlight_text = 0xFFFFFFFF, - .text = 0xFF000000, - .text_secondary = 0xFF4D4D4D, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54000000, - .rom_highlight = 0xFFFFFFFF, - .rom_highlight_shadow = 0x54000000, - .keyaction_frame = 0xFFFF0000, - }, - // 2 - blue/white - { - .background = 0xFFDCDCDC, - .highlight_bg = 0xFF5677FC, - .highlight_hover = 0xFF91A7FF, - .highlight_text = 0xFFFFFFFF, - .text = 0xFF000000, - .text_secondary = 0xFF4D4D4D, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54000000, - .rom_highlight = 0xFFFFFFFF, - .rom_highlight_shadow = 0x54000000, - .keyaction_frame = 0xFFFF0000, - }, - // 3 - purple/white - { - .background = 0xFFDCDCDC, - .highlight_bg = 0xFF673AB7, - .highlight_hover = 0xFF9575CD, - .highlight_text = 0xFFFFFFFF, - .text = 0xFF000000, - .text_secondary = 0xFF4D4D4D, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54000000, - .rom_highlight = 0xFFFFFFFF, - .rom_highlight_shadow = 0x54000000, - .keyaction_frame = 0xFFFF0000, - }, - // 4 - green/white - { - .background = 0xFFDCDCDC, - .highlight_bg = 0xFF259B24, - .highlight_hover = 0xFF72D572, - .highlight_text = 0xFFFFFFFF, - .text = 0xFF000000, - .text_secondary = 0xFF4D4D4D, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54000000, - .rom_highlight = 0xFFFFFFFF, - .rom_highlight_shadow = 0x54000000, - .keyaction_frame = 0xFFFF0000, - }, - // 5 - dark blue - { - .background = 0xFF263238, - .highlight_bg = 0xFF607D8B, - .highlight_hover = 0xFF90A4AE, - .highlight_text = 0xFFFFFFFF, - .text = 0xFFFFFFFF, - .text_secondary = 0xFFE6E6E6, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54000000, - .rom_highlight = 0xFF607D8B, - .rom_highlight_shadow = 0x54000000, - .keyaction_frame = 0xFFFF0000, - }, - // 6 - dark blue/black - { - .background = 0xFF000000, - .highlight_bg = 0xFF263238, - .highlight_hover = 0xFF607D8B, - .highlight_text = 0xFFFFFFFF, - .text = 0xFFFFFFFF, - .text_secondary = 0xFFE6E6E6, - .ncard_bg = 0xFF37474F, - .ncard_text = 0xFFFFFFFF, - .ncard_text_secondary = 0xFFE6E6E6, - .ncard_shadow = 0x54424242, - .rom_highlight = 0xFF263238, - .rom_highlight_shadow = 0x54424242, - .keyaction_frame = 0xFFFF0000, - }, -}; - -const struct multirom_color_theme *color_theme = &color_themes[0]; - -void multirom_ui_select_color(size_t color_theme_idx) -{ - if(color_theme_idx >= ARRAY_SIZE(color_themes)) - return; - color_theme = &color_themes[color_theme_idx]; -} - -const struct multirom_color_theme *multirom_ui_get_color_theme(size_t color_theme_idx) -{ - if(color_theme_idx >= ARRAY_SIZE(color_themes)) - return NULL; - return &color_themes[color_theme_idx]; -} - -int multirom_ui_get_color_theme_count(void) -{ - return ARRAY_SIZE(color_themes); -} diff --git a/multirom_ui_themes.h b/multirom_ui_themes.h index 224e3bd..b3e2abd 100644 --- a/multirom_ui_themes.h +++ b/multirom_ui_themes.h @@ -18,19 +18,19 @@ #ifndef MULTIROM_UI_P_H #define MULTIROM_UI_P_H -#include "framebuffer.h" -#include "button.h" -#include "progressdots.h" -#include "listview.h" +#include "lib/framebuffer.h" +#include "lib/button.h" +#include "lib/progressdots.h" +#include "lib/listview.h" +#include "lib/tabview.h" #include "multirom_ui.h" -#include "tabview.h" // universal themes has these as width and height, // instead of real resolution #define TH_PORTRAIT (-1) #define TH_LANDSCAPE (-2) -typedef struct +typedef struct { listview *list; button **buttons; @@ -41,7 +41,7 @@ typedef struct progdots *usb_prog; } tab_data_roms; -typedef struct +typedef struct { button **buttons; void **ui_elements; @@ -82,40 +82,4 @@ multirom_themes_info *multirom_ui_init_themes(void); void multirom_ui_free_themes(multirom_themes_info *info); multirom_theme *multirom_ui_select_theme(multirom_themes_info *i, int w, int h); -struct multirom_color_theme -{ - uint32_t background; - uint32_t highlight_bg; - uint32_t highlight_hover; - uint32_t highlight_text; - uint32_t text; - uint32_t text_secondary; - uint32_t ncard_bg; - uint32_t ncard_text; - uint32_t ncard_text_secondary; - uint32_t ncard_shadow; - uint32_t rom_highlight; - uint32_t rom_highlight_shadow; - uint32_t keyaction_frame; -}; - -extern const struct multirom_color_theme *color_theme; -#define C_BACKGROUND (color_theme->background) -#define C_HIGHLIGHT_BG (color_theme->highlight_bg) -#define C_HIGHLIGHT_HOVER (color_theme->highlight_hover) -#define C_HIGHLIGHT_TEXT (color_theme->highlight_text) -#define C_TEXT (color_theme->text) -#define C_TEXT_SECONDARY (color_theme->text_secondary) -#define C_NCARD_BG (color_theme->ncard_bg) -#define C_NCARD_TEXT (color_theme->ncard_text) -#define C_NCARD_TEXT_SECONDARY (color_theme->ncard_text_secondary) -#define C_NCARD_SHADOW (color_theme->ncard_shadow) -#define C_ROM_HIGHLIGHT (color_theme->rom_highlight) -#define C_ROM_HIGHLIGHT_SHADOW (color_theme->rom_highlight_shadow) -#define C_KEYACT_FRAME (color_theme->keyaction_frame) - -void multirom_ui_select_color(size_t color_theme_idx); -const struct multirom_color_theme *multirom_ui_get_color_theme(size_t color_theme_idx); -int multirom_ui_get_color_theme_count(void); - #endif diff --git a/pong.c b/pong.c index 0107e84..b5d7aee 100644 --- a/pong.c +++ b/pong.c @@ -22,11 +22,11 @@ #include #include -#include "framebuffer.h" -#include "input.h" +#include "lib/framebuffer.h" +#include "lib/input.h" #include "pong.h" -#include "util.h" -#include "containers.h" +#include "lib/util.h" +#include "lib/containers.h" #define SCORE_SPACE (75*DPI_MUL) #define L 0 diff --git a/pong.h b/pong.h index 3e95e63..2a3233e 100644 --- a/pong.h +++ b/pong.h @@ -18,7 +18,7 @@ #ifndef PONG_H #define PONG_H -#include "input.h" +#include "lib/input.h" void pong(void); int pong_touch_handler(touch_event *ev, void *data); diff --git a/rom_quirks.c b/rom_quirks.c index 95e9af6..16c2d8c 100644 --- a/rom_quirks.c +++ b/rom_quirks.c @@ -26,8 +26,8 @@ #include "multirom.h" #include "rom_quirks.h" -#include "log.h" -#include "util.h" +#include "lib/log.h" +#include "lib/util.h" #define MULTIROM_DIR_ANDROID "/data/media/0/multirom" #define MULTIROM_DIR_ANDROID_LEN 22 diff --git a/trampoline/Android.mk b/trampoline/Android.mk index 2d68827..cbbc8fd 100644 --- a/trampoline/Android.mk +++ b/trampoline/Android.mk @@ -1,25 +1,20 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_C_INCLUDES += $(multirom_local_path) +LOCAL_C_INCLUDES += $(multirom_local_path) $(multirom_local_path)/lib LOCAL_SRC_FILES:= \ trampoline.c \ devices.c \ - ../util.c \ adb.c \ - ../fstab.c \ - ../containers.c LOCAL_MODULE:= trampoline LOCAL_MODULE_TAGS := eng LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) -LOCAL_STATIC_LIBRARIES := libcutils libc +LOCAL_STATIC_LIBRARIES := libcutils libc libmultirom_static LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_CFLAGS += -DMR_LOG_TAG=\"trampoline\" - ifeq ($(MR_INIT_DEVICES),) $(info MR_INIT_DEVICES was not defined in device files!) endif diff --git a/trampoline/adb.c b/trampoline/adb.c index 821243d..4c88478 100644 --- a/trampoline/adb.c +++ b/trampoline/adb.c @@ -29,8 +29,8 @@ #include #include "adb.h" -#include "../util.h" -#include "../log.h" +#include "../lib/util.h" +#include "../lib/log.h" static pthread_t adb_thread; static volatile int run_thread = 0; diff --git a/trampoline/devices.c b/trampoline/devices.c index 3dfccf4..ef9ae6d 100644 --- a/trampoline/devices.c +++ b/trampoline/devices.c @@ -45,8 +45,8 @@ #include #include "devices.h" -#include "../util.h" -#include "../log.h" +#include "../lib/util.h" +#include "../lib/log.h" //#define DEBUG_MISSING_UEVENTS 1 @@ -610,7 +610,7 @@ static char **parse_platform_block_device(struct uevent *uevent) p = strdup(uevent->partition_name); sanitize(p); if (strcmp(uevent->partition_name, p)) - NOTICE("Linking partition '%s' as '%s'\n", uevent->partition_name, p); + INFO("Linking partition '%s' as '%s'\n", uevent->partition_name, p); if (asprintf(&links[link_num], "%s/by-name/%s", link_path, p) > 0) link_num++; else diff --git a/trampoline/trampoline.c b/trampoline/trampoline.c index 2f70cef..da63bf3 100644 --- a/trampoline/trampoline.c +++ b/trampoline/trampoline.c @@ -26,11 +26,11 @@ #include #include "devices.h" -#include "../log.h" -#include "../util.h" +#include "../lib/log.h" +#include "../lib/util.h" +#include "../lib/fstab.h" #include "../version.h" #include "adb.h" -#include "../fstab.h" #include "../hooks.h" #define EXEC_MASK (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) @@ -260,6 +260,7 @@ int main(int argc, char *argv[]) mount("sysfs", "/sys", "sysfs", 0, NULL); klog_init(); + mrom_set_log_tag("trampoline"); ERROR("Running trampoline v%d\n", VERSION_TRAMPOLINE); if(is_charger_mode()) diff --git a/trampoline_encmnt/Android.mk b/trampoline_encmnt/Android.mk index b2392bf..96c4c77 100644 --- a/trampoline_encmnt/Android.mk +++ b/trampoline_encmnt/Android.mk @@ -5,17 +5,12 @@ LOCAL_MODULE:= trampoline_encmnt LOCAL_MODULE_TAGS := eng LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) -LOCAL_SHARED_LIBRARIES := libcutils libcryptfslollipop +LOCAL_SHARED_LIBRARIES := libcutils libcryptfslollipop libmultirom mr_twrp_path := bootable/recovery LOCAL_C_INCLUDES += $(multirom_local_path) $(mr_twrp_path) $(mr_twrp_path)/crypto/scrypt/lib/crypto external/openssl/include LOCAL_SRC_FILES := \ encmnt.c \ - ../fstab.c \ - ../containers.c \ - ../util.c \ - -LOCAL_CFLAGS += -DMR_LOG_TAG=\"trampoline_encmnt\" include $(BUILD_EXECUTABLE) diff --git a/trampoline_encmnt/encmnt.c b/trampoline_encmnt/encmnt.c index 85431ff..21bbc52 100644 --- a/trampoline_encmnt/encmnt.c +++ b/trampoline_encmnt/encmnt.c @@ -21,8 +21,8 @@ #include #include -#include "../log.h" -#include "../fstab.h" +#include "../lib/log.h" +#include "../lib/fstab.h" #include "crypto/lollipop/cryptfs.h"