一.基本名词解释:
WearRecoveryUI::WearRecoveryUI()
: kProgressBarBaseline(RECOVERY_UI_PROGRESS_BAR_BASELINE),
kMenuUnusableRows(RECOVERY_UI_MENU_UNUSABLE_ROWS)
{
....
}
RECOVERY_UI_PROGRESS_BAR_BASELINE //进度条垂直显示的坐标位置,它水平居中
ScreenRecoveryUI::ScreenRecoveryUI()
: kMarginWidth(RECOVERY_UI_MARGIN_WIDTH),
kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT),
kAnimationFps(RECOVERY_UI_ANIMATION_FPS),
RECOVERY_UI_MARGIN_WIDTH //文本列显示
RECOVERY_UI_MARGIN_HEIGHT // 文本行显示
二.继承关系如下:
class WearRecoveryUI : public ScreenRecoveryUI
class ScreenRecoveryUI : public RecoveryUI
wear来自 screen screen来自recovery
解释如下:wear ui的init 会先调用父类的 screen的ui的init,在这个init里面会有用到screen的ui的init,而screen的ui的类会用到recovery的ui的init的方法。
1. bool WearRecoveryUI::Init(const std::string& locale) {
if (!ScreenRecoveryUI::Init(locale)) {
return false;
}
.....
}
2. bool ScreenRecoveryUI::Init(const std::string& locale) {
RecoveryUI::Init(locale);
if (!InitTextParams()) {
return false;
}
{
....
}
3. bool ScreenRecoveryUI::InitTextParams() {
if (gr_init() < 0) {
return false;
}
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;
}
4.class ScreenRecoveryUI : public RecoveryUI {
public:
.....
protected:
// 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;
// Number of frames per sec (default: 30) for both parts of the animation.
const int kAnimationFps;
二.deivce:recovery.cpp main的
Device* device = make_device();
1. boardconfig.mk 修改
TARGET_RECOVERY_UI_LIB = librecovery_ui_wear
2. bootable/recovery/Android.mk
106 ifeq ($(TARGET_RECOVERY_UI_LIB),)
107 LOCAL_SRC_FILES += default_device.cpp
108 else
109 LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UI_LIB)
因此在make_device()的时候调用的是 wear_ui.cpp,不修改是默认走的default_device.cpp。