diff --git a/Android.mk b/Android.mk index 23a3b3f8..3a57d048 100755 --- a/Android.mk +++ b/Android.mk @@ -42,9 +42,6 @@ endif include $(CLEAR_VARS) -TWRES_PATH := /twres/ -TWHTCD_PATH := $(TWRES_PATH)htcd/ - TARGET_RECOVERY_GUI := true LOCAL_STATIC_LIBRARIES := @@ -88,7 +85,6 @@ LOCAL_C_INCLUDES += \ system/gsid/include/ \ system/core/init/ \ system/extras/ext4_utils/include \ - $(LOCAL_PATH)/twinstall/include ifneq ($(TARGET_RECOVERY_REBOOT_SRC),) LOCAL_SRC_FILES += $(TARGET_RECOVERY_REBOOT_SRC) @@ -114,6 +110,8 @@ LOCAL_C_INCLUDES += \ external/boringssl/include \ external/libcxx/include \ external/libselinux/include \ + external/libpng \ + $(LOCAL_PATH)/gui/include \ $(LOCAL_PATH)/recovery_ui/include \ $(LOCAL_PATH)/otautil/include \ $(LOCAL_PATH)/install/include \ @@ -121,7 +119,9 @@ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/install/include \ $(LOCAL_PATH)/twrpinstall/include \ $(LOCAL_PATH)/recovery_utils/include \ - $(LOCAL_PATH)/libpixelflinger/include + $(LOCAL_PATH)/libpixelflinger/include \ + $(LOCAL_PATH)/minuitwrp/include \ + $(LOCAL_PATH)/twinstall/include LOCAL_STATIC_LIBRARIES += libguitwrp LOCAL_SHARED_LIBRARIES += libz libc libcutils libstdc++ libtar libblkid libminuitwrp libmtdutils libtwadbbu @@ -404,7 +404,9 @@ TWRP_REQUIRED_MODULES += \ twrpbu \ adbd_system_api_recovery \ me.twrp.twrpapp.apk \ - privapp-permissions-twrpapp.xml + privapp-permissions-twrpapp.xml \ + adbd_system_api_recovery \ + libsync.recovery ifneq ($(TW_EXCLUDE_TZDATA), true) TWRP_REQUIRED_MODULES += \ @@ -500,8 +502,6 @@ endif ifneq ($(TARGET_RECOVERY_DEVICE_MODULES),) TWRP_REQUIRED_MODULES += $(TARGET_RECOVERY_DEVICE_MODULES) endif -LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\" -LOCAL_CFLAGS += -DTWHTCD_PATH=\"$(TWHTCD_PATH)\" ifeq ($(TW_INCLUDE_NTFS_3G),true) TWRP_REQUIRED_MODULES += \ mount.ntfs \ diff --git a/gui/Android.bp b/gui/Android.bp index aa2bbc41..e5b97d8a 100644 --- a/gui/Android.bp +++ b/gui/Android.bp @@ -31,16 +31,19 @@ cc_library_static { "system/core/libziparchive/include", "bootable/recovery/recovery_ui/include", "bootable/recovery/fuse_sideload/include", + "bootable/recovery/gui/include", "bootable/recovery/twrpinstall", "bootable/recovery/twrpinstall/include", "bootable/recovery/libpixelflinger/include", + "bootable/recovery/minuitwrp/include", "bionic", "system/core/base/include", "system/core/include", - "external/freetype/include" + "external/freetype/include", + "external/libpng" ], - srcs: [ + srcs: [ "gui.cpp", "resources.cpp", "pages.cpp", @@ -78,6 +81,7 @@ cc_library_static { "libziparchive" ], static_libs: [ - "libotautil" + "libotautil", + "libpng" ] } \ No newline at end of file diff --git a/gui/action.cpp b/gui/action.cpp index 52981f23..58211d35 100755 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -55,7 +55,7 @@ extern "C" { #include "twinstall/adb_install.h" }; #include "set_metadata.h" -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" @@ -221,9 +221,6 @@ GUIAction::GUIAction(xml_node<>* node) ADD_ACTION(fixpermissions); ADD_ACTION(dd); ADD_ACTION(partitionsd); - ADD_ACTION(installhtcdumlock); - ADD_ACTION(htcdumlockrestoreboot); - ADD_ACTION(htcdumlockreflashrecovery); ADD_ACTION(cmd); ADD_ACTION(terminalcommand); ADD_ACTION(reinjecttwrp); @@ -1362,42 +1359,6 @@ int GUIAction::partitionsd(std::string arg __unused) } -int GUIAction::installhtcdumlock(std::string arg __unused) -{ - operation_start("Install HTC Dumlock"); - if (simulate) { - simulate_progress_bar(); - } else - TWFunc::install_htc_dumlock(); - - operation_end(0); - return 0; -} - -int GUIAction::htcdumlockrestoreboot(std::string arg __unused) -{ - operation_start("HTC Dumlock Restore Boot"); - if (simulate) { - simulate_progress_bar(); - } else - TWFunc::htc_dumlock_restore_original_boot(); - - operation_end(0); - return 0; -} - -int GUIAction::htcdumlockreflashrecovery(std::string arg __unused) -{ - operation_start("HTC Dumlock Reflash Recovery"); - if (simulate) { - simulate_progress_bar(); - } else - TWFunc::htc_dumlock_reflash_recovery_to_boot(); - - operation_end(0); - return 0; -} - int GUIAction::cmd(std::string arg) { int op_status = 0; diff --git a/gui/animation.cpp b/gui/animation.cpp index 2244503e..ed32da44 100644 --- a/gui/animation.cpp +++ b/gui/animation.cpp @@ -38,7 +38,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp index a9573ad5..61356d34 100755 --- a/gui/blanktimer.cpp +++ b/gui/blanktimer.cpp @@ -27,7 +27,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "../twrp-functions.hpp" #include "../variables.h" diff --git a/gui/button.cpp b/gui/button.cpp index 7c7f69f1..4ce595b2 100755 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -37,7 +37,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp index ad16f24c..8bacd8f3 100755 --- a/gui/checkbox.cpp +++ b/gui/checkbox.cpp @@ -38,7 +38,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/console.cpp b/gui/console.cpp index 77fdd967..78723442 100755 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -32,7 +32,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index a32743a5..5835e906 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -32,7 +32,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/fill.cpp b/gui/fill.cpp index 3cfbe6ed..f813bf36 100644 --- a/gui/fill.cpp +++ b/gui/fill.cpp @@ -38,7 +38,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/gui.cpp b/gui/gui.cpp index da35d236..00aab7ff 100755 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -39,7 +39,7 @@ extern "C" #include "../twcommon.h" #include } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/image.cpp b/gui/image.cpp index 2b5c5419..84eac8c5 100644 --- a/gui/image.cpp +++ b/gui/image.cpp @@ -38,7 +38,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/placement.h b/gui/include/gui/placement.h similarity index 100% rename from gui/placement.h rename to gui/include/gui/placement.h diff --git a/gui/input.cpp b/gui/input.cpp index 458eb551..a3c074af 100755 --- a/gui/input.cpp +++ b/gui/input.cpp @@ -40,8 +40,8 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 026984c3..13fd7794 100755 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -27,8 +27,8 @@ extern "C" { #include "../twcommon.h" #include "gui.h" } -#include "../minuitwrp/minui.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/listbox.cpp b/gui/listbox.cpp index 3386465e..91cb7a7b 100644 --- a/gui/listbox.cpp +++ b/gui/listbox.cpp @@ -21,7 +21,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/mousecursor.cpp b/gui/mousecursor.cpp index 93c635ab..8c0d438b 100644 --- a/gui/mousecursor.cpp +++ b/gui/mousecursor.cpp @@ -36,7 +36,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/objects.hpp b/gui/objects.hpp index d4b42c29..3948fb28 100755 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -34,7 +34,7 @@ using namespace rapidxml; #include "resources.hpp" #include "pages.hpp" #include "../partitions.hpp" -#include "placement.h" +#include "gui/placement.h" #ifndef TW_X_OFFSET #define TW_X_OFFSET 0 diff --git a/gui/pages.cpp b/gui/pages.cpp index 0dc80ad1..3145c15f 100755 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -47,7 +47,7 @@ extern "C" { #include "../twcommon.h" #include "gui.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp index 19153c50..406dbbb7 100755 --- a/gui/partitionlist.cpp +++ b/gui/partitionlist.cpp @@ -23,7 +23,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp index a75ed156..cedfda3d 100755 --- a/gui/patternpassword.cpp +++ b/gui/patternpassword.cpp @@ -32,7 +32,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "../twrp-functions.hpp" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp index defd9517..62ce7ce8 100644 --- a/gui/progressbar.cpp +++ b/gui/progressbar.cpp @@ -38,7 +38,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/resources.cpp b/gui/resources.cpp index 9c4eec1e..cf677f61 100755 --- a/gui/resources.cpp +++ b/gui/resources.cpp @@ -37,8 +37,8 @@ extern "C" { #include "gui.h" } -#include "../minuitwrp/truetype.hpp" -#include "../minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" @@ -100,7 +100,7 @@ void Resource::LoadImage(ZipArchiveHandle pZip, std::string file, gr_surface* su void Resource::CheckAndScaleImage(gr_surface source, gr_surface* destination, int retain_aspect) { if (!source) { - *destination = NULL; + *destination = nullptr; return; } if (get_scale_w() != 0 && get_scale_h() != 0) { @@ -214,7 +214,7 @@ ImageResource::ImageResource(xml_node<>* node, ZipArchiveHandle pZip) : Resource(node, pZip) { std::string file; - gr_surface temp_surface = NULL; + gr_surface temp_surface = nullptr; mSurface = NULL; if (!node) { @@ -264,7 +264,8 @@ AnimationResource::AnimationResource(xml_node<>* node, ZipArchiveHandle pZip) std::ostringstream fileName; fileName << file << std::setfill ('0') << std::setw (3) << fileNum; - gr_surface surface, temp_surface = NULL; + gr_surface surface = nullptr; + gr_surface temp_surface = nullptr; LoadImage(pZip, fileName.str(), &temp_surface); CheckAndScaleImage(temp_surface, &surface, retain_aspect); if (surface) { diff --git a/gui/resources.hpp b/gui/resources.hpp index aeacd197..8c122769 100755 --- a/gui/resources.hpp +++ b/gui/resources.hpp @@ -26,10 +26,10 @@ #include #include "rapidxml.hpp" #include "ziparchive/zip_archive.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/truetype.hpp" extern "C" { -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" } // Base Objects diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp index 0a4eed85..cdc6c9e9 100755 --- a/gui/scrolllist.cpp +++ b/gui/scrolllist.cpp @@ -21,8 +21,8 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/slider.cpp b/gui/slider.cpp index 3c5f6526..a183d280 100755 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -40,7 +40,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index 5ed9c4fa..8deb9e08 100755 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -38,8 +38,8 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/terminal.cpp b/gui/terminal.cpp index d7037e1d..7ce81547 100755 --- a/gui/terminal.cpp +++ b/gui/terminal.cpp @@ -33,8 +33,8 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" #include "gui.hpp" diff --git a/gui/text.cpp b/gui/text.cpp index b72dd047..d081e0d8 100755 --- a/gui/text.cpp +++ b/gui/text.cpp @@ -38,8 +38,8 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" -#include "../minuitwrp/truetype.hpp" +#include "minuitwrp/minui.h" +#include "minuitwrp/truetype.hpp" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/gui/textbox.cpp b/gui/textbox.cpp index 824daf32..c0620eeb 100644 --- a/gui/textbox.cpp +++ b/gui/textbox.cpp @@ -23,7 +23,7 @@ extern "C" { #include "../twcommon.h" } -#include "../minuitwrp/minui.h" +#include "minuitwrp/minui.h" #include "rapidxml.hpp" #include "objects.hpp" diff --git a/libpixelflinger/Android.bp b/libpixelflinger/Android.bp index 8a4489c3..1dee6b30 100644 --- a/libpixelflinger/Android.bp +++ b/libpixelflinger/Android.bp @@ -1,21 +1,3 @@ -//bootstrap_go_package { -// name: "soong-libpixelflingertwrp_defaults", -// pkgPath: "bootable/recovery/libpixelflinger", -// deps: [ -// "soong", -// "soong-android", -// "soong-cc" -// ], -// srcs: [ -// "libpixelflingertwrp_defaults.go" -// ], -// pluginFor: ["soong_build"] -//} - -//libpixelflingertwrp_defaults { -// name: "libpixelflingertwrp_defaults" -//} - cc_defaults { name: "libpixelflingertwrp_defaults", diff --git a/minui/minui.h b/minui/minui.h deleted file mode 100644 index 766b943f..00000000 --- a/minui/minui.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _MINUI_H_ -#define _MINUI_H_ - -#ifndef TW_USE_MINUI_21 - -#include - -#include -#include - -// -// Graphics. -// - -struct GRSurface { - int width; - int height; - int row_bytes; - int pixel_bytes; - unsigned char* data; -}; - -struct GRFont { - GRSurface* texture; - int char_width; - int char_height; -}; - -int gr_init(); -void gr_exit(); - -int gr_fb_width(); -int gr_fb_height(); - -void gr_flip(); -void gr_fb_blank(bool blank); - -void gr_clear(); // clear entire surface to current color -void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void gr_fill(int x1, int y1, int x2, int y2); - -void gr_texticon(int x, int y, GRSurface* icon); -#ifdef TW_NO_MINUI_CUSTOM_FONTS -void gr_text(int x, int y, const char *s, bool bold); -int gr_measure(const char *s); -void gr_font_size(int *x, int *y); -void gr_set_font(__attribute__ ((unused))const char* name); -#else - -const GRFont* gr_sys_font(); -int gr_init_font(const char* name, GRFont** dest); -void gr_text(const GRFont* font, int x, int y, const char *s, bool bold); -int gr_measure(const GRFont* font, const char *s); -void gr_font_size(const GRFont* font, int *x, int *y); -#endif - -void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy); -unsigned int gr_get_width(GRSurface* surface); -unsigned int gr_get_height(GRSurface* surface); - -// -// Input events. -// - -struct input_event; - -#ifdef TW_USE_MINUI_WITH_DATA -typedef int (*ev_callback)(int fd, uint32_t epevents, void* data); -typedef int (*ev_set_key_callback)(int code, int value, void* data); - -int ev_init(ev_callback input_cb, void* data); -int ev_add_fd(int fd, ev_callback cb, void* data); -int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data); -#else -using ev_callback = std::function; -using ev_set_key_callback = std::function; - -int ev_init(ev_callback input_cb); -int ev_add_fd(int fd, ev_callback cb); -int ev_sync_key_state(const ev_set_key_callback& set_key_cb); -#endif -void ev_exit(); -void ev_iterate_available_keys(const std::function& f); - -// 'timeout' has the same semantics as poll(2). -// 0 : don't block -// < 0 : block forever -// > 0 : block for 'timeout' milliseconds -int ev_wait(int timeout); - -int ev_get_input(int fd, uint32_t epevents, input_event* ev); -void ev_dispatch(); -int ev_get_epollfd(); - -// -// Resources -// - -bool matches_locale(const std::string& prefix, const std::string& locale); - -// res_create_*_surface() functions return 0 if no error, else -// negative. -// -// A "display" surface is one that is intended to be drawn to the -// screen with gr_blit(). An "alpha" surface is a grayscale image -// interpreted as an alpha mask used to render text in the current -// color (with gr_text() or gr_texticon()). -// -// All these functions load PNG images from "/res/images/${name}.png". - -// Load a single display surface from a PNG image. -int res_create_display_surface(const char* name, GRSurface** pSurface); - -// Load an array of display surfaces from a single PNG image. The PNG -// should have a 'Frames' text chunk whose value is the number of -// frames this image represents. The pixel data itself is interlaced -// by row. -int res_create_multi_display_surface(const char* name, int* frames, - int* fps, GRSurface*** pSurface); -int res_create_multi_display_surface(const char* name, int* frames, - GRSurface*** pSurface); - -// Load a single alpha surface from a grayscale PNG image. -int res_create_alpha_surface(const char* name, GRSurface** pSurface); - -// Load part of a grayscale PNG image that is the first match for the -// given locale. The image is expected to be a composite of multiple -// translations of the same text, with special added rows that encode -// the subimages' size and intended locale in the pixel data. See -// bootable/recovery/tools/recovery_l10n for an app that will generate -// these specialized images from Android resources. -int res_create_localized_alpha_surface(const char* name, const char* locale, - GRSurface** pSurface); - -// Free a surface allocated by any of the res_create_*_surface() -// functions. -void res_free_surface(GRSurface* surface); - -#else //ifndef TW_USE_MINUI_21 - -// This the old minui21/minui.h for compatibility with building TWRP -// in pre 6.0 trees. - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* gr_surface; -typedef unsigned short gr_pixel; - -int gr_init(void); -void gr_exit(void); - -int gr_fb_width(void); -int gr_fb_height(void); -gr_pixel *gr_fb_data(void); -void gr_flip(void); -void gr_fb_blank(bool blank); - -void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void gr_fill(int x1, int y1, int x2, int y2); - -// system/core/charger uses different gr_print signatures in diferent -// Android versions, either with or without int bold. -int gr_text(int x, int y, const char *s, ...); -int gr_text_impl(int x, int y, const char *s, int bold); - - void gr_texticon(int x, int y, gr_surface icon); -int gr_measure(const char *s); -void gr_font_size(int *x, int *y); -void gr_get_memory_surface(gr_surface); - -void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); -unsigned int gr_get_width(gr_surface surface); -unsigned int gr_get_height(gr_surface surface); - -// input event structure, include for the definition. -// see http://www.mjmwired.net/kernel/Documentation/input/ for info. -struct input_event; - -typedef int (*ev_callback)(int fd, uint32_t epevents, void *data); -typedef int (*ev_set_key_callback)(int code, int value, void *data); - -int ev_init(ev_callback input_cb, void *data); -void ev_exit(void); -int ev_add_fd(int fd, ev_callback cb, void *data); -int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data); - -/* timeout has the same semantics as for poll - * 0 : don't block - * < 0 : block forever - * > 0 : block for 'timeout' milliseconds - */ -int ev_wait(int timeout); - -int ev_get_input(int fd, uint32_t epevents, struct input_event *ev); -void ev_dispatch(void); -int ev_get_epollfd(void); - -// Resources - -// Returns 0 if no error, else negative. -int res_create_surface(const char* name, gr_surface* pSurface); - -// Load an array of display surfaces from a single PNG image. The PNG -// should have a 'Frames' text chunk whose value is the number of -// frames this image represents. The pixel data itself is interlaced -// by row. -int res_create_multi_display_surface(const char* name, - int* frames, gr_surface** pSurface); - -int res_create_localized_surface(const char* name, gr_surface* pSurface); -void res_free_surface(gr_surface surface); -static inline int res_create_display_surface(const char* name, gr_surface* pSurface) { - return res_create_surface(name, pSurface); -} - -// These are new graphics functions from 5.0 that were not available in -// 4.4 that are required by charger and healthd -void gr_clear(); - - -#ifdef __cplusplus -} -#endif - -#endif // ifndef TW_USE_MINUI_21 -#endif // ifndef _MINUI_H_ diff --git a/minuitwrp/Android.bp b/minuitwrp/Android.bp old mode 100755 new mode 100644 index 294b7477..ad664779 --- a/minuitwrp/Android.bp +++ b/minuitwrp/Android.bp @@ -1,52 +1,58 @@ -bootstrap_go_package { - name: "soong-libminuitwrp_defaults", - pkgPath: "bootable/recovery/minuitwrp", - deps: [ - "soong", - "soong-android", - "soong-cc" - ], - srcs: [ - "libminuitwrp_defaults.go" - ], - pluginFor: ["soong_build"] -} - -libminuitwrp_defaults { - name: "libminuitwrp_defaults" -} - -cc_library_shared { - name: "libminuitwrp", - defaults: ["libminuitwrp_defaults"], - cflags: [], - include_dirs: [ - "external/libpng", - "external/zlib", - "system/core/include", - "external/freetype/include", - "external/libcxx/include", - "bootable/recovery/twrpinstall/include", - "bootable/recovery/libpixelflinger/include" - ], - srcs: [ - "graphics.cpp", - "graphics_fbdev.cpp", - "resources.cpp", - "truetype.cpp", - "graphics_utils.cpp", - "events.cpp" - ], - shared_libs: [ - "libft2", - "libz", - "libc", - "libcutils", - "libpng", - "libutils", - "libc++", - "libcutils", - "liblog", - ], - static_libs: ["libpixelflinger_twrp"] -} +bootstrap_go_package { + name: "soong-libminuitwrp_defaults", + pkgPath: "bootable/recovery/minuitwrp", + deps: [ + "soong", + "soong-android", + "soong-cc" + ], + srcs: [ + "libminuitwrp_defaults.go" + ], + pluginFor: ["soong_build"] +} + +libminuitwrp_defaults { + name: "libminuitwrp_defaults" +} + +cc_library_shared { + name: "libminuitwrp", + defaults: ["libminuitwrp_defaults"], + cflags: [ + "-DTWRES=\"/twres/\"" + ], + include_dirs: [ + "external/libpng", + "external/zlib", + "system/core/include", + "external/freetype/include", + "external/libcxx/include", + "bootable/recovery/twrpinstall/include", + "bootable/recovery/libpixelflinger/include", + "bootable/recovery/minuitwrp/include", + "bootable/recovery/gui/include" + ], + srcs: [ + "graphics.cpp", + "graphics_fbdev.cpp", + "resources.cpp", + "truetype.cpp", + "graphics_utils.cpp", + "events.cpp" + ], + shared_libs: [ + "libft2", + "libz", + "libc", + "libcutils", + "libpng", + "libutils", + "libc++", + "libcutils", + "liblog", + "libbase", + "libsync" + ], + static_libs: ["libpixelflinger_twrp"] +} diff --git a/minuitwrp/events.cpp b/minuitwrp/events.cpp old mode 100755 new mode 100644 index 6d576c67..34c01e33 --- a/minuitwrp/events.cpp +++ b/minuitwrp/events.cpp @@ -34,7 +34,7 @@ #include "common.h" -#include "minui.h" +#include "minuitwrp/minui.h" //#define _EVENT_LOGGING diff --git a/minuitwrp/graphics.cpp b/minuitwrp/graphics.cpp old mode 100755 new mode 100644 index e1734375..2c2031ab --- a/minuitwrp/graphics.cpp +++ b/minuitwrp/graphics.cpp @@ -33,12 +33,12 @@ #include #include -#include "../gui/placement.h" -#include "minui.h" +#include "gui/placement.h" +#include "minuitwrp/minui.h" #include "graphics.h" // For std::min and std::max #include -#include "truetype.hpp" +#include "minuitwrp/truetype.hpp" struct GRFont { GRSurface* texture; @@ -260,7 +260,6 @@ void gr_fill(int x, int y, int w, int h) r_disp = std::max(x0_disp, x1_disp); t_disp = std::min(y0_disp, y1_disp); b_disp = std::max(y0_disp, y1_disp); - gl->recti(gl, l_disp, t_disp, r_disp, b_disp); if(gr_is_curr_clr_opaque) diff --git a/minuitwrp/graphics.h b/minuitwrp/graphics.h index a4115fd5..5df39ab9 100644 --- a/minuitwrp/graphics.h +++ b/minuitwrp/graphics.h @@ -17,7 +17,7 @@ #ifndef _GRAPHICS_H_ #define _GRAPHICS_H_ -#include "minui.h" +#include "minuitwrp/minui.h" // TODO: lose the function pointers. struct minui_backend { diff --git a/minuitwrp/graphics_drm.cpp b/minuitwrp/graphics_drm.cpp index 409a1237..2b94dda2 100644 --- a/minuitwrp/graphics_drm.cpp +++ b/minuitwrp/graphics_drm.cpp @@ -28,7 +28,7 @@ #include #include -#include "minui.h" +#include "minuitwrp/minui.h" #include "graphics.h" #include diff --git a/minuitwrp/graphics_drm.h b/minuitwrp/graphics_drm.h new file mode 100644 index 00000000..2a16af85 --- /dev/null +++ b/minuitwrp/graphics_drm.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2017 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 +#include + +#include + +#include + +#include "graphics.h" +#include "minuitwrp/minui.h" + +class GRSurfaceDrm : public GRSurface { + public: + ~GRSurfaceDrm() override; + + // Creates a GRSurfaceDrm instance. + static std::unique_ptr Create(int drm_fd, int width, int height); + + uint8_t* data() override { + return mmapped_buffer_; + } + + private: + friend class MinuiBackendDrm; + + GRSurfaceDrm(size_t width, size_t height, size_t row_bytes, size_t pixel_bytes, int drm_fd, + uint32_t handle) + : GRSurface(width, height, row_bytes, pixel_bytes), drm_fd_(drm_fd), handle(handle) {} + + const int drm_fd_; + + uint32_t fb_id{ 0 }; + uint32_t handle{ 0 }; + uint8_t* mmapped_buffer_{ nullptr }; +}; + +class MinuiBackendDrm : public MinuiBackend { + public: + MinuiBackendDrm() = default; + ~MinuiBackendDrm() override; + + GRSurface* Init() override; + GRSurface* Flip() override; + void Blank(bool) override; + + private: + void DrmDisableCrtc(int drm_fd, drmModeCrtc* crtc); + bool DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, const std::unique_ptr& surface); + void DisableNonMainCrtcs(int fd, drmModeRes* resources, drmModeCrtc* main_crtc); + drmModeConnector* FindMainMonitor(int fd, drmModeRes* resources, uint32_t* mode_index); + + std::unique_ptr GRSurfaceDrms[2]; + int current_buffer{ 0 }; + drmModeCrtc* main_monitor_crtc{ nullptr }; + drmModeConnector* main_monitor_connector{ nullptr }; + int drm_fd{ -1 }; +}; diff --git a/minuitwrp/graphics_fbdev.cpp b/minuitwrp/graphics_fbdev.cpp index fc5fcf38..499e0eaf 100644 --- a/minuitwrp/graphics_fbdev.cpp +++ b/minuitwrp/graphics_fbdev.cpp @@ -30,7 +30,7 @@ #include #include -#include "minui.h" +#include "minuitwrp/minui.h" #include "graphics.h" #include diff --git a/minuitwrp/graphics_fbdev.h b/minuitwrp/graphics_fbdev.h new file mode 100644 index 00000000..704d26db --- /dev/null +++ b/minuitwrp/graphics_fbdev.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2017 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 +#include +#include + +#include +#include + +#include + +#include "graphics.h" +#include "minuitwrp/minui.h" + +class GRSurfaceFbdev : public GRSurface { + public: + // Creates and returns a GRSurfaceFbdev instance, or nullptr on error. + static std::unique_ptr Create(size_t width, size_t height, size_t row_bytes, + size_t pixel_bytes); + + uint8_t* data() override { + return buffer_; + } + + protected: + using GRSurface::GRSurface; + + private: + friend class MinuiBackendFbdev; + + // Points to the start of the buffer: either the mmap'd framebuffer or one allocated in-memory. + uint8_t* buffer_{ nullptr }; +}; + +class MinuiBackendFbdev : public MinuiBackend { + public: + MinuiBackendFbdev() = default; + ~MinuiBackendFbdev() override = default; + + GRSurface* Init() override; + GRSurface* Flip() override; + void Blank(bool) override; + + private: + void SetDisplayedFramebuffer(size_t n); + + std::unique_ptr gr_framebuffer[2]; + // Points to the current surface (i.e. one of the two gr_framebuffer's). + GRSurfaceFbdev* gr_draw{ nullptr }; + bool double_buffered; + std::vector memory_buffer; + size_t displayed_buffer{ 0 }; + fb_var_screeninfo vi; + android::base::unique_fd fb_fd; +}; diff --git a/minuitwrp/graphics_utils.cpp b/minuitwrp/graphics_utils.cpp index 0bc86828..03b333ac 100644 --- a/minuitwrp/graphics_utils.cpp +++ b/minuitwrp/graphics_utils.cpp @@ -21,7 +21,7 @@ #include #include -#include "minui.h" +#include "minuitwrp/minui.h" struct fb_var_screeninfo vi; extern GGLSurface gr_mem_surface; diff --git a/minuitwrp/minui.h b/minuitwrp/include/minuitwrp/minui.h similarity index 99% rename from minuitwrp/minui.h rename to minuitwrp/include/minuitwrp/minui.h index a6c2a712..f364fe35 100644 --- a/minuitwrp/minui.h +++ b/minuitwrp/include/minuitwrp/minui.h @@ -17,7 +17,7 @@ #ifndef _MINUI_H_ #define _MINUI_H_ -#include "../gui/placement.h" +#include "gui/placement.h" #include struct GRSurface { diff --git a/minuitwrp/truetype.hpp b/minuitwrp/include/minuitwrp/truetype.hpp similarity index 100% rename from minuitwrp/truetype.hpp rename to minuitwrp/include/minuitwrp/truetype.hpp diff --git a/minuitwrp/include/private/resources.h b/minuitwrp/include/private/resources.h new file mode 100644 index 00000000..047ebe2e --- /dev/null +++ b/minuitwrp/include/private/resources.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2018 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 + +#include +#include + +#include + +// This class handles the PNG file parsing. It also holds the ownership of the PNG pointer and the +// opened file pointer. Both will be destroyed / closed when this object goes out of scope. +class PngHandler { + public: + // Constructs an instance by loading the PNG file from '/res/images/.png', or ''. + PngHandler(const std::string& name); + + ~PngHandler(); + + png_uint_32 width() const { + return width_; + } + + png_uint_32 height() const { + return height_; + } + + png_byte channels() const { + return channels_; + } + + int bit_depth() const { + return bit_depth_; + } + + int color_type() const { + return color_type_; + } + + png_structp png_ptr() const { + return png_ptr_; + } + + png_infop info_ptr() const { + return info_ptr_; + } + + int error_code() const { + return error_code_; + }; + + operator bool() const { + return error_code_ == 0; + } + + private: + png_structp png_ptr_{ nullptr }; + png_infop info_ptr_{ nullptr }; + png_uint_32 width_; + png_uint_32 height_; + png_byte channels_; + int bit_depth_; + int color_type_; + + // The |error_code_| is set to a negative value if an error occurs when opening the png file. + int error_code_{ 0 }; + // After initialization, we'll keep the file pointer open before destruction of PngHandler. + std::unique_ptr png_fp_{ nullptr, fclose }; +}; + +// Overrides the default resource dir, for testing purpose. +void res_set_resource_dir(const std::string&); diff --git a/minuitwrp/libminuitwrp_defaults.go b/minuitwrp/libminuitwrp_defaults.go index 29170987..e56dbf33 100644 --- a/minuitwrp/libminuitwrp_defaults.go +++ b/minuitwrp/libminuitwrp_defaults.go @@ -1,304 +1,304 @@ -package libminui_defaults - -import ( - "android/soong/android" - "android/soong/cc" - "fmt" - "path/filepath" - "strings" -) - -func globalFlags(ctx android.BaseContext) []string { - var cflags []string - - if ctx.AConfig().Getenv("TW_SUPPORT_INPUT_1_2_HAPTICS") == "true" { - cflags = append(cflags, "-DUSE_QTI_HAPTICS") - } - - if ctx.AConfig().Getenv("TW_TARGET_USES_QCOM_BSP") == "true" { - cflags = append(cflags, "-DMSM_BSP") - } - - matches, err := filepath.Glob("system/core/adf/Android.*") - _ = matches - if err == nil { - cflags = append(cflags, "-DHAS_ADF") - } - - if ctx.AConfig().Getenv("TW_NEW_ION_HEAP") == "true" { - cflags = append(cflags, "-DNEW_ION_HEAP") - } - - matches, err = filepath.Glob("external/libdrm/Android.*") - if err == nil { - cflags = append(cflags, "-DHAS_DRM") - } - - if ctx.AConfig().Getenv("TW_INCLUDE_JPEG") != "" { - cflags = append(cflags, "-DTW_INCLUDE_JPEG") - } - - if ctx.AConfig().Getenv("RECOVERY_TOUCHSCREEN_SWAP_XY") == "true" { - cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_SWAP_XY") - } - - if ctx.AConfig().Getenv("RECOVERY_TOUCHSCREEN_FLIP_X") == "true" { - cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_FLIP_X") - } - - if ctx.AConfig().Getenv("RECOVERY_TOUCHSCREEN_FLIP_Y") == "true" { - cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_FLIP_Y") - } - - if ctx.AConfig().Getenv("RECOVERY_GRAPHICS_FORCE_USE_LINELENGTH") == "true" { - cflags = append(cflags, "-DRECOVERY_GRAPHICS_FORCE_USE_LINELENGTH") - } - - if ctx.AConfig().Getenv("RECOVERY_GRAPHICS_FORCE_SINGLE_BUFFER") == "true" { - cflags = append(cflags, "-DRECOVERY_GRAPHICS_FORCE_SINGLE_BUFFER") - } - - if ctx.AConfig().Getenv("TWRP_EVENT_LOGGING") == "true" { - cflags = append(cflags, "-D_EVENT_LOGGING") - } - - var pixelFormat = strings.Replace(ctx.AConfig().Getenv("TARGET_RECOVERY_FORCE_PIXEL_FORMAT"), "\"", "", -1) - - switch pixelFormat { - case "RGBA_8888": - fmt.Println("****************************************************************************)") - fmt.Println("* TARGET_RECOVERY_FORCE_PIXEL_FORMAT := RGBA_8888 not implemented yet *)") - fmt.Println("****************************************************************************)") - cflags = append(cflags, "-DRECOVERY_RGBA") - break - - case "RGBX_8888": - fmt.Println("****************************************************************************)") - fmt.Println("* TARGET_RECOVERY_FORCE_PIXEL_FORMAT := RGBX_8888 not implemented yet *)") - fmt.Println("****************************************************************************)") - cflags = append(cflags, "-DRECOVERY_RGBX") - break - - case "BGRA_8888": - fmt.Println("****************************************************************************)") - fmt.Println("* TARGET_RECOVERY_FORCE_PIXEL_FORMAT := BGRA_8888 not implemented yet *)") - fmt.Println("****************************************************************************)") - cflags = append(cflags, "-DRECOVERY_BGRA") - break - - case "RGB_565": - cflags = append(cflags, "-DRECOVERY_FORCE_RGB_565") - break - } - - pixelFormat = strings.Replace(ctx.AConfig().Getenv("TARGET_RECOVERY_PIXEL_FORMAT"), "\"", "", -1) - switch pixelFormat { - case "ABGR_8888": - cflags = append(cflags, "-DRECOVERY_ABGR") - break - - case "RGBX_8888": - cflags = append(cflags, "-DRECOVERY_RGBX") - break - - case "BGRA_8888": - cflags = append(cflags, "-DRECOVERY_BGRA") - break - } - - if ctx.AConfig().Getenv("TARGET_RECOVERY_OVERSCAN_PERCENT") != "" { - cflags = append(cflags, "-DDOVERSCAN_PERCENT="+ctx.AConfig().Getenv("TARGET_RECOVERY_OVERSCAN_PERCENT")) - } else { - cflags = append(cflags, "-DOVERSCAN_PERCENT=0") - } - - if ctx.AConfig().Getenv("TW_SCREEN_BLANK_ON_BOOT") == "true" { - cflags = append(cflags, "-DTW_SCREEN_BLANK_ON_BOOT") - } - - if ctx.AConfig().Getenv("TW_FBIOPAN") == "true" { - cflags = append(cflags, "-DTW_FBIOPAN") - } - - var tw_rotation = ctx.AConfig().Getenv("TW_ROTATION") - switch tw_rotation { - case "0": - case "90": - case "180": - case "270": - cflags = append(cflags, "-DTW_ROTATION="+tw_rotation) - default: - if ctx.AConfig().Getenv("BOARD_HAS_FLIPPED_SCREEN") == "true" { - cflags = append(cflags, "-DTW_ROTATION=180") - } else { - cflags = append(cflags, "-DTW_ROTATION=0") - } - } - - if ctx.AConfig().Getenv("TW_IGNORE_MAJOR_AXIS_0") == "true" { - cflags = append(cflags, "-DTW_IGNORE_MAJOR_AXIS_0") - } - - if ctx.AConfig().Getenv("TW_IGNORE_MT_POSITION_0") == "true" { - cflags = append(cflags, "-DTW_IGNORE_MT_POSITION_0") - } - - if ctx.AConfig().Getenv("TW_IGNORE_ABS_MT_TRACKING_ID") == "true" { - cflags = append(cflags, "-DTW_IGNORE_ABS_MT_TRACKING_ID") - } - - if ctx.AConfig().Getenv("TW_INPUT_BLACKLIST") != "" { - cflags = append(cflags, "-DTW_INPUT_BLACKLIST="+ctx.AConfig().Getenv("TW_INPUT_BLACKLIST")) - } - - if ctx.AConfig().Getenv("TW_WHITELIST_INPUT") != "" { - cflags = append(cflags, "-DWHITELIST_INPUT="+ctx.AConfig().Getenv("TW_WHITELIST_INPUT")) - } - - if ctx.AConfig().Getenv("TW_HAPTICS_TSPDRV") == "true" { - cflags = append(cflags, "-DTW_HAPTICS_TSPDRV") - } - - cflags = append(cflags, "-DTWRES="+ctx.AConfig().Getenv("TWRES_PATH")) - return cflags -} - -func globalSrcs(ctx android.BaseContext) []string { - var srcs []string - - if ctx.AConfig().Getenv("TW_TARGET_USES_QCOM_BSP") == "true" { - srcs = append(srcs, "graphics_overlay.cpp") - } - - matches, err := filepath.Glob("system/core/adf/Android.*") - _ = matches - if err == nil { - srcs = append(srcs, "graphics_adf.cpp") - } - - matches, err = filepath.Glob("external/libdrm/Android.*") - if err == nil { - srcs = append(srcs, "graphics_drm.cpp") - } - - if ctx.AConfig().Getenv("TW_HAPTICS_TSPDRV") == "true" { - srcs = append(srcs, "tspdrv.cpp") - } - return srcs -} - -func globalIncludes(ctx android.BaseContext) []string { - var includes []string - - if ctx.AConfig().Getenv("TW_INCLUDE_CRYPTO") != "" { - includes = append(includes, "bootable/recovery/crypto/fscrypt") - } - - if ctx.AConfig().Getenv("TW_TARGET_USES_QCOM_BSP") == "true" { - if ctx.AConfig().Getenv("TARGET_PREBUILT_KERNEL") != "" { - includes = append(includes, ctx.AConfig().Getenv("TARGET_OUT_INTERMEDIATES")+"/KERNEL_OBJ/usr/include") - } else { - if ctx.AConfig().Getenv("TARGET_CUSTOM_KERNEL_HEADERS") != "" { - includes = append(includes, "bootable/recovery/minuitwrp") - } else { - includes = append(includes, ctx.AConfig().Getenv("TARGET_CUSTOM_KERNEL_HEADERS")) - } - } - } else { - includes = append(includes, "bootable/recovery/minuitwrp") - } - - if ctx.AConfig().Getenv("TW_INCLUDE_JPEG") != "" { - includes = append(includes, "external/jpeg") - } - - return includes -} - -func globalStaticLibs(ctx android.BaseContext) []string { - var staticLibs []string - - matches, err := filepath.Glob("system/core/adf/Android.*") - _ = matches - if err == nil { - staticLibs = append(staticLibs, "libadf") - } - - matches, err = filepath.Glob("external/libdrm/Android.*") - if err == nil { - matches, err = filepath.Glob("external/libdrm/Android.common.mk") - if err != nil { - staticLibs = append(staticLibs, "libdrm_platform") - } else { - staticLibs = append(staticLibs, "libdrm") - } - } - - return staticLibs -} - -func globalSharedLibs(ctx android.BaseContext) []string { - var sharedLibs []string - - if ctx.AConfig().Getenv("TW_SUPPORT_INPUT_1_2_HAPTICS") == "true" { - sharedLibs = append(sharedLibs, "android.hardware.vibrator@1.2") - sharedLibs = append(sharedLibs, "libhidlbase") - } - - if ctx.AConfig().Getenv("TW_INCLUDE_JPEG") != "" { - sharedLibs = append(sharedLibs, "libjpeg") - } - return sharedLibs -} - -func globalRequiredModules(ctx android.BaseContext) []string { - var requiredModules []string - - if ctx.AConfig().Getenv("TARGET_PREBUILT_KERNEL") != "" { - var kernelDir = ctx.AConfig().Getenv("TARGET_OUT_INTERMEDIATES") + ")/KERNEL_OBJ/usr" - requiredModules = append(requiredModules, kernelDir) - } - return requiredModules -} - -func libMinuiTwrpDefaults(ctx android.LoadHookContext) { - type props struct { - Target struct { - Android struct { - Cflags []string - Enabled *bool - } - } - Cflags []string - Srcs []string - Include_dirs []string - Static_libs []string - Shared_libs []string - Required []string - } - - p := &props{} - p.Cflags = globalFlags(ctx) - s := globalSrcs(ctx) - p.Srcs = s - i := globalIncludes(ctx) - p.Include_dirs = i - staticLibs := globalStaticLibs(ctx) - p.Static_libs = staticLibs - sharedLibs := globalSharedLibs(ctx) - p.Shared_libs = sharedLibs - requiredModules := globalRequiredModules(ctx) - p.Required = requiredModules - ctx.AppendProperties(p) -} - -func init() { - android.RegisterModuleType("libminuitwrp_defaults", libMinuiTwrpDefaultsFactory) -} - -func libMinuiTwrpDefaultsFactory() android.Module { - module := cc.DefaultsFactory() - android.AddLoadHook(module, libMinuiTwrpDefaults) - - return module -} +package twrp + +import ( + "android/soong/android" + "android/soong/cc" + "fmt" + "path/filepath" + "strings" +) + +func globalFlags(ctx android.BaseContext) []string { + var cflags []string + + if ctx.AConfig().Getenv("TW_SUPPORT_INPUT_1_2_HAPTICS") == "true" { + cflags = append(cflags, "-DUSE_QTI_HAPTICS") + } + + if ctx.AConfig().Getenv("TW_TARGET_USES_QCOM_BSP") == "true" { + cflags = append(cflags, "-DMSM_BSP") + } + + matches, err := filepath.Glob("system/core/adf/Android.*") + _ = matches + if err == nil { + cflags = append(cflags, "-DHAS_ADF") + } + + if ctx.AConfig().Getenv("TW_NEW_ION_HEAP") == "true" { + cflags = append(cflags, "-DNEW_ION_HEAP") + } + + matches, err = filepath.Glob("external/libdrm/Android.*") + _ = matches + if err == nil { + cflags = append(cflags, "-DHAS_DRM") + } + + if ctx.AConfig().Getenv("TW_INCLUDE_JPEG") != "" { + cflags = append(cflags, "-DTW_INCLUDE_JPEG") + } + + if ctx.AConfig().Getenv("RECOVERY_TOUCHSCREEN_SWAP_XY") == "true" { + cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_SWAP_XY") + } + + if ctx.AConfig().Getenv("RECOVERY_TOUCHSCREEN_FLIP_X") == "true" { + cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_FLIP_X") + } + + if ctx.AConfig().Getenv("RECOVERY_TOUCHSCREEN_FLIP_Y") == "true" { + cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_FLIP_Y") + } + + if ctx.AConfig().Getenv("RECOVERY_GRAPHICS_FORCE_USE_LINELENGTH") == "true" { + cflags = append(cflags, "-DRECOVERY_GRAPHICS_FORCE_USE_LINELENGTH") + } + + if ctx.AConfig().Getenv("RECOVERY_GRAPHICS_FORCE_SINGLE_BUFFER") == "true" { + cflags = append(cflags, "-DRECOVERY_GRAPHICS_FORCE_SINGLE_BUFFER") + } + + if ctx.AConfig().Getenv("TWRP_EVENT_LOGGING") == "true" { + cflags = append(cflags, "-D_EVENT_LOGGING") + } + + var pixelFormat = strings.Replace(ctx.AConfig().Getenv("TARGET_RECOVERY_FORCE_PIXEL_FORMAT"), "\"", "", -1) + + switch pixelFormat { + case "RGBA_8888": + fmt.Println("****************************************************************************)") + fmt.Println("* TARGET_RECOVERY_FORCE_PIXEL_FORMAT := RGBA_8888 not implemented yet *)") + fmt.Println("****************************************************************************)") + cflags = append(cflags, "-DRECOVERY_RGBA") + break + + case "RGBX_8888": + fmt.Println("****************************************************************************)") + fmt.Println("* TARGET_RECOVERY_FORCE_PIXEL_FORMAT := RGBX_8888 not implemented yet *)") + fmt.Println("****************************************************************************)") + cflags = append(cflags, "-DRECOVERY_RGBX") + break + + case "BGRA_8888": + fmt.Println("****************************************************************************)") + fmt.Println("* TARGET_RECOVERY_FORCE_PIXEL_FORMAT := BGRA_8888 not implemented yet *)") + fmt.Println("****************************************************************************)") + cflags = append(cflags, "-DRECOVERY_BGRA") + break + + case "RGB_565": + cflags = append(cflags, "-DRECOVERY_FORCE_RGB_565") + break + } + + pixelFormat = strings.Replace(ctx.AConfig().Getenv("TWRP_EVENT_LOGGING"), "\"", "", -1) + switch pixelFormat { + case "ABGR_8888": + cflags = append(cflags, "-DRECOVERY_ABGR") + break + + case "RGBX_8888": + cflags = append(cflags, "-DRECOVERY_RGBX") + break + + case "BGRA_8888": + cflags = append(cflags, "-DRECOVERY_BGRA") + break + } + + if ctx.AConfig().Getenv("TARGET_RECOVERY_OVERSCAN_PERCENT") != "" { + cflags = append(cflags, "-DDOVERSCAN_PERCENT="+ctx.AConfig().Getenv("TARGET_RECOVERY_OVERSCAN_PERCENT")) + } else { + cflags = append(cflags, "-DOVERSCAN_PERCENT=0") + } + + if ctx.AConfig().Getenv("TW_SCREEN_BLANK_ON_BOOT") == "true" { + cflags = append(cflags, "-DTW_SCREEN_BLANK_ON_BOOT") + } + + if ctx.AConfig().Getenv("TW_FBIOPAN") == "true" { + cflags = append(cflags, "-DTW_FBIOPAN") + } + + var tw_rotation = ctx.AConfig().Getenv("TW_ROTATION") + switch tw_rotation { + case "0": + case "90": + case "180": + case "270": + cflags = append(cflags, "-DTW_ROTATION="+tw_rotation) + default: + if ctx.AConfig().Getenv("BOARD_HAS_FLIPPED_SCREEN") == "true" { + cflags = append(cflags, "-DTW_ROTATION=180") + } else { + cflags = append(cflags, "-DTW_ROTATION=0") + } + } + + if ctx.AConfig().Getenv("TW_IGNORE_MAJOR_AXIS_0") == "true" { + cflags = append(cflags, "-DTW_IGNORE_MAJOR_AXIS_0") + } + + if ctx.AConfig().Getenv("TW_IGNORE_MT_POSITION_0") == "true" { + cflags = append(cflags, "-DTW_IGNORE_MT_POSITION_0") + } + + if ctx.AConfig().Getenv("TW_IGNORE_ABS_MT_TRACKING_ID") == "true" { + cflags = append(cflags, "-DTW_IGNORE_ABS_MT_TRACKING_ID") + } + + if ctx.AConfig().Getenv("TW_INPUT_BLACKLIST") != "" { + cflags = append(cflags, "-DTW_INPUT_BLACKLIST="+ctx.AConfig().Getenv("TW_INPUT_BLACKLIST")) + } + + if ctx.AConfig().Getenv("TW_WHITELIST_INPUT") != "" { + cflags = append(cflags, "-DWHITELIST_INPUT="+ctx.AConfig().Getenv("TW_WHITELIST_INPUT")) + } + + if ctx.AConfig().Getenv("TW_HAPTICS_TSPDRV") == "true" { + cflags = append(cflags, "-DTW_HAPTICS_TSPDRV") + } + + return cflags +} + +func globalSrcs(ctx android.BaseContext) []string { + var srcs []string + + if ctx.AConfig().Getenv("TW_TARGET_USES_QCOM_BSP") == "true" { + srcs = append(srcs, "graphics_overlay.cpp") + } + + matches, err := filepath.Glob("system/core/adf/Android.*") + _ = matches + if err == nil { + srcs = append(srcs, "graphics_adf.cpp") + } + + matches, err = filepath.Glob("external/libdrm/Android.*") + if err == nil { + srcs = append(srcs, "graphics_drm.cpp") + } + + if ctx.AConfig().Getenv("TW_HAPTICS_TSPDRV") == "true" { + srcs = append(srcs, "tspdrv.cpp") + } + return srcs +} + +func globalIncludes(ctx android.BaseContext) []string { + var includes []string + + if ctx.AConfig().Getenv("TW_INCLUDE_CRYPTO") != "" { + includes = append(includes, "bootable/recovery/crypto/fscrypt") + } + + if ctx.AConfig().Getenv("TW_TARGET_USES_QCOM_BSP") == "true" { + if ctx.AConfig().Getenv("TARGET_PREBUILT_KERNEL") != "" { + includes = append(includes, ctx.AConfig().Getenv("TARGET_OUT_INTERMEDIATES")+"/KERNEL_OBJ/usr/include") + } else { + if ctx.AConfig().Getenv("TARGET_CUSTOM_KERNEL_HEADERS") != "" { + includes = append(includes, "bootable/recovery/minuitwrp") + } else { + includes = append(includes, ctx.AConfig().Getenv("TARGET_CUSTOM_KERNEL_HEADERS")) + } + } + } else { + includes = append(includes, "bootable/recovery/minuitwrp") + } + + if ctx.AConfig().Getenv("TW_INCLUDE_JPEG") != "" { + includes = append(includes, "external/jpeg") + } + + return includes +} + +func globalStaticLibs(ctx android.BaseContext) []string { + var staticLibs []string + + matches, err := filepath.Glob("system/core/adf/Android.*") + _ = matches + if err == nil { + staticLibs = append(staticLibs, "libadf") + } + + matches, err = filepath.Glob("external/libdrm/Android.*") + if err == nil { + matches, err = filepath.Glob("external/libdrm/Android.common.mk") + if err != nil { + staticLibs = append(staticLibs, "libdrm_platform") + } else { + staticLibs = append(staticLibs, "libdrm") + } + } + + return staticLibs +} + +func globalSharedLibs(ctx android.BaseContext) []string { + var sharedLibs []string + + if ctx.AConfig().Getenv("TW_SUPPORT_INPUT_1_2_HAPTICS") == "true" { + sharedLibs = append(sharedLibs, "android.hardware.vibrator@1.2") + sharedLibs = append(sharedLibs, "libhidlbase") + } + + if ctx.AConfig().Getenv("TW_INCLUDE_JPEG") != "" { + sharedLibs = append(sharedLibs, "libjpeg") + } + return sharedLibs +} + +func globalRequiredModules(ctx android.BaseContext) []string { + var requiredModules []string + + if ctx.AConfig().Getenv("TARGET_PREBUILT_KERNEL") != "" { + var kernelDir = ctx.AConfig().Getenv("TARGET_OUT_INTERMEDIATES") + ")/KERNEL_OBJ/usr" + requiredModules = append(requiredModules, kernelDir) + } + return requiredModules +} + +func libMinuiTwrpDefaults(ctx android.LoadHookContext) { + type props struct { + Target struct { + Android struct { + Cflags []string + Enabled *bool + } + } + Cflags []string + Srcs []string + Include_dirs []string + Static_libs []string + Shared_libs []string + Required []string + } + + p := &props{} + p.Cflags = globalFlags(ctx) + s := globalSrcs(ctx) + p.Srcs = s + i := globalIncludes(ctx) + p.Include_dirs = i + staticLibs := globalStaticLibs(ctx) + p.Static_libs = staticLibs + sharedLibs := globalSharedLibs(ctx) + p.Shared_libs = sharedLibs + requiredModules := globalRequiredModules(ctx) + p.Required = requiredModules + ctx.AppendProperties(p) +} + +func init() { + android.RegisterModuleType("libminuitwrp_defaults", libMinuiTwrpDefaultsFactory) +} + +func libMinuiTwrpDefaultsFactory() android.Module { + module := cc.DefaultsFactory() + android.AddLoadHook(module, libMinuiTwrpDefaults) + + return module +} diff --git a/minuitwrp/resources.cpp b/minuitwrp/resources.cpp index c4325e41..f3abd59b 100644 --- a/minuitwrp/resources.cpp +++ b/minuitwrp/resources.cpp @@ -36,7 +36,7 @@ extern "C" { #include "jpeglib.h" } #endif -#include "minui.h" +#include "minuitwrp/minui.h" #define SURFACE_DATA_ALIGNMENT 8 @@ -355,7 +355,6 @@ exit: int res_create_surface(const char* name, gr_surface* pSurface) { int ret; - if (!name) return -1; #ifdef TW_INCLUDE_JPEG @@ -363,7 +362,7 @@ int res_create_surface(const char* name, gr_surface* pSurface) { return res_create_surface_jpg(name,pSurface); #endif - ret = res_create_surface_png(name,pSurface); + ret = res_create_surface_png(name, pSurface); #ifdef TW_INCLUDE_JPEG if (ret < 0) ret = res_create_surface_jpg(name,pSurface); diff --git a/minuitwrp/truetype.cpp b/minuitwrp/truetype.cpp index 9ab8c7a0..d224fbb1 100644 --- a/minuitwrp/truetype.cpp +++ b/minuitwrp/truetype.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "truetype.hpp" +#include "minuitwrp/truetype.hpp" extern unsigned int gr_rotation; diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 16a3653f..ff04e925 100755 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -422,61 +422,6 @@ string TWFunc::Get_Root_Path(const string& Path) { return Local_Path; } -void TWFunc::install_htc_dumlock(void) { - int need_libs = 0; - - if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true)) - return; - - if (!PartitionManager.Mount_By_Path("/data", true)) - return; - - gui_msg("install_dumlock=Installing HTC Dumlock to system..."); - copy_file(TWHTCD_PATH "htcdumlocksys", "/system/bin/htcdumlock", 0755); - if (!Path_Exists("/system/bin/flash_image")) { - LOGINFO("Installing flash_image...\n"); - copy_file(TWHTCD_PATH "flash_imagesys", "/system/bin/flash_image", 0755); - need_libs = 1; - } else - LOGINFO("flash_image is already installed, skipping...\n"); - if (!Path_Exists("/system/bin/dump_image")) { - LOGINFO("Installing dump_image...\n"); - copy_file(TWHTCD_PATH "dump_imagesys", "/system/bin/dump_image", 0755); - need_libs = 1; - } else - LOGINFO("dump_image is already installed, skipping...\n"); - if (need_libs) { - LOGINFO("Installing libs needed for flash_image and dump_image...\n"); - copy_file(TWHTCD_PATH "libbmlutils.so", "/system/lib/libbmlutils.so", 0644); - copy_file(TWHTCD_PATH "libflashutils.so", "/system/lib/libflashutils.so", 0644); - copy_file(TWHTCD_PATH "libmmcutils.so", "/system/lib/libmmcutils.so", 0644); - copy_file(TWHTCD_PATH "libmtdutils.so", "/system/lib/libmtdutils.so", 0644); - } - LOGINFO("Installing HTC Dumlock app...\n"); - mkdir("/data/app", 0777); - unlink("/data/app/com.teamwin.htcdumlock*"); - copy_file(TWHTCD_PATH "HTCDumlock.apk", "/data/app/com.teamwin.htcdumlock.apk", 0777); - sync(); - gui_msg("done=Done."); -} - -void TWFunc::htc_dumlock_restore_original_boot(void) { - if (!PartitionManager.Mount_By_Path("/sdcard", true)) - return; - - gui_msg("dumlock_restore=Restoring original boot..."); - Exec_Cmd("htcdumlock restore"); - gui_msg("done=Done."); -} - -void TWFunc::htc_dumlock_reflash_recovery_to_boot(void) { - if (!PartitionManager.Mount_By_Path("/sdcard", true)) - return; - gui_msg("dumlock_reflash=Reflashing recovery to boot..."); - Exec_Cmd("htcdumlock recovery noreboot"); - gui_msg("done=Done."); -} - int TWFunc::Recursive_Mkdir(string Path) { std::vector parts = Split_String(Path, "/", true); std::string cur_path;