mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
b952a7e874
@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/ability/dmsfwk/dmsfwk.gni")
|
||||
|
||||
config("continuationmanager_napi_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
@ -46,6 +47,7 @@ ohos_shared_library("continuationmanager_napi") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${dms_path}/common:distributed_sched_utils",
|
||||
"../../../innerkits/common:common_sdk",
|
||||
"../../../innerkits/continuation_manager:continuation_manager",
|
||||
]
|
||||
@ -56,6 +58,7 @@ ohos_shared_library("continuationmanager_napi") {
|
||||
"ability_runtime:extensionkit_native",
|
||||
"ability_runtime:napi_common",
|
||||
"ability_runtime:runtime",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "base/continuationmgr_log.h"
|
||||
#include "distributed_ability_manager_client.h"
|
||||
#include "distributed_sched_utils.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "napi_common_util.h"
|
||||
#include "napi_error_code.h"
|
||||
@ -787,14 +788,15 @@ bool JsContinuationManager::IsCallbackValid(napi_env env, napi_value listenerObj
|
||||
bool JsContinuationManager::IsCallbackRegistered(int32_t token, const std::string& cbType)
|
||||
{
|
||||
if (jsCbMap_.empty() || jsCbMap_.find(token) == jsCbMap_.end()) {
|
||||
HILOGE("token %{public}d not registered callback!", token);
|
||||
HILOGE("token %{public}s not registered callback!", GetAnonymStr(std::to_string(token)).c_str());
|
||||
return false;
|
||||
}
|
||||
if (jsCbMap_[token].empty() || jsCbMap_[token].find(cbType) == jsCbMap_[token].end()) {
|
||||
HILOGE("cbType %{public}s not registered callback!", cbType.c_str());
|
||||
return false;
|
||||
}
|
||||
HILOGI("callback already registered, token: %{public}d, cbType %{public}s", token, cbType.c_str());
|
||||
HILOGI("callback already registered, token: %{public}s, cbType %{public}s",
|
||||
GetAnonymStr(std::to_string(token)).c_str(), cbType.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ int32_t DistributedAbilityManagerService::RegisterDeviceSelectionCallback(
|
||||
callbackMap_[token] = std::move(notifierInfo);
|
||||
notifier->AddDeathRecipient(notifierDeathRecipient_);
|
||||
}
|
||||
HILOGD("token %{public}d register success", token);
|
||||
HILOGD("token register success");
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -268,7 +268,7 @@ int32_t DistributedAbilityManagerService::UnregisterDeviceSelectionCallback(int3
|
||||
}
|
||||
}
|
||||
}
|
||||
HILOGD("token %{public}d unregister success", token);
|
||||
HILOGD("token unregister success");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ int32_t DistributedAbilityManagerService::StartDeviceManager(
|
||||
}
|
||||
int32_t errCode = ConnectAbility(token, continuationExtraParams);
|
||||
if (errCode != ERR_OK) {
|
||||
HILOGE("token %{public}d connect to app failed", token);
|
||||
HILOGE("token connect to app failed");
|
||||
return CONNECT_ABILITY_FAILED;
|
||||
}
|
||||
// 2. sendRequest data(token, filter, dmsStub, connectStatusInfo) to app by app proxy when connect callback.
|
||||
@ -508,7 +508,7 @@ bool DistributedAbilityManagerService::IsExceededRegisterMaxNum(uint32_t accessT
|
||||
std::lock_guard<std::mutex> tokenMapLock(tokenMapMutex_);
|
||||
auto iter = tokenMap_.find(accessToken);
|
||||
if (iter != tokenMap_.end() && iter->second.size() >= MAX_REGISTER_NUM) {
|
||||
HILOGE("accessToken %{public}u registered too much times", accessToken);
|
||||
HILOGE("accessToken registered too much times");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -547,7 +547,7 @@ bool DistributedAbilityManagerService::IsTokenRegistered(uint32_t accessToken, i
|
||||
return true;
|
||||
}
|
||||
}
|
||||
HILOGE("token %{public}d has not registered", token);
|
||||
HILOGE("token has not registered");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ bool DistributedAbilityManagerService::IsNotifierRegistered(int32_t token)
|
||||
return false;
|
||||
}
|
||||
if (iter->second == nullptr) {
|
||||
HILOGE("notifierInfo is nullptr, token: %{public}d ", token);
|
||||
HILOGE("notifierInfo is nullptr");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -573,10 +573,10 @@ bool DistributedAbilityManagerService::IsNotifierRegisteredLocked(int32_t token,
|
||||
return false;
|
||||
}
|
||||
if (callbackMap_[token]->GetNotifier(cbType) != nullptr) {
|
||||
HILOGD("token: %{public}d cbType:%{public}s has already registered", token, cbType.c_str());
|
||||
HILOGD("token and cbType:%{public}s has already registered", cbType.c_str());
|
||||
return true;
|
||||
}
|
||||
HILOGE("token: %{public}d cbType:%{public}s has not registered", token, cbType.c_str());
|
||||
HILOGE("token and cbType:%{public}s has not registered", cbType.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -912,6 +912,9 @@ DistributedWant* DistributedWant::ParseUri(const std::string& uri)
|
||||
}
|
||||
std::string content = uri.substr(begin, pos - begin);
|
||||
if (content.compare("PICK") == 0) {
|
||||
if (want != nullptr) {
|
||||
delete want;
|
||||
}
|
||||
want = new (std::nothrow) DistributedWant();
|
||||
if (want == nullptr) {
|
||||
delete baseWant;
|
||||
@ -1677,7 +1680,7 @@ DistributedWant* DistributedWant::FromString(std::string& string)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nlohmann::json wantJson = nlohmann::json::parse(string);
|
||||
nlohmann::json wantJson = nlohmann::json::parse(string, nullptr, false);
|
||||
if (wantJson.is_discarded()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1740,7 +1740,7 @@ int32_t DistributedSchedService::TryStartRemoteAbilityByCall(const OHOS::AAFwk::
|
||||
AAFwk::Want remoteWant = want;
|
||||
int32_t connectToken = SaveConnectToken(want, connect);
|
||||
remoteWant.SetParam(DMS_CONNECT_TOKEN, connectToken);
|
||||
HILOGD("connectToken is %{public}d", connectToken);
|
||||
HILOGD("connectToken is %{public}s", GetAnonymStr(std::to_string(connectToken)).c_str());
|
||||
int32_t result = remoteDms->StartAbilityByCallFromRemote(remoteWant, connect, callerInfo, accountInfo);
|
||||
HILOGD("[PerformanceTest] TryStartRemoteAbilityByCall RPC end");
|
||||
if (result == ERR_OK) {
|
||||
@ -2332,8 +2332,8 @@ int32_t DistributedSchedService::ConnectAbilityFromRemote(const OHOS::AAFwk::Wan
|
||||
HILOGE("ConnectAbilityFromRemote connect is null");
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
HILOGD("ConnectAbilityFromRemote uid is %{public}d, pid is %{public}d, AccessTokenID is %{public}u",
|
||||
callerInfo.uid, callerInfo.pid, callerInfo.accessToken);
|
||||
HILOGD("ConnectAbilityFromRemote uid is %{public}d, pid is %{public}d, AccessTokenID is %{public}s",
|
||||
callerInfo.uid, callerInfo.pid, GetAnonymStr(std::to_string(callerInfo.accessToken)).c_str());
|
||||
std::string localDeviceId;
|
||||
std::string destinationDeviceId = want.GetElement().GetDeviceID();
|
||||
if (!GetLocalDeviceId(localDeviceId) ||
|
||||
@ -3288,7 +3288,7 @@ bool DistributedSchedService::RegisterAppStateObserver(const OHOS::AAFwk::Want&
|
||||
{
|
||||
HILOGD("register app state observer called");
|
||||
int32_t connectToken = want.GetIntParam(DMS_CONNECT_TOKEN, DEFAULT_DMS_CONNECT_TOKEN);
|
||||
HILOGD("Get connectToken = %{private}d", connectToken);
|
||||
HILOGD("Get connectToken = %{private}s", GetAnonymStr(std::to_string(connectToken)).c_str());
|
||||
if (connectToken == DEFAULT_DMS_CONNECT_TOKEN) {
|
||||
return false;
|
||||
}
|
||||
@ -3407,7 +3407,7 @@ int32_t DistributedSchedService::NotifyStateChanged(int32_t abilityState, AppExe
|
||||
}
|
||||
}
|
||||
}
|
||||
HILOGD("Get connectToken = %{private}d", connectToken);
|
||||
HILOGD("Get connectToken = %{private}s", GetAnonymStr(std::to_string(connectToken)).c_str());
|
||||
std::string localDeviceId;
|
||||
if (!GetLocalDeviceId(localDeviceId) || !CheckDeviceId(localDeviceId, srcDeviceId)) {
|
||||
HILOGE("check deviceId failed");
|
||||
@ -3425,7 +3425,7 @@ int32_t DistributedSchedService::NotifyStateChanged(int32_t abilityState, AppExe
|
||||
int32_t DistributedSchedService::NotifyStateChangedFromRemote(int32_t abilityState, int32_t connectToken,
|
||||
const AppExecFwk::ElementName& element)
|
||||
{
|
||||
HILOGD("Get connectToken = %{private}d", connectToken);
|
||||
HILOGD("Get connectToken = %{private}s", GetAnonymStr(std::to_string(connectToken)).c_str());
|
||||
sptr<IRemoteObject> connect;
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(callLock_);
|
||||
@ -3468,8 +3468,9 @@ int32_t DistributedSchedService::CheckTargetPermission(const OHOS::AAFwk::Want&
|
||||
}
|
||||
HILOGD("target ability info bundleName:%{public}s abilityName:%{public}s visible:%{public}d",
|
||||
targetAbility.bundleName.c_str(), targetAbility.name.c_str(), targetAbility.visible);
|
||||
HILOGD("callerType:%{public}d accountType:%{public}d callerUid:%{public}d AccessTokenID:%{public}u",
|
||||
callerInfo.callerType, accountInfo.accountType, callerInfo.uid, callerInfo.accessToken);
|
||||
HILOGD("callerType:%{public}d accountType:%{public}d callerUid:%{public}d AccessTokenID:%{public}s",
|
||||
callerInfo.callerType, accountInfo.accountType, callerInfo.uid,
|
||||
GetAnonymStr(std::to_string(callerInfo.accessToken)).c_str());
|
||||
if (flag == START_PERMISSION) {
|
||||
HILOGD("start CheckStartPermission");
|
||||
return permissionInstance.CheckStartPermission(want, callerInfo, accountInfo, targetAbility);
|
||||
|
@ -255,7 +255,8 @@ int32_t DistributedSchedStub::StartRemoteAbilityInner(MessageParcel& data, Messa
|
||||
PARCEL_READ_HELPER(data, Int32, requestCode);
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}u", callerUid, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}s", callerUid,
|
||||
GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
DistributedSchedPermission::GetInstance().MarkUriPermission(*want, accessToken);
|
||||
int32_t result = StartRemoteAbility(*want, callerUid, requestCode, accessToken);
|
||||
ReportEvent(*want, BehaviorEvent::START_REMOTE_ABILITY, result, callerUid);
|
||||
@ -420,7 +421,7 @@ void DistributedSchedStub::SaveExtraInfo(const nlohmann::json& extraInfoJson, Ca
|
||||
extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN].is_number_unsigned()) {
|
||||
uint32_t accessToken = extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN];
|
||||
callerInfo.accessToken = accessToken;
|
||||
HILOGD("parse extra info, accessTokenID = %u", accessToken);
|
||||
HILOGD("parse extra info, accessTokenID = %s", GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
}
|
||||
|
||||
if (extraInfoJson.find(DMS_VERSION_ID) != extraInfoJson.end() && extraInfoJson[DMS_VERSION_ID].is_string()) {
|
||||
@ -648,7 +649,7 @@ int32_t DistributedSchedStub::StartContinuationInner(MessageParcel& data, Messag
|
||||
int32_t status = data.ReadInt32();
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGI("get AccessTokenID = %{public}u", accessToken);
|
||||
HILOGI("get AccessTokenID = %{public}s", GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
DistributedSchedPermission::GetInstance().MarkUriPermission(*want, accessToken);
|
||||
|
||||
// set in ability runtime, used to seperate callings from FA or stage model
|
||||
@ -756,8 +757,8 @@ int32_t DistributedSchedStub::ConnectRemoteAbilityInner(MessageParcel& data, Mes
|
||||
PARCEL_READ_HELPER(data, Int32, callerPid);
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, callerPid = %{public}d, AccessTokenID = %{private}u", callerUid, callerPid,
|
||||
accessToken);
|
||||
HILOGD("get callerUid = %{public}d, callerPid = %{public}d, AccessTokenID = %{private}s", callerUid, callerPid,
|
||||
GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
int32_t result = ConnectRemoteAbility(*want, connect, callerUid, callerPid, accessToken);
|
||||
ReportEvent(*want, BehaviorEvent::CONNECT_REMOTE_ABILITY, result, callerUid);
|
||||
HILOGI("result = %{public}d", result);
|
||||
@ -776,7 +777,8 @@ int32_t DistributedSchedStub::DisconnectRemoteAbilityInner(MessageParcel& data,
|
||||
PARCEL_READ_HELPER(data, Int32, callerUid);
|
||||
uint32_t accessToken = 0;
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}u", callerUid, accessToken);
|
||||
HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}s", callerUid,
|
||||
GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
int32_t result = DisconnectRemoteAbility(connect, callerUid, accessToken);
|
||||
BehaviorEventParam eventParam = { EventCallingType::LOCAL, BehaviorEvent::DISCONNECT_REMOTE_ABILITY, result };
|
||||
DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
|
||||
@ -1586,7 +1588,8 @@ int32_t DistributedSchedStub::StopRemoteExtensionAbilityInner(MessageParcel& dat
|
||||
PARCEL_READ_HELPER(data, Uint32, accessToken);
|
||||
int32_t serviceType = 0;
|
||||
PARCEL_READ_HELPER(data, Int32, serviceType);
|
||||
HILOGD("get callerUid = %{private}d, AccessTokenID = %{private}u", callerUid, accessToken);
|
||||
HILOGD("get callerUid = %{private}d, AccessTokenID = %{private}s", callerUid,
|
||||
GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
auto result = StopRemoteExtensionAbility(*want, callerUid, accessToken, serviceType);
|
||||
HILOGD("StartRemoteAbilityInner result = %{public}d", result);
|
||||
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
|
||||
@ -1626,7 +1629,7 @@ int32_t DistributedSchedStub::StopExtensionAbilityFromRemoteInner(MessageParcel&
|
||||
extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN].is_number_unsigned()) {
|
||||
uint32_t accessToken = extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN];
|
||||
callerInfo.accessToken = accessToken;
|
||||
HILOGD("parse extra info, accessTokenID = %{private}u", accessToken);
|
||||
HILOGD("parse extra info, accessTokenID = %{private}s", GetAnonymStr(std::to_string(accessToken)).c_str());
|
||||
}
|
||||
auto result = StopExtensionAbilityFromRemote(*want, callerInfo, accountInfo, serviceType);
|
||||
HILOGD("result = %{public}d", result);
|
||||
|
@ -167,7 +167,8 @@ int32_t DSchedTransportSoftbusAdapter::AddNewPeerSession(const std::string &peer
|
||||
}
|
||||
|
||||
ret = SetFirstCallerTokenID(callingTokenId_);
|
||||
HILOGD("SetFirstCallerTokenID callingTokenId: %{public}d, ret: %{public}d", callingTokenId_, ret);
|
||||
HILOGD("SetFirstCallerTokenID callingTokenId: %{public}s, ret: %{public}d",
|
||||
GetAnonymStr(std::to_string(callingTokenId_)).c_str(), ret);
|
||||
callingTokenId_ = 0;
|
||||
|
||||
do {
|
||||
|
Loading…
Reference in New Issue
Block a user