美文网首页
recovery代码调试方法探索

recovery代码调试方法探索

作者: Ed_Lannister | 来源:发表于2018-03-06 14:55 被阅读146次

    进入recovery模式后,shell和logcat等工具都无法正常使用,这些工具都需要静态编译生成到out 目录中recovery文件夹的system/bin下面。recovery模式相对于正常模式都是独立的一套系统。通过在控制台添加服务的方式,都可以使能shell工具,logcat的使能;但是logcat的使能,涉及到很多动态库转静态库的mk文件夹添加。目前没有看到比较高效率的修改方式。
    recovery目录下面的代码本身自带打印log的方式
    recovery.cpp内含如下调用

ui->Print("Failed to make convert_fbe dir %s\n", strerror(errno));

screen_ui.cpp中也有相关的函数实现

void ScreenRecoveryUI::PrintV(const char* fmt, bool copy_to_stdout, va_list ap) {
    std::string str;
    android::base::StringAppendV(&str, fmt, ap);

    if (copy_to_stdout) {
        fputs(str.c_str(), stdout);
    }

    pthread_mutex_lock(&updateMutex);
    if (text_rows_ > 0 && text_cols_ > 0) {
        for (const char* ptr = str.c_str(); *ptr != '\0'; ++ptr) {
            if (*ptr == '\n' || text_col_ >= text_cols_) {
                text_[text_row_][text_col_] = '\0';
                text_col_ = 0;
                text_row_ = (text_row_ + 1) % text_rows_;
                if (text_row_ == text_top_) text_top_ = (text_top_ + 1) % text_rows_;
            }
            if (*ptr != '\n') text_[text_row_][text_col_++] = *ptr;
        }
        text_[text_row_][text_col_] = '\0';
        update_screen_locked();
    }
    pthread_mutex_unlock(&updateMutex);
}

void ScreenRecoveryUI::Print(const char* fmt, ...) {
    va_list ap;
    va_start(ap, fmt);
    PrintV(fmt, true, ap);
    va_end(ap);
}

这里也可以使用标准输出进行log打印,例如

printf("Trying BLKSECDISCARD...\t");

每次升级成功或失败,log都会储存在如下目录

/cache/recovery/last_log

相关文章

网友评论

      本文标题:recovery代码调试方法探索

      本文链接:https://www.haomeiwen.com/subject/shzlfftx.html