bootable: Change how blank screen works

This is required on some devices where previous to 8.1/8.0 the blank
screen flag worked but don't now.

Test: Tested on begonia, screen is now no longer black

Change-Id: Ib4ff607d220bcb1aa5166fea23cc7ecb0e012fdd
(cherry picked from commit 28d8dec40d60a31309fcf6259dad38cd328f0717)
diff --git a/gui/Android.mk b/gui/Android.mk
index 450748d..bf64a77 100755
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -1,4 +1,146 @@
 LOCAL_PATH := $(call my-dir)
+<<<<<<< HEAD
+=======
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := -fno-strict-aliasing -Wno-implicit-fallthrough
+
+LOCAL_SRC_FILES := \
+    gui.cpp \
+    resources.cpp \
+    pages.cpp \
+    text.cpp \
+    image.cpp \
+    action.cpp \
+    console.cpp \
+    fill.cpp \
+    button.cpp \
+    checkbox.cpp \
+    fileselector.cpp \
+    progressbar.cpp \
+    animation.cpp \
+    object.cpp \
+    slider.cpp \
+    slidervalue.cpp \
+    listbox.cpp \
+    keyboard.cpp \
+    input.cpp \
+    blanktimer.cpp \
+    partitionlist.cpp \
+    mousecursor.cpp \
+    scrolllist.cpp \
+    patternpassword.cpp \
+    textbox.cpp \
+    terminal.cpp \
+    twmsg.cpp
+
+ifneq ($(TW_DELAY_TOUCH_INIT_MS),)
+    LOCAL_CFLAGS += -DTW_DELAY_TOUCH_INIT_MS=$(TW_DELAY_TOUCH_INIT_MS)
+endif
+
+ifneq ($(TWRP_CUSTOM_KEYBOARD),)
+    LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
+else
+    LOCAL_SRC_FILES += hardwarekeyboard.cpp
+endif
+
+LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libaosprecovery libselinux
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../otautil/include
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../twrpinstall/include
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
+    LOCAL_SHARED_LIBRARIES += libziparchive
+    LOCAL_STATIC_LIBRARIES += libotautil libtwrpinstall
+    ifneq ($(TW_INCLUDE_CRYPTO),)
+        LOCAL_C_INCLUDES += bootable/recovery/crypto/fscrypt
+    endif
+    ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 28; echo $$?),0)
+        LOCAL_C_INCLUDES += $(LOCAL_PATH)/../install/include \
+            system/core/libziparchive/include/ \
+            $(LOCAL_PATH)/../recovery_ui/include \
+            $(LOCAL_PATH)/../fuse_sideload/include
+        LOCAL_CFLAGS += -D_USE_SYSTEM_ZIPARCHIVE
+    else
+        LOCAL_C_INCLUDES += $(LOCAL_PATH)/../install28/ \
+            $(LOCAL_PATH)/../fuse_sideload28/
+        LOCAL_CFLAGS += -DUSE_28_INSTALL -DUSE_OTAUTIL_ZIPARCHIVE
+    endif
+else
+    LOCAL_SHARED_LIBRARIES += libminzip
+    LOCAL_CFLAGS += -DUSE_MINZIP
+endif
+ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
+    ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 28; echo $$?),0)
+        LOCAL_C_INCLUDES += system/extras/ext4_utils \
+            system/extras/ext4_utils/include \
+            $(LOCAL_PATH)/../crypto/ext4crypt
+        LOCAL_SHARED_LIBRARIES += libext4_utils
+    endif
+endif
+
+LOCAL_MODULE := libguitwrp
+
+#TWRP_EVENT_LOGGING := true
+ifeq ($(TWRP_EVENT_LOGGING), true)
+    LOCAL_CFLAGS += -D_EVENT_LOGGING
+endif
+ifneq ($(TW_USE_KEY_CODE_TOUCH_SYNC),)
+    LOCAL_CFLAGS += -DTW_USE_KEY_CODE_TOUCH_SYNC=$(TW_USE_KEY_CODE_TOUCH_SYNC)
+endif
+ifneq ($(TW_OZIP_DECRYPT_KEY),)
+    LOCAL_CFLAGS += -DTW_OZIP_DECRYPT_KEY=\"$(TW_OZIP_DECRYPT_KEY)\"
+else
+    LOCAL_CFLAGS += -DTW_OZIP_DECRYPT_KEY=0
+endif
+ifneq ($(TW_NO_SCREEN_BLANK),)
+    LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK
+endif
+ifneq ($(TW_NO_SCREEN_TIMEOUT),)
+    LOCAL_CFLAGS += -DTW_NO_SCREEN_TIMEOUT
+endif
+ifeq ($(TW_OEM_BUILD), true)
+    LOCAL_CFLAGS += -DTW_OEM_BUILD
+endif
+ifneq ($(TW_X_OFFSET),)
+    LOCAL_CFLAGS += -DTW_X_OFFSET=$(TW_X_OFFSET)
+endif
+ifneq ($(TW_Y_OFFSET),)
+    LOCAL_CFLAGS += -DTW_Y_OFFSET=$(TW_Y_OFFSET)
+endif
+ifneq ($(TW_W_OFFSET),)
+    LOCAL_CFLAGS += -DTW_W_OFFSET=$(TW_W_OFFSET)
+endif
+ifneq ($(TW_H_OFFSET),)
+    LOCAL_CFLAGS += -DTW_H_OFFSET=$(TW_H_OFFSET)
+endif
+ifeq ($(TW_ROUND_SCREEN), true)
+    LOCAL_CFLAGS += -DTW_ROUND_SCREEN
+endif
+ifeq ($(TW_EXCLUDE_NANO), true)
+    LOCAL_CFLAGS += -DTW_EXCLUDE_NANO
+endif
+ifeq ($(AB_OTA_UPDATER),true)
+    LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
+endif
+ifeq ($(TW_SCREEN_BLANK_ON_BOOT), true)
+    LOCAL_CFLAGS += -DTW_SCREEN_BLANK_ON_BOOT
+endif
+
+LOCAL_C_INCLUDES += \
+    bionic \
+    system/core/base/include \
+    system/core/include \
+    system/core/libpixelflinger/include \
+    external/freetype/include
+
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
+    LOCAL_C_INCLUDES += external/stlport/stlport
+    LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
+endif
+
+LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\"
+
+include $(BUILD_STATIC_LIBRARY)
+>>>>>>> 8fde396e... bootable: Change how blank screen works
 
 # Transfer in the resources for the device
 include $(CLEAR_VARS)
diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp
index fe7b77c..6aca270 100644
--- a/gui/blanktimer.hpp
+++ b/gui/blanktimer.hpp
@@ -42,10 +42,11 @@
 
 	bool isScreenOff();
 
+	void blank(void);
+
 private:
 	void setTimer(void);
 	string getBrightness(void);
-	void blank(void);
 
 	pthread_mutex_t mutex;
 	enum State { kOn = 0, kDim = 1, kOff = 2, kBlanked = 3 };
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 2a36fec..da35d23 100755
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -755,6 +755,12 @@
 	gr_init();
 	TWFunc::Set_Brightness(DataManager::GetStrValue("tw_brightness"));
 
+#ifdef TW_SCREEN_BLANK_ON_BOOT
+        printf("TW_SCREEN_BLANK_ON_BOOT := true\n");
+        blankTimer.blank();
+        blankTimer.resetTimerAndUnblank();
+#endif
+
 	// load and show splash screen
 	if (PageManager::LoadPackage("splash", TWRES "splash.xml", "splash")) {
 		LOGERR("Failed to load splash screen XML.\n");
diff --git a/minuitwrp/Android.mk.old b/minuitwrp/Android.mk.old
index df0a039..9455130 100644
--- a/minuitwrp/Android.mk.old
+++ b/minuitwrp/Android.mk.old
@@ -151,9 +151,6 @@
 else
   LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0
 endif
-ifeq ($(TW_SCREEN_BLANK_ON_BOOT), true)
-    LOCAL_CFLAGS += -DTW_SCREEN_BLANK_ON_BOOT
-endif
 ifeq ($(TW_FBIOPAN), true)
     LOCAL_CFLAGS += -DTW_FBIOPAN
 endif
diff --git a/minuitwrp/graphics.cpp b/minuitwrp/graphics.cpp
index 35ffaeb..e173437 100755
--- a/minuitwrp/graphics.cpp
+++ b/minuitwrp/graphics.cpp
@@ -436,12 +436,6 @@
     gr_flip();
     gr_flip();
 
-#ifdef TW_SCREEN_BLANK_ON_BOOT
-    printf("TW_SCREEN_BLANK_ON_BOOT := true\n");
-    gr_fb_blank(true);
-    gr_fb_blank(false);
-#endif
-
     return 0;
 }