summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2023-01-15 11:40:16 -0800
committerLinux Build Service Account <lnxbuild@localhost>2023-01-15 11:40:16 -0800
commit95471c03b6247171ae830d5186910c17f28a82c3 (patch)
tree2a7aad601e0655ae8634a1d6be09195fa19a4ff5
parent1f13efa151082311cc0f1739a3553879b01aaf1c (diff)
parent7d7c1f8031682a2705203c0eeebe0458004b2c7b (diff)
Merge 7d7c1f8031682a2705203c0eeebe0458004b2c7b on remote branch
Change-Id: I01afb8d73d92b95ab99688a079a6fc8c0de6121d
-rw-r--r--minui/graphics.cpp4
-rw-r--r--minui/graphics.h5
-rw-r--r--minui/graphics_drm.cpp4
-rw-r--r--minui/graphics_drm.h1
-rw-r--r--minui/graphics_fbdev.cpp5
-rw-r--r--minui/graphics_fbdev.h1
-rw-r--r--minui/include/minui/minui.h1
-rw-r--r--recovery_ui/include/recovery_ui/screen_ui.h6
-rw-r--r--recovery_ui/include/recovery_ui/stub_ui.h4
-rw-r--r--recovery_ui/include/recovery_ui/ui.h2
-rw-r--r--recovery_ui/screen_ui.cpp54
-rw-r--r--recovery_ui/ui.cpp5
-rw-r--r--tests/Android.bp1
-rw-r--r--tests/RecoveryHostTest.xml (renamed from tests/AndroidTest.xml)0
-rw-r--r--tools/recovery_l10n/res/values-or/strings.xml2
-rw-r--r--tools/recovery_l10n/res/values-ro/strings.xml6
16 files changed, 95 insertions, 6 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index b24c2b11..41a36611 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -502,3 +502,7 @@ void gr_fb_blank(bool blank, int index) {
void gr_rotate(GRRotation rot) {
rotation = rot;
}
+
+bool gr_has_multiple_connectors() {
+ return gr_backend->HasMultipleConnectors();
+}
diff --git a/minui/graphics.h b/minui/graphics.h
index 5408c93e..ff063ae2 100644
--- a/minui/graphics.h
+++ b/minui/graphics.h
@@ -40,8 +40,11 @@ class MinuiBackend {
// Blank (or unblank) the specific screen.
virtual void Blank(bool blank, DrmConnector index) = 0;
+ // Return true if the device supports multiple connectors.
+ virtual bool HasMultipleConnectors() = 0;
+
// Device cleanup when drawing is done.
- virtual ~MinuiBackend() {};
+ virtual ~MinuiBackend() = default;
};
#endif // _GRAPHICS_H_
diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp
index e9ee9347..c17cef95 100644
--- a/minui/graphics_drm.cpp
+++ b/minui/graphics_drm.cpp
@@ -471,6 +471,10 @@ void MinuiBackendDrm::Blank(bool blank, DrmConnector index) {
drmModeAtomicFree(atomic_req);
}
+bool MinuiBackendDrm::HasMultipleConnectors() {
+ return (drm[DRM_SEC].GRSurfaceDrms[0] && drm[DRM_SEC].GRSurfaceDrms[1]);
+}
+
static drmModeCrtc* find_crtc_for_connector(int fd, drmModeRes* resources,
drmModeConnector* connector) {
// Find the encoder. If we already have one, just use it.
diff --git a/minui/graphics_drm.h b/minui/graphics_drm.h
index 2d6fab3a..5124dbe9 100644
--- a/minui/graphics_drm.h
+++ b/minui/graphics_drm.h
@@ -81,6 +81,7 @@ class MinuiBackendDrm : public MinuiBackend {
GRSurface* Flip() override;
void Blank(bool) override;
void Blank(bool blank, DrmConnector index) override;
+ bool HasMultipleConnectors() override;
private:
int DrmDisableCrtc(drmModeAtomicReqPtr atomic_req, DrmConnector index);
diff --git a/minui/graphics_fbdev.cpp b/minui/graphics_fbdev.cpp
index 1cb0c0ab..4a7d3252 100644
--- a/minui/graphics_fbdev.cpp
+++ b/minui/graphics_fbdev.cpp
@@ -47,6 +47,11 @@ void MinuiBackendFbdev::Blank(bool blank, DrmConnector index) {
fprintf(stderr, "Unsupported multiple connectors, blank = %d, index = %d\n", blank, index);
}
+bool MinuiBackendFbdev::HasMultipleConnectors() {
+ fprintf(stderr, "Unsupported multiple connectors\n");
+ return false;
+}
+
void MinuiBackendFbdev::SetDisplayedFramebuffer(size_t n) {
if (n > 1 || !double_buffered) return;
diff --git a/minui/graphics_fbdev.h b/minui/graphics_fbdev.h
index 7e193c4f..c772428d 100644
--- a/minui/graphics_fbdev.h
+++ b/minui/graphics_fbdev.h
@@ -57,6 +57,7 @@ class MinuiBackendFbdev : public MinuiBackend {
GRSurface* Flip() override;
void Blank(bool) override;
void Blank(bool blank, DrmConnector index) override;
+ bool HasMultipleConnectors() override;
private:
void SetDisplayedFramebuffer(size_t n);
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index f9be82f5..2353ed3b 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -129,6 +129,7 @@ int gr_fb_height();
void gr_flip();
void gr_fb_blank(bool blank);
void gr_fb_blank(bool blank, int index);
+bool gr_has_multiple_connectors();
// Clears entire surface to current color.
void gr_clear();
diff --git a/recovery_ui/include/recovery_ui/screen_ui.h b/recovery_ui/include/recovery_ui/screen_ui.h
index 92b3c254..99ad5342 100644
--- a/recovery_ui/include/recovery_ui/screen_ui.h
+++ b/recovery_ui/include/recovery_ui/screen_ui.h
@@ -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::function<int(int, bool)>& key_handler) override;
+ // For Lid switch handle
+ int SetSwCallback(int code, int value) override;
+
protected:
static constexpr int kMenuIndent = 4;
@@ -404,6 +407,9 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
std::mutex updateMutex;
+ // Switch the display to active one after graphics is ready
+ bool is_graphics_available;
+
private:
void SetLocale(const std::string&);
diff --git a/recovery_ui/include/recovery_ui/stub_ui.h b/recovery_ui/include/recovery_ui/stub_ui.h
index 511b1314..49689ba3 100644
--- a/recovery_ui/include/recovery_ui/stub_ui.h
+++ b/recovery_ui/include/recovery_ui/stub_ui.h
@@ -80,6 +80,10 @@ class StubRecoveryUI : public RecoveryUI {
}
void SetTitle(const std::vector<std::string>& /* lines */) override {}
+
+ int SetSwCallback(int /* code */, int /* value */) override {
+ return 0;
+ }
};
#endif // RECOVERY_STUB_UI_H
diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h
index 512732f9..c3e3ee26 100644
--- a/recovery_ui/include/recovery_ui/ui.h
+++ b/recovery_ui/include/recovery_ui/ui.h
@@ -231,6 +231,8 @@ class RecoveryUI {
bool InitScreensaver();
void SetScreensaverState(ScreensaverState state);
+ virtual int SetSwCallback(int code, int value) = 0;
+
// Key event input queue
std::mutex key_queue_mutex;
std::condition_variable key_queue_cond;
diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index b2c828f3..ee3cbb13 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;
+}
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index 6e67b1d4..eb87f526 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -341,6 +341,11 @@ int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
ProcessKey(ev.code, ev.value);
}
+ // For Lid switch handle
+ if (ev.type == EV_SW) {
+ SetSwCallback(ev.code, ev.value);
+ }
+
return 0;
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 9ad3d3b8..0708e855 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -216,6 +216,7 @@ cc_test_host {
],
test_suites: ["general-tests"],
+ test_config: "RecoveryHostTest.xml",
data: ["testdata/*"],
diff --git a/tests/AndroidTest.xml b/tests/RecoveryHostTest.xml
index 0ac75e4e..0ac75e4e 100644
--- a/tests/AndroidTest.xml
+++ b/tests/RecoveryHostTest.xml
diff --git a/tools/recovery_l10n/res/values-or/strings.xml b/tools/recovery_l10n/res/values-or/strings.xml
index 25b28e65..683bf191 100644
--- a/tools/recovery_l10n/res/values-or/strings.xml
+++ b/tools/recovery_l10n/res/values-or/strings.xml
@@ -10,5 +10,5 @@
<string name="recovery_try_again" msgid="7168248750158873496">"ପୁଣି ଚେଷ୍ଟା କରନ୍ତୁ"</string>
<string name="recovery_factory_data_reset" msgid="7321351565602894783">"ଫ୍ୟାକ୍ଟୋରୀ ଡାଟା ରିସେଟ୍‌"</string>
<string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"ସମସ୍ଯ ଉପଯୋଗକର୍ତ୍ତା ଡାଟା ୱାଇପ୍‍ କରିବେ?\n\n ଏହା ଫେରାଇ ନିଆଯାଇପାରିବ ନାହିଁ!"</string>
- <string name="recovery_cancel_wipe_data" msgid="66987687653647384">"ବାତିଲ୍‌ କରନ୍ତୁ"</string>
+ <string name="recovery_cancel_wipe_data" msgid="66987687653647384">"ବାତିଲ କରନ୍ତୁ"</string>
</resources>
diff --git a/tools/recovery_l10n/res/values-ro/strings.xml b/tools/recovery_l10n/res/values-ro/strings.xml
index 585db835..2f1cccdb 100644
--- a/tools/recovery_l10n/res/values-ro/strings.xml
+++ b/tools/recovery_l10n/res/values-ro/strings.xml
@@ -6,9 +6,9 @@
<string name="recovery_no_command" msgid="4465476568623024327">"Nicio comandă"</string>
<string name="recovery_error" msgid="5748178989622716736">"Eroare!"</string>
<string name="recovery_installing_security" msgid="9184031299717114342">"Se instalează actualizarea de securitate"</string>
- <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Nu se poate încărca sistemul Android. Datele dvs. pot fi corupte. Dacă primiți în continuare acest mesaj, poate fi necesar să reveniți la setările din fabrică și să ștergeți toate datele utilizatorului stocate pe acest dispozitiv."</string>
+ <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Nu se poate încărca sistemul Android. Datele tale pot fi corupte. Dacă primești în continuare acest mesaj, poate fi necesar să revii la setările din fabrică și să ștergi toate datele utilizatorului stocate pe acest dispozitiv."</string>
<string name="recovery_try_again" msgid="7168248750158873496">"Reîncercați"</string>
<string name="recovery_factory_data_reset" msgid="7321351565602894783">"Revenire la setările din fabrică"</string>
- <string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"Ștergeți toate datele utilizatorului?\n\n ACEST LUCRU NU POATE FI ANULAT!"</string>
- <string name="recovery_cancel_wipe_data" msgid="66987687653647384">"Anulați"</string>
+ <string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"Șterge toate datele utilizatorului?\n\n ACEST LUCRU NU POATE FI ANULAT!"</string>
+ <string name="recovery_cancel_wipe_data" msgid="66987687653647384">"Anulează"</string>
</resources>