mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-04 05:22:25 +00:00
commit
7c13c08d11
@ -27,12 +27,12 @@ char* CreateCStringFromString(const std::string& source)
|
||||
size_t length = source.size() + 1;
|
||||
auto res = static_cast<char*>(malloc(length));
|
||||
if (res == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "fail to mallc string.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null res");
|
||||
return nullptr;
|
||||
}
|
||||
if (strcpy_s(res, length, source.c_str()) != 0) {
|
||||
free(res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "fail to strcpy source.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Strcpy failed");
|
||||
return nullptr;
|
||||
}
|
||||
return res;
|
||||
|
@ -32,7 +32,7 @@ WantHandle FFICJWantCreateWithWantInfo(CJWantParams params)
|
||||
{
|
||||
Want* want = new (std::nothrow) Want();
|
||||
if (want == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "fail to new want.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null want");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ WantHandle FFICJWantCreateWithWantInfo(CJWantParams params)
|
||||
void FFICJWantDelete(WantHandle want)
|
||||
{
|
||||
if (want == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "input want handle is null.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null want");
|
||||
return;
|
||||
}
|
||||
auto actualWant = reinterpret_cast<Want*>(want);
|
||||
@ -62,7 +62,7 @@ CJWantParams* FFICJWantGetWantInfo(WantHandle want)
|
||||
{
|
||||
CJWantParams* buffer = static_cast<CJWantParams*>(malloc(sizeof(CJWantParams)));
|
||||
if (buffer == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "fail to malloc want params.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null buffer");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ CJWantParams* FFICJWantGetWantInfo(WantHandle want)
|
||||
element.GetDeviceID(), element.GetBundleName(), element.GetAbilityName(), element.GetModuleName());
|
||||
if (elementName == nullptr) {
|
||||
free(buffer);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "fail to new element name.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "element name null");
|
||||
return nullptr;
|
||||
}
|
||||
buffer->elementName = elementName;
|
||||
@ -88,7 +88,7 @@ CJWantParams* FFICJWantGetWantInfo(WantHandle want)
|
||||
void FFICJWantParamsDelete(CJWantParams* params)
|
||||
{
|
||||
if (params == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "input want params is null.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "argc null");
|
||||
return;
|
||||
}
|
||||
auto actualElementName = reinterpret_cast<ElementName*>(params->elementName);
|
||||
@ -106,7 +106,7 @@ void FFICJWantParamsDelete(CJWantParams* params)
|
||||
void FFICJWantAddEntity(WantHandle want, const char* entity)
|
||||
{
|
||||
if (want == nullptr || entity == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "input want handle or entity is null.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Want or entity null");
|
||||
return;
|
||||
}
|
||||
auto actualWant = reinterpret_cast<Want*>(want);
|
||||
@ -116,7 +116,7 @@ void FFICJWantAddEntity(WantHandle want, const char* entity)
|
||||
WantHandle FFICJWantParseUri(const char* uri)
|
||||
{
|
||||
if (uri == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "input uri is null.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Uri null");
|
||||
return nullptr;
|
||||
}
|
||||
return Want::ParseUri(uri);
|
||||
|
@ -120,7 +120,7 @@ napi_value JsStartupManager::OnGetResult(napi_env env, NapiCallbackInfo &info)
|
||||
}
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert failed");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to convert startupTask, must be a string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -128,12 +128,12 @@ napi_value JsStartupManager::OnGetResult(napi_env env, NapiCallbackInfo &info)
|
||||
std::shared_ptr<StartupTaskResult> result;
|
||||
int32_t res = DelayedSingleton<StartupManager>::GetInstance()->GetResult(startupTask, result);
|
||||
if (res != ERR_OK || result == nullptr || result->GetResultCode() != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to get result.", startupTask.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "get %{public}s result failed", startupTask.c_str());
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to get result.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (result->GetResultType() != StartupTaskResult::ResultType::JS) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, the result type is not js.", startupTask.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s result type error", startupTask.c_str());
|
||||
ThrowInvalidParamError(env, "%{public}s, the result type is not js.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -154,13 +154,13 @@ napi_value JsStartupManager::OnIsInitialized(napi_env env, NapiCallbackInfo &inf
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "invalid argc");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert failed");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to convert startupTask,"
|
||||
"must be a string or startupTask name is not matched.");
|
||||
return CreateJsUndefined(env);
|
||||
@ -169,7 +169,7 @@ napi_value JsStartupManager::OnIsInitialized(napi_env env, NapiCallbackInfo &inf
|
||||
bool isInitialized = false;
|
||||
int32_t res = DelayedSingleton<StartupManager>::GetInstance()->IsInitialized(startupTask, isInitialized);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to get result, res = %{public}d.", startupTask.c_str(), res);
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "get %{public}s result failed:%{public}d", startupTask.c_str(), res);
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to get result, res = %{public}d.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -180,13 +180,13 @@ napi_value JsStartupManager::OnRemoveResult(napi_env env, NapiCallbackInfo &info
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "invalid argc");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert failed");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to convert startupTask,"
|
||||
"must be a string or startupTask name is not matched.");
|
||||
return CreateJsUndefined(env);
|
||||
@ -194,7 +194,7 @@ napi_value JsStartupManager::OnRemoveResult(napi_env env, NapiCallbackInfo &info
|
||||
|
||||
int32_t res = DelayedSingleton<StartupManager>::GetInstance()->RemoveResult(startupTask);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to remove result, res = %{public}d.", startupTask.c_str(), res);
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "remove %{public}s result failed:%{public}d", startupTask.c_str(), res);
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to get result, res = %{public}d.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -205,7 +205,7 @@ napi_value JsStartupManagerInit(napi_env env, napi_value exportObj)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called");
|
||||
if (env == nullptr || exportObj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Env or exportObj nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Env or exportObj null");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ int32_t JsStartupManager::GetDependencies(napi_env env, napi_value value, std::v
|
||||
bool isArray;
|
||||
napi_is_array(env, value, &isArray);
|
||||
if (!isArray) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "value is not array.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "value not array");
|
||||
ThrowInvalidParamError(env, "Parameter error: StartupTasks must be a Array.");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -241,14 +241,14 @@ int32_t JsStartupManager::GetDependencies(napi_env env, napi_value value, std::v
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(env, napiDep, &valueType);
|
||||
if (valueType != napi_string) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "element is not string.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "element not string");
|
||||
ThrowInvalidParamError(env, "Parameter error: StartupTasks element must be a string.");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, napiDep, startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert failed");
|
||||
ThrowInvalidParamError(env, "Parameter error: Convert startupTask name failed. Please check it.");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
@ -261,11 +261,11 @@ int32_t JsStartupManager::GetConfig(napi_env env, napi_value value, std::shared_
|
||||
{
|
||||
std::shared_ptr<JsStartupConfig> startupConfig = std::make_shared<JsStartupConfig>(env);
|
||||
if (startupConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupConfig is null.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupConfig null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
if (startupConfig->Init(value) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "failed to init config");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "init config failed");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to init config, must be a StartupConfig.");
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
@ -278,7 +278,7 @@ int32_t JsStartupManager::RunStartupTask(napi_env env, NapiCallbackInfo &info,
|
||||
{
|
||||
std::vector<std::string> dependencies;
|
||||
if (GetDependencies(env, info.argv[INDEX_ZERO], dependencies) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "failed to get dependencies.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "get dependencies failed");
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<StartupConfig> config;
|
||||
@ -297,7 +297,7 @@ int32_t JsStartupManager::RunStartupTask(napi_env env, NapiCallbackInfo &info,
|
||||
return result;
|
||||
}
|
||||
if (startupTaskManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTaskManager is nullptr");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTaskManager null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
result = startupTaskManager->Prepare();
|
||||
|
@ -67,21 +67,21 @@ public:
|
||||
|
||||
static bool ReleaseObject(JsCallerComplex* data)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "ReleaseObject begin");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called");
|
||||
if (data == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseObject begin, but input parameters is nullptr");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null data");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data->ChangeCurrentState(OBJSTATE::OBJ_RELEASE)) {
|
||||
auto handler = data->GetEventHandler();
|
||||
if (handler == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseObject error end, Get eventHandler failed");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null handler");
|
||||
return false;
|
||||
}
|
||||
auto releaseObjTask = [pdata = data] () {
|
||||
if (!FindJsCallerComplex(pdata)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseObject error end, but input parameters does not found");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "argc not found");
|
||||
return;
|
||||
}
|
||||
ReleaseObject(pdata);
|
||||
@ -93,7 +93,7 @@ public:
|
||||
// when the object is about to be destroyed, does not reset state
|
||||
std::unique_ptr<JsCallerComplex> delObj(data);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "ReleaseObject success end");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public:
|
||||
|
||||
auto ptr = static_cast<JsCallerComplex*>(data);
|
||||
if (!FindJsCallerComplex(ptr)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "input parameters does not found");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "argc not found");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ public:
|
||||
std::lock_guard<std::mutex> lck (jsCallerComplexMutex);
|
||||
auto iter = jsCallerComplexManagerList.find(ptr);
|
||||
if (iter == jsCallerComplexManagerList.end()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "input parameters not found");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "argc not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ public:
|
||||
static bool FindJsCallerComplex(JsCallerComplex* ptr)
|
||||
{
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null ptr");
|
||||
return false;
|
||||
}
|
||||
auto ret = true;
|
||||
@ -192,29 +192,26 @@ public:
|
||||
if (iter == jsCallerComplexManagerList.end()) {
|
||||
ret = false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, execution ends and retval is %{public}s", __func__,
|
||||
ret ? "true" : "false");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "retval %{public}s", ret ? "true" : "false");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool FindJsCallerComplexAndChangeState(JsCallerComplex* ptr, OBJSTATE state)
|
||||
{
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null ptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lck (jsCallerComplexMutex);
|
||||
auto iter = jsCallerComplexManagerList.find(ptr);
|
||||
if (iter == jsCallerComplexManagerList.end()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, execution end, but not found", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "argc not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = ptr->ChangeCurrentState(state);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT,
|
||||
"JsAbilityContext::%{public}s, execution ends and ChangeCurrentState retval is %{public}s", __func__,
|
||||
ret ? "true" : "false");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "ChangeCurrentState ret:%{public}s", ret ? "true" : "false");
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -240,13 +237,13 @@ public:
|
||||
if (currentState_ == OBJSTATE::OBJ_NORMAL) {
|
||||
currentState_ = state;
|
||||
ret = true;
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "currentState_ == OBJSTATE::OBJ_NORMAL");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "currentState_:OBJ_NORMAL");
|
||||
} else if (currentState_ == state) {
|
||||
ret = true;
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "currentState_ == state");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "currentState_:state");
|
||||
} else {
|
||||
ret = false;
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "ret = false");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "ret: false");
|
||||
}
|
||||
|
||||
stateMechanismMutex_.unlock();
|
||||
@ -291,28 +288,28 @@ private:
|
||||
|
||||
void OnReleaseNotify(const std::string &str)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotify begin");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "begin");
|
||||
if (handler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "handler parameters error");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null handler");
|
||||
return;
|
||||
}
|
||||
|
||||
auto task = [notify = this, &str] () {
|
||||
if (!FindJsCallerComplex(notify)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "address error");
|
||||
return;
|
||||
}
|
||||
notify->OnReleaseNotifyTask(str);
|
||||
};
|
||||
handler_->PostSyncTask(task, "OnReleaseNotify");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotify end");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "end");
|
||||
}
|
||||
|
||||
void OnReleaseNotifyTask(const std::string &str)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotifyTask begin");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "begin");
|
||||
if (jsReleaseCallBackObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, jsreleaseObj is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null jsreleaseObj");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -320,36 +317,34 @@ private:
|
||||
napi_value callback = jsReleaseCallBackObj_->GetNapiValue();
|
||||
napi_value args[] = { CreateJsValue(releaseCallBackEngine_, str) };
|
||||
napi_call_function(releaseCallBackEngine_, value, callback, 1, args, nullptr);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotifyTask CallFunction call done");
|
||||
callee_ = nullptr;
|
||||
StateReset();
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotifyTask end");
|
||||
}
|
||||
|
||||
void OnRemoteStateChangedNotify(const std::string &str)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotify begin");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "begin");
|
||||
if (handler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "handler parameters error");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null handler");
|
||||
return;
|
||||
}
|
||||
|
||||
auto task = [notify = this, &str] () {
|
||||
if (!FindJsCallerComplex(notify)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found");
|
||||
return;
|
||||
}
|
||||
notify->OnRemoteStateChangedNotifyTask(str);
|
||||
};
|
||||
handler_->PostSyncTask(task, "OnRemoteStateChangedNotify");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotify end");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "end");
|
||||
}
|
||||
|
||||
void OnRemoteStateChangedNotifyTask(const std::string &str)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotifyTask begin");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "begin");
|
||||
if (jsRemoteStateChangedObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, jsRemoteStateChangedObj is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null jsRemoteStateChangedObj");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -357,21 +352,20 @@ private:
|
||||
napi_value callback = jsRemoteStateChangedObj_->GetNapiValue();
|
||||
napi_value args[] = { CreateJsValue(remoteStateChanegdEngine_, str) };
|
||||
napi_call_function(remoteStateChanegdEngine_, value, callback, 1, args, nullptr);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotifyTask CallFunction call done");
|
||||
StateReset();
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotifyTask end");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "end");
|
||||
}
|
||||
|
||||
napi_value ReleaseCallInner(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, called", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called");
|
||||
if (callerCallBackObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, CallBacker is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null CallBacker");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
}
|
||||
|
||||
if (!releaseCallFunc_) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, releaseFunc is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null releaseFunc");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
}
|
||||
callee_ = nullptr;
|
||||
@ -379,8 +373,7 @@ private:
|
||||
ReleaseJsRemoteObj();
|
||||
int32_t innerErrorCode = releaseCallFunc_(callerCallBackObj_);
|
||||
if (innerErrorCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, ReleaseAbility failed %{public}d",
|
||||
__func__, static_cast<int>(innerErrorCode));
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseAbility failed %{public}d", static_cast<int>(innerErrorCode));
|
||||
ThrowError(env, innerErrorCode);
|
||||
}
|
||||
|
||||
@ -389,28 +382,27 @@ private:
|
||||
|
||||
napi_value SetOnReleaseCallBackInner(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, start", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "start");
|
||||
constexpr size_t argcOne = 1;
|
||||
if (info.argc < argcOne) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, Invalid input parameters", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid argc");
|
||||
ThrowTooFewParametersError(env);
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env, info.argv[0], &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, IsCallable is %{public}s.",
|
||||
__func__, isCallable ? "true" : "false");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "IsCallable %{public}s", isCallable ? "true" : "false");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
|
||||
if (callerCallBackObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, CallBacker is null", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null CallBacker");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
}
|
||||
|
||||
auto param1 = info.argv[0];
|
||||
if (param1 == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, param1 is null", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null param1");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
}
|
||||
|
||||
@ -419,40 +411,38 @@ private:
|
||||
jsReleaseCallBackObj_.reset(reinterpret_cast<NativeReference*>(ref));
|
||||
auto task = [notify = this] (const std::string &str) {
|
||||
if (!FindJsCallerComplexAndChangeState(notify, OBJSTATE::OBJ_EXECUTION)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "address error");
|
||||
return;
|
||||
}
|
||||
notify->OnReleaseNotify(str);
|
||||
};
|
||||
callerCallBackObj_->SetOnRelease(task);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, end", __func__);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value SetOnRemoteStateChangedInner(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, begin", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "begin");
|
||||
constexpr size_t argcOne = 1;
|
||||
if (info.argc < argcOne) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, Invalid input params", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid argc");
|
||||
ThrowTooFewParametersError(env);
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env, info.argv[0], &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, IsCallable is %{public}s.",
|
||||
__func__, isCallable ? "true" : "false");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "IsCallable %{public}s", isCallable ? "true" : "false");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
|
||||
if (callerCallBackObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, CallBacker is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "CallBacker null");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
}
|
||||
|
||||
auto param1 = info.argv[0];
|
||||
if (param1 == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, param1 is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "param1 null");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
}
|
||||
|
||||
@ -462,13 +452,13 @@ private:
|
||||
auto task = [notify = this] (const std::string &str) {
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "state changed");
|
||||
if (!FindJsCallerComplexAndChangeState(notify, OBJSTATE::OBJ_EXECUTION)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "address error");
|
||||
return;
|
||||
}
|
||||
notify->OnRemoteStateChangedNotify(str);
|
||||
};
|
||||
callerCallBackObj_->SetOnRemoteStateChanged(task);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, end", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "end");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@ -498,9 +488,9 @@ napi_value CreateJsCallerComplex(
|
||||
napi_env env, ReleaseCallFunc releaseCallFunc, sptr<IRemoteObject> callee,
|
||||
std::shared_ptr<CallerCallBack> callerCallBack)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, begin", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "begin");
|
||||
if (callee == nullptr || callerCallBack == nullptr || releaseCallFunc == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called, input params error. %{public}s is nullptr", __func__,
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s null",
|
||||
(callee == nullptr) ? ("callee") :
|
||||
((releaseCallFunc == nullptr) ? ("releaseCallFunc") : ("callerCallBack")));
|
||||
return CreateJsUndefined(env);
|
||||
@ -511,7 +501,7 @@ napi_value CreateJsCallerComplex(
|
||||
auto jsCaller = std::make_unique<JsCallerComplex>(env, releaseCallFunc, callee, callerCallBack);
|
||||
auto remoteObj = jsCaller->GetRemoteObject();
|
||||
if (remoteObj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called,remoteObj is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "remoteObj null");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@ -524,19 +514,19 @@ napi_value CreateJsCallerComplex(
|
||||
BindNativeFunction(env, object, "onRelease", moduleName, JsCallerComplex::JsSetOnReleaseCallBack);
|
||||
BindNativeFunction(env, object, "onRemoteStateChange", moduleName, JsCallerComplex::JsSetOnRemoteStateChanged);
|
||||
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, end", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "end");
|
||||
return object;
|
||||
}
|
||||
|
||||
napi_value CreateJsCalleeRemoteObject(napi_env env, sptr<IRemoteObject> callee)
|
||||
{
|
||||
if (callee == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called, input params is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "null data");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
napi_value napiRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(env, callee);
|
||||
if (napiRemoteObject == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called, but remoteObj is nullptr", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "remoteObj null");
|
||||
}
|
||||
return napiRemoteObject;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ ValuesBucket ValuesBucket::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ValuesBucket valuesBucket;
|
||||
if (!valuesBucket.ReadFromParcel(parcel)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ValuesBucket::Unmarshalling ReadFromParcel failed");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ReadFromParcel failed");
|
||||
}
|
||||
return valuesBucket;
|
||||
}
|
||||
@ -56,7 +56,7 @@ ValuesBucket ValuesBucket::Unmarshalling(Parcel &parcel)
|
||||
bool ValuesBucket::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "valuesBucket::Marshalling WriteString16 failed");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "WriteString16 failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ void FormExtension::Init(const std::shared_ptr<AbilityLocalRecord> &record,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
ExtensionBase<FormExtensionContext>::Init(record, application, handler, token);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "FormExtension begin init");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "init");
|
||||
}
|
||||
|
||||
std::shared_ptr<FormExtensionContext> FormExtension::CreateAndInitContext(
|
||||
@ -56,7 +56,7 @@ std::shared_ptr<FormExtensionContext> FormExtension::CreateAndInitContext(
|
||||
std::shared_ptr<FormExtensionContext> context =
|
||||
ExtensionBase<FormExtensionContext>::CreateAndInitContext(record, application, handler, token);
|
||||
if (record == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "FormExtension::CreateAndInitContext record is nullptr");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "null record");
|
||||
return context;
|
||||
}
|
||||
context->SetAbilityInfo(record->GetAbilityInfo());
|
||||
@ -119,7 +119,7 @@ void FormExtension::OnConfigurationUpdated(const AppExecFwk::Configuration &conf
|
||||
|
||||
auto context = GetContext();
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Context is invalid.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "null context");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ int FormExtensionProviderClient::AcquireProviderFormInfo(const AppExecFwk::FormJ
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "formId:%{public}" PRId64, formJsInfo.formId);
|
||||
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
|
||||
if (formSupplyClient == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "IFormSupply is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "IFormSupply null");
|
||||
return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ int FormExtensionProviderClient::AcquireProviderFormInfo(const AppExecFwk::FormJ
|
||||
connectWant.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formJsInfo.formId));
|
||||
|
||||
if (!FormProviderClient::CheckIsSystemApp()) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Permission denied.");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Permission denied");
|
||||
FormProviderInfo formProviderInfo;
|
||||
connectWant.SetParam(Constants::PROVIDER_FLAG, ERR_APPEXECFWK_FORM_PERMISSION_DENY);
|
||||
return FormProviderClient::HandleAcquire(formProviderInfo, connectWant, callerToken);
|
||||
@ -78,7 +78,7 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const AppExec
|
||||
FormProviderInfo formProviderInfo;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
connectWant.SetParam(Constants::PROVIDER_FLAG, ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY);
|
||||
} else {
|
||||
Want createWant(want);
|
||||
@ -101,7 +101,7 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const AppExec
|
||||
}
|
||||
|
||||
formProviderInfo = ownerFormExtension->OnCreate(createWant);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "FormJsInfo.formId: %{public}s, data: %{public}s, proxies size: %{public}zu.",
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "formId: %{public}s, data: %{public}s, size: %{public}zu",
|
||||
createWant.GetStringParam(Constants::PARAM_FORM_IDENTITY_KEY).c_str(),
|
||||
formProviderInfo.GetFormDataString().c_str(),
|
||||
formProviderInfo.GetFormProxies().size());
|
||||
@ -112,10 +112,9 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const AppExec
|
||||
}
|
||||
int error = FormProviderClient::HandleAcquire(formProviderInfo, connectWant, callerToken);
|
||||
if (error != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "HandleAcquire failed with %{public}d.", error);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "HandleAcquire failed: %{public}d", error);
|
||||
HandleResultCode(error, connectWant, callerToken);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::NotifyFormDelete(const int64_t formId, const Want &want,
|
||||
@ -124,7 +123,7 @@ int FormExtensionProviderClient::NotifyFormDelete(const int64_t formId, const Wa
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -144,21 +143,20 @@ void FormExtensionProviderClient::NotifyFormExtensionDelete(const int64_t formId
|
||||
int errorCode = ERR_OK;
|
||||
auto hostToken = want.GetRemoteObject(Constants::PARAM_FORM_HOST_TOKEN);
|
||||
if (hostToken != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "remove provider caller.");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "null hostToken");
|
||||
FormCallerMgr::GetInstance().RemoveFormProviderCaller(formId, hostToken);
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnDestroy(formId);
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::NotifyFormsDelete(const std::vector<int64_t> &formIds, const Want &want,
|
||||
@ -167,7 +165,7 @@ int FormExtensionProviderClient::NotifyFormsDelete(const std::vector<int64_t> &f
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -187,7 +185,7 @@ void FormExtensionProviderClient::NotifyFormExtensionsDelete(const std::vector<i
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
for (int64_t formId : formIds) {
|
||||
@ -196,7 +194,6 @@ void FormExtensionProviderClient::NotifyFormExtensionsDelete(const std::vector<i
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::NotifyFormUpdate(const int64_t formId, const Want &want,
|
||||
@ -205,7 +202,7 @@ int FormExtensionProviderClient::NotifyFormUpdate(const int64_t formId, const Wa
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -225,7 +222,7 @@ void FormExtensionProviderClient::NotifyFormExtensionUpdate(const int64_t formId
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnUpdate(formId, want.GetParams());
|
||||
@ -234,7 +231,6 @@ void FormExtensionProviderClient::NotifyFormExtensionUpdate(const int64_t formId
|
||||
if (want.HasParameter(Constants::FORM_CONNECT_ID)) {
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::EventNotify(const std::vector<int64_t> &formIds, const int32_t formVisibleType,
|
||||
@ -243,7 +239,7 @@ int FormExtensionProviderClient::EventNotify(const std::vector<int64_t> &formIds
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -263,7 +259,7 @@ void FormExtensionProviderClient::EventNotifyExtension(const std::vector<int64_t
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
std::map<int64_t, int32_t> formEventsMap;
|
||||
@ -274,7 +270,6 @@ void FormExtensionProviderClient::EventNotifyExtension(const std::vector<int64_t
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::NotifyFormCastTempForm(const int64_t formId, const Want &want,
|
||||
@ -283,7 +278,7 @@ int FormExtensionProviderClient::NotifyFormCastTempForm(const int64_t formId, co
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -303,14 +298,13 @@ void FormExtensionProviderClient::NotifyFormExtensionCastTempForm(const int64_t
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnCastToNormal(formId);
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::FireFormEvent(const int64_t formId, const std::string &message,
|
||||
@ -319,7 +313,7 @@ int FormExtensionProviderClient::FireFormEvent(const int64_t formId, const std::
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -335,11 +329,11 @@ int FormExtensionProviderClient::FireFormEvent(const int64_t formId, const std::
|
||||
void FormExtensionProviderClient::FireFormExtensionEvent(const int64_t formId, const std::string &message,
|
||||
const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnEvent(formId, message);
|
||||
@ -348,7 +342,6 @@ void FormExtensionProviderClient::FireFormExtensionEvent(const int64_t formId, c
|
||||
if (want.HasParameter(Constants::FORM_CONNECT_ID)) {
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
int FormExtensionProviderClient::AcquireState(const Want &wantArg, const std::string &provider, const Want &want,
|
||||
@ -357,7 +350,7 @@ int FormExtensionProviderClient::AcquireState(const Want &wantArg, const std::st
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed with %{public}d.", errorCode.first);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "CheckParam failed: %{public}d", errorCode.first);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -378,18 +371,17 @@ void FormExtensionProviderClient::NotifyFormExtensionAcquireState(const Want &wa
|
||||
FormState state = FormState::UNKNOWN;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
} else {
|
||||
state = ownerFormExtension->OnAcquireFormState(wantArg);
|
||||
}
|
||||
HandleAcquireStateResult(state, provider, wantArg, want, callerToken);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called end.");
|
||||
}
|
||||
|
||||
void FormExtensionProviderClient::SetOwner(const std::shared_ptr<FormExtension> formExtension)
|
||||
{
|
||||
if (formExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "FormExtension is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "FormExtension null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -400,7 +392,7 @@ void FormExtensionProviderClient::SetOwner(const std::shared_ptr<FormExtension>
|
||||
void FormExtensionProviderClient::ClearOwner(const std::shared_ptr<FormExtension> formExtension)
|
||||
{
|
||||
if (formExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "FormExtension is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "FormExtension null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -429,7 +421,7 @@ int FormExtensionProviderClient::HandleResultCode(int errorCode, const Want &wan
|
||||
} else {
|
||||
// If errorCode is ERR_OK return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "disconnect error: %{public}d.", disconnectErrorCode);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "disconnect error: %{public}d", disconnectErrorCode);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -443,13 +435,13 @@ std::pair<ErrCode, ErrCode> FormExtensionProviderClient::CheckParam(const Want &
|
||||
}
|
||||
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
|
||||
if (formSupplyClient == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "IFormSupply is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "IFormSupply null");
|
||||
return std::pair<ErrCode, ErrCode>(ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED,
|
||||
ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED);
|
||||
}
|
||||
|
||||
if (!FormProviderClient::CheckIsSystemApp()) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Permission denied.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Permission denied");
|
||||
int errorCode = HandleResultCode(ERR_APPEXECFWK_FORM_PERMISSION_DENY, want, callerToken);
|
||||
return std::pair<ErrCode, ErrCode>(ERR_APPEXECFWK_FORM_PERMISSION_DENY, errorCode);
|
||||
}
|
||||
@ -462,14 +454,14 @@ int32_t FormExtensionProviderClient::AcquireShareFormData(int64_t formId, const
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
|
||||
if (!FormProviderClient::CheckIsSystemApp()) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Permission denied.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Permission denied");
|
||||
return ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
}
|
||||
|
||||
std::shared_ptr<EventHandler> mainHandler = std::make_shared<EventHandler>(EventRunner::GetMainEventRunner());
|
||||
auto formCall = iface_cast<IFormSupply>(formSupplyCallback);
|
||||
if (formCall == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "IFormSupply is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "IFormSupply null");
|
||||
return ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
}
|
||||
|
||||
@ -490,7 +482,7 @@ bool FormExtensionProviderClient::AcquireFormExtensionProviderShareFormInfo(
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -503,14 +495,14 @@ int32_t FormExtensionProviderClient::AcquireFormData(int64_t formId, const sptr<
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
|
||||
if (!FormProviderClient::CheckIsSystemApp()) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Permission denied.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Permission denied");
|
||||
return ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
}
|
||||
|
||||
std::shared_ptr<EventHandler> mainHandler = std::make_shared<EventHandler>(EventRunner::GetMainEventRunner());
|
||||
auto formCall = iface_cast<IFormSupply>(formSupplyCallback);
|
||||
if (formCall == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "error, callback is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Callback null");
|
||||
return ERR_APPEXECFWK_FORM_INVALID_PARAM;
|
||||
}
|
||||
|
||||
@ -531,7 +523,7 @@ bool FormExtensionProviderClient::FormExtensionProviderAcquireFormData(
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Owner is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "null Owner");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,12 @@ napi_value AttachFormExtensionContext(napi_env env, void* value, void*)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "call");
|
||||
if (value == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "invalid parameter");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "null value ");
|
||||
return nullptr;
|
||||
}
|
||||
auto ptr = reinterpret_cast<std::weak_ptr<FormExtensionContext>*>(value)->lock();
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "invalid context");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "null context");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value object = CreateJsFormExtensionContext(env, ptr);
|
||||
@ -79,7 +79,7 @@ JsFormExtension* JsFormExtension::Create(const std::unique_ptr<Runtime>& runtime
|
||||
JsFormExtension::JsFormExtension(JsRuntime& jsRuntime) : jsRuntime_(jsRuntime) {}
|
||||
JsFormExtension::~JsFormExtension()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "Js form extension destructor.");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "destructor");
|
||||
auto context = GetContext();
|
||||
if (context) {
|
||||
context->Unbind();
|
||||
@ -99,27 +99,27 @@ void JsFormExtension::Init(const std::shared_ptr<AbilityLocalRecord> &record,
|
||||
std::string srcPath;
|
||||
GetSrcPath(srcPath);
|
||||
if (srcPath.empty()) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to get srcPath");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get srcPath failed");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string moduleName(Extension::abilityInfo_->moduleName);
|
||||
moduleName.append("::").append(abilityInfo_->name);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "JsFormExtension::Init moduleName:%{public}s,srcPath:%{public}s,"
|
||||
"compileMode :%{public}d.", moduleName.c_str(), srcPath.c_str(), abilityInfo_->compileMode);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "moduleName:%{public}s,srcPath:%{public}s,"
|
||||
"compileMode :%{public}d", moduleName.c_str(), srcPath.c_str(), abilityInfo_->compileMode);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
jsObj_ = jsRuntime_.LoadModule(
|
||||
moduleName, srcPath, abilityInfo_->hapPath, abilityInfo_->compileMode == CompileMode::ES_MODULE);
|
||||
if (jsObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Error to get jsObj_");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "null jsObj");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value obj = jsObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Error to get JsFormExtension object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get JsFormExtension error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -130,19 +130,19 @@ void JsFormExtension::BindContext(napi_env env, napi_value obj)
|
||||
{
|
||||
auto context = GetContext();
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to get context");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get context error");
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "call");
|
||||
napi_value contextObj = CreateJsFormExtensionContext(env, context);
|
||||
shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.FormExtensionContext", &contextObj, 1);
|
||||
if (shellContextRef_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to load module");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "load module failed");
|
||||
return;
|
||||
}
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to get context native object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get context failed");
|
||||
return;
|
||||
}
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<FormExtensionContext>(context);
|
||||
@ -172,19 +172,19 @@ OHOS::AppExecFwk::FormProviderInfo JsFormExtension::OnCreate(const OHOS::AAFwk::
|
||||
|
||||
OHOS::AppExecFwk::FormProviderInfo formProviderInfo;
|
||||
if (!CheckTypeForNapiValue(env, nativeResult, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult null");
|
||||
return formProviderInfo;
|
||||
}
|
||||
|
||||
napi_value nativeDataValue = nullptr;
|
||||
napi_get_named_property(env, nativeResult, "data", &nativeDataValue);
|
||||
if (nativeDataValue == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult get data is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult null");
|
||||
return formProviderInfo;
|
||||
}
|
||||
std::string formDataStr;
|
||||
if (!ConvertFromJsValue(env, nativeDataValue, formDataStr)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "convert formDataStr failed.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Convert formDataStr failed");
|
||||
return formProviderInfo;
|
||||
}
|
||||
AppExecFwk::FormProviderData formData = AppExecFwk::FormProviderData(formDataStr);
|
||||
@ -194,7 +194,7 @@ OHOS::AppExecFwk::FormProviderInfo JsFormExtension::OnCreate(const OHOS::AAFwk::
|
||||
napi_get_named_property(env, nativeResult, "proxies", &nativeProxies);
|
||||
std::vector<FormDataProxy> formDataProxies;
|
||||
if (nativeProxies != nullptr && !ConvertFromDataProxies(env, nativeProxies, formDataProxies)) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "convert formDataProxies failed.");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Convert formDataProxies failed");
|
||||
return formProviderInfo;
|
||||
}
|
||||
formProviderInfo.SetFormDataProxies(formDataProxies);
|
||||
@ -204,7 +204,7 @@ OHOS::AppExecFwk::FormProviderInfo JsFormExtension::OnCreate(const OHOS::AAFwk::
|
||||
|
||||
void JsFormExtension::OnDestroy(const int64_t formId)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "OnDestroy, formId: %{public}" PRId64 ".", formId);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "formId: %{public}" PRId64, formId);
|
||||
FormExtension::OnDestroy(formId);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
@ -224,13 +224,13 @@ void JsFormExtension::OnStop()
|
||||
bool ret = ConnectionManager::GetInstance().DisconnectCaller(GetContext()->GetToken());
|
||||
if (ret) {
|
||||
ConnectionManager::GetInstance().ReportConnectionLeakEvent(getpid(), gettid());
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "The service extension connection is not disconnected.");
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "disconnected failed");
|
||||
}
|
||||
}
|
||||
|
||||
void JsFormExtension::OnEvent(const int64_t formId, const std::string& message)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "OnEvent, formId: %{public}" PRId64 ".", formId);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "formId: %{public}" PRId64, formId);
|
||||
FormExtension::OnEvent(formId, message);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
@ -248,7 +248,7 @@ void JsFormExtension::OnEvent(const int64_t formId, const std::string& message)
|
||||
|
||||
void JsFormExtension::OnUpdate(const int64_t formId, const AAFwk::WantParams &wantParams)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "OnUpdate, formId: %{public}" PRId64 ".", formId);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "formId: %{public}" PRId64, formId);
|
||||
FormExtension::OnUpdate(formId, wantParams);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
@ -265,7 +265,7 @@ void JsFormExtension::OnUpdate(const int64_t formId, const AAFwk::WantParams &wa
|
||||
|
||||
void JsFormExtension::OnCastToNormal(const int64_t formId)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "OnCastToNormal, formId: %{public}" PRId64 ".", formId);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "formId: %{public}" PRId64, formId);
|
||||
FormExtension::OnCastToNormal(formId);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
@ -298,13 +298,12 @@ sptr<IRemoteObject> JsFormExtension::OnConnect(const OHOS::AAFwk::Want& want)
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "call");
|
||||
Extension::OnConnect(want);
|
||||
if (providerRemoteObject_ == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "providerRemoteObject_ is nullptr, need init.");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "null providerRemoteObject");
|
||||
sptr<FormExtensionProviderClient> providerClient = new (std::nothrow) FormExtensionProviderClient();
|
||||
std::shared_ptr<JsFormExtension> formExtension = std::static_pointer_cast<JsFormExtension>(shared_from_this());
|
||||
providerClient->SetOwner(formExtension);
|
||||
providerRemoteObject_ = providerClient->AsObject();
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "ok");
|
||||
return providerRemoteObject_;
|
||||
}
|
||||
|
||||
@ -313,7 +312,7 @@ napi_value JsFormExtension::CallObjectMethod(const char* name, const char *bakNa
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "CallObjectMethod(%{public}s)", name);
|
||||
if (!jsObj_) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "jsObj_ is nullptr");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "jsObj null");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -322,14 +321,14 @@ napi_value JsFormExtension::CallObjectMethod(const char* name, const char *bakNa
|
||||
|
||||
napi_value obj = jsObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to get FormExtension object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get FormExtension failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value method = nullptr;
|
||||
napi_get_named_property(env, obj, name, &method);
|
||||
if (!CheckTypeForNapiValue(env, method, napi_function)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to get '%{public}s' from FormExtension object", name);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get '%{public}s' failed", name);
|
||||
if (bakName == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -378,7 +377,7 @@ void JsFormExtension::OnConfigurationUpdated(const AppExecFwk::Configuration& co
|
||||
// Notify extension context
|
||||
auto fullConfig = GetContext()->GetConfiguration();
|
||||
if (!fullConfig) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "configuration is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "configuration null");
|
||||
return;
|
||||
}
|
||||
JsExtensionContext::ConfigurationUpdated(env, shellContextRef_, fullConfig);
|
||||
@ -398,12 +397,12 @@ FormState JsFormExtension::OnAcquireFormState(const Want &want)
|
||||
napi_value argv[] = { napiWant };
|
||||
napi_value nativeResult = CallObjectMethod("onAcquireFormState", nullptr, argv, 1);
|
||||
if (nativeResult == nullptr) {
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "function onAcquireFormState not found.");
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "onAcquireFormState not found");
|
||||
return FormState::DEFAULT;
|
||||
}
|
||||
|
||||
if (!ConvertFromJsValue(env, nativeResult, state)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "convert form state failed.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "convert failed");
|
||||
return FormState::UNKNOWN;
|
||||
}
|
||||
|
||||
@ -414,16 +413,15 @@ FormState JsFormExtension::OnAcquireFormState(const Want &want)
|
||||
} else {
|
||||
return static_cast<AppExecFwk::FormState>(state);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "end");
|
||||
}
|
||||
|
||||
bool JsFormExtension::OnShare(int64_t formId, AAFwk::WantParams &wantParams)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnShare, formId: %{public}" PRId64 ".", formId);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "formId: %{public}" PRId64, formId);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
napi_env env = jsRuntime_.GetNapiEnv();
|
||||
if (env == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "env is null.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "env null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -431,31 +429,30 @@ bool JsFormExtension::OnShare(int64_t formId, AAFwk::WantParams &wantParams)
|
||||
napi_value argv[] = { CreateJsValue(env, formIdStr) };
|
||||
napi_value nativeResult = CallObjectMethod("onShareForm", "onShare", argv, 1);
|
||||
if (nativeResult == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "OnShare return value is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, nativeResult, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "OnShare return value`s type is not object.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult not object");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!OHOS::AppExecFwk::UnwrapWantParams(env, nativeResult, wantParams)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Unwrap want params error.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "unwrap want failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnShare called end.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsFormExtension::OnAcquireData(int64_t formId, AAFwk::WantParams &wantParams)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnAcquireData, formId: %{public}" PRId64 ".", formId);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "formId: %{public}" PRId64, formId);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
napi_env env = jsRuntime_.GetNapiEnv();
|
||||
if (env == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "env is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "env null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -463,21 +460,19 @@ bool JsFormExtension::OnAcquireData(int64_t formId, AAFwk::WantParams &wantParam
|
||||
napi_value argv[] = { CreateJsValue(env, formIdStr) };
|
||||
napi_value nativeResult = CallObjectMethod("onAcquireFormData", "OnAcquireData", argv, 1);
|
||||
if (nativeResult == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "return value is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, nativeResult, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "return value`s type is not object.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "nativeResult not object");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!OHOS::AppExecFwk::UnwrapWantParams(env, nativeResult, wantParams)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Unwrap want params failed.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "argc failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnAcquireData called end.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -485,7 +480,7 @@ bool JsFormExtension::ConvertFromDataProxies(napi_env env, napi_value jsValue,
|
||||
std::vector<FormDataProxy> &formDataProxies)
|
||||
{
|
||||
if (jsValue == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "%{public}s, jsValue is nullptr not array", __func__);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsValue null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -507,7 +502,7 @@ bool JsFormExtension::ConvertFromDataProxies(napi_env env, napi_value jsValue,
|
||||
bool JsFormExtension::ConvertFormDataProxy(napi_env env, napi_value jsValue, FormDataProxy &formDataProxy)
|
||||
{
|
||||
if (!CheckTypeForNapiValue(env, jsValue, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "%{public}s, jsValue is nullptr not object", __func__);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsValue null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -520,7 +515,7 @@ bool JsFormExtension::ConvertFormDataProxy(napi_env env, napi_value jsValue, For
|
||||
napi_value subscribeId = nullptr;
|
||||
napi_get_named_property(env, jsValue, "subscriberId", &subscribeId);
|
||||
if (subscribeId != nullptr && !ConvertFromJsValue(env, subscribeId, formDataProxy.subscribeId)) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Parse subscriberId failed, use empty as default value.");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Parse subscriberId failed");
|
||||
formDataProxy.subscribeId = "";
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "key is %{public}s, subscriberId is %{public}s", formDataProxy.key.c_str(),
|
||||
|
@ -52,13 +52,13 @@ void RemoveConnection(int64_t connectId)
|
||||
return connectId == obj.first.id;
|
||||
});
|
||||
if (item != g_connects.end()) {
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "remove conn ability exist.");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "ability exist");
|
||||
if (item->second) {
|
||||
item->second->RemoveConnectionObject();
|
||||
}
|
||||
g_connects.erase(item);
|
||||
} else {
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "remove connection ability not exist");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "ability not exist");
|
||||
}
|
||||
}
|
||||
class JsFormExtensionContext final {
|
||||
@ -119,10 +119,10 @@ private:
|
||||
napi_value nativeDataValue = nullptr;
|
||||
napi_get_named_property(env, info.argv[1], "data", &nativeDataValue);
|
||||
if (nativeDataValue == nullptr || !ConvertFromJsValue(env, nativeDataValue, formDataStr)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "NativeDataValue is nullptr or ConvertFromJsValue failed.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "NativeDataValue null or ConvertFromJsValue failed");
|
||||
}
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "not object.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Not object");
|
||||
}
|
||||
|
||||
formProviderData = AppExecFwk::FormProviderData(formDataStr);
|
||||
@ -130,7 +130,7 @@ private:
|
||||
[weak = context_, formId, formProviderData](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "context is released");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Context released");
|
||||
task.Reject(env, CreateJsError(env, 1, "Context is released"));
|
||||
return;
|
||||
}
|
||||
@ -152,7 +152,7 @@ private:
|
||||
|
||||
napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "OnStartAbility is called");
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called");
|
||||
// only support one or two params
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Not enough params");
|
||||
@ -164,11 +164,11 @@ private:
|
||||
AAFwk::Want want;
|
||||
bool unwrapResult = OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
if (!unwrapResult) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to unwrap want.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "unwrap want failed");
|
||||
NapiFormUtil::ThrowParamTypeError(env, "want", "Want");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "Start ability, bundleName: %{public}s abilityName: %{public}s.",
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "Start bundle: %{public}s ability: %{public}s",
|
||||
want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
unwrapArgc++;
|
||||
@ -189,7 +189,7 @@ private:
|
||||
if (innerErrorCode == ERR_OK) {
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to StartAbility, errorCode: %{public}d.", innerErrorCode);
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Start failed: %{public}d", innerErrorCode);
|
||||
task.Reject(env, NapiFormUtil::CreateErrorByInternalErrorCode(env, innerErrorCode));
|
||||
}
|
||||
};
|
||||
@ -205,13 +205,13 @@ private:
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
if (!CheckCallerIsSystemApp()) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "ConnectAbility app is not system-app, can not use system-api");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "not system app");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
// Check params count
|
||||
if (info.argc < ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Connect ability failed, not enough arguments.");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "invalid argc");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -228,7 +228,7 @@ private:
|
||||
[weak = context_, want, connection, connectId](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "context is free");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Context is free");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
RemoveConnection(connectId);
|
||||
return;
|
||||
@ -252,7 +252,7 @@ private:
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "DisconnectAbility");
|
||||
if (!CheckCallerIsSystemApp()) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "DisconnectAbility app is not system-app, can not use system-api");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "not system app");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -276,16 +276,15 @@ private:
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "release context");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Release context");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
return;
|
||||
}
|
||||
if (connection == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "connection null");
|
||||
TAG_LOGW(AAFwkTag::FORM_EXT, "Connection null");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "context->DisconnectAbility.");
|
||||
auto innerErrorCode = context->DisconnectAbility(want, connection);
|
||||
if (innerErrorCode == 0) {
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
@ -305,7 +304,7 @@ private:
|
||||
sptr<JSFormExtensionConnection>& connection, AAFwk::Want& want) const
|
||||
{
|
||||
if (!CheckTypeForNapiValue(env, value, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Failed to get connection object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get connection object failed");
|
||||
return false;
|
||||
}
|
||||
connection->SetJsConnectionObject(value);
|
||||
@ -319,14 +318,13 @@ private:
|
||||
} else {
|
||||
g_serialNumber = 0;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "make new one, not find connection");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "not find connection");
|
||||
return true;
|
||||
}
|
||||
|
||||
void FindConnection(AAFwk::Want& want, sptr<JSFormExtensionConnection>& connection, int64_t& connectId) const
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "Disconnect ability begin, connection:%{public}d.",
|
||||
static_cast<int32_t>(connectId));
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "connection:%{public}d", static_cast<int32_t>(connectId));
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
g_connects.end(),
|
||||
[&connectId](const auto &obj) {
|
||||
@ -336,7 +334,7 @@ private:
|
||||
// match id
|
||||
want = item->first.want;
|
||||
connection = item->second;
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "find conn ability exist");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "ability not exist");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -345,7 +343,7 @@ private:
|
||||
|
||||
napi_value CreateJsFormExtensionContext(napi_env env, std::shared_ptr<FormExtensionContext> context)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "Create js form extension context.");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
std::shared_ptr<OHOS::AppExecFwk::AbilityInfo> abilityInfo = nullptr;
|
||||
if (context) {
|
||||
abilityInfo = context->GetAbilityInfo();
|
||||
@ -363,7 +361,6 @@ napi_value CreateJsFormExtensionContext(napi_env env, std::shared_ptr<FormExtens
|
||||
BindNativeFunction(env, object, "disconnectServiceExtensionAbility",
|
||||
moduleName, JsFormExtensionContext::DisconnectAbility);
|
||||
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "Create end.");
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -422,13 +419,13 @@ int64_t JSFormExtensionConnection::GetConnectionId()
|
||||
void JSFormExtensionConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called, resultCode:%{public}d", resultCode);
|
||||
wptr<JSFormExtensionConnection> connection = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([connection, element, remoteObject, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
sptr<JSFormExtensionConnection> connectionSptr = connection.promote();
|
||||
if (!connectionSptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "connectionSptr nullptr");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "connectionSptr null");
|
||||
return;
|
||||
}
|
||||
connectionSptr->HandleOnAbilityConnectDone(element, remoteObject, resultCode);
|
||||
@ -443,7 +440,7 @@ void JSFormExtensionConnection::OnAbilityConnectDone(const AppExecFwk::ElementNa
|
||||
void JSFormExtensionConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "HandleOnAbilityConnectDone start, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called, resultCode:%{public}d", resultCode);
|
||||
// wrap ElementName
|
||||
napi_value napiElementName = OHOS::AppExecFwk::WrapElementName(env_, element);
|
||||
|
||||
@ -451,18 +448,18 @@ void JSFormExtensionConnection::HandleOnAbilityConnectDone(const AppExecFwk::Ele
|
||||
napi_value napiRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(env_, remoteObject);
|
||||
napi_value argv[] = {napiElementName, napiRemoteObject};
|
||||
if (jsConnectionObject_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsConnectionObject_ null");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsConnectionObject null");
|
||||
return;
|
||||
}
|
||||
napi_value obj = jsConnectionObject_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env_, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "error to get object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get object error");
|
||||
return;
|
||||
}
|
||||
napi_value methodOnConnect = nullptr;
|
||||
napi_get_named_property(env_, obj, "onConnect", &methodOnConnect);
|
||||
if (methodOnConnect == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Error to get onConnect from object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get onConnect error");
|
||||
return;
|
||||
}
|
||||
napi_call_function(env_, obj, methodOnConnect, ARGC_TWO, argv, nullptr);
|
||||
@ -470,13 +467,13 @@ void JSFormExtensionConnection::HandleOnAbilityConnectDone(const AppExecFwk::Ele
|
||||
|
||||
void JSFormExtensionConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called, resultCode:%{public}d", resultCode);
|
||||
wptr<JSFormExtensionConnection> connection = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([connection, element, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
sptr<JSFormExtensionConnection> connectionSptr = connection.promote();
|
||||
if (!connectionSptr) {
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "connectionSptr nullptr");
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "connectionSptr null");
|
||||
return;
|
||||
}
|
||||
connectionSptr->HandleOnAbilityDisconnectDone(element, resultCode);
|
||||
@ -490,11 +487,11 @@ void JSFormExtensionConnection::OnAbilityDisconnectDone(const AppExecFwk::Elemen
|
||||
void JSFormExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
|
||||
int resultCode)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGI(AAFwkTag::FORM_EXT, "called, resultCode:%{public}d", resultCode);
|
||||
napi_value napiElementName = OHOS::AppExecFwk::WrapElementName(env_, element);
|
||||
napi_value argv[] = {napiElementName};
|
||||
if (jsConnectionObject_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsConnectionObject_ null");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsConnectionObject null");
|
||||
return;
|
||||
}
|
||||
napi_value obj = jsConnectionObject_->GetNapiValue();
|
||||
@ -506,12 +503,12 @@ void JSFormExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::
|
||||
napi_value method = nullptr;
|
||||
napi_get_named_property(env_, obj, "onDisconnect", &method);
|
||||
if (method == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Error to get onDisconnect from object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get onDisconnect error");
|
||||
return;
|
||||
}
|
||||
|
||||
// release connect
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnAbilityDisconnectDone g_connects.size:%{public}zu.", g_connects.size());
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "size:%{public}zu", g_connects.size());
|
||||
std::string bundleName = element.GetBundleName();
|
||||
std::string abilityName = element.GetAbilityName();
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
@ -525,7 +522,7 @@ void JSFormExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::
|
||||
if (item != g_connects.end()) {
|
||||
// match bundleName && abilityName
|
||||
g_connects.erase(item);
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "OnAbilityDisconnectDone erase g_connects.size:%{public}zu.", g_connects.size());
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "erase size:%{public}zu", g_connects.size());
|
||||
}
|
||||
napi_call_function(env_, obj, method, ARGC_ONE, argv, nullptr);
|
||||
}
|
||||
@ -544,21 +541,21 @@ void JSFormExtensionConnection::RemoveConnectionObject()
|
||||
|
||||
void JSFormExtensionConnection::CallJsFailed(int32_t errorCode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "CallJsFailed start");
|
||||
TAG_LOGD(AAFwkTag::FORM_EXT, "called");
|
||||
if (jsConnectionObject_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsConnectionObject_ null");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "jsConnectionObject null");
|
||||
return;
|
||||
}
|
||||
napi_value obj = jsConnectionObject_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env_, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Error to get object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get object error");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value method = nullptr;
|
||||
napi_get_named_property(env_, obj, "onFailed", &method);
|
||||
if (method == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "Error to get onFailed from object");
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "get onFailed error");
|
||||
return;
|
||||
}
|
||||
napi_value argv[] = {CreateJsValue(env_, errorCode)};
|
||||
|
@ -29,32 +29,32 @@ JsStartupConfig::~JsStartupConfig() = default;
|
||||
int32_t JsStartupConfig::Init(std::unique_ptr<NativeReference> &configEntryJsRef)
|
||||
{
|
||||
if (configEntryJsRef == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config entry is null");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config entry null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
HandleScope handleScope(env_);
|
||||
|
||||
napi_value configEntry = configEntryJsRef->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env_, configEntry, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config entry is not napi object.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "not napi object");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value onConfig = nullptr;
|
||||
napi_get_named_property(env_, configEntry, "onConfig", &onConfig);
|
||||
if (onConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "no property onConfig in config entry.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "onConfig invalid");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env_, onConfig, &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "onConfig is not callable.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "onConfig not callable");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value config = nullptr;
|
||||
napi_call_function(env_, configEntry, onConfig, 0, nullptr, &config);
|
||||
if (config == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config is null.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ int32_t JsStartupConfig::Init(std::unique_ptr<NativeReference> &configEntryJsRef
|
||||
int32_t JsStartupConfig::Init(napi_value config)
|
||||
{
|
||||
if (config == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config is null.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "config null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -80,19 +80,19 @@ void JsStartupConfig::InitAwaitTimeout(napi_env env, napi_value config)
|
||||
napi_value awaitTimeout = nullptr;
|
||||
napi_get_named_property(env, config, "timeoutMs", &awaitTimeout);
|
||||
if (awaitTimeout == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "no property timeoutMs in config.");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "timeoutMs invalid");
|
||||
return;
|
||||
}
|
||||
int32_t awaitTimeoutNum = DEFAULT_AWAIT_TIMEOUT_MS;
|
||||
if (!ConvertFromJsValue(env, awaitTimeout, awaitTimeoutNum)) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "failed to covert awaitTimeout to number.");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "covert failed");
|
||||
return;
|
||||
}
|
||||
if (awaitTimeoutNum <= 0) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "awaitTimeoutNum is invalid. set to default");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "invalid argc");
|
||||
awaitTimeoutNum = DEFAULT_AWAIT_TIMEOUT_MS;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "set awaitTimeoutMs to %{public}d.", awaitTimeoutNum);
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "set awaitTimeoutMs to %{public}d", awaitTimeoutNum);
|
||||
awaitTimeoutMs_ = awaitTimeoutNum;
|
||||
}
|
||||
|
||||
@ -101,18 +101,18 @@ void JsStartupConfig::InitListener(napi_env env, napi_value config)
|
||||
napi_value listener = nullptr;
|
||||
napi_get_named_property(env, config, "startupListener", &listener);
|
||||
if (listener == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "no property startupListener in config.");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "null startupListener");
|
||||
return;
|
||||
}
|
||||
if (!CheckTypeForNapiValue(env, listener, napi_object)) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "listener is not napi object.");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "not napi object");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value onCompleted = nullptr;
|
||||
napi_get_named_property(env, listener, "onCompleted", &onCompleted);
|
||||
if (onCompleted == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "no property onCompleted in listener.");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "null onCompleted");
|
||||
return;
|
||||
}
|
||||
napi_ref listenerRef = nullptr;
|
||||
@ -121,7 +121,7 @@ void JsStartupConfig::InitListener(napi_env env, napi_value config)
|
||||
OnCompletedCallbackFunc onCompletedCallback =
|
||||
[env, listenerRefSp](const std::shared_ptr<StartupTaskResult> &result) {
|
||||
if (env == nullptr || listenerRefSp == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "env or listenerRefSp is null");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "env or listenerRefSp null");
|
||||
return;
|
||||
}
|
||||
HandleScope handleScope(env);
|
||||
@ -130,13 +130,13 @@ void JsStartupConfig::InitListener(napi_env env, napi_value config)
|
||||
napi_value onCompleted = nullptr;
|
||||
napi_get_named_property(env, listener, "onCompleted", &onCompleted);
|
||||
if (onCompleted == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "no property onCompleted in listener.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "null onCompleted");
|
||||
return;
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env, onCompleted, &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "onCompleted is not callable.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "onCompleted not callable");
|
||||
return;
|
||||
}
|
||||
napi_value argv[1] = { JsStartupConfig::BuildResult(env, result) };
|
||||
|
@ -43,15 +43,14 @@ int32_t JsStartupTask::Init()
|
||||
int32_t JsStartupTask::RunTaskInit(std::unique_ptr<StartupTaskResultCallback> callback)
|
||||
{
|
||||
if (state_ != State::CREATED) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP,
|
||||
"%{public}s, state is wrong %{public}d", name_.c_str(), static_cast<int32_t>(state_));
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, state wrong %{public}d", name_.c_str(), static_cast<int32_t>(state_));
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
state_ = State::INITIALIZING;
|
||||
callback->Push([weak = weak_from_this()](const std::shared_ptr<StartupTaskResult> &result) {
|
||||
auto startupTask = weak.lock();
|
||||
if (startupTask == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTask is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTask null");
|
||||
return;
|
||||
}
|
||||
startupTask->SaveResult(result);
|
||||
@ -63,7 +62,7 @@ int32_t JsStartupTask::RunTaskInit(std::unique_ptr<StartupTaskResultCallback> ca
|
||||
}
|
||||
|
||||
if (LoadJsAsyncTaskExcutor() != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Load async task excutor is failed.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "LoadJsAsyncTaskExcutor failed");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
LoadJsAsyncTaskCallback();
|
||||
@ -88,7 +87,7 @@ int32_t JsStartupTask::LoadJsAsyncTaskExcutor()
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Object null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -123,7 +122,7 @@ void JsStartupTask::OnAsyncTaskCompleted(const std::shared_ptr<StartupTaskResult
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called");
|
||||
if (startupTaskResultCallback_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Startup task result callback object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "null startupTaskResultCallback");
|
||||
return;
|
||||
}
|
||||
startupTaskResultCallback_->Call(result);
|
||||
@ -136,7 +135,7 @@ int32_t JsStartupTask::RunTaskOnDependencyCompleted(const std::string &dependenc
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
if (startupJsRef_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, startup task is null", name_.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "null ref_:%{public}s", name_.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value startupValue = startupJsRef_->GetNapiValue();
|
||||
@ -148,13 +147,13 @@ int32_t JsStartupTask::RunTaskOnDependencyCompleted(const std::string &dependenc
|
||||
napi_get_named_property(env, startupValue, "onDependencyCompleted", &startupOnDepCompleted);
|
||||
if (startupOnDepCompleted == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP,
|
||||
"%{public}s, failed to get property onDependencyCompleted from startup task.", name_.c_str());
|
||||
"%{public}s, get onDependencyCompleted failed", name_.c_str());
|
||||
return ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP;
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env, startupOnDepCompleted, &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, startup task onDependencyCompleted is not callable.", name_.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "onDependencyCompleted not callable:%{public}s", name_.c_str());
|
||||
return ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP;
|
||||
}
|
||||
|
||||
@ -174,7 +173,7 @@ napi_value JsStartupTask::GetDependencyResult(napi_env env, const std::string &d
|
||||
} else {
|
||||
std::shared_ptr<JsStartupTaskResult> jsResultPtr = std::static_pointer_cast<JsStartupTaskResult>(result);
|
||||
if (jsResultPtr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to convert to js result.", dependencyName.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, convert failed", dependencyName.c_str());
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::shared_ptr<NativeReference> jsResultRef = jsResultPtr->GetJsStartupResultRef();
|
||||
@ -195,7 +194,7 @@ napi_value AsyncTaskCallBack::AsyncTaskCompleted(napi_env env, napi_callback_inf
|
||||
|
||||
std::string startupName;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], startupName)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Convert from js startupName error.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Convert error");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
@ -53,24 +53,24 @@ int32_t JsStartupTaskExecutor::RunOnTaskPool(
|
||||
auto env = jsRuntime.GetNapiEnv();
|
||||
|
||||
if (startup == nullptr || context == nullptr || asyncTaskExcutor == nullptr || asyncTaskCallback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncTaskExcutor or startup or context or async task callback is null.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "args null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value asyncTaskExcutorValue = asyncTaskExcutor->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, asyncTaskExcutorValue, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncTaskExcutor is not napi object.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "not napi object");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value asyncPushTask = nullptr;
|
||||
napi_get_named_property(env, asyncTaskExcutorValue, "asyncPushTask", &asyncPushTask);
|
||||
if (asyncPushTask == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Failed to get property asyncPushTask from AsyncTaskExcutor.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncPushTask null");
|
||||
return ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP;
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env, asyncPushTask, &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncPushTask is not callable.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncPushTask not callable");
|
||||
return ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP;
|
||||
}
|
||||
napi_value returnVal = nullptr;
|
||||
|
@ -32,7 +32,7 @@ int32_t StartupManager::RegisterStartupTask(const std::string &name, const std::
|
||||
{
|
||||
auto result = startupTasks_.emplace(name, startupTask);
|
||||
if (!result.second) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Failed to register startup task, name: %{public}s already exist.", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s exist", name.c_str());
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
return ERR_OK;
|
||||
@ -44,7 +44,7 @@ int32_t StartupManager::BuildAutoStartupTaskManager(std::shared_ptr<StartupTaskM
|
||||
std::set<std::string> dependenciesSet;
|
||||
for (auto &iter : startupTasks_) {
|
||||
if (iter.second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task is null");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
if (iter.second->GetIsExcludeFromAutoStart()) {
|
||||
@ -85,7 +85,7 @@ int32_t StartupManager::BuildStartupTaskManager(const std::vector<std::string> &
|
||||
return ERR_STARTUP_DEPENDENCY_NOT_FOUND;
|
||||
}
|
||||
if (findResult->second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s startup task is null", iter.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s startup task null", iter.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
currentStartupTasks.emplace(iter, findResult->second);
|
||||
@ -114,7 +114,7 @@ int32_t StartupManager::OnStartupTaskManagerComplete(uint32_t id)
|
||||
{
|
||||
auto result = startupTaskManagerMap_.find(id);
|
||||
if (result == startupTaskManagerMap_.end()) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "StartupTaskManager id: %{public}u not found.", id);
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "StartupTaskManager id: %{public}u not found", id);
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "erase StartupTaskManager id: %{public}u", id);
|
||||
@ -148,7 +148,7 @@ int32_t StartupManager::RemoveResult(const std::string &name)
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called, name: %{public}s", name.c_str());
|
||||
auto findResult = startupTasks_.find(name);
|
||||
if (findResult == startupTasks_.end() || findResult->second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "name: %{public}s, not found", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s not found", name.c_str());
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
return findResult->second->RemoveResult();
|
||||
@ -159,12 +159,12 @@ int32_t StartupManager::GetResult(const std::string &name, std::shared_ptr<Start
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called, name: %{public}s", name.c_str());
|
||||
auto findResult = startupTasks_.find(name);
|
||||
if (findResult == startupTasks_.end() || findResult->second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "name: %{public}s, not found", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s not found", name.c_str());
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
StartupTask::State state = findResult->second->GetState();
|
||||
if (state != StartupTask::State::INITIALIZED) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "name: %{public}s, not initialized", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s not initialized", name.c_str());
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
result = findResult->second->GetResult();
|
||||
@ -176,7 +176,7 @@ int32_t StartupManager::IsInitialized(const std::string &name, bool &isInitializ
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called, name: %{public}s", name.c_str());
|
||||
auto findResult = startupTasks_.find(name);
|
||||
if (findResult == startupTasks_.end() || findResult->second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "name: %{public}s, not found", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, not found", name.c_str());
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
StartupTask::State state = findResult->second->GetState();
|
||||
@ -187,7 +187,7 @@ int32_t StartupManager::IsInitialized(const std::string &name, bool &isInitializ
|
||||
int32_t StartupManager::PostMainThreadTask(const std::function<void()> &task)
|
||||
{
|
||||
if (mainHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "failed to get mainHandler_");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "get mainHandler failed");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
mainHandler_->PostTask(task);
|
||||
@ -214,7 +214,7 @@ int32_t StartupManager::AddStartupTask(const std::string &name,
|
||||
}
|
||||
taskMap.emplace(taskName, findResult->second);
|
||||
if (findResult->second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task is null, %{public}s", taskName.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "null task:%{public}s", taskName.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
auto dependencies = findResult->second->GetDependencies();
|
||||
|
@ -71,7 +71,7 @@ void StartupTask::SetIsExcludeFromAutoStart(bool excludeFromAutoStart)
|
||||
void StartupTask::SaveResult(const std::shared_ptr<StartupTaskResult> &result)
|
||||
{
|
||||
if (result == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task: %{public}s, result is null", name_.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task: %{public}s, result null", name_.c_str());
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::STARTUP,
|
||||
@ -87,7 +87,7 @@ void StartupTask::SaveResult(const std::shared_ptr<StartupTaskResult> &result)
|
||||
int32_t StartupTask::RemoveResult()
|
||||
{
|
||||
if (state_ != State::INITIALIZED) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, the result is not init", name_.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, result not init", name_.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
result_ = nullptr;
|
||||
@ -131,7 +131,7 @@ uint32_t StartupTask::getDependenciesCount() const
|
||||
int32_t StartupTask::AddExtraCallback(std::unique_ptr<StartupTaskResultCallback> callback)
|
||||
{
|
||||
if (state_ != State::INITIALIZING) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "state is not INITIALIZING");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "state not INITIALIZING");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
// extra callback will called while init done
|
||||
|
@ -34,12 +34,12 @@ int32_t StartupTaskDispatcher::Run(const std::shared_ptr<OnCompletedCallback> &c
|
||||
const std::shared_ptr<OnCompletedCallback> &mainThreadAwaitCallback)
|
||||
{
|
||||
if (sortResult_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "sortResult_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "sortResult null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
for (auto &iter : tasks_) {
|
||||
if (iter.second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task %{public}s is nullptr", iter.first.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task %{public}s null", iter.first.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
inDegreeMap_.emplace(iter.first, iter.second->getDependenciesCount());
|
||||
@ -52,7 +52,7 @@ int32_t StartupTaskDispatcher::Run(const std::shared_ptr<OnCompletedCallback> &c
|
||||
mainThreadAwaitCallback_ = mainThreadAwaitCallback;
|
||||
|
||||
if (mainThreadAwaitCount_ == 0) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "no main thread await task. call mainThreadAwaitCallback");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "no main thread await task");
|
||||
if (mainThreadAwaitCallback_ != nullptr) {
|
||||
auto result = std::make_shared<StartupTaskResult>();
|
||||
mainThreadAwaitCallback_->Call(result);
|
||||
@ -66,7 +66,7 @@ int32_t StartupTaskDispatcher::Run(const std::shared_ptr<OnCompletedCallback> &c
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
if (findResult->second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task %{public}s is nullptr", iter.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startup task %{public}s null", iter.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
int32_t result = RunTaskInit(iter, findResult->second);
|
||||
@ -79,7 +79,7 @@ int32_t StartupTaskDispatcher::Run(const std::shared_ptr<OnCompletedCallback> &c
|
||||
|
||||
void StartupTaskDispatcher::Dispatch(const std::string &name, const std::shared_ptr<StartupTaskResult> &result)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "run startup task %{public}s dispatch.", name.c_str());
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "run startup task %{public}s dispatch", name.c_str());
|
||||
if (result == nullptr) {
|
||||
OnError(ERR_STARTUP_INTERNAL_ERROR, name + ": result is null");
|
||||
return;
|
||||
@ -99,7 +99,7 @@ void StartupTaskDispatcher::Dispatch(const std::string &name, const std::shared_
|
||||
|
||||
if (findResult->second->GetWaitOnMainThread()) {
|
||||
mainThreadAwaitCount_--;
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "mainThreadAwaitCount_ %{public}d.", mainThreadAwaitCount_);
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "mainThreadAwaitCount %{public}d", mainThreadAwaitCount_);
|
||||
if (mainThreadAwaitCount_ == 0) {
|
||||
if (mainThreadAwaitCallback_ != nullptr) {
|
||||
mainThreadAwaitCallback_->Call(result);
|
||||
@ -107,7 +107,7 @@ void StartupTaskDispatcher::Dispatch(const std::string &name, const std::shared_
|
||||
}
|
||||
}
|
||||
tasksCount_--;
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "tasksCount_ %{public}d.", tasksCount_);
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "tasksCount %{public}d", tasksCount_);
|
||||
if (tasksCount_ == 0) {
|
||||
if (completedCallback_ != nullptr) {
|
||||
completedCallback_->Call(result);
|
||||
@ -159,12 +159,12 @@ int32_t StartupTaskDispatcher::NotifyChildren(const std::string &name, const std
|
||||
|
||||
int32_t StartupTaskDispatcher::RunTaskInit(const std::string &name, const std::shared_ptr<StartupTask> &task)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "run startup task %{public}s init.", name.c_str());
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "%{public}s init", name.c_str());
|
||||
std::unique_ptr<StartupTaskResultCallback> callback = std::make_unique<StartupTaskResultCallback>();
|
||||
callback->Push([weak = weak_from_this(), name](const std::shared_ptr<StartupTaskResult> &result) {
|
||||
auto startupTaskDispatcher = weak.lock();
|
||||
if (startupTaskDispatcher == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "startupTaskDispatcher may have been release due to previous error.");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "startupTaskDispatcher may have been release due to previous error");
|
||||
return;
|
||||
}
|
||||
startupTaskDispatcher->Dispatch(name, result);
|
||||
@ -179,7 +179,7 @@ int32_t StartupTaskDispatcher::RunTaskInit(const std::string &name, const std::s
|
||||
return task->AddExtraCallback(std::move(callback));
|
||||
} else {
|
||||
// state: INVALID
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s task state is: INVALID", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s task state: INVALID", name.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ StartupTaskManager::~StartupTaskManager()
|
||||
int32_t StartupTaskManager::AddTask(const std::shared_ptr<StartupTask> &task)
|
||||
{
|
||||
if (task == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Invalid task.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Invalid task");
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
std::string name = task->GetName();
|
||||
auto result = tasks_.emplace(name, task);
|
||||
if (!result.second) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Failed to add task, name: %{public}s already exist.", name.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s exist", name.c_str());
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
return ERR_OK;
|
||||
@ -61,12 +61,12 @@ int32_t StartupTaskManager::Prepare()
|
||||
return result;
|
||||
}
|
||||
if (startupSortResult == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupSortResult is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupSortResult null");
|
||||
CallListenerOnCompleted(ERR_STARTUP_INTERNAL_ERROR);
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
if (tasks_.empty()) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "no tasks.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "no tasks");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
dispatcher_ = std::make_shared<StartupTaskDispatcher>(tasks_, startupSortResult);
|
||||
@ -77,7 +77,7 @@ int32_t StartupTaskManager::Run(const std::shared_ptr<OnCompletedCallback> &main
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "id: %{public}u, task number: %{public}zu", startupTaskManagerId_, tasks_.size());
|
||||
if (dispatcher_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "dispatcher_ is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "dispatcher null");
|
||||
CallListenerOnCompleted(ERR_STARTUP_INTERNAL_ERROR);
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
@ -86,12 +86,12 @@ int32_t StartupTaskManager::Run(const std::shared_ptr<OnCompletedCallback> &main
|
||||
[weak = weak_from_this()](const std::shared_ptr<StartupTaskResult> &result) {
|
||||
auto startupTaskManager = weak.lock();
|
||||
if (startupTaskManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTaskManager is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTaskManager null");
|
||||
return;
|
||||
}
|
||||
startupTaskManager->CancelAsyncTimeoutTimer();
|
||||
if (result == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "result is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "result null");
|
||||
return;
|
||||
}
|
||||
startupTaskManager->CallListenerOnCompleted(result->GetResultCode(), result->GetResultMessage());
|
||||
@ -130,7 +130,7 @@ void StartupTaskManager::AddAsyncTimeoutTimer()
|
||||
{
|
||||
mainHandler_ = std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner());
|
||||
if (mainHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "failed to get mainHandler_");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "get mainHandler failed");
|
||||
return;
|
||||
}
|
||||
int32_t timeoutMs = StartupConfig::DEFAULT_AWAIT_TIMEOUT_MS;
|
||||
@ -141,7 +141,7 @@ void StartupTaskManager::AddAsyncTimeoutTimer()
|
||||
auto callback = [weak = weak_from_this()]() {
|
||||
auto startupTaskManager = weak.lock();
|
||||
if (startupTaskManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTaskManager is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "startupTaskManager null");
|
||||
return;
|
||||
}
|
||||
startupTaskManager->OnTimeout();
|
||||
@ -152,7 +152,7 @@ void StartupTaskManager::AddAsyncTimeoutTimer()
|
||||
void StartupTaskManager::CancelAsyncTimeoutTimer()
|
||||
{
|
||||
if (mainHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "failed to get mainHandler_");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "get mainHandler failed");
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "id: %{public}d, cancel timeout timer", startupTaskManagerId_);
|
||||
|
@ -62,11 +62,11 @@ OnCompletedCallback::~OnCompletedCallback() = default;
|
||||
void OnCompletedCallback::Call(const std::shared_ptr<StartupTaskResult> &result)
|
||||
{
|
||||
if (isCalled_) {
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "the callback already is called");
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "callback already called");
|
||||
return;
|
||||
}
|
||||
if (callbackFunc_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the callback is null");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "callbackFunc null");
|
||||
return;
|
||||
}
|
||||
callbackFunc_(result);
|
||||
|
@ -23,14 +23,14 @@ int32_t StartupTopologySort::Sort(const std::map<std::string, std::shared_ptr<St
|
||||
{
|
||||
startupSortResult = std::make_shared<StartupSortResult>();
|
||||
if (startupSortResult == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Create StartupSortResult obj fail.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Create result obj fail");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
std::deque<std::string> zeroDeque;
|
||||
std::map<std::string, std::uint32_t> inDegreeMap;
|
||||
for (auto &iter : startupMap) {
|
||||
if (iter.second == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "StartupTask is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "StartupTask null");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
int32_t result = SortZeroDeque(iter.second, startupMap, inDegreeMap, zeroDeque, startupSortResult);
|
||||
@ -81,7 +81,7 @@ int32_t StartupTopologySort::SortZeroDeque(const std::shared_ptr<StartupTask> &s
|
||||
std::string key = startup->GetName();
|
||||
auto result = inDegreeMap.emplace(key, startup->getDependenciesCount());
|
||||
if (!result.second) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to emplace to inDegreeMap.", key.c_str());
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, emplace to inDegreeMap failed", key.c_str());
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
std::vector<std::string> dependencies = startup->GetDependencies();
|
||||
@ -92,7 +92,7 @@ int32_t StartupTopologySort::SortZeroDeque(const std::shared_ptr<StartupTask> &s
|
||||
for (auto &parentName : dependencies) {
|
||||
if (startupMap.find(parentName) == startupMap.end()) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP,
|
||||
"%{public}s, failed to find dep: %{public}s.", key.c_str(), parentName.c_str());
|
||||
"%{public}s, failed to find dep: %{public}s", key.c_str(), parentName.c_str());
|
||||
return ERR_STARTUP_DEPENDENCY_NOT_FOUND;
|
||||
}
|
||||
auto &childStartVector = startupSortResult->startupChildrenMap_[parentName];
|
||||
|
@ -33,11 +33,11 @@ const int32_t UID_TRANSFORM_DIVISOR = 200000;
|
||||
ErrCode OsAccountManagerWrapper::QueryActiveOsAccountIds(std::vector<int32_t>& ids)
|
||||
{
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "Without os account subsystem");
|
||||
ids.emplace_back(DEFAULT_OS_ACCOUNT_ID);
|
||||
return ERR_OK;
|
||||
#else
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "os account subsystem");
|
||||
return AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
}
|
||||
@ -45,11 +45,11 @@ ErrCode OsAccountManagerWrapper::QueryActiveOsAccountIds(std::vector<int32_t>& i
|
||||
ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id)
|
||||
{
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "Without os account subsystem");
|
||||
id = uid / UID_TRANSFORM_DIVISOR;
|
||||
return ERR_OK;
|
||||
#else
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "os account subsystem");
|
||||
return AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, id);
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
}
|
||||
@ -57,11 +57,11 @@ ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(const int32_t uid, i
|
||||
ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(int &id)
|
||||
{
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Without os account subsystem");
|
||||
id = DEFAULT_OS_ACCOUNT_ID;
|
||||
return ERR_OK;
|
||||
#else
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "os account subsystem");
|
||||
return AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(id);
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
}
|
||||
@ -69,11 +69,11 @@ ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(int &id)
|
||||
ErrCode OsAccountManagerWrapper::IsOsAccountExists(const int id, bool &isOsAccountExists)
|
||||
{
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Without os account subsystem");
|
||||
isOsAccountExists = (id == DEFAULT_OS_ACCOUNT_ID);
|
||||
return ERR_OK;
|
||||
#else // OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "os account subsystem");
|
||||
return AccountSA::OsAccountManager::IsOsAccountExists(id, isOsAccountExists);
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
}
|
||||
@ -81,11 +81,11 @@ ErrCode OsAccountManagerWrapper::IsOsAccountExists(const int id, bool &isOsAccou
|
||||
ErrCode OsAccountManagerWrapper::CreateOsAccount(const std::string &name, int32_t &osAccountUserId)
|
||||
{
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Without os account subsystem");
|
||||
osAccountUserId = USER_ID_U100;
|
||||
return ERR_OK;
|
||||
#else // OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "os account subsystem");
|
||||
AccountSA::OsAccountInfo osAccountInfo;
|
||||
ErrCode errCode = AccountSA::OsAccountManager::CreateOsAccount(name,
|
||||
AccountSA::OsAccountType::NORMAL, osAccountInfo);
|
||||
@ -97,10 +97,10 @@ ErrCode OsAccountManagerWrapper::CreateOsAccount(const std::string &name, int32_
|
||||
ErrCode OsAccountManagerWrapper::RemoveOsAccount(const int id)
|
||||
{
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Without os account subsystem");
|
||||
return ERR_OK;
|
||||
#else // OS_ACCOUNT_PART_ENABLED
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "os account subsystem");
|
||||
return AccountSA::OsAccountManager::RemoveOsAccount(id);
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
}
|
||||
@ -110,18 +110,18 @@ int32_t OsAccountManagerWrapper::GetCurrentActiveAccountId()
|
||||
std::vector<int32_t> accountIds;
|
||||
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
|
||||
if (instance == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Failed to get OsAccountManager instance.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Get OsAccountManager Failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ErrCode ret = instance->QueryActiveOsAccountIds(accountIds);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Query active account id failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Query active id failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (accountIds.empty()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "No active account.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "account empty");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ sptr<IRemoteObject> SaMgrClient::GetSystemAbility(const int32_t systemAbilityId)
|
||||
if (saMgr_ == nullptr) {
|
||||
saMgr_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (saMgr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Failed to get registry.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Get registry fialed");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -53,7 +53,7 @@ sptr<IRemoteObject> SaMgrClient::CheckSystemAbility(const int32_t systemAbilityI
|
||||
if (saMgr_ == nullptr) {
|
||||
saMgr_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (saMgr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Fail to get registry.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Get registry fialed");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ bool AbilityRuntimeErrorUtil::Throw(napi_env env, int32_t errCode, const std::st
|
||||
napi_value error = nullptr;
|
||||
napi_create_error(env, CreateJsValue(env, errCode), CreateJsValue(env, eMes), &error);
|
||||
if (error == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Failed to create error.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "create error");
|
||||
return false;
|
||||
}
|
||||
napi_throw(env, error);
|
||||
@ -171,7 +171,7 @@ bool AbilityRuntimeErrorUtil::Throw(napi_env env, int32_t errCode, const std::st
|
||||
bool AbilityRuntimeErrorUtil::ThrowByInternalErrCode(napi_env env, int32_t errCode)
|
||||
{
|
||||
if (ERROR_CODE_MAP.find(errCode) == ERROR_CODE_MAP.end()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid inner errCode, check ERROR_CODE_MAP");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid errCode");
|
||||
return false;
|
||||
}
|
||||
return Throw(env, ERROR_CODE_MAP.at(errCode));
|
||||
@ -180,7 +180,7 @@ bool AbilityRuntimeErrorUtil::ThrowByInternalErrCode(napi_env env, int32_t errCo
|
||||
napi_value AbilityRuntimeErrorUtil::CreateErrorByInternalErrCode(napi_env env, int32_t errCode)
|
||||
{
|
||||
if (ERROR_CODE_MAP.find(errCode) == ERROR_CODE_MAP.end()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid inner errCode, check ERROR_CODE_MAP");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid errCode");
|
||||
return nullptr;
|
||||
}
|
||||
int32_t externalErrCode = ERROR_CODE_MAP.at(errCode);
|
||||
|
@ -25,21 +25,21 @@ void SessionHandlerProxy::OnSessionMovedToFront(int32_t sessionId)
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(ISessionHandler::GetDescriptor())) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "write token failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(sessionId)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "sessionId write failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "sessionId write failed");
|
||||
return;
|
||||
}
|
||||
auto remote = Remote();
|
||||
if (!remote) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "remote null");
|
||||
return;
|
||||
}
|
||||
int32_t ret = remote->SendRequest(ISessionHandler::ON_SESSION_MOVED_TO_FRONT, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "OnSessionMovedToFront fail to Send request, err: %{public}d.", ret);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "request failed: %{public}d", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ int32_t SessionHandlerStub::OnRemoteRequest(
|
||||
std::u16string descriptor = SessionHandlerStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "local descriptor is not equal to remote.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "descriptor not equal remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ int32_t SessionHandlerStub::OnSessionMovedToFrontInner(MessageParcel &data, Mess
|
||||
|
||||
void SessionHandlerStub::OnSessionMovedToFront(int32_t sessionId)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "call, sessionId:%{public}d", sessionId);
|
||||
TAG_LOGI(AAFwkTag::DEFAULT, "sessionId:%{public}d", sessionId);
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ bool ContinueRadar::ClickIconContinue(const std::string& func)
|
||||
BIZ_STAGE, static_cast<int32_t>(ClickIcon::CLICKICON_CONTINUE),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC));
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ClickIconContinue error, res:%{public}d", res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "error, res:%{public}d", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -85,7 +85,7 @@ bool ContinueRadar::ClickIconStartAbility(const std::string& func, int32_t errCo
|
||||
ERROR_CODE, errCode);
|
||||
}
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ClickIconStartAbility error, res:%{public}d", res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "error, res:%{public}d", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -104,7 +104,7 @@ bool ContinueRadar::ClickIconRecvOver(const std::string& func)
|
||||
BIZ_STAGE, static_cast<int32_t>(ClickIcon::CLICKICON_RECV_OVER),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC));
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "ClickIconRecvOver error, res:%{public}d", res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "error, res:%{public}d", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -122,7 +122,7 @@ bool ContinueRadar::SaveDataContinue(const std::string& func)
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_CONTINUE),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC));
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "SaveDataContinue error, res:%{public}d", res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "error, res:%{public}d", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -140,7 +140,7 @@ bool ContinueRadar::SaveDataRes(const std::string& func)
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_RES),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC));
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "SaveDataRes error, res:%{public}d", res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "error, res:%{public}d", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -159,7 +159,7 @@ bool ContinueRadar::SaveDataRemoteWant(const std::string& func)
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC),
|
||||
TO_CALL_PKG, DMS_PKG_NAME);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "SaveDataRemoteWant error, res:%{public}d", res);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "error, res:%{public}d", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -104,7 +104,7 @@ bool AppUtils::IsInheritWindowSplitScreenMode()
|
||||
isInheritWindowSplitScreenMode_.value = system::GetBoolParameter(INHERIT_WINDOW_SPLIT_SCREEN_MODE, true);
|
||||
isInheritWindowSplitScreenMode_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isInheritWindowSplitScreenMode is %{public}d", isInheritWindowSplitScreenMode_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isInheritWindowSplitScreenMode_.value);
|
||||
return isInheritWindowSplitScreenMode_.value;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ bool AppUtils::IsSupportAncoApp()
|
||||
isSupportAncoApp_.value = system::GetBoolParameter(SUPPORT_ANCO_APP, false);
|
||||
isSupportAncoApp_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isSupportAncoApp is %{public}d", isSupportAncoApp_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isSupportAncoApp_.value);
|
||||
return isSupportAncoApp_.value;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ int32_t AppUtils::GetTimeoutUnitTimeRatio()
|
||||
timeoutUnitTimeRatio_.value = system::GetIntParameter<int32_t>(TIMEOUT_UNIT_TIME_RATIO, 1);
|
||||
timeoutUnitTimeRatio_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "timeoutUnitTimeRatio is %{public}d", timeoutUnitTimeRatio_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", timeoutUnitTimeRatio_.value);
|
||||
return timeoutUnitTimeRatio_.value;
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ bool AppUtils::IsSelectorDialogDefaultPossion()
|
||||
isSelectorDialogDefaultPossion_.value = system::GetBoolParameter(SELECTOR_DIALOG_POSSION, true);
|
||||
isSelectorDialogDefaultPossion_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isSelectorDialogDefaultPossion is %{public}d", isSelectorDialogDefaultPossion_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isSelectorDialogDefaultPossion_.value);
|
||||
return isSelectorDialogDefaultPossion_.value;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ bool AppUtils::IsStartSpecifiedProcess()
|
||||
isStartSpecifiedProcess_.value = system::GetBoolParameter(START_SPECIFIED_PROCESS, false);
|
||||
isStartSpecifiedProcess_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isStartSpecifiedProcess is %{public}d", isStartSpecifiedProcess_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isStartSpecifiedProcess_.value);
|
||||
return isStartSpecifiedProcess_.value;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ bool AppUtils::IsUseMultiRenderProcess()
|
||||
isUseMultiRenderProcess_.value = system::GetBoolParameter(USE_MULTI_RENDER_PROCESS, true);
|
||||
isUseMultiRenderProcess_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isUseMultiRenderProcess is %{public}d", isUseMultiRenderProcess_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isUseMultiRenderProcess_.value);
|
||||
return isUseMultiRenderProcess_.value;
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ bool AppUtils::IsLimitMaximumOfRenderProcess()
|
||||
isLimitMaximumOfRenderProcess_.value = system::GetBoolParameter(LIMIT_MAXIMUM_OF_RENDER_PROCESS, true);
|
||||
isLimitMaximumOfRenderProcess_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isLimitMaximumOfRenderProcess_ is %{public}d", isLimitMaximumOfRenderProcess_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isLimitMaximumOfRenderProcess_.value);
|
||||
return isLimitMaximumOfRenderProcess_.value;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ bool AppUtils::IsGrantPersistUriPermission()
|
||||
isGrantPersistUriPermission_.value = system::GetBoolParameter(GRANT_PERSIST_URI_PERMISSION, false);
|
||||
isGrantPersistUriPermission_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isGrantPersistUriPermission_ is %{public}d", isGrantPersistUriPermission_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isGrantPersistUriPermission_.value);
|
||||
return isGrantPersistUriPermission_.value;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ bool AppUtils::IsStartOptionsWithAnimation()
|
||||
isStartOptionsWithAnimation_.value = system::GetBoolParameter(START_OPTIONS_WITH_ANIMATION, false);
|
||||
isStartOptionsWithAnimation_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isStartOptionsWithAnimation_ is %{public}d", isStartOptionsWithAnimation_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isStartOptionsWithAnimation_.value);
|
||||
return isStartOptionsWithAnimation_.value;
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ bool AppUtils::IsMultiProcessModel()
|
||||
isMultiProcessModel_.value = system::GetBoolParameter(MULTI_PROCESS_MODEL, false);
|
||||
isMultiProcessModel_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isMultiProcessModel_ is %{public}d", isMultiProcessModel_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isMultiProcessModel_.value);
|
||||
return isMultiProcessModel_.value;
|
||||
}
|
||||
|
||||
@ -204,8 +204,7 @@ bool AppUtils::IsStartOptionsWithProcessOptions()
|
||||
isStartOptionsWithProcessOptions_.value = system::GetBoolParameter(START_OPTIONS_WITH_PROCESS_OPTION, false);
|
||||
isStartOptionsWithProcessOptions_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT,
|
||||
"isStartOptionsWithProcessOptions_ is %{public}d", isStartOptionsWithProcessOptions_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isStartOptionsWithProcessOptions_.value);
|
||||
return isStartOptionsWithProcessOptions_.value;
|
||||
}
|
||||
|
||||
@ -216,8 +215,7 @@ bool AppUtils::EnableMoveUIAbilityToBackgroundApi()
|
||||
system::GetBoolParameter(MOVE_UI_ABILITY_TO_BACKGROUND_API_ENABLE, true);
|
||||
enableMoveUIAbilityToBackgroundApi_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT,
|
||||
"enableMoveUIAbilityToBackgroundApi_ is %{public}d", enableMoveUIAbilityToBackgroundApi_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", enableMoveUIAbilityToBackgroundApi_.value);
|
||||
return enableMoveUIAbilityToBackgroundApi_.value;
|
||||
}
|
||||
|
||||
@ -227,7 +225,7 @@ bool AppUtils::IsLaunchEmbededUIAbility()
|
||||
isLaunchEmbededUIAbility_.value = system::GetBoolParameter(LAUNCH_EMBEDED_UI_ABILITY, false);
|
||||
isLaunchEmbededUIAbility_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isLaunchEmbededUIAbility_ is %{public}d", isLaunchEmbededUIAbility_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isLaunchEmbededUIAbility_.value);
|
||||
return isLaunchEmbededUIAbility_.value;
|
||||
}
|
||||
|
||||
@ -237,7 +235,7 @@ bool AppUtils::IsSupportNativeChildProcess()
|
||||
isSupportNativeChildProcess_.value = system::GetBoolParameter(SUPPROT_NATIVE_CHILD_PROCESS, false);
|
||||
isSupportNativeChildProcess_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isSupportNativeChildProcess_ is %{public}d", isSupportNativeChildProcess_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isSupportNativeChildProcess_.value);
|
||||
return isSupportNativeChildProcess_.value;
|
||||
}
|
||||
|
||||
@ -247,7 +245,7 @@ bool AppUtils::IsAllowResidentInExtremeMemory(const std::string& bundleName, con
|
||||
LoadResidentProcessInExtremeMemory();
|
||||
residentProcessInExtremeMemory_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "isSupportNativeChildProcess_ is %{public}d", isSupportNativeChildProcess_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isSupportNativeChildProcess_.value);
|
||||
for (auto &element : residentProcessInExtremeMemory_.value) {
|
||||
if (bundleName == element.first &&
|
||||
(abilityName == "" || abilityName == element.second)) {
|
||||
@ -261,22 +259,22 @@ void AppUtils::LoadResidentProcessInExtremeMemory()
|
||||
{
|
||||
nlohmann::json object;
|
||||
if (!JsonUtils::GetInstance().LoadConfiguration(CONFIG_PATH, object)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "load resident process in extreme memory failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "resident process failed");
|
||||
return;
|
||||
}
|
||||
if (!object.contains(RESIDENT_PROCESS_IN_EXTREME_MEMORY)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "resident process in extreme memory config not existed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "resident process invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &item : object.at(RESIDENT_PROCESS_IN_EXTREME_MEMORY).items()) {
|
||||
const nlohmann::json& jsonObject = item.value();
|
||||
if (!jsonObject.contains(BUNDLE_NAME) || !jsonObject.at(BUNDLE_NAME).is_string()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed to load bundleName.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "load bundleName failed");
|
||||
return;
|
||||
}
|
||||
if (!jsonObject.contains(ABILITY_NAME) || !jsonObject.at(ABILITY_NAME).is_string()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed to load abilityName.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "load abilityName failed");
|
||||
return;
|
||||
}
|
||||
std::string bundleName = jsonObject.at(BUNDLE_NAME).get<std::string>();
|
||||
@ -292,7 +290,7 @@ int32_t AppUtils::GetLimitMaximumExtensionsPerProc()
|
||||
system::GetIntParameter<int32_t>(LIMIT_MAXIMUM_EXTENSIONS_OF_PER_PROCESS, DEFAULT_MAX_EXT_PER_PROC);
|
||||
limitMaximumExtensionsPerProc_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "limitMaximumExtensionsPerProc is %{public}d", limitMaximumExtensionsPerProc_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "limitMaximumExtensionsPerProc: %{public}d", limitMaximumExtensionsPerProc_.value);
|
||||
return limitMaximumExtensionsPerProc_.value;
|
||||
}
|
||||
|
||||
@ -303,8 +301,7 @@ int32_t AppUtils::GetLimitMaximumExtensionsPerDevice()
|
||||
system::GetIntParameter<int32_t>(LIMIT_MAXIMUM_EXTENSIONS_OF_PER_DEVICE, DEFAULT_MAX_EXT_PER_DEV);
|
||||
limitMaximumExtensionsPerDevice_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "limitMaximumExtensionsPerDevice is %{public}d",
|
||||
limitMaximumExtensionsPerDevice_.value);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "limitMaximumExtensionsPerDevice: %{public}d", limitMaximumExtensionsPerDevice_.value);
|
||||
return limitMaximumExtensionsPerDevice_.value;
|
||||
}
|
||||
|
||||
@ -336,22 +333,22 @@ void AppUtils::LoadStartAbilityWithoutCallerToken()
|
||||
nlohmann::json object;
|
||||
if (!JsonUtils::GetInstance().LoadConfiguration(
|
||||
START_ABILITY_WITHOUT_CALLERTOKEN_PATH, object, START_ABILITY_WITHOUT_CALLERTOKEN)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "load start ability without caller token list failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "token list failed");
|
||||
return;
|
||||
}
|
||||
if (!object.contains(START_ABILITY_WITHOUT_CALLERTOKEN_TITLE)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "start ability without caller token config not existed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "token config invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &item : object.at(START_ABILITY_WITHOUT_CALLERTOKEN_TITLE).items()) {
|
||||
const nlohmann::json& jsonObject = item.value();
|
||||
if (!jsonObject.contains(BUNDLE_NAME) || !jsonObject.at(BUNDLE_NAME).is_string()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "failed to load bundleName.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "load bundleName failed");
|
||||
return;
|
||||
}
|
||||
if (!jsonObject.contains(ABILITY_NAME) || !jsonObject.at(ABILITY_NAME).is_string()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "failed to load abilityName.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "load abilityName failed");
|
||||
return;
|
||||
}
|
||||
std::string bundleName = jsonObject.at(BUNDLE_NAME).get<std::string>();
|
||||
|
@ -79,7 +79,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type,
|
||||
break;
|
||||
case EventName::DRAWN_COMPLETED:
|
||||
TAG_LOGI(AAFwkTag::DEFAULT,
|
||||
"HiSysEvent name: DRAWN_COMPLETED, bundleName: %{public}s, abilityName: %{public}s",
|
||||
"DRAWN_COMPLETED, bundle: %{public}s, ability: %{public}s",
|
||||
eventInfo.bundleName.c_str(), eventInfo.abilityName.c_str());
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
@ -181,7 +181,7 @@ void EventReport::LogAbilityOnActiveEvent(const std::string &name, HiSysEventTyp
|
||||
|
||||
void EventReport::LogStartStandardEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "EventInfo is [%{public}d, %{public}s, %{public}s, %{public}s]",
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "EventInfo: [%{public}d, %{public}s, %{public}s, %{public}s]",
|
||||
eventInfo.userId, eventInfo.bundleName.c_str(), eventInfo.moduleName.c_str(),
|
||||
eventInfo.abilityName.c_str());
|
||||
HiSysEventWrite(
|
||||
|
@ -39,13 +39,13 @@ const std::set<std::string> OBSERVER_NATIVE_CALLER = {
|
||||
}
|
||||
bool PermissionVerification::VerifyPermissionByTokenId(const int &tokenId, const std::string &permissionName) const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "VerifyPermissionByTokenId permission %{public}s", permissionName.c_str());
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "permission %{public}s", permissionName.c_str());
|
||||
int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(tokenId, permissionName, false);
|
||||
if (ret != Security::AccessToken::PermissionState::PERMISSION_GRANTED) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "permission %{public}s: PERMISSION_DENIED", permissionName.c_str());
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: PERMISSION_DENIED", permissionName.c_str());
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify AccessToken success");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify token success");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -53,16 +53,16 @@ bool PermissionVerification::VerifyCallingPermission(
|
||||
const std::string &permissionName, const uint32_t specifyTokenId) const
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "VerifyCallingPermission permission %{public}s, specifyTokenId is %{public}u",
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "permission %{public}s, specifyTokenId: %{public}u",
|
||||
permissionName.c_str(), specifyTokenId);
|
||||
auto callerToken = specifyTokenId == 0 ? GetCallingTokenID() : specifyTokenId;
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "callerToken is %{public}u", callerToken);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Token: %{public}u", callerToken);
|
||||
int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, permissionName, false);
|
||||
if (ret != Security::AccessToken::PermissionState::PERMISSION_GRANTED) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "permission %{public}s: PERMISSION_DENIED", permissionName.c_str());
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: PERMISSION_DENIED", permissionName.c_str());
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify AccessToken success");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify Token success");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ bool PermissionVerification::IsSACall() const
|
||||
auto callerToken = GetCallingTokenID();
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerToken);
|
||||
if (tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "caller tokenType is native, verify success");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify success");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Not SA called");
|
||||
@ -85,7 +85,7 @@ bool PermissionVerification::IsShellCall() const
|
||||
auto callerToken = GetCallingTokenID();
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerToken);
|
||||
if (tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_SHELL) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "caller tokenType is shell, verify success");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify success");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Not shell called");
|
||||
@ -97,14 +97,14 @@ bool PermissionVerification::CheckSpecificSystemAbilityAccessPermission(const st
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called");
|
||||
if (!IsSACall()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "caller tokenType is not native, verify failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "verify failed");
|
||||
return false;
|
||||
}
|
||||
auto callerToken = GetCallingTokenID();
|
||||
Security::AccessToken::NativeTokenInfo nativeTokenInfo;
|
||||
int32_t result = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(callerToken, nativeTokenInfo);
|
||||
if (result != ERR_OK || nativeTokenInfo.processName != processName) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Check process name failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Check process failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -114,7 +114,7 @@ bool PermissionVerification::CheckObserverCallerPermission() const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "called");
|
||||
if (!IsSACall()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "caller tokenType is not native");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "tokenType not native");
|
||||
return false;
|
||||
}
|
||||
auto callerToken = GetCallingTokenID();
|
||||
@ -122,7 +122,7 @@ bool PermissionVerification::CheckObserverCallerPermission() const
|
||||
int32_t result = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(callerToken, nativeTokenInfo);
|
||||
if (result != ERR_OK ||
|
||||
OBSERVER_NATIVE_CALLER.find(nativeTokenInfo.processName) == OBSERVER_NATIVE_CALLER.end()) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Check native token failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Check token failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -131,20 +131,20 @@ bool PermissionVerification::CheckObserverCallerPermission() const
|
||||
bool PermissionVerification::VerifyRunningInfoPerm() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_GET_RUNNING_INFO)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s: Permission verification succeeded.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: Permission verification failed.", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PermissionVerification::VerifyControllerPerm() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_SET_ABILITY_CONTROLLER)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s: Permission verification succeeded.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: Permission verification failed.", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ bool PermissionVerification::VerifyDlpPermission(Want &want) const
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_ACCESS_DLP)) {
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: Permission verification failed", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ int PermissionVerification::VerifyAccountPermission() const
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_INTERACT_ACROSS_LOCAL_ACCOUNTS)) {
|
||||
return ERR_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: Permission verification failed", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
@ -175,20 +175,20 @@ bool PermissionVerification::VerifyMissionPermission() const
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_MANAGE_MISSION)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s: Permission verification succeeded.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s: Permission verification failed", __func__);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
int PermissionVerification::VerifyAppStateObserverPermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_RUNNING_STATE_OBSERVER)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission verification succeeded.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted");
|
||||
return ERR_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission verification failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
@ -196,11 +196,11 @@ int32_t PermissionVerification::VerifyUpdateConfigurationPerm() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_UPDATE_CONFIGURATION)) {
|
||||
TAG_LOGI(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s succeed.", PermissionConstants::PERMISSION_UPDATE_CONFIGURATION);
|
||||
"Permission %{public}s granted", PermissionConstants::PERMISSION_UPDATE_CONFIGURATION);
|
||||
return ERR_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s failed.", PermissionConstants::PERMISSION_UPDATE_CONFIGURATION);
|
||||
"Permission %{public}s denied", PermissionConstants::PERMISSION_UPDATE_CONFIGURATION);
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
@ -208,11 +208,11 @@ int32_t PermissionVerification::VerifyUpdateAPPConfigurationPerm() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_UPDATE_APP_CONFIGURATION)) {
|
||||
TAG_LOGI(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s succeed.", PermissionConstants::PERMISSION_UPDATE_APP_CONFIGURATION);
|
||||
"Permission %{public}s granted", PermissionConstants::PERMISSION_UPDATE_APP_CONFIGURATION);
|
||||
return ERR_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s failed.", PermissionConstants::PERMISSION_UPDATE_APP_CONFIGURATION);
|
||||
"Permission %{public}s denied", PermissionConstants::PERMISSION_UPDATE_APP_CONFIGURATION);
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
@ -220,11 +220,11 @@ bool PermissionVerification::VerifyInstallBundlePermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_INSTALL_BUNDLE)) {
|
||||
TAG_LOGI(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s succeed.", PermissionConstants::PERMISSION_INSTALL_BUNDLE);
|
||||
"Permission %{public}s granted", PermissionConstants::PERMISSION_INSTALL_BUNDLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Verify permission %{public}s failed.", PermissionConstants::PERMISSION_INSTALL_BUNDLE);
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission %{public}s denied", PermissionConstants::PERMISSION_INSTALL_BUNDLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -232,12 +232,12 @@ bool PermissionVerification::VerifyGetBundleInfoPrivilegedPermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) {
|
||||
TAG_LOGI(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s succeed.", PermissionConstants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED);
|
||||
"Permission %{public}s granted", PermissionConstants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s failed.", PermissionConstants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED);
|
||||
"Permission %{public}s denied", PermissionConstants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ bool PermissionVerification::VerifyStartRecentAbilityPermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_START_RECENT_ABILITY)) {
|
||||
TAG_LOGI(AAFwkTag::DEFAULT,
|
||||
"Verify permission %{public}s succeed.", PermissionConstants::PERMISSION_START_RECENT_ABILITY);
|
||||
"Permission %{public}s granted", PermissionConstants::PERMISSION_START_RECENT_ABILITY);
|
||||
return true;
|
||||
}
|
||||
return VerifyMissionPermission();
|
||||
@ -255,17 +255,16 @@ int PermissionVerification::CheckCallDataAbilityPermission(const VerificationInf
|
||||
{
|
||||
if ((verificationInfo.apiTargetVersion > API8 || isShell) &&
|
||||
!JudgeStartAbilityFromBackground(verificationInfo.isBackgroundCall, verificationInfo.withContinuousTask)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Application can not start DataAbility from background after API8.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Start DataAbility failed");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
if (!JudgeStartInvisibleAbility(verificationInfo.accessTokenId, verificationInfo.visible)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Target DataAbility is not visible, and caller does not have INVISIBLE permission.");
|
||||
"caller INVISIBLE permission invalid");
|
||||
return ABILITY_VISIBLE_FALSE_DENY_REQUEST;
|
||||
}
|
||||
if (!JudgeAssociatedWakeUp(verificationInfo.accessTokenId, verificationInfo.associatedWakeUp)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Target DataAbility's associatedWakeUp is false, reject start it from other application.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "associatedWakeUp is false");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
@ -275,22 +274,20 @@ int PermissionVerification::CheckCallDataAbilityPermission(const VerificationInf
|
||||
int PermissionVerification::CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const
|
||||
{
|
||||
if (CheckSpecificSystemAbilityAccessPermission(FOUNDATION_PROCESS_NAME)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Allow fms to connect service ability.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Allow fms to connect service ability");
|
||||
return ERR_OK;
|
||||
}
|
||||
if ((verificationInfo.apiTargetVersion > API8 || IsShellCall()) &&
|
||||
!JudgeStartAbilityFromBackground(verificationInfo.isBackgroundCall, verificationInfo.withContinuousTask)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Application can not start ServiceAbility from background after API8.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Start ServiceAbility failed");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
if (!JudgeStartInvisibleAbility(verificationInfo.accessTokenId, verificationInfo.visible)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Target ServiceAbility is not visible, and caller does not have INVISIBLE permission.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "caller INVISIBLE permission invalid");
|
||||
return ABILITY_VISIBLE_FALSE_DENY_REQUEST;
|
||||
}
|
||||
if (!JudgeAssociatedWakeUp(verificationInfo.accessTokenId, verificationInfo.associatedWakeUp)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"Target ServiceAbility's associatedWakeUp is false, reject start it from other application.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "associatedWakeUp is false");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
@ -311,13 +308,12 @@ int PermissionVerification::CheckCallServiceExtensionPermission(const Verificati
|
||||
int PermissionVerification::CheckStartByCallPermission(const VerificationInfo &verificationInfo) const
|
||||
{
|
||||
if (IsCallFromSameAccessToken(verificationInfo.accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Not remote call, Caller is from same APP, StartAbilityByCall reject");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "StartAbilityByCall reject");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
// Different APP call, check permissions
|
||||
if (!VerifyCallingPermission(PermissionConstants::PERMISSION_ABILITY_BACKGROUND_COMMUNICATION)) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT,
|
||||
"PERMISSION_ABILITY_BACKGROUND_COMMUNICATION verification failed, StartAbilityByCall reject");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
if (!JudgeStartInvisibleAbility(verificationInfo.accessTokenId, verificationInfo.visible)) {
|
||||
@ -333,7 +329,7 @@ int PermissionVerification::CheckStartByCallPermission(const VerificationInfo &v
|
||||
unsigned int PermissionVerification::GetCallingTokenID() const
|
||||
{
|
||||
auto callerToken = IPCSkeleton::GetCallingTokenID();
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "callerToken : %{private}u", callerToken);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "callerToken: %{private}u", callerToken);
|
||||
return callerToken;
|
||||
}
|
||||
|
||||
@ -341,22 +337,22 @@ bool PermissionVerification::JudgeStartInvisibleAbility(const uint32_t accessTok
|
||||
const uint32_t specifyTokenId) const
|
||||
{
|
||||
if (visible) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "TargetAbility visible is true, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "visible:true");
|
||||
return true;
|
||||
}
|
||||
if (specifyTokenId > 0 && accessTokenId == specifyTokenId) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "AccessTokenId is the same as specifyTokenId, targetAbility is in same APP, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "accessTokenId equal specifyTokenId");
|
||||
return true;
|
||||
}
|
||||
if (IsCallFromSameAccessToken(accessTokenId)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "TargetAbility is in same APP, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "TargetAbility in same APP");
|
||||
return true;
|
||||
}
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_START_INVISIBLE_ABILITY, specifyTokenId)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller has PERMISSION_START_INVISIBLE_ABILITY, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller PASS");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "PERMISSION_START_INVISIBLE_ABILITY verification failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "verification failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -364,12 +360,12 @@ bool PermissionVerification::JudgeStartAbilityFromBackground(
|
||||
const bool isBackgroundCall, bool withContinuousTask) const
|
||||
{
|
||||
if (!isBackgroundCall) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller is not background, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller not background");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (withContinuousTask) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller has continuous task, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "continuousTask: true");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -377,24 +373,24 @@ bool PermissionVerification::JudgeStartAbilityFromBackground(
|
||||
// PERMISSION_START_ABILIIES_FROM_BACKGROUND will be removed later due to misspelling
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_START_ABILITIES_FROM_BACKGROUND) ||
|
||||
VerifyCallingPermission(PermissionConstants::PERMISSION_START_ABILIIES_FROM_BACKGROUND)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller has PERMISSION_START_ABILITIES_FROM_BACKGROUND, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Caller PASS");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "PERMISSION_START_ABILITIES_FROM_BACKGROUND verification failed.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "verification failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const
|
||||
{
|
||||
if (IsCallFromSameAccessToken(accessTokenId)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "TargetAbility is in same APP, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "TargetAbility in same APP");
|
||||
return true;
|
||||
}
|
||||
if (associatedWakeUp) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "TargetAbility is allowed associatedWakeUp, PASS.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "associatedWakeUp: true");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "The target is not allowed associatedWakeUp.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "not allowed associatedWakeUp");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -402,7 +398,7 @@ int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &
|
||||
bool isCallByShortcut) const
|
||||
{
|
||||
uint32_t specifyTokenId = verificationInfo.specifyTokenId;
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "specifyTokenId = %{public}u, isCallByShortcut %{public}d",
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "specifyTokenId: %{public}u, isCallByShortcut %{public}d",
|
||||
specifyTokenId, isCallByShortcut);
|
||||
if (specifyTokenId == 0 &&
|
||||
SupportSystemAbilityPermission::IsSupportSaCallPermission() && IsSACall()) {
|
||||
@ -439,10 +435,10 @@ bool PermissionVerification::IsSystemAppCall() const
|
||||
bool PermissionVerification::VerifyPrepareTerminatePermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_PREPARE_TERMINATE)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s: Permission verification succeeded.", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s: Permission verification failed", __func__);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -451,7 +447,7 @@ bool PermissionVerification::VerifyPrepareTerminatePermission(const int &tokenId
|
||||
int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(tokenId,
|
||||
PermissionConstants::PERMISSION_PREPARE_TERMINATE, false);
|
||||
if (ret != Security::AccessToken::PermissionState::PERMISSION_GRANTED) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "permission denied.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "permission denied");
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "verify AccessToken success");
|
||||
@ -463,18 +459,18 @@ bool PermissionVerification::VerifyShellStartExtensionType(int32_t type) const
|
||||
if (IsShellCall() && type >= SHELL_START_EXTENSION_FLOOR && type <= SHELL_START_EXTENSION_CEIL) {
|
||||
return true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "VerifyShellStartExtensionType, reject start.");
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "reject start");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PermissionVerification::VerifyPreloadApplicationPermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_PRELOAD_APPLICATION)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Verify permission %{public}s succeed.",
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission %{public}s granted",
|
||||
PermissionConstants::PERMISSION_PRELOAD_APPLICATION);
|
||||
return true;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Verify permission %{public}s failed.",
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Permission %{public}s denied",
|
||||
PermissionConstants::PERMISSION_PRELOAD_APPLICATION);
|
||||
return false;
|
||||
}
|
||||
@ -482,11 +478,11 @@ bool PermissionVerification::VerifyPreloadApplicationPermission() const
|
||||
bool PermissionVerification::VerifyPreStartAtomicServicePermission() const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_PRE_START_ATOMIC_SERVICE)) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "verify permission %{public}s succeeded.",
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Permission %{public}s granted",
|
||||
PermissionConstants::PERMISSION_PRE_START_ATOMIC_SERVICE);
|
||||
return true;
|
||||
}
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "verify permission %{public}s failed.",
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "Permission %{public}s denied",
|
||||
PermissionConstants::PERMISSION_PRE_START_ATOMIC_SERVICE);
|
||||
return false;
|
||||
}
|
||||
@ -494,10 +490,10 @@ bool PermissionVerification::VerifyPreStartAtomicServicePermission() const
|
||||
bool PermissionVerification::VerifyKillProcessDependedOnWebPermission() const
|
||||
{
|
||||
if (IsSACall() && VerifyCallingPermission(PermissionConstants::PERMISSION_KILL_PROCESS_DEPENDED_ON_WEB)) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Permission verification succeeded.");
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Permission granted");
|
||||
return true;
|
||||
}
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "Permission verification failed");
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "Permission denied");
|
||||
return false;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
@ -44,7 +44,7 @@ int64_t ResSchedUtil::convertType(int64_t resSchedType)
|
||||
return static_cast<int64_t>(AssociatedStartType::MISSION_LIST_START_ABILITY);
|
||||
}
|
||||
#endif
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "res sched type invalid");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "sched invalid");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ void TaskHandle::Sync() const
|
||||
{
|
||||
auto handler = handler_.lock();
|
||||
if (!status_ || !handler || !innerTaskHandle_) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid state");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid status");
|
||||
return;
|
||||
}
|
||||
auto &status = *status_;
|
||||
|
@ -68,6 +68,6 @@ void FreezeUtil::DeleteLifecycleEventInner(const LifecycleFlow &flow)
|
||||
if (lifecycleFlow_.count(flow)) {
|
||||
lifecycleFlow_.erase(flow);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "lifecycleFlow_ size: %{public}zu", lifecycleFlow_.size());
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "lifecycleFlow size: %{public}zu", lifecycleFlow_.size());
|
||||
}
|
||||
} // namespace OHOS::AbilityRuntime
|
||||
|
Loading…
Reference in New Issue
Block a user