| 94 | } |
| 95 | |
| 96 | std::string DeviceOperateWrapper::toString() const { |
| 97 | std::string ret; |
| 98 | try { |
| 99 | nlohmann::json retJson; |
| 100 | retJson["act"] = actName[this->act]; |
| 101 | retJson["pos"] = nlohmann::json::array({this->pos.left, this->pos.top, |
| 102 | this->pos.right, this->pos.bottom}); |
| 103 | retJson["sid"] = this->sid; |
| 104 | retJson["aid"] = this->aid; |
| 105 | retJson["waitTime"] = this->waitTime; |
| 106 | retJson["throttle"] = this->throttle; |
| 107 | retJson["allowFuzzing"] = this->allowFuzzing; |
| 108 | retJson["extra0"] = this->extra0; |
| 109 | retJson["name"] = this->name; |
| 110 | retJson["text"] = this->_text; |
| 111 | retJson["clear"] = BOOL_TO_STR(this->clear); |
| 112 | retJson["adbInput"] = BOOL_TO_STR(this->adbInput); |
| 113 | retJson["rawInput"] = BOOL_TO_STR(this->rawInput); |
| 114 | retJson["editable"] = BOOL_TO_STR(this->editable); |
| 115 | retJson["jAction"] = this->jAction; |
| 116 | ret = retJson.dump(); |
| 117 | } |
| 118 | catch (nlohmann::json::exception &e) // may some char encoding error |
| 119 | { |
| 120 | BLOGE("Parse Operate For Device Error! %s", e.what()); |
| 121 | char returnCString[2000]; |
| 122 | sprintf(returnCString, "{\"act\":\"%s\", \"pos\":[%d,%d,%d,%d],\"sid\":\"%s\", \ |
| 123 | \"aid\":\"%s\",\"waitTime\":%d,\"throttle\":%.2f,\"extra0\":\"%s\", \ |
| 124 | \"name\":\"%s\",\"text\":\"%s\",\"allowFuzzing\":\"%s\",\"clear\":\"%s\",\"adbInput\":\"%s\", \ |
| 125 | \"rawInput\":\"%s\",\"editable\":\"%s\",\"jAction\":\"%s\"}", |
| 126 | actName[this->act].c_str(), |
| 127 | pos.left, pos.top, pos.right, pos.bottom, sid.c_str(), aid.c_str(), |
| 128 | waitTime, throttle, extra0.c_str(), name.c_str(), _text.c_str(), |
| 129 | BOOL_TO_STR(this->allowFuzzing), BOOL_TO_STR(this->clear), |
| 130 | BOOL_TO_STR(this->adbInput), |
| 131 | BOOL_TO_STR(this->rawInput), BOOL_TO_STR(this->editable), |
| 132 | this->jAction.c_str()); |
| 133 | ret = std::string(returnCString); |
| 134 | } |
| 135 | return ret; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | std::shared_ptr<DeviceOperateWrapper> DeviceOperateWrapper::OperateNop = std::make_shared<DeviceOperateWrapper>(); |