twrp gui/actions.cpp 中的功能实现 tw_action ,tw_action_param ,第二章
继续分析 twrp ui.xml中的相关内容,以<page name="reboot">为讲解内容
<object type="button">
<highlight color="%highlight_color%" />
<condition var1="tw_reboot_system" var2="1" />
<placement x="%col1_x%" y="%row1_y%" />
<font resource="font" color="%button_text_color%" />
<text>System</text>
<image resource="main_button" />
<actions>
<action function="set">tw_back=reboot</action>
<action function="set">tw_action=reboot</action>
<action function="set">tw_action_param=system</action>
<action function="set">tw_has_action2=0</action>
<action function="set">tw_text1=No OS Installed! Are you</action>
<action function="set">tw_text2=sure you wish to reboot?</action>
<action function="set">tw_action_text1=Rebooting...</action>
<action function="set">tw_complete_text1=Rebooting...</action>
<action function="set">tw_slider_text=Swipe to Reboot</action>
<action function="page">rebootcheck</action>
</actions>
</object> <object type="button">
<highlight color="%highlight_color%" />
<condition var1="tw_reboot_poweroff" var2="1" />
<placement x="%col2_x%" y="%row1_y%" />
<font resource="font" color="%button_text_color%" />
<text>Power Off</text>
<image resource="main_button" />
<actions>
<action function="set">tw_back=reboot</action>
<action function="set">tw_action=reboot</action>
<action function="set">tw_action_param=poweroff</action>
<action function="set">tw_has_action2=0</action>
<action function="set">tw_text1=No OS Installed! Are you</action>
<action function="set">tw_text2=sure you wish to power off?</action>
<action function="set">tw_action_text1=Turning Off...</action>
<action function="set">tw_complete_text1=Turning Off...</action>
<action function="set">tw_slider_text=Swipe to Power Off</action>
<action function="page">rebootcheck</action>
</actions>
</object> <object type="button">
<highlight color="%highlight_color%" />
<condition var1="tw_reboot_recovery" var2="1" />
<placement x="%col1_x%" y="%row2_y%" />
<font resource="font" color="%button_text_color%" />
<text>Recovery</text>
<image resource="main_button" />
<actions>
<action function="set">tw_back=reboot</action>
<action function="set">tw_action=reboot</action>
<action function="set">tw_action_param=recovery</action>
<action function="set">tw_has_action2=0</action>
<action function="set">tw_text1=No OS Installed! Are you</action>
<action function="set">tw_text2=sure you wish to reboot?</action>
<action function="set">tw_action_text1=Rebooting...</action>
<action function="set">tw_complete_text1=Rebooting...</action>
<action function="set">tw_slider_text=Swipe to Reboot</action>
<action function="page">rebootcheck</action>
</actions>
</object> <object type="button">
<highlight color="%highlight_color%" />
<condition var1="tw_reboot_bootloader" var2="1" />
<placement x="%col2_x%" y="%row2_y%" />
<font resource="font" color="%button_text_color%" />
<text>Bootloader</text>
<image resource="main_button" />
<actions>
<action function="set">tw_back=reboot</action>
<action function="set">tw_action=reboot</action>
<action function="set">tw_action_param=bootloader</action>
<action function="set">tw_has_action2=0</action>
<action function="set">tw_text1=No OS Installed! Are you</action>
<action function="set">tw_text2=sure you wish to reboot?</action>
<action function="set">tw_action_text1=Rebooting...</action>
<action function="set">tw_complete_text1=Rebooting...</action>
<action function="set">tw_slider_text=Swipe to Reboot</action>
<action function="page">rebootcheck</action>
</actions>
</object>
tw_actoin=reboot传入的是命令,tw_action_param=system 传入的是参数
在gui/actions.cpp 中有如下的函数定义
int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
{
static string zip_queue[];
static int zip_queue_index;
static pthread_t terminal_command;
int simulate; std::string arg = gui_parse_text(action.mArg); //这里获取tw_action=的参数即tw_action_param传入的参数 std::string function = gui_parse_text(action.mFunction); //获取tw_action传入的函数名字 DataManager::GetValue(TW_SIMULATE_ACTIONS, simulate); if (function == "reboot")
{
//curtainClose(); this sometimes causes a crash sync();
DataManager::SetValue("tw_gui_done", );
DataManager::SetValue("tw_reboot_arg", arg); //把参数传入到,其中tw_reboot_arg的类型是 map<string, string> return ;
}
...
好了,再看别外一个文件:
// reboot: Reboot the system. Return -1 on error, no return on success
int TWFunc::tw_reboot(RebootCommand command) //RebootCommand 中一个enum类型,定义在twrp-functions.hpp中
{
// Always force a sync before we reboot
sync(); switch (command) {
case rb_current:
case rb_system:
Update_Log_File();
Update_Intent_File("s");
sync();
check_and_run_script("/sbin/rebootsystem.sh", "reboot system");
return reboot(RB_AUTOBOOT);
case rb_recovery:
check_and_run_script("/sbin/rebootrecovery.sh", "reboot recovery");
return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "recovery");
case rb_bootloader:
check_and_run_script("/sbin/rebootbootloader.sh", "reboot bootloader");
return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "bootloader");
case rb_poweroff:
check_and_run_script("/sbin/poweroff.sh", "power off");
#ifdef ANDROID_RB_POWEROFF
android_reboot(ANDROID_RB_POWEROFF, , );
#endif
return reboot(RB_POWER_OFF);
case rb_download:
check_and_run_script("/sbin/rebootdownload.sh", "reboot download");
return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "download");
default:
return -;
}
return -;
}
RebootCommand类型定义如下:
typedef enum {
rb_recovery,
rb_poweroff,
rb_bootloader,
rb_download,
} RebootCommand;
触发重启进入什么类型的调用在twrp.cpp::main()函数中
定义如下:
...
// Reboot
TWFunc::Update_Intent_File(Reboot_Value);
TWFunc::Update_Log_File();
gui_print("Rebooting...\n");
string Reboot_Arg;
DataManager::GetValue("tw_reboot_arg", Reboot_Arg); //这里获取tw_reboot_arg中的变量
if (Reboot_Arg == "recovery")
TWFunc::tw_reboot(rb_recovery); //传入enum变量,触发重启进入recovery动作
else if (Reboot_Arg == "poweroff")
TWFunc::tw_reboot(rb_poweroff);
else if (Reboot_Arg == "bootloader")
TWFunc::tw_reboot(rb_bootloader);
else if (Reboot_Arg == "download")
TWFunc::tw_reboot(rb_download);
else
TWFunc::tw_reboot(rb_system);
...
twrp gui/actions.cpp 中的功能实现 tw_action ,tw_action_param ,第二章的更多相关文章
- c/cpp中怎样切割字符串,相似于split的功能
在python中,假设要求当前时间的unix时间戳,我特别喜欢这么用: import time timestr = time.time() timestamp = int(timestr.split( ...
- Django——Xadmin中的功能
app_label 功能 如果不在标准models.py里面定义model,则必须指定这个model归属于哪个app. 使用 app_label = 'oms' actions 功能 Action插件 ...
- template 不能分别在.h和.cpp中定义模板
先上代码: #ifndef SEQLIST_H #define SEQLIST_H #include <iostream> ; template <typename type> ...
- Qt调用dll中的功能函数
声明: 事先我已经自己动手写了一个简单的dll文件(myDLL.dll),C版接口的.并且用我前两篇有关DLL文章里面的方法,从dll中导出了导入库(.lib)文件,dll中有两个函数,原型如下: ...
- OpenGL中的功能与OSG对应功能 (摘)
将OpenGL中的功能与OSG对应功能进行列举: OpenGL function OpenSceneGraph implementation glClear( GLbitfield mask ) os ...
- oracle数据库不支持mysql中limit功能
oracle数据库不支持mysql中limit功能,但可以通过rownum来限制返回的结果集的行数,rownum并不是用户添加的字段,而是oracle系统自动添加的. (1)使查询结果最多返回前10行 ...
- ppt画笔标记在哪里|ppt中画笔工具功能怎么用?
一.ppt中画笔工具功能在哪里? 这个画笔工具其实就相当于我们的一个标记工具,要实现标记功能首先将需要演示的PPT按住F5进入到放映状态,然后在右击ppt上的空白处就会弹出衣蛾对话框,在对话框中选择“ ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第14章节--使用Office Services开发应用程序 Excel Services中新功能
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第14章节--使用Office Services开发应用程序 Excel Services中新功能 从S ...
- 浏览器中 F12 功能的简单介绍
chrome浏览器中 F12 功能的简单介绍 由于F12是前端开发人员的利器,所以我自己也在不断摸索中,查看一些博客和资料后,自己总结了一下来帮助自己理解和记忆,也希望能帮到有需要的小伙伴,嘿嘿! 首 ...
随机推荐
- 简单的 "双缓冲" 绘图的例子(研究一下)
所谓双缓冲就是先画到内存画布(如: TBitmap), 然后再转帖到目的地. 譬如下面小程序: procedure TForm1.FormCreate(Sender: TObject); begin ...
- ThinkPHP页面跳转、Ajax技巧详细介绍(十八)
原文:ThinkPHP页面跳转.Ajax技巧详细介绍(十八) ThinkPHP页面跳转.Ajax技巧详细介绍 一.页面跳转 $this->success('查询成功',U('User/test' ...
- [C++]new和delete
Date:2014-1-5 Summary: C++中的动态内存创建与释放(这里就只记录C++中的new和delete了,其他的C风格操作就略过了) 单独记录new和delete的原因是为了学习时候关 ...
- 欧拉计划·第四题
题目4:找出由两个三位数乘积构成的回文. 一个回文数指的是从左向右和从右向左读都一样的数字.最大的由两个两位数乘积构成的回文数是9009 = 91 * 99. 找出最大的有由个三位数乘积构成的回文数. ...
- JavaScript 中的事件类型4(读书笔记思维导图)
Web 浏览器中可能发生的事件有很多类型.如前所述,不同的事件类型具有不同的信息,而“ DOM3级事件”规定了以下几类事件. UI(User Interface,用户界面)事件:当用户与页面上的元素交 ...
- Deep learning From Image to Sequence
本文笔记旨在概括地讲deep learning的经典应用.内容太大,分三块. ------------------------------------------------------------- ...
- 基于WEB 的认证防火墙的设计
项目要求: 1. 采用Linux iptbles作为接入防火墙,默认放行所以访问入口的80端口 2. 访问者通过http://x.x.x.x 访问防火墙的认证系统,进行账号的登陆操作,同时系统对用 ...
- Codeforces 452A Eevee
#include<bits/stdc++.h> using namespace std; string m[]={"vaporeon","jolteon&qu ...
- elf 文件格式探秘——程序运行背后的故事
摘要:本文主要讲解elf文件格式,通过readelf命令结合底层的相关数据结构,讲解相关内容,分析程序运行的基本原理. 本文来源:elf 文件格式探秘——程序运行背后的故事 http://blog.c ...
- 自定义Annotation
来源:http://blog.csdn.net/lifetragedy/article/details/7394910 概念篇 来看一个最简单的annotation示例 @Target(Element ...