recovery: Blank screen on init

* Fixes touch on some devices like chiron/sagit

* Some other devices (e.g. most MTK) need this because their kernel driver
  implementations do not perform as expected (initial unblank is only
  happening when altering the panel brightness x -> 0 -> y). In regular
  Android, that "unblanking" is done on boot when the lights HAL loads and
  sets the initial brightness.

Change-Id: I2fffac508d09d07355a7a7f087805b0dceb5f97e
diff --git a/recovery_ui/include/recovery_ui/screen_ui.h b/recovery_ui/include/recovery_ui/screen_ui.h
index 2e0fcc2..e24ff84 100644
--- a/recovery_ui/include/recovery_ui/screen_ui.h
+++ b/recovery_ui/include/recovery_ui/screen_ui.h
@@ -262,6 +262,9 @@
   // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi.
   const float density_;
 
+  // Whether we should blank and unblank screen on init to workaround device specific issues
+  bool blank_unblank_on_init_;
+
   virtual bool InitTextParams();
 
   virtual bool LoadWipeDataMenuText();
diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index 679acac..578dd14 100644
--- a/recovery_ui/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -319,6 +319,8 @@
       animation_fps_(
           android::base::GetIntProperty("ro.recovery.ui.animation_fps", kDefaultAnimationFps)),
       density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
+      blank_unblank_on_init_(
+          android::base::GetBoolProperty("ro.recovery.ui.blank_unblank_on_init", false)),
       current_icon_(NONE),
       current_frame_(0),
       intro_done_(false),
@@ -918,6 +920,11 @@
     return false;
   }
 
+  if (blank_unblank_on_init_) {
+    gr_fb_blank(true);
+    gr_fb_blank(false);
+  }
+
   // Are we portrait or landscape?
   layout_ = (gr_fb_width() > gr_fb_height()) ? LANDSCAPE : PORTRAIT;
   // Are we the large variant of our base layout?