summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk18
-rw-r--r--screen_ui.cpp137
-rw-r--r--screen_ui.h12
-rw-r--r--tests/Android.mk4
-rw-r--r--tests/component/update_verifier_test.cpp2
-rw-r--r--tests/component/updater_test.cpp96
-rw-r--r--update_verifier/Android.mk4
-rw-r--r--update_verifier/update_verifier.cpp21
-rw-r--r--vr_ui.cpp31
-rw-r--r--vr_ui.h4
10 files changed, 125 insertions, 204 deletions
diff --git a/Android.mk b/Android.mk
index 5348e365e..4ac8856ea 100644
--- a/Android.mk
+++ b/Android.mk
@@ -93,6 +93,24 @@ endif
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
LOCAL_CFLAGS += -Wno-unused-parameter -Werror
+ifneq ($(TARGET_RECOVERY_UI_MARGIN_HEIGHT),)
+LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_HEIGHT=$(TARGET_RECOVERY_UI_MARGIN_HEIGHT)
+else
+LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_HEIGHT=0
+endif
+
+ifneq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
+LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_WIDTH=$(TARGET_RECOVERY_UI_MARGIN_WIDTH)
+else
+LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_WIDTH=0
+endif
+
+ifneq ($(TARGET_RECOVERY_UI_VR_STEREO_OFFSET),)
+LOCAL_CFLAGS += -DRECOVERY_UI_VR_STEREO_OFFSET=$(TARGET_RECOVERY_UI_VR_STEREO_OFFSET)
+else
+LOCAL_CFLAGS += -DRECOVERY_UI_VR_STEREO_OFFSET=0
+endif
+
LOCAL_C_INCLUDES += \
system/vold \
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 61ef5911f..c41bb22e1 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -43,8 +43,6 @@
#include "screen_ui.h"
#include "ui.h"
-#define TEXT_INDENT 4
-
// Return the current time as a double (including fractions of a second).
static double now() {
struct timeval tv;
@@ -53,7 +51,10 @@ static double now() {
}
ScreenRecoveryUI::ScreenRecoveryUI()
- : currentIcon(NONE),
+ : kMarginWidth(RECOVERY_UI_MARGIN_WIDTH),
+ kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT),
+ density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
+ currentIcon(NONE),
progressBarType(EMPTY),
progressScopeStart(0),
progressScopeSize(0),
@@ -282,65 +283,66 @@ static const char* LONG_PRESS_HELP[] = {
NULL
};
-// Redraw everything on the screen. Does not flip pages.
-// Should only be called with updateMutex locked.
+// Redraws everything on the screen. Does not flip pages. Should only be called with updateMutex
+// locked.
void ScreenRecoveryUI::draw_screen_locked() {
- if (!show_text) {
- draw_background_locked();
- draw_foreground_locked();
- } else {
- gr_color(0, 0, 0, 255);
- gr_clear();
-
- int y = 0;
- if (show_menu) {
- std::string recovery_fingerprint =
- android::base::GetProperty("ro.bootimage.build.fingerprint", "");
-
- SetColor(INFO);
- DrawTextLine(TEXT_INDENT, &y, "Android Recovery", true);
- for (auto& chunk : android::base::Split(recovery_fingerprint, ":")) {
- DrawTextLine(TEXT_INDENT, &y, chunk.c_str(), false);
- }
- DrawTextLines(TEXT_INDENT, &y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP);
-
- SetColor(HEADER);
- DrawTextLines(TEXT_INDENT, &y, menu_headers_);
-
- SetColor(MENU);
- DrawHorizontalRule(&y);
- y += 4;
- for (int i = 0; i < menu_items; ++i) {
- if (i == menu_sel) {
- // Draw the highlight bar.
- SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG);
- DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4);
- // Bold white text for the selected item.
- SetColor(MENU_SEL_FG);
- DrawTextLine(TEXT_INDENT, &y, menu_[i], true);
- SetColor(MENU);
- } else {
- DrawTextLine(TEXT_INDENT, &y, menu_[i], false);
- }
- }
- DrawHorizontalRule(&y);
- }
+ if (!show_text) {
+ draw_background_locked();
+ draw_foreground_locked();
+ return;
+ }
- // display from the bottom up, until we hit the top of the
- // screen, the bottom of the menu, or we've displayed the
- // entire text buffer.
- SetColor(LOG);
- int row = (text_top_ + text_rows_ - 1) % text_rows_;
- size_t count = 0;
- for (int ty = gr_fb_height() - char_height_ - log_bottom_offset_;
- ty >= y && count < text_rows_;
- ty -= char_height_, ++count) {
- int temp_y = ty;
- DrawTextLine(0, &temp_y, text_[row], false);
- --row;
- if (row < 0) row = text_rows_ - 1;
- }
+ gr_color(0, 0, 0, 255);
+ gr_clear();
+
+ static constexpr int TEXT_INDENT = 4;
+ int x = TEXT_INDENT + kMarginWidth;
+ int y = kMarginHeight;
+ if (show_menu) {
+ std::string recovery_fingerprint =
+ android::base::GetProperty("ro.bootimage.build.fingerprint", "");
+
+ SetColor(INFO);
+ DrawTextLine(x, &y, "Android Recovery", true);
+ for (const auto& chunk : android::base::Split(recovery_fingerprint, ":")) {
+ DrawTextLine(x, &y, chunk.c_str(), false);
+ }
+ DrawTextLines(x, &y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP);
+
+ SetColor(HEADER);
+ DrawTextLines(x, &y, menu_headers_);
+
+ SetColor(MENU);
+ DrawHorizontalRule(&y);
+ y += 4;
+ for (int i = 0; i < menu_items; ++i) {
+ if (i == menu_sel) {
+ // Draw the highlight bar.
+ SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG);
+ DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4);
+ // Bold white text for the selected item.
+ SetColor(MENU_SEL_FG);
+ DrawTextLine(x, &y, menu_[i], true);
+ SetColor(MENU);
+ } else {
+ DrawTextLine(x, &y, menu_[i], false);
+ }
}
+ DrawHorizontalRule(&y);
+ }
+
+ // Display from the bottom up, until we hit the top of the screen, the bottom of the menu, or
+ // we've displayed the entire text buffer.
+ SetColor(LOG);
+ int row = (text_top_ + text_rows_ - 1) % text_rows_;
+ size_t count = 0;
+ for (int ty = gr_fb_height() - kMarginHeight - char_height_;
+ ty >= y && count < text_rows_; ty -= char_height_, ++count) {
+ int temp_y = ty;
+ DrawTextLine(x, &temp_y, text_[row], false);
+ --row;
+ if (row < 0) row = text_rows_ - 1;
+ }
}
// Redraw everything on the screen and flip the screen (make it visible).
@@ -450,15 +452,14 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) {
}
bool ScreenRecoveryUI::InitTextParams() {
- if (gr_init() < 0) {
- return false;
- }
+ if (gr_init() < 0) {
+ return false;
+ }
- gr_font_size(gr_sys_font(), &char_width_, &char_height_);
- text_rows_ = gr_fb_height() / char_height_;
- text_cols_ = gr_fb_width() / char_width_;
- log_bottom_offset_ = 0;
- return true;
+ gr_font_size(gr_sys_font(), &char_width_, &char_height_);
+ text_rows_ = (gr_fb_height() - kMarginHeight * 2) / char_height_;
+ text_cols_ = (gr_fb_width() - kMarginWidth * 2) / char_width_;
+ return true;
}
bool ScreenRecoveryUI::Init(const std::string& locale) {
@@ -467,8 +468,6 @@ bool ScreenRecoveryUI::Init(const std::string& locale) {
return false;
}
- density_ = static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f;
-
// Are we portrait or landscape?
layout_ = (gr_fb_width() > gr_fb_height()) ? LANDSCAPE : PORTRAIT;
// Are we the large variant of our base layout?
diff --git a/screen_ui.h b/screen_ui.h
index bd99254f6..2500575ca 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -72,10 +72,16 @@ class ScreenRecoveryUI : public RecoveryUI {
void SetColor(UIElement e);
protected:
- Icon currentIcon;
+ // The margin that we don't want to use for showing texts (e.g. round screen, or screen with
+ // rounded corners).
+ const int kMarginWidth;
+ const int kMarginHeight;
// The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi.
- float density_;
+ const float density_;
+
+ Icon currentIcon;
+
// The layout to use.
int layout_;
@@ -107,7 +113,6 @@ class ScreenRecoveryUI : public RecoveryUI {
// Log text overlay, displayed when a magic key is pressed.
char** text_;
size_t text_col_, text_row_, text_top_;
- int log_bottom_offset_;
bool show_text;
bool show_text_ever; // has show_text ever been true?
@@ -136,6 +141,7 @@ class ScreenRecoveryUI : public RecoveryUI {
int char_width_;
int char_height_;
+
pthread_mutex_t updateMutex;
virtual bool InitTextParams();
diff --git a/tests/Android.mk b/tests/Android.mk
index 262f4ffdd..346873dbe 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -92,6 +92,10 @@ ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
LOCAL_CFLAGS += -DPRODUCT_SUPPORTS_VERITY=1
endif
+ifeq ($(BOARD_AVB_ENABLE),true)
+LOCAL_CFLAGS += -DBOARD_AVB_ENABLE=1
+endif
+
LOCAL_MODULE := recovery_component_test
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_C_INCLUDES := bootable/recovery
diff --git a/tests/component/update_verifier_test.cpp b/tests/component/update_verifier_test.cpp
index 73b4478aa..5fc7ef63f 100644
--- a/tests/component/update_verifier_test.cpp
+++ b/tests/component/update_verifier_test.cpp
@@ -24,7 +24,7 @@
class UpdateVerifierTest : public ::testing::Test {
protected:
void SetUp() override {
-#ifdef PRODUCT_SUPPORTS_VERITY
+#if defined(PRODUCT_SUPPORTS_VERITY) || defined(BOARD_AVB_ENABLE)
verity_supported = true;
#else
verity_supported = false;
diff --git a/tests/component/updater_test.cpp b/tests/component/updater_test.cpp
index 35e87fd56..0298a7645 100644
--- a/tests/component/updater_test.cpp
+++ b/tests/component/updater_test.cpp
@@ -224,102 +224,6 @@ TEST_F(UpdaterTest, file_getprop) {
expect("", script6.c_str(), kNoCause);
}
-TEST_F(UpdaterTest, package_extract_dir) {
- // package_extract_dir expects 2 arguments.
- expect(nullptr, "package_extract_dir()", kArgsParsingFailure);
- expect(nullptr, "package_extract_dir(\"arg1\")", kArgsParsingFailure);
- expect(nullptr, "package_extract_dir(\"arg1\", \"arg2\", \"arg3\")", kArgsParsingFailure);
-
- std::string zip_path = from_testdata_base("ziptest_valid.zip");
- ZipArchiveHandle handle;
- ASSERT_EQ(0, OpenArchive(zip_path.c_str(), &handle));
-
- // Need to set up the ziphandle.
- UpdaterInfo updater_info;
- updater_info.package_zip = handle;
-
- // Extract "b/c.txt" and "b/d.txt" with package_extract_dir("b", "<dir>").
- TemporaryDir td;
- std::string temp_dir(td.path);
- std::string script("package_extract_dir(\"b\", \"" + temp_dir + "\")");
- expect("t", script.c_str(), kNoCause, &updater_info);
-
- // Verify.
- std::string data;
- std::string file_c = temp_dir + "/c.txt";
- ASSERT_TRUE(android::base::ReadFileToString(file_c, &data));
- ASSERT_EQ(kCTxtContents, data);
-
- std::string file_d = temp_dir + "/d.txt";
- ASSERT_TRUE(android::base::ReadFileToString(file_d, &data));
- ASSERT_EQ(kDTxtContents, data);
-
- // Modify the contents in order to retry. It's expected to be overwritten.
- ASSERT_TRUE(android::base::WriteStringToFile("random", file_c));
- ASSERT_TRUE(android::base::WriteStringToFile("random", file_d));
-
- // Extract again and verify.
- expect("t", script.c_str(), kNoCause, &updater_info);
-
- ASSERT_TRUE(android::base::ReadFileToString(file_c, &data));
- ASSERT_EQ(kCTxtContents, data);
- ASSERT_TRUE(android::base::ReadFileToString(file_d, &data));
- ASSERT_EQ(kDTxtContents, data);
-
- // Clean up the temp files under td.
- ASSERT_EQ(0, unlink(file_c.c_str()));
- ASSERT_EQ(0, unlink(file_d.c_str()));
-
- // Extracting "b/" (with slash) should give the same result.
- script = "package_extract_dir(\"b/\", \"" + temp_dir + "\")";
- expect("t", script.c_str(), kNoCause, &updater_info);
-
- ASSERT_TRUE(android::base::ReadFileToString(file_c, &data));
- ASSERT_EQ(kCTxtContents, data);
- ASSERT_TRUE(android::base::ReadFileToString(file_d, &data));
- ASSERT_EQ(kDTxtContents, data);
-
- ASSERT_EQ(0, unlink(file_c.c_str()));
- ASSERT_EQ(0, unlink(file_d.c_str()));
-
- // Extracting "" is allowed. The entries will carry the path name.
- script = "package_extract_dir(\"\", \"" + temp_dir + "\")";
- expect("t", script.c_str(), kNoCause, &updater_info);
-
- std::string file_a = temp_dir + "/a.txt";
- ASSERT_TRUE(android::base::ReadFileToString(file_a, &data));
- ASSERT_EQ(kATxtContents, data);
- std::string file_b = temp_dir + "/b.txt";
- ASSERT_TRUE(android::base::ReadFileToString(file_b, &data));
- ASSERT_EQ(kBTxtContents, data);
- std::string file_b_c = temp_dir + "/b/c.txt";
- ASSERT_TRUE(android::base::ReadFileToString(file_b_c, &data));
- ASSERT_EQ(kCTxtContents, data);
- std::string file_b_d = temp_dir + "/b/d.txt";
- ASSERT_TRUE(android::base::ReadFileToString(file_b_d, &data));
- ASSERT_EQ(kDTxtContents, data);
-
- ASSERT_EQ(0, unlink(file_a.c_str()));
- ASSERT_EQ(0, unlink(file_b.c_str()));
- ASSERT_EQ(0, unlink(file_b_c.c_str()));
- ASSERT_EQ(0, unlink(file_b_d.c_str()));
- ASSERT_EQ(0, rmdir((temp_dir + "/b").c_str()));
-
- // Extracting non-existent entry should still give "t".
- script = "package_extract_dir(\"doesntexist\", \"" + temp_dir + "\")";
- expect("t", script.c_str(), kNoCause, &updater_info);
-
- // Only relative zip_path is allowed.
- script = "package_extract_dir(\"/b\", \"" + temp_dir + "\")";
- expect("", script.c_str(), kNoCause, &updater_info);
-
- // Only absolute dest_path is allowed.
- script = "package_extract_dir(\"b\", \"path\")";
- expect("", script.c_str(), kNoCause, &updater_info);
-
- CloseArchive(handle);
-}
-
// TODO: Test extracting to block device.
TEST_F(UpdaterTest, package_extract_file) {
// package_extract_file expects 1 or 2 arguments.
diff --git a/update_verifier/Android.mk b/update_verifier/Android.mk
index 37d9bfed3..33c5fe9e7 100644
--- a/update_verifier/Android.mk
+++ b/update_verifier/Android.mk
@@ -39,6 +39,10 @@ ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
LOCAL_CFLAGS += -DPRODUCT_SUPPORTS_VERITY=1
endif
+ifeq ($(BOARD_AVB_ENABLE),true)
+LOCAL_CFLAGS += -DBOARD_AVB_ENABLE=1
+endif
+
include $(BUILD_STATIC_LIBRARY)
# update_verifier (executable)
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index fdbcfde56..d3a5185b8 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -99,12 +99,21 @@ static bool read_blocks(const std::string& partition, const std::string& range_s
std::string content;
if (!android::base::ReadFileToString(path, &content)) {
PLOG(WARNING) << "Failed to read " << path;
- } else if (android::base::Trim(content) == partition) {
- dm_block_device = DEV_PATH + std::string(namelist[n]->d_name);
- while (n--) {
- free(namelist[n]);
+ } else {
+ std::string dm_block_name = android::base::Trim(content);
+#ifdef BOARD_AVB_ENABLE
+ // AVB is using 'vroot' for the root block device but we're expecting 'system'.
+ if (dm_block_name == "vroot") {
+ dm_block_name = "system";
+ }
+#endif
+ if (dm_block_name == partition) {
+ dm_block_device = DEV_PATH + std::string(namelist[n]->d_name);
+ while (n--) {
+ free(namelist[n]);
+ }
+ break;
}
- break;
}
free(namelist[n]);
}
@@ -229,7 +238,7 @@ int update_verifier(int argc, char** argv) {
if (is_successful == BoolResult::FALSE) {
// The current slot has not booted successfully.
-#ifdef PRODUCT_SUPPORTS_VERITY
+#if defined(PRODUCT_SUPPORTS_VERITY) || defined(BOARD_AVB_ENABLE)
std::string verity_mode = android::base::GetProperty("ro.boot.veritymode", "");
if (verity_mode.empty()) {
LOG(ERROR) << "Failed to get dm-verity mode.";
diff --git a/vr_ui.cpp b/vr_ui.cpp
index b2c65e3af..8b8261e35 100644
--- a/vr_ui.cpp
+++ b/vr_ui.cpp
@@ -18,39 +18,18 @@
#include <minui/minui.h>
-VrRecoveryUI::VrRecoveryUI() :
- x_offset(400),
- y_offset(400),
- stereo_offset(100) {
-}
+VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {}
bool VrRecoveryUI::InitTextParams() {
- if (gr_init() < 0) {
- return false;
- }
-
- gr_font_size(gr_sys_font(), &char_width_, &char_height_);
+ if (!ScreenRecoveryUI::InitTextParams()) return false;
int mid_divide = gr_fb_width() / 2;
- text_rows_ = (gr_fb_height() - 2 * y_offset) / char_height_;
- text_cols_ = (mid_divide - x_offset - stereo_offset) / char_width_;
- log_bottom_offset_ = gr_fb_height() - 2 * y_offset;
+ text_cols_ = (mid_divide - kMarginWidth - kStereoOffset) / char_width_;
return true;
}
-void VrRecoveryUI::DrawHorizontalRule(int* y) {
- SetColor(MENU);
- *y += 4;
- gr_fill(0, *y + y_offset, gr_fb_width(), *y + y_offset + 2);
- *y += 4;
-}
-
-void VrRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
- gr_fill(x, y + y_offset, x + width, y + y_offset + height);
-}
-
void VrRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
int mid_divide = gr_fb_width() / 2;
- gr_text(gr_sys_font(), x + x_offset + stereo_offset, *y + y_offset, line, bold);
- gr_text(gr_sys_font(), x + x_offset - stereo_offset + mid_divide, *y + y_offset, line, bold);
+ gr_text(gr_sys_font(), x + kStereoOffset, *y, line, bold);
+ gr_text(gr_sys_font(), x - kStereoOffset + mid_divide, *y, line, bold);
*y += char_height_ + 4;
}
diff --git a/vr_ui.h b/vr_ui.h
index 85c570815..31ca4a61d 100644
--- a/vr_ui.h
+++ b/vr_ui.h
@@ -26,12 +26,10 @@ class VrRecoveryUI : public ScreenRecoveryUI {
protected:
// Pixel offsets to move drawing functions to visible range.
// Can vary per device depending on screen size and lens distortion.
- int x_offset, y_offset, stereo_offset;
+ const int kStereoOffset;
bool InitTextParams() override;
- void DrawHorizontalRule(int* y) override;
- void DrawHighlightBar(int x, int y, int width, int height) const override;
void DrawTextLine(int x, int* y, const char* line, bool bold) const override;
};