MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / registerANRCallback

Method registerANRCallback

libapp2sys/src/main/cpp/protocol.h:988–1023  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986 }
987
988 int64_t registerANRCallback(int tid, int64_t timestamp) {
989 IClientEngine *pEngine = engine();
990 if (!pEngine) {
991 return -3;
992 }
993
994 int64_t requestid = 0L;
995 if (HEADER_VERSION >= HEADER_JSON_VERSION) {//json
996 cJSON *jsonRequest;
997 jsonRequest = cJSON_CreateObject();
998 cJSON_AddNumberToObject(jsonRequest, "jsonVersion", JSON_VERSION);
999 cJSON_AddNumberToObject(jsonRequest, "funcid", FUNC_REG_ANR_CALLBACK);
1000 cJSON_AddNumberToObject(jsonRequest, "status", STATUS_NONE);
1001 cJSON_AddNumberToObject(jsonRequest, "type", REGISTER_CALLBACK_TYPE_ANR);
1002 cJSON_AddNumberToObject(jsonRequest, "uid", getuid());
1003 cJSON_AddNumberToObject(jsonRequest, "pid", getpid());
1004
1005 char *body = cJSON_Print(jsonRequest);
1006 std::string str(body);
1007 uint32_t len = str.length();
1008 cJSON_Delete(jsonRequest);
1009 requestid = pEngine ->sendReq(FUNC_REG_ANR_CALLBACK, (uint8_t *)body, len, tid, timestamp);
1010 free(body);
1011 } else {
1012 amc::RegisterCallback request;
1013 request.set_type(REGISTER_CALLBACK_TYPE_ANR);
1014 request.set_uid(getuid());
1015 request.set_pid(getpid());
1016 uint32_t len = request.ByteSize();
1017 uint8_t body[len];
1018 request.SerializeToArray(body, len);
1019 requestid = pEngine->sendReq(FUNC_REG_ANR_CALLBACK, body, len, tid, timestamp);
1020 }
1021 pdbg("registerANRCallback requestid:%lld ", requestid);
1022 return requestid;
1023 }
1024
1025 int64_t registerSystemEventCallback(int tid, int64_t timestamp) {
1026 IClientEngine *pEngine = engine();

Calls 7

cJSON_CreateObjectFunction · 0.85
cJSON_AddNumberToObjectFunction · 0.85
cJSON_PrintFunction · 0.85
cJSON_DeleteFunction · 0.85
set_typeMethod · 0.80
ByteSizeMethod · 0.80
sendReqMethod · 0.45

Tested by

no test coverage detected