android wear recovery UI代码走读

一.基本名词解释:

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)

110 endif

因此在make_device()的时候调用的是 wear_ui.cpp,不修改是默认走的default_device.cpp

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值