ADB命令历史 [英] ADB command history
问题描述
我需要类似于bash历史记录的 ADB
命令历史记录。
我需要在Android手机中创建一个历史记录文件。
I need ADB
command history similar to bash history.
I need a history file to be created in the Android phone.
有没有这样的功能?
如果没有,是否有人可以指向 ADBD
中的代码,该代码从桌面接收命令?
If not, can any one point me to the code in ADBD
where it receives the commands form the desktop?
我可以实现相同的功能。
I can implement the same.
我尝试在Android上启用外壳程序历史记录,但不适用于 ADB
调用的命令。
I tried enabling shell history on Android, but it does not work for the commands invoked by ADB
.
推荐答案
我更改了ADBD中的代码实现功能。
修改后的文件:system / core / adb / shell_service.cpp
I changed the code in ADBD to implement the functionality. Modified file: system/core/adb/shell_service.cpp
bool Subprocess::ForkAndExec(std::string* error) {
-----------
/* Writing the command to history file just before it is executed. */
addToHistory(command_.c_str());
execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data());
-----------
}
void addToHistory(const char * cmd)
{
FILE *fp = fopen("/data/adb_history.txt", "a");
if(NULL == fp)
{
printf("ERROR\n");
return;
}
fwrite(cmd, strlen(cmd), 1, fp);
fwrite("\n", 1, 1, fp);
fclose(fp);
return;
}
目前,它仅在超级用户模式下工作。
For now, it is working in superuser mode only.
这篇关于ADB命令历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!