libtwrpgui: convert gui to use new ziparchive library

Change-Id: Iea94855257c6d02c2f663c25d390cb1cfb91a727
This commit is contained in:
bigbiff
2021-01-17 11:06:57 -05:00
parent 28653c98b0
commit d81833a5e5
48 changed files with 660 additions and 777 deletions
+8 -8
View File
@@ -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 \
+7 -3
View File
@@ -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"
]
}
+1 -40
View File
@@ -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;
+1 -1
View File
@@ -38,7 +38,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -27,7 +27,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "../twrp-functions.hpp"
#include "../variables.h"
+1 -1
View File
@@ -37,7 +37,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -38,7 +38,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -32,7 +32,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -32,7 +32,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -38,7 +38,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -39,7 +39,7 @@ extern "C"
#include "../twcommon.h"
#include <pixelflinger/pixelflinger.h>
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -38,7 +38,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+2 -2
View File
@@ -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"
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -21,7 +21,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -36,7 +36,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -23,7 +23,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -38,7 +38,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+6 -5
View File
@@ -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) {
+2 -2
View File
@@ -26,10 +26,10 @@
#include <map>
#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
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -40,7 +40,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
+2 -2
View File
@@ -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"
+2 -2
View File
@@ -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"
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -23,7 +23,7 @@
extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
-18
View File
@@ -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",
-246
View File
@@ -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 <sys/types.h>
#include <functional>
#include <string>
//
// 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<int(int fd, uint32_t epevents)>;
using ev_set_key_callback = std::function<int(int code, int value)>;
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<void(int)>& 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 <stdbool.h>
#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 <linux/input.h> 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_
Executable → Regular
+58 -52
View File
@@ -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"]
}
Executable → Regular
+1 -1
View File
@@ -34,7 +34,7 @@
#include "common.h"
#include "minui.h"
#include "minuitwrp/minui.h"
//#define _EVENT_LOGGING
Executable → Regular
+3 -4
View File
@@ -33,12 +33,12 @@
#include <cutils/properties.h>
#include <pixelflinger/pixelflinger.h>
#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 <algorithm>
#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)
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -28,7 +28,7 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "minui.h"
#include "minuitwrp/minui.h"
#include "graphics.h"
#include <pixelflinger/pixelflinger.h>
+74
View File
@@ -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 <stddef.h>
#include <stdint.h>
#include <memory>
#include <xf86drmMode.h>
#include "graphics.h"
#include "minuitwrp/minui.h"
class GRSurfaceDrm : public GRSurface {
public:
~GRSurfaceDrm() override;
// Creates a GRSurfaceDrm instance.
static std::unique_ptr<GRSurfaceDrm> 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<GRSurfaceDrm>& surface);
void DisableNonMainCrtcs(int fd, drmModeRes* resources, drmModeCrtc* main_crtc);
drmModeConnector* FindMainMonitor(int fd, drmModeRes* resources, uint32_t* mode_index);
std::unique_ptr<GRSurfaceDrm> GRSurfaceDrms[2];
int current_buffer{ 0 };
drmModeCrtc* main_monitor_crtc{ nullptr };
drmModeConnector* main_monitor_connector{ nullptr };
int drm_fd{ -1 };
};
+1 -1
View File
@@ -30,7 +30,7 @@
#include <linux/fb.h>
#include <linux/kd.h>
#include "minui.h"
#include "minuitwrp/minui.h"
#include "graphics.h"
#include <pixelflinger/pixelflinger.h>
+71
View File
@@ -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 <linux/fb.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <vector>
#include <android-base/unique_fd.h>
#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<GRSurfaceFbdev> 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<GRSurfaceFbdev> 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<uint8_t> memory_buffer;
size_t displayed_buffer{ 0 };
fb_var_screeninfo vi;
android::base::unique_fd fb_fd;
};
+1 -1
View File
@@ -21,7 +21,7 @@
#include <linux/fb.h>
#include <string.h>
#include "minui.h"
#include "minuitwrp/minui.h"
struct fb_var_screeninfo vi;
extern GGLSurface gr_mem_surface;
@@ -17,7 +17,7 @@
#ifndef _MINUI_H_
#define _MINUI_H_
#include "../gui/placement.h"
#include "gui/placement.h"
#include <stdbool.h>
struct GRSurface {
+87
View File
@@ -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 <stdio.h>
#include <memory>
#include <string>
#include <png.h>
// 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/<name>.png', or '<name>'.
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<FILE, decltype(&fclose)> png_fp_{ nullptr, fclose };
};
// Overrides the default resource dir, for testing purpose.
void res_set_resource_dir(const std::string&);
+304 -304
View File
@@ -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
}
+2 -3
View File
@@ -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);
+1 -1
View File
@@ -26,7 +26,7 @@
#include <pthread.h>
#include <algorithm>
#include <string>
#include "truetype.hpp"
#include "minuitwrp/truetype.hpp"
extern unsigned int gr_rotation;
-55
View File
@@ -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<std::string> parts = Split_String(Path, "/", true);
std::string cur_path;