MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / patchOperate

Method patchOperate

native/events/Preference.cpp:189–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 }
188
189 void Preference::patchOperate(const OperatePtr &opt) {
190 if (!this->_doInputFuzzing)
191 return;
192
193 // input texts
194 char prelog[30];
195 std::srand((unsigned int) std::time(nullptr));
196 if (opt->editable && opt->getText().empty()
197 && (opt->act == ActionType::CLICK || opt->act == ActionType::LONG_CLICK)) {
198 if (this->_randomInputText &&
199 this->_inputTexts.size() > 0) {
200 int randIdx = randomInt(0, (int) this->_inputTexts.size());
201 std::string &txt = this->_inputTexts[randIdx];
202 opt->setText(txt);
203 strcpy(prelog, "user preset strings");
204 } else {
205 float rate = randomInt(0, 100);
206 if (!this->_fuzzingTexts.empty() && rate < 50) {
207 int randIdx = randomInt(0, (int) this->_fuzzingTexts.size());
208 std::string &txt = this->_fuzzingTexts[randIdx];
209 opt->setText(txt);
210 strcpy(prelog, "fuzzing text");
211 } else if (rate < 85) {
212 int randIdx = randomInt(0, (int) this->_pageTextsCache.size());
213 std::string &txt = this->_pageTextsCache[randIdx];
214 opt->setText(txt);
215 strcpy(prelog, "page text");
216 }
217 }
218 BLOG("patch %s input text: %s", prelog, opt->getText().c_str());
219 }
220 }
221
222 /// Before exploring page, prune the UI tree of this page if possible
223 /// \param activity

Callers 1

getOperateOptMethod · 0.80

Calls 6

randomIntFunction · 0.85
emptyMethod · 0.80
getTextMethod · 0.80
setTextMethod · 0.80
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected