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是前端开发人员的利器,所以我自己也在不断摸索中,查看一些博客和资料后,自己总结了一下来帮助自己理解和记忆,也希望能帮到有需要的小伙伴,嘿嘿! 首 ...
随机推荐
- Python3.2官方文档翻译--实例对象和方法对象
6.3.3 实例对象 如今我们用实例对象做什么呢?实例对象唯一可用的操作就是属性引用.如今有两种合法的属性名称:数据属性和方法. 数据属性相当于smallTalk中的实例变量,C++中的数据成员.数据 ...
- [Android学习笔记]页面布局
线性布局:LinearLayout 1.集成ViewGroup,故可容纳多个View 2.线性布局,可设置水平或者垂直方向 相对布局:RelativeLayout
- java学习笔记13--比较器(Comparable、Comparator)
java学习笔记13--比较器(Comparable.Comparator) 分类: JAVA 2013-05-20 23:20 3296人阅读 评论(0) 收藏 举报 Comparable接口的作用 ...
- Java+7入门经典 - 6 扩展类与继承 Part 2/2
6.12 设计类 1) 通过已定义的基类派生子类, 并且添加方法和数据成员来自定义子类, 创建出类的层次结构; Dog 'IS-A' Animal 2) 定义一系列没有层次结构, 由类对象作为数据成员 ...
- python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overflow
python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overfl ...
- Activity数据传输到服务
activity数据接口负责启动该服务包.service获取数据.手术. 详细demo如下面: package com.example.android_service_trance; import a ...
- hdu2389(HK算法)
传送门:Rain on your Parade 题意:t个单位时间后开始下雨,给你N个访客的位置(一维坐标平面内)和他的移动速度,再给M个雨伞的位置,问在下雨前最多有多少人能够拿到雨伞(两个人不共用一 ...
- hdu1428之spfa+dfs
漫步校园 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- poj2236(并查集)
题目连接 题意:一张图上分布着n台坏了的电脑,并知道它们的坐标.两台修好的电脑如果距离<=d就可以联网,也可以通过其他修好的电脑间接相连.给出操作“O x”表示修好x,给出操作“S x y”,请 ...
- Android 自己定义View (二) 进阶
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24300125 继续自己定义View之旅.前面已经介绍过一个自己定义View的基础 ...