Loading logd/CommandListener.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, registerCmd(new SetPruneListCmd(buf)); registerCmd(new GetPruneListCmd(buf)); registerCmd(new ReinitCmd()); registerCmd(new ExitCmd(this)); } CommandListener::ShutdownCmd::ShutdownCmd(LogReader *reader, Loading Loading @@ -297,6 +298,21 @@ int CommandListener::ReinitCmd::runCommand(SocketClient *cli, return 0; } CommandListener::ExitCmd::ExitCmd(CommandListener *parent) : LogCommand("EXIT"), mParent(*parent) { } int CommandListener::ExitCmd::runCommand(SocketClient * cli, int /*argc*/, char ** /*argv*/) { setname(); cli->sendMsg("success"); release(cli); return 0; } int CommandListener::getLogSocket() { static const char socketName[] = "logd"; int sock = android_get_control_socket(socketName); Loading logd/CommandListener.h +30 −14 Original line number Diff line number Diff line Loading @@ -52,22 +52,38 @@ private: explicit name##Cmd(LogBuffer *buf); \ virtual ~name##Cmd() {} \ int runCommand(SocketClient *c, int argc, char ** argv); \ }; } LogBufferCmd(Clear) LogBufferCmd(GetBufSize) LogBufferCmd(SetBufSize) LogBufferCmd(GetBufSizeUsed) LogBufferCmd(GetStatistics) LogBufferCmd(GetPruneList) LogBufferCmd(SetPruneList) LogBufferCmd(Clear); LogBufferCmd(GetBufSize); LogBufferCmd(SetBufSize); LogBufferCmd(GetBufSizeUsed); LogBufferCmd(GetStatistics); LogBufferCmd(GetPruneList); LogBufferCmd(SetPruneList); class ReinitCmd : public LogCommand { public: ReinitCmd(); virtual ~ReinitCmd() {} int runCommand(SocketClient *c, int argc, char ** argv); }; #define LogCmd(name) \ class name##Cmd : public LogCommand { \ public: \ name##Cmd(); \ virtual ~name##Cmd() {} \ int runCommand(SocketClient *c, int argc, char ** argv); \ } LogCmd(Reinit); #define LogParentCmd(name) \ class name##Cmd : public LogCommand { \ CommandListener &mParent; \ public: \ name##Cmd(); \ explicit name##Cmd(CommandListener *parent); \ virtual ~name##Cmd() {} \ int runCommand(SocketClient *c, int argc, char ** argv); \ void release(SocketClient *c) { mParent.release(c); } \ } LogParentCmd(Exit); }; Loading Loading
logd/CommandListener.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, registerCmd(new SetPruneListCmd(buf)); registerCmd(new GetPruneListCmd(buf)); registerCmd(new ReinitCmd()); registerCmd(new ExitCmd(this)); } CommandListener::ShutdownCmd::ShutdownCmd(LogReader *reader, Loading Loading @@ -297,6 +298,21 @@ int CommandListener::ReinitCmd::runCommand(SocketClient *cli, return 0; } CommandListener::ExitCmd::ExitCmd(CommandListener *parent) : LogCommand("EXIT"), mParent(*parent) { } int CommandListener::ExitCmd::runCommand(SocketClient * cli, int /*argc*/, char ** /*argv*/) { setname(); cli->sendMsg("success"); release(cli); return 0; } int CommandListener::getLogSocket() { static const char socketName[] = "logd"; int sock = android_get_control_socket(socketName); Loading
logd/CommandListener.h +30 −14 Original line number Diff line number Diff line Loading @@ -52,22 +52,38 @@ private: explicit name##Cmd(LogBuffer *buf); \ virtual ~name##Cmd() {} \ int runCommand(SocketClient *c, int argc, char ** argv); \ }; } LogBufferCmd(Clear) LogBufferCmd(GetBufSize) LogBufferCmd(SetBufSize) LogBufferCmd(GetBufSizeUsed) LogBufferCmd(GetStatistics) LogBufferCmd(GetPruneList) LogBufferCmd(SetPruneList) LogBufferCmd(Clear); LogBufferCmd(GetBufSize); LogBufferCmd(SetBufSize); LogBufferCmd(GetBufSizeUsed); LogBufferCmd(GetStatistics); LogBufferCmd(GetPruneList); LogBufferCmd(SetPruneList); class ReinitCmd : public LogCommand { public: ReinitCmd(); virtual ~ReinitCmd() {} int runCommand(SocketClient *c, int argc, char ** argv); }; #define LogCmd(name) \ class name##Cmd : public LogCommand { \ public: \ name##Cmd(); \ virtual ~name##Cmd() {} \ int runCommand(SocketClient *c, int argc, char ** argv); \ } LogCmd(Reinit); #define LogParentCmd(name) \ class name##Cmd : public LogCommand { \ CommandListener &mParent; \ public: \ name##Cmd(); \ explicit name##Cmd(CommandListener *parent); \ virtual ~name##Cmd() {} \ int runCommand(SocketClient *c, int argc, char ** argv); \ void release(SocketClient *c) { mParent.release(c); } \ } LogParentCmd(Exit); }; Loading