Merge branch 'master' of gitee.com:openharmony/aafwk_standard into fix_bug

Change-Id: I47bda5d150633b921623eef2b5e95ddad393064e
This commit is contained in:
zhoujun62 2022-03-30 14:33:35 +08:00
commit 85960a85c7
28 changed files with 270 additions and 743 deletions

View File

@ -485,16 +485,10 @@ private:
} Action;
std::shared_ptr<AbilityLifecycleCallbacks> abilityLifecycleCallbacks_;
std::shared_ptr<ApplicationImpl> applactionImpl_;
std::shared_ptr<ApplicationImpl> applicationImpl_;
std::shared_ptr<ContextDeal> contextDeal_;
private:
#ifdef SUPPORT_GRAPHICS
/**
* @brief Multimodal Events Register.
*/
void WindowEventRegister();
#endif
bool hasSaveData_ = false;
bool needSaveDate_ = false;
PacMap restoreData_;

View File

@ -96,13 +96,6 @@ void AbilityImpl::Start(const Want &want)
#endif
abilityLifecycleCallbacks_->OnAbilityStart(ability_);
#ifdef SUPPORT_GRAPHICS
// Multimodal Events Register
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
(!ability_->GetAbilityInfo()->isStageBasedModel)) {
WindowEventRegister();
}
#endif
HILOG_INFO("%{public}s end.", __func__);
}
@ -896,22 +889,6 @@ void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::Poin
HILOG_INFO("AbilityImpl::DoPointerEvent called.");
abilityImpl_->DoPointerEvent(pointerEvent);
}
/**
* @brief Multimodal Events Register.
*/
void AbilityImpl::WindowEventRegister()
{
HILOG_INFO("%{public}s called.", __func__);
if (!ability_->GetAbilityInfo()->isStageBasedModel) {
auto window = ability_->GetWindow();
if (window) {
std::shared_ptr<MMI::IInputEventConsumer> inputEventListener =
std::make_shared<AbilityImpl::InputEventConsumerImpl>(shared_from_this());
window->AddInputEventListener(inputEventListener);
}
}
}
#endif
/**

View File

@ -44,6 +44,13 @@ void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
return;
}
if (lifecycleState_ == AAFwk::ABILITY_STATE_BACKGROUND || lifecycleState_ == AAFwk::ABILITY_STATE_BACKGROUND_NEW) {
if (targetState.state == AAFwk::ABILITY_STATE_ACTIVE || targetState.state == AAFwk::ABILITY_STATE_INACTIVE) {
HILOG_ERROR("Invalid state.");
return;
}
}
SetLifeCycleStateInfo(targetState);
if (ability_ && lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL) {
@ -217,9 +224,9 @@ void PageAbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
HILOG_ERROR("PageAbilityImpl::DoKeyDown ability_ == nullptr");
return;
}
auto abilitInfo = ability_->GetAbilityInfo();
auto abilityInfo = ability_->GetAbilityInfo();
HILOG_INFO("PageAbilityImpl::DoKeyDown called %{public}s And Focus is %{public}s",
abilitInfo->name.c_str(),
abilityInfo->name.c_str(),
ability_->HasWindowFocus() ? "true" : "false");
ability_->OnKeyDown(keyEvent);
@ -241,9 +248,9 @@ void PageAbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
HILOG_ERROR("PageAbilityImpl::DoKeyUp ability_ == nullptr");
return;
}
auto abilitInfo = ability_->GetAbilityInfo();
auto abilityInfo = ability_->GetAbilityInfo();
HILOG_INFO("PageAbilityImpl::DoKeyUp called %{public}s And Focus is %{public}s",
abilitInfo->name.c_str(),
abilityInfo->name.c_str(),
ability_->HasWindowFocus() ? "true" : "false");
ability_->OnKeyUp(keyEvent);
@ -265,9 +272,9 @@ void PageAbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointer
HILOG_ERROR("PageAbilityImpl::DoPointerEvent ability_ == nullptr");
return;
}
auto abilitInfo = ability_->GetAbilityInfo();
auto abilityInfo = ability_->GetAbilityInfo();
HILOG_INFO("PageAbilityImpl::DoPointerEvent called %{public}s And Focus is %{public}s",
abilitInfo->name.c_str(),
abilityInfo->name.c_str(),
ability_->HasWindowFocus() ? "true" : "false");
ability_->OnPointerEvent(pointerEvent);

View File

@ -129,6 +129,8 @@ HWTEST_F(FormHostClientTest, AaFwk_FormHostClient_OnAcquired_0100, Function | Me
std::shared_ptr<Ability> ability = std::make_shared<Ability>();
instance_->AddForm(ability, formId);
formInfo.formId = 1;
formInfo.jsFormCodePath = "/data/test";
formInfo.formData = "test";
instance_->OnAcquired(formInfo);
GTEST_LOG_(INFO) << "AaFwk_FormHostClient_OnAcquired_0100 end";

View File

@ -373,8 +373,6 @@ void Operation::SetEntities(const std::vector<std::string> &entities)
void Operation::DumpInfo(int level) const
{
ABILITYBASE_LOGI("=======Operation::DumpInfo level: %{public}d start=============", level);
ABILITYBASE_LOGI("===Operation::abilityName_ %{public}s =============", abilityName_.c_str());
ABILITYBASE_LOGI("===Operation::action_ %{public}s =============", action_.c_str());
ABILITYBASE_LOGI("===Operation::bundleName_ %{public}s =============", bundleName_.c_str());
@ -386,8 +384,6 @@ void Operation::DumpInfo(int level) const
}
ABILITYBASE_LOGI("===Operation::flags_ %{public}ud =============", flags_);
ABILITYBASE_LOGI("===Operation::uri_ %{public}s =============", uri_.ToString().c_str());
ABILITYBASE_LOGI("=======Operation::DumpInfo level: %{public}d end=============", level);
}
} // namespace AAFwk
} // namespace OHOS

View File

@ -1923,14 +1923,12 @@ bool Want::CheckAndSetParameters(Want &want, const std::string &key, std::string
void Want::DumpInfo(int level) const
{
ABILITYBASE_LOGI("==================Want::DumpInfo level: %{public}d start=============", level);
operation_.DumpInfo(level);
parameters_.DumpInfo(level);
if (picker_ != nullptr) {
picker_->DumpInfo(level + 1);
}
ABILITYBASE_LOGI("==================Want::DumpInfo level: %{public}d end=============", level);
}
nlohmann::json Want::ToJson() const
@ -1995,13 +1993,15 @@ bool Want::ReadFromJson(nlohmann::json &wantJson)
std::string parametersString = wantJson.at("parameters").get<std::string>();
WantParams parameters = WantParamWrapper::ParseWantParams(parametersString);
SetParams(parameters);
std::vector<std::string> entities;
wantJson.at("entities").get_to<std::vector<std::string>>(entities);
for (size_t i = 0; i < entities.size(); i++) {
AddEntity(entities[i]);
if (wantJson.at("entities").is_null()) {
ABILITYBASE_LOGI("entities is null");
} else {
std::vector<std::string> entities;
wantJson.at("entities").get_to<std::vector<std::string>>(entities);
for (size_t i = 0; i < entities.size(); i++) {
AddEntity(entities[i]);
}
}
return true;
}

View File

@ -18,6 +18,7 @@
#include <cstdint>
#include "ability_manager_client.h"
#include "errors.h"
#include "hilog_wrapper.h"
#include "js_runtime.h"
#include "js_runtime_utils.h"
@ -118,26 +119,35 @@ private:
NativeValue* OnUpdateConfiguration(NativeEngine &engine, NativeCallbackInfo &info)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
if (info.argc == 0) {
HILOG_ERROR("Not enough params");
return engine.CreateUndefined();
}
AsyncTask::CompleteCallback complete;
AppExecFwk::Configuration changeConfig;
if (!UnwrapConfiguration(reinterpret_cast<napi_env>(&engine),
reinterpret_cast<napi_value>(info.argv[0]), changeConfig)) {
HILOG_INFO("OnStartAbility start options is used.");
return engine.CreateUndefined();
}
AsyncTask::CompleteCallback complete = [changeConfig](NativeEngine& engine, AsyncTask& task, int32_t status) {
auto errcode = AbilityManagerClient::GetInstance()->UpdateConfiguration(changeConfig);
if (errcode == 0) {
task.Resolve(engine, engine.CreateUndefined());
} else {
task.Reject(engine, CreateJsError(engine, errcode, "update config failed."));
do {
if (info.argc == 0) {
HILOG_ERROR("Not enough params");
complete = [](NativeEngine& engine, AsyncTask& task, int32_t status) {
task.Reject(engine, CreateJsError(engine, ERR_INVALID_VALUE, "no enough params."));
};
break;
}
};
AppExecFwk::Configuration changeConfig;
if (!UnwrapConfiguration(reinterpret_cast<napi_env>(&engine),
reinterpret_cast<napi_value>(info.argv[0]), changeConfig)) {
complete = [](NativeEngine& engine, AsyncTask& task, int32_t status) {
task.Reject(engine, CreateJsError(engine, ERR_INVALID_VALUE, "config is invalid."));
};
break;
}
complete = [changeConfig](NativeEngine& engine, AsyncTask& task, int32_t status) {
auto errcode = AbilityManagerClient::GetInstance()->UpdateConfiguration(changeConfig);
if (errcode == 0) {
task.Resolve(engine, engine.CreateUndefined());
} else {
task.Reject(engine, CreateJsError(engine, errcode, "update config failed."));
}
};
} while (0);
NativeValue* lastParam = (info.argc == 1) ? nullptr : info.argv[1];
NativeValue* result = nullptr;

View File

@ -173,9 +173,9 @@ napi_value StartAbilityForResultAsync(napi_env env, AsyncCallbackInfo *asyncCall
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -207,10 +207,10 @@ napi_value StartAbilityForResultAsync(napi_env env, AsyncCallbackInfo *asyncCall
HILOG_INFO("NAPI_StartAbilityForResult, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
napi_value result = 0;
napi_get_null(env, &result);
NAPI_CALL(env, napi_get_null(env, &result));
HILOG_INFO("%{public}s, asyncCallback end.", __func__);
return result;
}
@ -343,15 +343,15 @@ napi_value SetResultAsync(
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_valuetype valuetype = napi_undefined;
napi_typeof(env, args[argCallback], &valuetype);
NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype));
if (valuetype == napi_function) {
napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback);
}
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -388,10 +388,10 @@ napi_value SetResultAsync(
HILOG_INFO("NAPI_SetResult, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
napi_value result = 0;
napi_get_null(env, &result);
NAPI_CALL(env, napi_get_null(env, &result));
HILOG_INFO("%{public}s, asyncCallback end", __func__);
return result;
}
@ -404,13 +404,13 @@ napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo)
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_deferred deferred;
napi_value promise = 0;
napi_create_promise(env, &deferred, &promise);
NAPI_CALL(env, napi_create_promise(env, &deferred, &promise));
asyncCallbackInfo->deferred = deferred;
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -437,8 +437,8 @@ napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo)
HILOG_INFO("NAPI_SetResult, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
HILOG_INFO("%{public}s, promise end", __func__);
return promise;
}
@ -519,15 +519,15 @@ napi_value TerminateAbilityAsync(
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_valuetype valuetype = napi_undefined;
napi_typeof(env, args[argCallback], &valuetype);
NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype));
if (valuetype == napi_function) {
napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback);
NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback));
}
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -562,10 +562,10 @@ napi_value TerminateAbilityAsync(
HILOG_INFO("NAPI_TerminateAbility, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
napi_value result = 0;
napi_get_null(env, &result);
NAPI_CALL(env, napi_get_null(env, &result));
HILOG_INFO("%{public}s, asyncCallback end", __func__);
return result;
}
@ -578,14 +578,14 @@ napi_value TerminateAbilityPromise(napi_env env, AsyncCallbackInfo *asyncCallbac
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_deferred deferred;
napi_value promise = 0;
napi_create_promise(env, &deferred, &promise);
NAPI_CALL(env, napi_create_promise(env, &deferred, &promise));
asyncCallbackInfo->deferred = deferred;
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -610,8 +610,8 @@ napi_value TerminateAbilityPromise(napi_env env, AsyncCallbackInfo *asyncCallbac
HILOG_INFO("NAPI_TerminateAbility, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
HILOG_INFO("%{public}s, promise end", __func__);
return promise;
}
@ -715,14 +715,14 @@ napi_value HasWindowFocusAsync(
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_valuetype valuetype = napi_undefined;
napi_typeof(env, args[argCallback], &valuetype);
NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype));
if (valuetype == napi_function) {
napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback);
NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback));
}
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -758,10 +758,10 @@ napi_value HasWindowFocusAsync(
HILOG_INFO("NAPI_HasWindowFocus, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
napi_value result = 0;
napi_get_null(env, &result);
NAPI_CALL(env, napi_get_null(env, &result));
HILOG_INFO("%{public}s, asyncCallback end.", __func__);
return result;
}
@ -774,13 +774,13 @@ napi_value HasWindowFocusPromise(napi_env env, AsyncCallbackInfo *asyncCallbackI
return nullptr;
}
napi_value resourceName = 0;
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
napi_deferred deferred;
napi_value promise = 0;
napi_create_promise(env, &deferred, &promise);
NAPI_CALL(env, napi_create_promise(env, &deferred, &promise));
asyncCallbackInfo->deferred = deferred;
napi_create_async_work(
NAPI_CALL(env, napi_create_async_work(
env,
nullptr,
resourceName,
@ -806,8 +806,8 @@ napi_value HasWindowFocusPromise(napi_env env, AsyncCallbackInfo *asyncCallbackI
HILOG_INFO("NAPI_HasWindowFocus, main event thread complete end.");
},
(void *)asyncCallbackInfo,
&asyncCallbackInfo->asyncWork);
napi_queue_async_work(env, asyncCallbackInfo->asyncWork);
&asyncCallbackInfo->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork));
HILOG_INFO("%{public}s, promise end.", __func__);
return promise;
}
@ -1303,16 +1303,16 @@ void GetDataAbilityHelperAsyncCompleteCB(napi_env env, napi_status status, void
{
HILOG_INFO("NAPI_GetDataAbilityHelper, main event thread complete.");
DataAbilityHelperCB *dataAbilityHelperCB = static_cast<DataAbilityHelperCB *>(data);
std::unique_ptr<DataAbilityHelperCB> callbackPtr {dataAbilityHelperCB};
napi_value uri = nullptr;
napi_value callback = nullptr;
napi_value undefined = nullptr;
napi_value result[ARGS_TWO] = {nullptr};
napi_value callResult = nullptr;
NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined));
NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, dataAbilityHelperCB->uri, &uri));
NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, dataAbilityHelperCB->cbBase.cbInfo.callback, &callback));
NAPI_CALL_RETURN_VOID(
env, napi_new_instance(env, GetGlobalDataAbilityHelper(env), 1, &uri, &dataAbilityHelperCB->result));
napi_get_undefined(env, &undefined);
napi_get_reference_value(env, dataAbilityHelperCB->uri, &uri);
napi_get_reference_value(env, dataAbilityHelperCB->cbBase.cbInfo.callback, &callback);
napi_new_instance(env, GetGlobalDataAbilityHelper(env), 1, &uri, &dataAbilityHelperCB->result);
if (IsTypeForNapiValue(env, dataAbilityHelperCB->result, napi_object)) {
result[PARAM1] = dataAbilityHelperCB->result;
} else {
@ -1320,14 +1320,14 @@ void GetDataAbilityHelperAsyncCompleteCB(napi_env env, napi_status status, void
result[PARAM1] = WrapVoidToJS(env);
}
result[PARAM0] = GetCallbackErrorValue(env, NO_ERROR);
NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult));
napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
if (dataAbilityHelperCB->cbBase.cbInfo.callback != nullptr) {
NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, dataAbilityHelperCB->cbBase.cbInfo.callback));
napi_delete_reference(env, dataAbilityHelperCB->cbBase.cbInfo.callback);
}
NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, dataAbilityHelperCB->cbBase.asyncWork));
delete dataAbilityHelperCB;
dataAbilityHelperCB = nullptr;
if (dataAbilityHelperCB->uri != nullptr) {
napi_delete_reference(env, dataAbilityHelperCB->uri);
}
napi_delete_async_work(env, dataAbilityHelperCB->cbBase.asyncWork);
HILOG_INFO("NAPI_GetDataAbilityHelper, main event thread complete end.");
}
@ -1335,22 +1335,24 @@ void GetDataAbilityHelperPromiseCompleteCB(napi_env env, napi_status status, voi
{
HILOG_INFO("NAPI_GetDataAbilityHelper, main event thread complete.");
DataAbilityHelperCB *dataAbilityHelperCB = static_cast<DataAbilityHelperCB *>(data);
std::unique_ptr<DataAbilityHelperCB> callbackPtr {dataAbilityHelperCB};
napi_value uri = nullptr;
napi_value result = nullptr;
NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, dataAbilityHelperCB->uri, &uri));
NAPI_CALL_RETURN_VOID(
env, napi_new_instance(env, GetGlobalDataAbilityHelper(env), 1, &uri, &dataAbilityHelperCB->result));
napi_get_reference_value(env, dataAbilityHelperCB->uri, &uri);
napi_new_instance(env, GetGlobalDataAbilityHelper(env), 1, &uri, &dataAbilityHelperCB->result);
if (IsTypeForNapiValue(env, dataAbilityHelperCB->result, napi_object)) {
result = dataAbilityHelperCB->result;
NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, dataAbilityHelperCB->cbBase.deferred, result));
napi_resolve_deferred(env, dataAbilityHelperCB->cbBase.deferred, result);
} else {
result = GetCallbackErrorValue(env, dataAbilityHelperCB->cbBase.errCode);
napi_reject_deferred(env, dataAbilityHelperCB->cbBase.deferred, result);
HILOG_INFO("NAPI_GetDataAbilityHelper, helper is nullptr.");
}
NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, dataAbilityHelperCB->cbBase.asyncWork));
delete dataAbilityHelperCB;
dataAbilityHelperCB = nullptr;
if (dataAbilityHelperCB->uri != nullptr) {
napi_delete_reference(env, dataAbilityHelperCB->uri);
}
napi_delete_async_work(env, dataAbilityHelperCB->cbBase.asyncWork);
HILOG_INFO("NAPI_GetDataAbilityHelper, main event thread complete end.");
}

File diff suppressed because it is too large Load Diff

View File

@ -56,20 +56,17 @@ bool& GetDataAbilityHelperStatus()
bool CheckAbilityType(AbilityType typeInAbility, AbilityType typeWant)
{
HILOG_INFO("%{public}s called.", __func__);
switch (typeWant) {
case AbilityType::PAGE:
return typeInAbility == AbilityType::PAGE;
default:
return typeInAbility != AbilityType::PAGE;
}
HILOG_INFO("%{public}s end.", __func__);
return false;
}
bool CheckAbilityType(const CBBase *cbBase)
{
HILOG_INFO("%{public}s called.", __func__);
if (cbBase == nullptr) {
HILOG_ERROR("%{public}s cbBase == nullptr", __func__);
return false;
@ -85,7 +82,6 @@ bool CheckAbilityType(const CBBase *cbBase)
HILOG_ERROR("%{public}s info == nullptr", __func__);
return false;
}
HILOG_INFO("%{public}s end.", __func__);
return CheckAbilityType((AbilityType)info->type, cbBase->abilityType);
}
@ -136,7 +132,6 @@ bool CheckAbilityType(const AsyncCallbackInfo *asyncCallbackInfo)
void SaveAppInfo(AppInfo_ &appInfo, const ApplicationInfo &appInfoOrg)
{
HILOG_INFO("%{public}s.", __func__);
appInfo.name = appInfoOrg.name;
appInfo.description = appInfoOrg.description;
appInfo.descriptionId = appInfoOrg.descriptionId;
@ -158,7 +153,6 @@ void SaveAppInfo(AppInfo_ &appInfo, const ApplicationInfo &appInfoOrg)
appInfo.moduleInfos.emplace_back(appInfoOrg.moduleInfos.at(i));
}
appInfo.entryDir = appInfoOrg.entryDir;
HILOG_INFO("%{public}s end.", __func__);
}
napi_value GetContinueAbilityOptionsInfoCommon(
@ -2662,7 +2656,6 @@ napi_value GetWantWrap(napi_env env, napi_callback_info info, AsyncCallbackInfo
*/
napi_value NAPI_GetWantCommon(napi_env env, napi_callback_info info, AbilityType abilityType)
{
HILOG_INFO("%{public}s, called.", __func__);
AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env);
if (asyncCallbackInfo == nullptr) {
HILOG_ERROR("%{public}s, asyncCallbackInfo == nullptr", __func__);
@ -2680,7 +2673,6 @@ napi_value NAPI_GetWantCommon(napi_env env, napi_callback_info info, AbilityType
}
ret = WrapVoidToJS(env);
}
HILOG_INFO("%{public}s, end.", __func__);
return ret;
}
@ -4489,14 +4481,12 @@ napi_value NAPI_StartBackgroundRunningCommon(napi_env env, napi_callback_info in
void CancelBackgroundRunningExecuteCB(napi_env env, void *data)
{
HILOG_INFO("NAPI_PACancelBackgroundRunning, worker pool thread execute.");
AsyncCallbackInfo *asyncCallbackInfo = static_cast<AsyncCallbackInfo *>(data);
if (asyncCallbackInfo->ability != nullptr) {
asyncCallbackInfo->ability->StopBackgroundRunning();
} else {
HILOG_ERROR("NAPI_PACancelBackgroundRunning, ability == nullptr");
}
HILOG_INFO("NAPI_PACancelBackgroundRunning, worker pool thread execute end.");
}
napi_value CancelBackgroundRunningAsync(

View File

@ -56,23 +56,20 @@ void InnerInitWantOptionsData(std::map<std::string, unsigned int> &flagMap)
napi_value WrapElementName(napi_env env, const ElementName &elementName)
{
HILOG_INFO("%{public}s called.", __func__);
HILOG_INFO("%{public}s called. DeviceID=%{public}s, BundleName=%{public}s, AbilityName=%{public}s", __func__,
elementName.GetDeviceID().c_str(), elementName.GetBundleName().c_str(), elementName.GetAbilityName().c_str());
napi_value jsObject = nullptr;
NAPI_CALL(env, napi_create_object(env, &jsObject));
napi_value jsValue = nullptr;
HILOG_INFO("%{public}s called. deviceID=%{public}s", __func__, elementName.GetDeviceID().c_str());
NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetDeviceID().c_str(), NAPI_AUTO_LENGTH, &jsValue));
NAPI_CALL(env, napi_set_named_property(env, jsObject, "deviceId", jsValue));
jsValue = nullptr;
HILOG_INFO("%{public}s called. GetBundleName=%{public}s", __func__, elementName.GetBundleName().c_str());
NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetBundleName().c_str(), NAPI_AUTO_LENGTH, &jsValue));
NAPI_CALL(env, napi_set_named_property(env, jsObject, "bundleName", jsValue));
jsValue = nullptr;
HILOG_INFO("%{public}s called. GetAbilityName=%{public}s", __func__, elementName.GetAbilityName().c_str());
NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetAbilityName().c_str(), NAPI_AUTO_LENGTH, &jsValue));
NAPI_CALL(env, napi_set_named_property(env, jsObject, "abilityName", jsValue));
@ -524,7 +521,6 @@ bool InnerWrapWantParamsArray(napi_env env, napi_value jsObject, const std::stri
napi_value WrapWantParams(napi_env env, const AAFwk::WantParams &wantParams)
{
HILOG_INFO("%{public}s called.", __func__);
napi_value jsObject = nullptr;
NAPI_CALL(env, napi_create_object(env, &jsObject));

View File

@ -1129,7 +1129,7 @@ private:
bool IsSystemUI(const std::string &bundleName) const;
bool VerificationAllToken(const sptr<IRemoteObject> &token);
const std::shared_ptr<DataAbilityManager> &GetDataAbilityManager(const sptr<IAbilityScheduler> &scheduler);
std::shared_ptr<DataAbilityManager> GetDataAbilityManager(const sptr<IAbilityScheduler> &scheduler);
bool CheckDataAbilityRequest(AbilityRequest &abilityRequest);
std::shared_ptr<AbilityStackManager> GetStackManagerByUserId(int32_t userId);
std::shared_ptr<MissionListManager> GetListManagerByUserId(int32_t userId);

View File

@ -111,7 +111,7 @@ const int32_t GET_PARAMETER_INCORRECT = -9;
const int32_t GET_PARAMETER_OTHER = -1;
const int32_t SIZE_10 = 10;
const bool isRamConstrainedDevice = false;
const std::string APP_MEMORY_MAX_SIZE_PARAMETER = "const.product.dalvikheaplimit";
const std::string APP_MEMORY_MAX_SIZE_PARAMETER = "const.product.arkheaplimit";
const std::string RAM_CONSTRAINED_DEVICE_SIGN = "const.product.islowram";
const std::string PKG_NAME = "ohos.distributedhardware.devicemanager";
const std::string ACTION_CHOOSE = "ohos.want.action.select";
@ -2916,7 +2916,7 @@ bool AbilityManagerService::VerificationAllToken(const sptr<IRemoteObject> &toke
return false;
}
const std::shared_ptr<DataAbilityManager> &AbilityManagerService::GetDataAbilityManager(
std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager(
const sptr<IAbilityScheduler> &scheduler)
{
if (scheduler == nullptr) {
@ -2925,7 +2925,7 @@ const std::shared_ptr<DataAbilityManager> &AbilityManagerService::GetDataAbility
}
std::shared_lock<std::shared_mutex> lock(managersMutex_);
for (auto item: dataAbilityManagers_) {
for (auto& item: dataAbilityManagers_) {
if (item.second && item.second->ContainsDataAbility(scheduler)) {
return item.second;
}
@ -3315,7 +3315,7 @@ void AbilityManagerService::GetSystemMemoryAttr(AppExecFwk::SystemMemoryAttr &me
int AbilityManagerService::GetAppMemorySize()
{
HILOG_INFO("service GetAppMemorySize start");
const char *key = "const.product.dalvikheaplimit";
const char *key = "const.product.arkheaplimit";
const char *def = "512m";
char *valueGet = nullptr;
unsigned int len = 128;

View File

@ -506,6 +506,7 @@ public:
int VerifyAccountPermission(const std::string &permissionName, const int userId);
void ClearAppRunningData(const std::shared_ptr<AppRunningRecord> &appRecord, bool containsApp);
private:
void StartEmptyResidentProcess(const BundleInfo &info, const std::string &processName, int restartCount);
@ -741,7 +742,7 @@ private:
void KillApplicationByRecord(const std::shared_ptr<AppRunningRecord> &appRecord);
void SendHiSysEvent(const int32_t innerEventId, const int64_t eventId);
int FinishUserTestLocked(
const std::string &msg, const int &resultCode, std::shared_ptr<AppRunningRecord> &appRecord);
const std::string &msg, const int &resultCode, const std::shared_ptr<AppRunningRecord> &appRecord);
const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask";
std::vector<sptr<IApplicationStateObserver>> appStateObservers_;
std::map<sptr<IRemoteObject>, sptr<IRemoteObject::DeathRecipient>> recipientMap_;

View File

@ -38,6 +38,7 @@ enum class ModuleRecordState {
};
class AppMgrServiceInner;
class AppRunningRecord;
class ModuleRunningRecord {
public:
ModuleRunningRecord(
@ -168,6 +169,8 @@ public:
void SetApplicationClient(std::shared_ptr<AppLifeCycleDeal> &appLifeCycleDeal);
void SetAppRunningRecord(const std::shared_ptr<AppRunningRecord> &appRunningRecord);
const std::shared_ptr<ApplicationInfo> GetAppInfo();
private:
@ -179,6 +182,7 @@ private:
std::map<const sptr<IRemoteObject>, std::shared_ptr<AbilityRunningRecord>> abilities_;
std::map<const sptr<IRemoteObject>, std::shared_ptr<AbilityRunningRecord>> terminateAbilitys_;
std::weak_ptr<AppMgrServiceInner> appMgrServiceInner_;
std::weak_ptr<AppRunningRecord> appRunningRecord_;
std::shared_ptr<AppLifeCycleDeal> appLifeCycleDeal_;
std::shared_ptr<ApplicationInfo> appInfo_; // the application's info
std::shared_ptr<AMSEventHandler> eventHandler_;

View File

@ -1196,7 +1196,6 @@ void AppMgrServiceInner::StateChangedNotifyObserver(const AbilityStateData abili
void AppMgrServiceInner::OnProcessCreated(const std::shared_ptr<AppRunningRecord> &appRecord)
{
HILOG_DEBUG("OnProcessCreated begin.");
if (!appRecord) {
HILOG_ERROR("app record is null");
return;
@ -1210,7 +1209,6 @@ void AppMgrServiceInner::OnProcessCreated(const std::shared_ptr<AppRunningRecord
observer->OnProcessCreated(data);
}
}
HILOG_DEBUG("end");
}
void AppMgrServiceInner::OnProcessDied(const std::shared_ptr<AppRunningRecord> &appRecord)
@ -1376,6 +1374,19 @@ void AppMgrServiceInner::OnRemoteDied(const wptr<IRemoteObject> &remote, bool is
return;
}
ClearAppRunningData(appRecord, false);
}
void AppMgrServiceInner::ClearAppRunningData(const std::shared_ptr<AppRunningRecord> &appRecord, bool containsApp)
{
if (!appRecord) {
return;
}
if (containsApp) {
appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId());
}
FinishUserTestLocked("App died", -1, appRecord);
// clear uri permission
@ -2023,7 +2034,7 @@ int AppMgrServiceInner::FinishUserTest(
}
int AppMgrServiceInner::FinishUserTestLocked(
const std::string &msg, const int &resultCode, std::shared_ptr<AppRunningRecord> &appRecord)
const std::string &msg, const int &resultCode, const std::shared_ptr<AppRunningRecord> &appRecord)
{
HILOG_INFO("Enter");
if (!appRecord) {

View File

@ -115,13 +115,7 @@ void AppSpawnMsgWrapper::DumpMsg() const
return;
}
HILOG_INFO("************AppSpawnMsg*************");
HILOG_INFO("uid: %{public}d", msg_->uid);
HILOG_INFO("gid: %{public}d", msg_->gid);
for (uint32_t i = 0; i < msg_->gidCount; ++i) {
HILOG_INFO("gidTable[%{public}d]: %{public}d", i, msg_->gidTable[i]);
}
HILOG_INFO("procName: %{public}s", msg_->processName);
HILOG_INFO("soPath: %{private}s", msg_->soPath);
HILOG_INFO("uid: %{public}d, gid: %{public}d, procName: %{public}s", msg_->uid, msg_->gid, msg_->processName);
HILOG_INFO("************************************");
}

View File

@ -15,6 +15,7 @@
#include "module_running_record.h"
#include "app_mgr_service_inner.h"
#include "app_running_record.h"
#include "hilog_wrapper.h"
namespace OHOS {
@ -224,7 +225,12 @@ void ModuleRunningRecord::TerminateAbility(const sptr<IRemoteObject> &token, con
if (appLifeCycleDeal_) {
appLifeCycleDeal_->ScheduleCleanAbility(token);
} else {
HILOG_ERROR("appLifeCycleDeal_ is null");
HILOG_WARN("appLifeCycleDeal_ is null");
auto serviceInner = appMgrServiceInner_.lock();
auto appRunningRecord = appRunningRecord_.lock();
if (serviceInner) {
serviceInner->ClearAppRunningData(appRunningRecord, true);
}
}
HILOG_INFO("ModuleRunningRecord::TerminateAbility end");
@ -296,5 +302,10 @@ ModuleRecordState ModuleRunningRecord::GetState() const
{
return owenState_;
}
void ModuleRunningRecord::SetAppRunningRecord(const std::shared_ptr<AppRunningRecord> &appRunningRecord)
{
appRunningRecord_ = appRunningRecord;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -134,7 +134,7 @@ HWTEST_F(FmsFormCacheMgrTest, FmsFormCacheMgrTest_004, TestSize.Level0)
* Function: AddData
* FunctionPoints: FormCacheMgr AddData interface
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: add data but key conflict
* CaseDescription: add data when key conflict
*/
HWTEST_F(FmsFormCacheMgrTest, FmsFormCacheMgrTest_010, TestSize.Level0)
{
@ -143,7 +143,7 @@ HWTEST_F(FmsFormCacheMgrTest, FmsFormCacheMgrTest_010, TestSize.Level0)
std::string dataResult1 = "{'a':'1','b':'2'}";
std::string dataResult2 = "{'a':'2','b':'2'}";
formCacheMgr_.AddData(PARAM_FORM_ID_FIRST, dataResult1);
EXPECT_FALSE(formCacheMgr_.AddData(PARAM_FORM_ID_FIRST, dataResult2));
EXPECT_TRUE(formCacheMgr_.AddData(PARAM_FORM_ID_FIRST, dataResult2));
GTEST_LOG_(INFO) << "fms_form_cache_mgr_test_010 end";
}

View File

@ -70,6 +70,7 @@ public:
void SetUp();
void TearDown();
void CreateProviderData();
protected:
sptr<MockFormHostClient> token_;
std::shared_ptr<FormMgrService> formyMgrServ_ = DelayedSingleton<FormMgrService>::GetInstance();
@ -111,7 +112,29 @@ void FmsFormMgrAddFormTest::TearDown()
{
formyMgrServ_->OnStop();
}
void FmsFormMgrAddFormTest::CreateProviderData()
{
std::unordered_map<std::string, std::shared_ptr<BundleFormInfo>> bundleFormInfoMap;
std::shared_ptr<BundleFormInfo> bundleFormInfo = std::make_shared<BundleFormInfo>(FORM_PROVIDER_BUNDLE_NAME);
std::vector<FormInfo> formInfos;
FormInfo formInfo;
formInfo.bundleName = FORM_PROVIDER_BUNDLE_NAME;
formInfo.abilityName = FORM_PROVIDER_ABILITY_NAME;
formInfo.moduleName = PARAM_PROVIDER_MODULE_NAME;
formInfo.name = PARAM_FORM_NAME;
formInfo.updateEnabled = true;
formInfo.updateDuration = 1;
formInfo.scheduledUpdateTime = "06:06";
formInfo.jsComponentName = FORM_JS_COMPOMENT_NAME;
formInfo.formVisibleNotify = true;
formInfo.supportDimensions = {1, 2};
formInfo.defaultDimension = 1;
formInfos.emplace_back(formInfo);
bundleFormInfo->formInfos_ = formInfos;
bundleFormInfoMap.emplace(FORM_PROVIDER_BUNDLE_NAME, bundleFormInfo);
FormInfoMgr::GetInstance().bundleFormInfoMap_ = bundleFormInfoMap;
}
/*
* Feature: FormMgrService
* Function: FormMgr
@ -124,6 +147,7 @@ void FmsFormMgrAddFormTest::TearDown()
HWTEST_F(FmsFormMgrAddFormTest, AddForm_001, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_001 start";
CreateProviderData();
// No cache
FormJsInfo formJsInfo;
Want want;
@ -180,6 +204,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_001, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_002, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_002 start";
CreateProviderData();
int64_t formId = 0x0ffabcff00000000;
int callingUid {0};
@ -252,6 +277,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_002, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_003, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_003 start";
CreateProviderData();
int64_t formId = 0x0ffabcdf00000000;
int callingUid {0};
@ -321,6 +347,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_003, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_004, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_004 start";
CreateProviderData();
int64_t formId = 0x0ffabcde00000000;
@ -350,6 +377,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_004, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_005, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_005 start";
CreateProviderData();
int64_t formId = 0x0ffabcdd00000000;
FormJsInfo formJsInfo;
@ -385,6 +413,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_005, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_006, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_006 start";
CreateProviderData();
int64_t formId = 0x0ababcff00000000;
int callingUid {0};
@ -436,6 +465,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_006, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_007, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_007 start";
CreateProviderData();
int64_t formId = 0x0ababc5f00000000;
int callingUid {0}, tempCount = 0;
@ -495,6 +525,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_007, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_008, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_008 start";
CreateProviderData();
// clear old data
FormDataMgr::GetInstance().formRecords_.clear();
FormDataMgr::GetInstance().tempForms_.clear();
@ -560,6 +591,7 @@ HWTEST_F(FmsFormMgrAddFormTest, AddForm_008, TestSize.Level0)
HWTEST_F(FmsFormMgrAddFormTest, AddForm_009, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_add_form_test_009 start";
CreateProviderData();
int64_t formId = 0x0abcdabc00000000;
int callingUid {0};

View File

@ -22,6 +22,7 @@
#include "form_db_cache.h"
#include "form_host_interface.h"
#define private public
#include "form_info_mgr.h"
#include "form_mgr.h"
#undef private
#include "form_mgr_service.h"
@ -69,6 +70,7 @@ public:
void SetUp();
void TearDown();
void CreateProviderData();
protected:
sptr<MockFormHostClient> token_;
std::shared_ptr<FormMgrService> formyMgrServ_ = DelayedSingleton<FormMgrService>::GetInstance();
@ -109,6 +111,29 @@ void FmsFormMgrDeathCallbackTest::SetUp()
void FmsFormMgrDeathCallbackTest::TearDown()
{}
void FmsFormMgrDeathCallbackTest::CreateProviderData()
{
std::unordered_map<std::string, std::shared_ptr<BundleFormInfo>> bundleFormInfoMap;
std::shared_ptr<BundleFormInfo> bundleFormInfo = std::make_shared<BundleFormInfo>(FORM_PROVIDER_BUNDLE_NAME);
std::vector<FormInfo> formInfos;
FormInfo formInfo;
formInfo.bundleName = FORM_PROVIDER_BUNDLE_NAME;
formInfo.abilityName = FORM_PROVIDER_ABILITY_NAME;
formInfo.moduleName = PARAM_PROVIDER_MODULE_NAME;
formInfo.name = PARAM_FORM_NAME;
formInfo.updateEnabled = true;
formInfo.updateDuration = 1;
formInfo.scheduledUpdateTime = "06:06";
formInfo.jsComponentName = FORM_JS_COMPOMENT_NAME;
formInfo.formVisibleNotify = true;
formInfo.supportDimensions = {1, 2};
formInfo.defaultDimension = 1;
formInfos.emplace_back(formInfo);
bundleFormInfo->formInfos_ = formInfos;
bundleFormInfoMap.emplace(FORM_PROVIDER_BUNDLE_NAME, bundleFormInfo);
FormInfoMgr::GetInstance().bundleFormInfoMap_ = bundleFormInfoMap;
}
/*
* Feature: FormMgrService
* Function: FormMgr::FormMgrDeathRecipient
@ -120,6 +145,7 @@ void FmsFormMgrDeathCallbackTest::TearDown()
HWTEST_F(FmsFormMgrDeathCallbackTest, OnRemoteDied_001, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_death_callback_test_001 start";
CreateProviderData();
// No cache
FormJsInfo formJsInfo;
Want want;

View File

@ -120,14 +120,14 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_001, TestSize.Level0)
FormDataMgr::GetInstance().ClearFormRecords();
std::vector<FormDBInfo> oldFormDBInfos;
FormDbCache::GetInstance().GetAllFormInfo(oldFormDBInfos);
FormDbCache::GetInstance().DeleteFormInfoByBundleName(FORM_HOST_BUNDLE_NAME, oldFormDBInfos);
FormDbCache::GetInstance().DeleteFormInfoByBundleName(FORM_PROVIDER_BUNDLE_NAME, oldFormDBInfos);
int64_t formId {12001};
int callingUid = IPCSkeleton::GetCallingUid();
// Create cache
FormItemInfo record1;
record1.SetFormId(formId);
record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
record1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
record1.SetTemporaryFlag(false);
FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1, callingUid);
@ -252,7 +252,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_006, TestSize.Level0)
int callingUid = IPCSkeleton::GetCallingUid();
FormItemInfo record1;
record1.SetFormId(formId);
record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
record1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
record1.SetTemporaryFlag(false);
FormDataMgr::GetInstance().AllotFormRecord(record1, callingUid);
@ -285,7 +285,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_007, TestSize.Level0)
// Create cache
FormItemInfo record1;
record1.SetFormId(formId);
record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
record1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
record1.SetTemporaryFlag(false);
FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1, callingUid);
@ -339,7 +339,7 @@ HWTEST_F(FmsFormMgrDeleteFormTest, DeleteForm_008, TestSize.Level0)
int callingUid = IPCSkeleton::GetCallingUid();
FormItemInfo record1;
record1.SetFormId(formId);
record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
record1.SetAbilityName("");
record1.SetTemporaryFlag(false);
FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1, callingUid);

View File

@ -78,6 +78,7 @@ ohos_unittest("FmsFormMgrMessageEventTest") {
"form_runtime:form_manager",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"power_manager_native:powermgr_client",
]
}

View File

@ -33,6 +33,7 @@
#include "mock_form_host_client.h"
#include "permission/permission.h"
#include "permission/permission_kit.h"
#include "power_mgr_client.h"
#include "running_process_info.h"
#include "system_ability_definition.h"
@ -119,11 +120,11 @@ HWTEST_F(FmsFormMgrMessageEventTest, MessageEvent_001, TestSize.Level0)
GTEST_LOG_(INFO) << "fms_form_mgr_message_event_test_001 start";
int64_t formId {10000001};
int callingUid {0};
int callingUid {20000007};
// Create cache
FormItemInfo record1;
record1.SetFormId(formId);
record1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
record1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
record1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
record1.SetTemporaryFlag(false);
FormRecord retFormRec = FormDataMgr::GetInstance().AllotFormRecord(record1, callingUid);
@ -144,7 +145,13 @@ HWTEST_F(FmsFormMgrMessageEventTest, MessageEvent_001, TestSize.Level0)
want.SetParam(Constants::PARAM_FORM_NAME_KEY, PARAM_FORM_NAME);
want.SetElementName(DEVICE_ID, FORM_PROVIDER_BUNDLE_NAME, FORM_PROVIDER_ABILITY_NAME);
want.SetParam(Constants::PARAM_MESSAGE_KEY, FORM_MESSAGE_EVENT_VALUE_1);
EXPECT_EQ(ERR_OK, FormMgr::GetInstance().MessageEvent(formId, want, token_));
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
if (!screenOnFlag) {
EXPECT_EQ(ERR_APPEXECFWK_FORM_COMMON_CODE, FormMgr::GetInstance().MessageEvent(formId, want, token_));
} else {
EXPECT_EQ(ERR_OK, FormMgr::GetInstance().MessageEvent(formId, want, token_));
}
GTEST_LOG_(INFO) << "fms_form_mgr_message_event_test_001 end";
}

View File

@ -21,6 +21,7 @@
#define private public
#include "form_mgr.h"
#undef private
#include "form_mgr_adapter.h"
#include "form_mgr_service.h"
#include "if_system_ability_manager.h"
#include "inner_bundle_info.h"
@ -115,21 +116,21 @@ HWTEST_F(FmsFormMgrUpdateFormTest, UpdateForm_001, TestSize.Level0)
// param editor
int64_t formId {100L};
int32_t callingUid {0};
std::string bandleName = FORM_HOST_BUNDLE_NAME;
int32_t callingUid {20000001};
std::string bandleName = FORM_PROVIDER_BUNDLE_NAME;
FormProviderData formProviderData = FormProviderData(std::string("{\"city\": \"beijing001\"}"));
// add formRecord
FormItemInfo formItemInfo;
formItemInfo.SetFormId(formId);
formItemInfo.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
formItemInfo.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
formItemInfo.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
formItemInfo.SetTemporaryFlag(false);
FormDataMgr::GetInstance().AllotFormRecord(formItemInfo, callingUid);
FormItemInfo formItemInfo1;
formItemInfo1.SetFormId(1000L);
formItemInfo1.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
formItemInfo1.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
formItemInfo1.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
formItemInfo1.SetTemporaryFlag(true);
FormDataMgr::GetInstance().AllotFormRecord(formItemInfo1, callingUid);
@ -167,7 +168,7 @@ HWTEST_F(FmsFormMgrUpdateFormTest, UpdateForm_003, TestSize.Level0)
// add formRecord
FormItemInfo formItemInfo;
formItemInfo.SetFormId(formId);
formItemInfo.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
formItemInfo.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
formItemInfo.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
formItemInfo.SetTemporaryFlag(false);
FormDataMgr::GetInstance().AllotFormRecord(formItemInfo, callingUid);
@ -177,7 +178,8 @@ HWTEST_F(FmsFormMgrUpdateFormTest, UpdateForm_003, TestSize.Level0)
FormDataMgr::GetInstance().AllotFormHostRecord(itemInfo, token_, formId, callingUid);
// test exec
EXPECT_EQ(ERR_APPEXECFWK_FORM_INVALID_PARAM, FormMgr::GetInstance().UpdateForm(formId, formProviderData));
EXPECT_EQ(ERR_APPEXECFWK_FORM_INVALID_PARAM,
FormMgrAdapter::GetInstance().UpdateForm(formId, bandleName, formProviderData));
GTEST_LOG_(INFO) << "fms_form_mgr_client_updateForm_test_003 end";
}
@ -249,7 +251,7 @@ HWTEST_F(FmsFormMgrUpdateFormTest, UpdateForm_005, TestSize.Level0)
FormDataMgr::GetInstance().AllotFormHostRecord(itemInfo, token_, formId, callingUid);
// test exec
EXPECT_EQ(ERR_APPEXECFWK_FORM_NOT_EXIST_ID, FormMgr::GetInstance().UpdateForm(formId, formProviderData));
EXPECT_EQ(ERR_APPEXECFWK_FORM_INVALID_PARAM, FormMgr::GetInstance().UpdateForm(formId, formProviderData));
GTEST_LOG_(INFO) << "fms_form_mgr_client_updateForm_test_005 end";
}
@ -305,7 +307,7 @@ HWTEST_F(FmsFormMgrUpdateFormTest, UpdateForm_007, TestSize.Level0)
// param editor
int64_t formId {700L};
int32_t callingUid {0};
std::string bandleName = FORM_HOST_BUNDLE_NAME;
std::string bandleName = FORM_PROVIDER_BUNDLE_NAME;
std::string jsonData = std::string("{");
for (int i = 0; i < 1024; i = i + 1) {
jsonData = jsonData + std::string("\"city" + std::to_string(i) + "\"" + ":" + "\"beijing007\"");
@ -319,7 +321,7 @@ HWTEST_F(FmsFormMgrUpdateFormTest, UpdateForm_007, TestSize.Level0)
// add formRecord
FormItemInfo formItemInfo;
formItemInfo.SetFormId(formId);
formItemInfo.SetProviderBundleName(FORM_HOST_BUNDLE_NAME);
formItemInfo.SetProviderBundleName(FORM_PROVIDER_BUNDLE_NAME);
formItemInfo.SetAbilityName(FORM_PROVIDER_ABILITY_NAME);
formItemInfo.SetTemporaryFlag(false);
FormRecord formRecord = FormDataMgr::GetInstance().AllotFormRecord(formItemInfo, callingUid);

View File

@ -75,6 +75,7 @@ ohos_unittest("FmsFormProviderMgrTest") {
"form_runtime:form_manager",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"power_manager_native:powermgr_client",
]
}

View File

@ -34,6 +34,7 @@
#include "mock_form_host_client.h"
#include "permission/permission_kit.h"
#include "permission/permission.h"
#include "power_mgr_client.h"
#include "running_process_info.h"
#include "system_ability_definition.h"
@ -113,7 +114,6 @@ void FmsFormProviderMgrTest::TearDown()
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Verify if AcquireForm works with invalid formid.
*/
HWTEST_F(FmsFormProviderMgrTest, AcquireForm_001, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_001 start";
@ -137,7 +137,6 @@ HWTEST_F(FmsFormProviderMgrTest, AcquireForm_001, TestSize.Level0)
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Verify if AcquireForm works without formrecord.
*/
HWTEST_F(FmsFormProviderMgrTest, AcquireForm_002, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_002 start";
@ -153,7 +152,6 @@ HWTEST_F(FmsFormProviderMgrTest, AcquireForm_002, TestSize.Level0)
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_002 end";
}
/*
* Feature: FmsFormProviderMgr
* Function: FormMgr
@ -162,7 +160,6 @@ HWTEST_F(FmsFormProviderMgrTest, AcquireForm_002, TestSize.Level0)
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Verify if AcquireForm works without form host record.
*/
HWTEST_F(FmsFormProviderMgrTest, AcquireForm_003, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_003 start";
@ -188,7 +185,6 @@ HWTEST_F(FmsFormProviderMgrTest, AcquireForm_003, TestSize.Level0)
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Verify if RefreshForm works without form host record.
*/
HWTEST_F(FmsFormProviderMgrTest, RefreshForm_001, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_004 start";
@ -214,7 +210,6 @@ HWTEST_F(FmsFormProviderMgrTest, RefreshForm_001, TestSize.Level0)
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Verify if RefreshForm works without form host record.
*/
HWTEST_F(FmsFormProviderMgrTest, RefreshForm_002, TestSize.Level0)
{
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_005 start";
@ -229,7 +224,13 @@ HWTEST_F(FmsFormProviderMgrTest, RefreshForm_002, TestSize.Level0)
FormRecord realFormRecord = FormDataMgr::GetInstance().AllotFormRecord(record, callingUid);
FormItemInfo info;
FormDataMgr::GetInstance().AllotFormHostRecord(info, token_, formId, callingUid);
EXPECT_EQ(ERR_APPEXECFWK_FORM_PROVIDER_DEL_FAIL, FormProviderMgr::GetInstance().RefreshForm(formId, want));
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
if (!screenOnFlag) {
EXPECT_EQ(ERR_OK, FormProviderMgr::GetInstance().RefreshForm(formId, want));
} else {
EXPECT_EQ(ERR_APPEXECFWK_FORM_PROVIDER_DEL_FAIL, FormProviderMgr::GetInstance().RefreshForm(formId, want));
}
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_005 end";
}
}

View File

@ -64,6 +64,7 @@ const std::string FORM_HOST_BUNDLE_NAME = "com.form.host.app";
const int32_t PARAM_FORM_DIMENSION_VALUE = 1;
const std::string KEY_UID = "uid";
const std::string KEY_USER_ID = "userId";
const std::string KEY_BUNDLE_NAME = "bundleName";
const std::string DEVICE_ID = "ohos-phone1";
const std::string DEF_LABEL1 = "PermissionFormRequireGrant";
@ -76,6 +77,8 @@ public:
void TearDown();
void CreateEventData(std::string bundle, int64_t formId,
int callingUid, std::string actionType, EventFwk::CommonEventData &eventData);
void CreateEventData(std::string bundle, int64_t formId,
int callingUid, int32_t userId, std::string actionType, EventFwk::CommonEventData &eventData);
void CreateFormRecordAndFormInfo(std::string bundle, int64_t formId, int callingUid);
void ClearFormRecord(int64_t formId);
@ -128,7 +131,16 @@ void FmsFormSysEventReceiverTest::CreateEventData(std::string bundle, int64_t fo
want.SetParam(KEY_UID, callingUid);
eventData.SetWant(want);
}
void FmsFormSysEventReceiverTest::CreateEventData(std::string bundle, int64_t formId,
int callingUid, int32_t userId, std::string actionType, EventFwk::CommonEventData &eventData)
{
Want want;
want.SetAction(actionType);
want.SetBundle(bundle);
want.SetParam(KEY_UID, callingUid);
want.SetParam(KEY_USER_ID, userId);
eventData.SetWant(want);
}
void FmsFormSysEventReceiverTest::CreateFormRecordAndFormInfo(std::string bundle, int64_t formId, int callingUid)
{
FormItemInfo record;
@ -267,7 +279,7 @@ HWTEST_F(FmsFormSysEventReceiverTest, OnReceiveEvent_003, TestSize.Level0)
FormSysEventReceiver testCase;
testCase.OnReceiveEvent(eventData);
ASSERT_FALSE(FormDataMgr::GetInstance().GetFormRecord(formId, tempFormRecord));
ASSERT_TRUE(FormDataMgr::GetInstance().GetFormRecord(formId, tempFormRecord));
ClearFormRecord(formId);