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

Method checkPermission

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

Source from the content-addressed store, hash-verified

563 ClientProtocal() {}
564
565 int64_t checkPermission(std::vector<std::string> manufactures, std::vector<std::string> certs, int pid, int uid, int tid, int64_t timestamp) {
566 IClientEngine *pEngine = engine();
567 if (!pEngine) {
568 return -3;
569 }
570
571 int64_t requestid = 0L;
572 if (HEADER_VERSION >= HEADER_JSON_VERSION) {//json
573 cJSON *jsonRequest;
574 jsonRequest = cJSON_CreateObject();
575 cJSON_AddNumberToObject(jsonRequest, "jsonVersion", JSON_VERSION);
576 cJSON_AddNumberToObject(jsonRequest, "funcid", FUNC_CHECK_PERMISSION);
577
578 if (!manufactures.empty() && manufactures.size() == certs.size()) {
579 cJSON *certTags;
580 cJSON_AddItemToObject(jsonRequest, "certTags", certTags = cJSON_CreateArray());
581 for (int index = 0; index < manufactures.size(); index++) {
582 cJSON *certTag;
583 certTag = cJSON_CreateObject();
584 cJSON_AddStringToObject(certTag, "manufacture", manufactures[index].c_str());
585 cJSON_AddStringToObject(certTag, "cert", certs[index].c_str());
586 cJSON_AddItemToArray(certTags, certTag);
587 }
588 }
589
590 char *body = cJSON_Print(jsonRequest);
591 std::string str(body);
592 uint32_t len = str.length();
593 cJSON_Delete(jsonRequest);
594 requestid = pEngine ->sendReq(FUNC_CHECK_PERMISSION, (uint8_t *)body, len, tid, timestamp);
595 free(body);
596 } else {
597 amc::CheckPermission request;
598 if (!manufactures.empty() && manufactures.size() == certs.size()) {
599 for (int index = 0; index < manufactures.size(); index++) {
600 amc::CertTag* certTag = request.add_certtags();
601 certTag->set_manufacture(manufactures[index]);
602 certTag->set_cert(certs[index]);
603 }
604 }
605 uint32_t len = request.ByteSize();
606 uint8_t body[len];
607 request.SerializeToArray(body, len);
608 requestid = pEngine->sendReq(FUNC_CHECK_PERMISSION, body, len, tid, timestamp);
609 }
610 pdbg("checkPermission requestid:%lld, pid:%d, uid:%d, local pid:%d, uid:%d, tid:%d, timestamp:%d", requestid,
611 pid, uid, getpid(), getuid(), tid, TOINT(timestamp / 1000000L));
612 return requestid;
613 }
614
615 int64_t requestCpuHighFreq(int scene, int64_t action, int level, int timeoutms, int tid, int64_t timestamp) {
616 IClientEngine *pEngine = engine();

Callers

nothing calls this directly

Calls 12

cJSON_CreateObjectFunction · 0.85
cJSON_AddNumberToObjectFunction · 0.85
cJSON_AddItemToObjectFunction · 0.85
cJSON_CreateArrayFunction · 0.85
cJSON_AddStringToObjectFunction · 0.85
cJSON_AddItemToArrayFunction · 0.85
cJSON_PrintFunction · 0.85
cJSON_DeleteFunction · 0.85
ByteSizeMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
sendReqMethod · 0.45

Tested by

no test coverage detected