Merge "recovery_ui:Add support for multiple connectors switch" am: 91688b36bb
Original change: https://android-review.googlesource.com/c/platform/bootable/recovery/+/2146827 Change-Id: I05360520fb299fb8413238278758c7aa5aecb881 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
5a3219c41f
5 changed files with 70 additions and 1 deletions
|
@ -245,6 +245,9 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
|
||||||
const std::vector<std::string>& backup_headers, const std::vector<std::string>& backup_items,
|
const std::vector<std::string>& backup_headers, const std::vector<std::string>& backup_items,
|
||||||
const std::function<int(int, bool)>& key_handler) override;
|
const std::function<int(int, bool)>& key_handler) override;
|
||||||
|
|
||||||
|
// For Lid switch handle
|
||||||
|
int SetSwCallback(int code, int value) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static constexpr int kMenuIndent = 4;
|
static constexpr int kMenuIndent = 4;
|
||||||
|
|
||||||
|
@ -404,6 +407,9 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
|
||||||
|
|
||||||
std::mutex updateMutex;
|
std::mutex updateMutex;
|
||||||
|
|
||||||
|
// Switch the display to active one after graphics is ready
|
||||||
|
bool is_graphics_available;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetLocale(const std::string&);
|
void SetLocale(const std::string&);
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,10 @@ class StubRecoveryUI : public RecoveryUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTitle(const std::vector<std::string>& /* lines */) override {}
|
void SetTitle(const std::vector<std::string>& /* lines */) override {}
|
||||||
|
|
||||||
|
int SetSwCallback(int /* code */, int /* value */) override {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECOVERY_STUB_UI_H
|
#endif // RECOVERY_STUB_UI_H
|
||||||
|
|
|
@ -231,6 +231,8 @@ class RecoveryUI {
|
||||||
bool InitScreensaver();
|
bool InitScreensaver();
|
||||||
void SetScreensaverState(ScreensaverState state);
|
void SetScreensaverState(ScreensaverState state);
|
||||||
|
|
||||||
|
virtual int SetSwCallback(int code, int value) = 0;
|
||||||
|
|
||||||
// Key event input queue
|
// Key event input queue
|
||||||
std::mutex key_queue_mutex;
|
std::mutex key_queue_mutex;
|
||||||
std::condition_variable key_queue_cond;
|
std::condition_variable key_queue_cond;
|
||||||
|
|
|
@ -48,6 +48,11 @@
|
||||||
#include "recovery_ui/device.h"
|
#include "recovery_ui/device.h"
|
||||||
#include "recovery_ui/ui.h"
|
#include "recovery_ui/ui.h"
|
||||||
|
|
||||||
|
enum DirectRenderManager {
|
||||||
|
DRM_INNER,
|
||||||
|
DRM_OUTER,
|
||||||
|
};
|
||||||
|
|
||||||
// Return the current time as a double (including fractions of a second).
|
// Return the current time as a double (including fractions of a second).
|
||||||
static double now() {
|
static double now() {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
@ -334,7 +339,8 @@ ScreenRecoveryUI::ScreenRecoveryUI(bool scrollable_menu)
|
||||||
stage(-1),
|
stage(-1),
|
||||||
max_stage(-1),
|
max_stage(-1),
|
||||||
locale_(""),
|
locale_(""),
|
||||||
rtl_locale_(false) {}
|
rtl_locale_(false),
|
||||||
|
is_graphics_available(false) {}
|
||||||
|
|
||||||
ScreenRecoveryUI::~ScreenRecoveryUI() {
|
ScreenRecoveryUI::~ScreenRecoveryUI() {
|
||||||
progress_thread_stopped_ = true;
|
progress_thread_stopped_ = true;
|
||||||
|
@ -906,6 +912,7 @@ bool ScreenRecoveryUI::Init(const std::string& locale) {
|
||||||
if (!InitGraphics()) {
|
if (!InitGraphics()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
is_graphics_available = true;
|
||||||
|
|
||||||
if (!InitTextParams()) {
|
if (!InitTextParams()) {
|
||||||
return false;
|
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.
|
// Keep the progress bar updated, even when the process is otherwise busy.
|
||||||
progress_thread_ = std::thread(&ScreenRecoveryUI::ProgressThreadLoop, this);
|
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;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -341,6 +341,11 @@ int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
|
||||||
ProcessKey(ev.code, ev.value);
|
ProcessKey(ev.code, ev.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Lid switch handle
|
||||||
|
if (ev.type == EV_SW) {
|
||||||
|
SetSwCallback(ev.code, ev.value);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue