summaryrefslogtreecommitdiffstats
path: root/recovery_ui/screen_ui.cpp
diff options
context:
space:
mode:
authorFred Chiou <fredchiou@google.com>2022-08-30 13:46:53 +0200
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-08-30 13:46:53 +0200
commit1e85c6b0e8ca49ebb304c11157f66774e35a86ae (patch)
treee5de93d3de54956d825d25f28b558b192b202f8d /recovery_ui/screen_ui.cpp
parent[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: 9aebac2722 -s ours am: 0f2cd4b915 -s ours am: 86ab8d23b7 -s ours (diff)
parentMerge "recovery_ui:Add support for multiple connectors switch" am: 91688b36bb am: 5a3219c41f am: fa3dd4dd49 (diff)
downloadandroid_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.tar
android_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.tar.gz
android_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.tar.bz2
android_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.tar.lz
android_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.tar.xz
android_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.tar.zst
android_bootable_recovery-1e85c6b0e8ca49ebb304c11157f66774e35a86ae.zip
Diffstat (limited to 'recovery_ui/screen_ui.cpp')
-rw-r--r--recovery_ui/screen_ui.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index b2c828f34..ee3cbb134 100644
--- a/recovery_ui/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -48,6 +48,11 @@
#include "recovery_ui/device.h"
#include "recovery_ui/ui.h"
+enum DirectRenderManager {
+ DRM_INNER,
+ DRM_OUTER,
+};
+
// Return the current time as a double (including fractions of a second).
static double now() {
struct timeval tv;
@@ -334,7 +339,8 @@ ScreenRecoveryUI::ScreenRecoveryUI(bool scrollable_menu)
stage(-1),
max_stage(-1),
locale_(""),
- rtl_locale_(false) {}
+ rtl_locale_(false),
+ is_graphics_available(false) {}
ScreenRecoveryUI::~ScreenRecoveryUI() {
progress_thread_stopped_ = true;
@@ -906,6 +912,7 @@ bool ScreenRecoveryUI::Init(const std::string& locale) {
if (!InitGraphics()) {
return false;
}
+ is_graphics_available = true;
if (!InitTextParams()) {
return false;
@@ -950,6 +957,9 @@ bool ScreenRecoveryUI::Init(const std::string& locale) {
// Keep the progress bar updated, even when the process is otherwise busy.
progress_thread_ = std::thread(&ScreenRecoveryUI::ProgressThreadLoop, this);
+ // set the callback for hall sensor event
+ (void)ev_sync_sw_state([this](auto&& a, auto&& b) { return this->SetSwCallback(a, b);});
+
return true;
}
@@ -1367,3 +1377,45 @@ void ScreenRecoveryUI::SetLocale(const std::string& new_locale) {
}
}
}
+
+int ScreenRecoveryUI::SetSwCallback(int code, int value) {
+ if (!is_graphics_available) { return -1; }
+ if (code > SW_MAX) { return -1; }
+ if (code != SW_LID) { return 0; }
+
+ /* detect dual display */
+ if (!gr_has_multiple_connectors()) { return -1; }
+
+ /* turn off all screen */
+ gr_fb_blank(true, DirectRenderManager::DRM_INNER);
+ gr_fb_blank(true, DirectRenderManager::DRM_OUTER);
+ gr_color(0, 0, 0, 255);
+ gr_clear();
+
+ /* turn on the screen */
+ gr_fb_blank(false, value);
+ gr_flip();
+
+ /* set the retation */
+ std::string rotation_str;
+ if (value == DirectRenderManager::DRM_OUTER) {
+ rotation_str =
+ android::base::GetProperty("ro.minui.second_rotation", "ROTATION_NONE");
+ } else {
+ rotation_str =
+ android::base::GetProperty("ro.minui.default_rotation", "ROTATION_NONE");
+ }
+
+ if (rotation_str == "ROTATION_RIGHT") {
+ gr_rotate(GRRotation::RIGHT);
+ } else if (rotation_str == "ROTATION_DOWN") {
+ gr_rotate(GRRotation::DOWN);
+ } else if (rotation_str == "ROTATION_LEFT") {
+ gr_rotate(GRRotation::LEFT);
+ } else { // "ROTATION_NONE" or unknown string
+ gr_rotate(GRRotation::NONE);
+ }
+ Redraw();
+
+ return 0;
+}