From 2329d67ed2f4ae39235dc56ecd28824c28dfaf8c Mon Sep 17 00:00:00 2001 From: zhaoyuan Date: Sat, 25 Sep 2021 18:43:30 +0000 Subject: [PATCH] modify codex and Modify formEnabled and isNativeAbility Signed-off-by: zhaoyuan --- .../appexecfwk_base/include/ability_info.h | 2 +- .../appexecfwk_base/include/hap_module_info.h | 2 +- .../appexecfwk_base/src/ability_info.cpp | 11 +- .../appexecfwk_base/src/module_info.cpp | 2 +- .../appexecfwk_base/src/shortcut_info.cpp | 6 +- .../src/bundlemgr/bundle_mgr_host.cpp | 104 ++++---- .../src/bundlemgr/bundle_mgr_proxy.cpp | 4 +- .../src/bundlemgr/status_receiver_proxy.cpp | 2 +- .../parallel_task_dispatcher_base.cpp | 2 +- .../src/dispatcher/serial_task_dispatcher.cpp | 2 +- .../task_dispatcher/src/task/sync_task.cpp | 2 +- .../src/threading/task_executor.cpp | 4 +- .../src/threading/worker_pool.cpp | 4 +- .../global_task_dispatcher_module_test.cpp | 1 - kits/appkit/napi/appMgr/app_mgr.cpp | 4 +- kits/appkit/napi/appMgr/native_module.cpp | 9 +- kits/appkit/napi/bundlemgr/bundle_mgr.cpp | 192 ++++++++++---- kits/appkit/napi/bundlemgr/bundle_mgr.h | 4 +- kits/appkit/napi/bundlemgr/native_module.cpp | 2 +- kits/appkit/native/app/src/main_thread.cpp | 2 +- .../appmgr/include/process_optimizer_uba.h | 2 +- services/appmgr/src/ams_mgr_scheduler.cpp | 14 +- services/appmgr/src/app_death_recipient.cpp | 2 +- services/appmgr/src/app_mgr_service.cpp | 14 +- services/appmgr/src/cgroup_manager.cpp | 12 +- .../ams_service_load_ability_process_test.cpp | 11 +- .../app_mgr_service_event_handler_test.cpp | 4 +- .../bundlemgr/include/bundle_data_storage.h | 2 +- .../include/bundle_data_storage_database.h | 4 +- .../bundle_permissions_changed_monitor.h | 6 +- services/bundlemgr/include/common_profile.h | 3 + .../bundlemgr/include/inner_bundle_info.h | 4 +- .../bundlemgr/src/base_bundle_installer.cpp | 6 +- services/bundlemgr/src/bundle_data_mgr.cpp | 8 +- .../src/bundle_data_storage_database.cpp | 6 +- .../bundlemgr/src/bundle_mgr_host_impl.cpp | 6 +- services/bundlemgr/src/bundle_profile.cpp | 39 ++- services/bundlemgr/src/bundle_util.cpp | 8 +- services/bundlemgr/src/inner_bundle_info.cpp | 12 +- .../src/module_usage_data_storage.cpp | 6 +- .../bms_bundle_data_storage_database_test.cpp | 2 +- .../bms_bundle_kit_service_test.cpp | 59 ++++- .../bms_bundle_parser_test.cpp | 4 +- .../bms_bundle_permission_test.cpp | 246 +++++++++++++++--- .../bms_bundle_uninstaller_test.cpp | 4 +- .../bms_service_startup_test.cpp | 10 +- services/formmgr/src/form_mgr_service.cpp | 21 +- .../ams_app_life_cycle_module_test.cpp | 10 +- .../bms_compatible_system_test.cpp | 2 +- 49 files changed, 618 insertions(+), 270 deletions(-) diff --git a/interfaces/innerkits/appexecfwk_base/include/ability_info.h b/interfaces/innerkits/appexecfwk_base/include/ability_info.h index 4757ef77de..1319feedab 100644 --- a/interfaces/innerkits/appexecfwk_base/include/ability_info.h +++ b/interfaces/innerkits/appexecfwk_base/include/ability_info.h @@ -71,7 +71,7 @@ struct CustomizeData { struct MetaData { std::vector parameters; std::vector results; - std::vector customizeData; + std::vector customizeData; }; struct AbilityInfo; diff --git a/interfaces/innerkits/appexecfwk_base/include/hap_module_info.h b/interfaces/innerkits/appexecfwk_base/include/hap_module_info.h index 7f058ec5d7..25b25d6599 100644 --- a/interfaces/innerkits/appexecfwk_base/include/hap_module_info.h +++ b/interfaces/innerkits/appexecfwk_base/include/hap_module_info.h @@ -24,7 +24,7 @@ namespace OHOS { namespace AppExecFwk { -enum class ModuleColorMode{ +enum class ModuleColorMode { AUTO = -1, DARK, LIGHT, diff --git a/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp b/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp index cbd638a7fb..a386208e35 100644 --- a/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp @@ -332,7 +332,7 @@ void AbilityInfo::Dump(std::string prefix, int fd) void to_json(nlohmann::json &jsonObject, const Parameters ¶meters) { - jsonObject = nlohmann::json{ + jsonObject = nlohmann::json { {JSON_KEY_DESCRIPTION, parameters.description}, {JSON_KEY_NAME, parameters.name}, {JSON_KEY_TYPE, parameters.type} @@ -341,7 +341,7 @@ void to_json(nlohmann::json &jsonObject, const Parameters ¶meters) void to_json(nlohmann::json &jsonObject, const Results &results) { - jsonObject = nlohmann::json{ + jsonObject = nlohmann::json { {JSON_KEY_DESCRIPTION, results.description}, {JSON_KEY_NAME, results.name}, {JSON_KEY_TYPE, results.type} @@ -350,7 +350,7 @@ void to_json(nlohmann::json &jsonObject, const Results &results) void to_json(nlohmann::json &jsonObject, const CustomizeData &customizeData) { - jsonObject = nlohmann::json{ + jsonObject = nlohmann::json { {JSON_KEY_NAME, customizeData.name}, {JSON_KEY_META_VALUE, customizeData.value}, {JSON_KEY_META_EXTRA, customizeData.extra} @@ -359,7 +359,7 @@ void to_json(nlohmann::json &jsonObject, const CustomizeData &customizeData) void to_json(nlohmann::json &jsonObject, const MetaData &metaData) { - jsonObject = nlohmann::json{ + jsonObject = nlohmann::json { {JSON_KEY_PARAMETERS, metaData.parameters}, {JSON_KEY_RESULTS, metaData.results}, {JSON_KEY_CUSTOMIZE_DATA, metaData.customizeData} @@ -368,7 +368,8 @@ void to_json(nlohmann::json &jsonObject, const MetaData &metaData) void to_json(nlohmann::json &jsonObject, const AbilityInfo &abilityInfo) { - jsonObject = nlohmann::json{{JSON_KEY_NAME, abilityInfo.name}, + jsonObject = nlohmann::json { + {JSON_KEY_NAME, abilityInfo.name}, {JSON_KEY_LABEL, abilityInfo.label}, {JSON_KEY_DESCRIPTION, abilityInfo.description}, {JSON_KEY_ICON_PATH, abilityInfo.iconPath}, diff --git a/interfaces/innerkits/appexecfwk_base/src/module_info.cpp b/interfaces/innerkits/appexecfwk_base/src/module_info.cpp index 9c7e51b030..af25a74eea 100644 --- a/interfaces/innerkits/appexecfwk_base/src/module_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/module_info.cpp @@ -51,7 +51,7 @@ bool ModuleInfo::Marshalling(Parcel &parcel) const void to_json(nlohmann::json &jsonObject, const ModuleInfo &moduleInfo) { - jsonObject = nlohmann::json{ + jsonObject = nlohmann::json { {"moduleName", moduleInfo.moduleName}, {"moduleSourceDir", moduleInfo.moduleSourceDir} }; diff --git a/interfaces/innerkits/appexecfwk_base/src/shortcut_info.cpp b/interfaces/innerkits/appexecfwk_base/src/shortcut_info.cpp index 533fcb542c..84943ba10e 100644 --- a/interfaces/innerkits/appexecfwk_base/src/shortcut_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/shortcut_info.cpp @@ -104,13 +104,15 @@ bool ShortcutInfo::Marshalling(Parcel &parcel) const void to_json(nlohmann::json &jsonObject, const ShortcutIntent &shortcutIntent) { - jsonObject = nlohmann::json{{JSON_KEY_BUNDLE_TARGET_BUNDLE, shortcutIntent.targetBundle}, + jsonObject = nlohmann::json { + {JSON_KEY_BUNDLE_TARGET_BUNDLE, shortcutIntent.targetBundle}, {JSON_KEY_BUNDLE_TARGET_CLASS, shortcutIntent.targetClass}}; } void to_json(nlohmann::json &jsonObject, const ShortcutInfo &shortcutInfo) { - jsonObject = nlohmann::json{{JSON_KEY_BUNDLE_ID, shortcutInfo.id}, + jsonObject = nlohmann::json { + {JSON_KEY_BUNDLE_ID, shortcutInfo.id}, {JSON_KEY_BUNDLE_NAME, shortcutInfo.bundleName}, {JSON_KEY_BUNDLE_HOST_ABILITY, shortcutInfo.hostAbility}, {JSON_KEY_BUNDLE_ICON, shortcutInfo.icon}, diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index 4fe20d5ebe..6cc4585316 100755 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -185,15 +185,15 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa case static_cast(IBundleMgr::Message::UNREGISTER_PERMISSIONS_CHANGED): errCode = HandleUnregisterPermissionsChanged(data, reply); break; - case static_cast(IBundleMgr::Message::GET_ALL_FORMS_INFO): + case static_cast(IBundleMgr::Message::GET_ALL_FORMS_INFO): errCode = HandleGetAllFormsInfo(data, reply); - break; - case static_cast(IBundleMgr::Message::GET_FORMS_INFO_BY_APP): + break; + case static_cast(IBundleMgr::Message::GET_FORMS_INFO_BY_APP): errCode = HandleGetFormsInfoByApp(data, reply); - break; - case static_cast(IBundleMgr::Message::GET_FORMS_INFO_BY_MODULE): + break; + case static_cast(IBundleMgr::Message::GET_FORMS_INFO_BY_MODULE): errCode = HandleGetFormsInfoByModule(data, reply); - break; + break; case static_cast(IBundleMgr::Message::GET_SHORTCUT_INFO): errCode = HandleGetShortcutInfos(data, reply); break; @@ -980,59 +980,59 @@ ErrCode BundleMgrHost::HandleGetBundleInstaller(Parcel &data, Parcel &reply) ErrCode BundleMgrHost::HandleGetAllFormsInfo(Parcel &data, Parcel &reply) { - std::vector infos; - bool ret = GetAllFormsInfo(infos); - if (!reply.WriteBool(ret)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - if (ret) { - if (!WriteParcelableVector(infos, reply)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; + std::vector infos; + bool ret = GetAllFormsInfo(infos); + if (!reply.WriteBool(ret)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (ret) { + if (!WriteParcelableVector(infos, reply)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + } + return ERR_OK; } ErrCode BundleMgrHost::HandleGetFormsInfoByApp(Parcel &data, Parcel &reply) { - std::string bundlename = data.ReadString(); - std::vector infos; - bool ret = GetFormsInfoByApp(bundlename, infos); - if (!reply.WriteBool(ret)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - if (ret) { - if (!WriteParcelableVector(infos, reply)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; + std::string bundlename = data.ReadString(); + std::vector infos; + bool ret = GetFormsInfoByApp(bundlename, infos); + if (!reply.WriteBool(ret)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (ret) { + if (!WriteParcelableVector(infos, reply)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + } + return ERR_OK; } ErrCode BundleMgrHost::HandleGetFormsInfoByModule(Parcel &data, Parcel &reply) { - std::string bundlename = data.ReadString(); - std::string modulename = data.ReadString(); - std::vector infos; - bool ret = GetFormsInfoByModule(bundlename, modulename, infos); - if (!reply.WriteBool(ret)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - if (ret) { - if (!WriteParcelableVector(infos, reply)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; + std::string bundlename = data.ReadString(); + std::string modulename = data.ReadString(); + std::vector infos; + bool ret = GetFormsInfoByModule(bundlename, modulename, infos); + if (!reply.WriteBool(ret)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (ret) { + if (!WriteParcelableVector(infos, reply)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + } + return ERR_OK; } ErrCode BundleMgrHost::HandleGetShortcutInfos(Parcel &data, Parcel &reply) @@ -1091,7 +1091,7 @@ ErrCode BundleMgrHost::HandleNotifyActivityLifeStatus(Parcel &data, Parcel &repl return ERR_OK; } -template +template bool BundleMgrHost::WriteParcelableVector(std::vector &parcelableVector, Parcel &reply) { if (!reply.WriteInt32(parcelableVector.size())) { diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index 95724fedf2..0550b9335f 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -1363,7 +1363,7 @@ bool BundleMgrProxy::NotifyActivityLifeStatus( } -template +template bool BundleMgrProxy::GetParcelableInfo(IBundleMgr::Message code, MessageParcel &data, T &parcelableInfo) { MessageParcel reply; @@ -1386,7 +1386,7 @@ bool BundleMgrProxy::GetParcelableInfo(IBundleMgr::Message code, MessageParcel & return true; } -template +template bool BundleMgrProxy::GetParcelableInfos(IBundleMgr::Message code, MessageParcel &data, std::vector &parcelableInfos) { MessageParcel reply; diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/status_receiver_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/status_receiver_proxy.cpp index 19520010ae..9c331b168b 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/status_receiver_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/status_receiver_proxy.cpp @@ -85,7 +85,7 @@ const std::string MSG_ERR_UNINSTALL_KILLING_APP_ERROR = "[ERR_UNINSTALL_KILLING_ const std::string MSG_ERR_UNINSTALL_SYSTEM_APP_ERROR = "[MSG_ERR_UNINSTALL_SYSTEM_APP_ERROR]"; const std::string MSG_ERR_UNKNOWN = "[ERR_UNKNOWN]"; -const std::map MAP_RECEIVED_RESULTS{ +const std::map MAP_RECEIVED_RESULTS { {ERR_OK, {IStatusReceiver::SUCCESS, MSG_SUCCESS}}, {ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR, {IStatusReceiver::ERR_INSTALL_INTERNAL_ERROR, MSG_ERR_INSTALL_INTERNAL_ERROR}}, diff --git a/interfaces/innerkits/task_dispatcher/src/dispatcher/parallel_task_dispatcher_base.cpp b/interfaces/innerkits/task_dispatcher/src/dispatcher/parallel_task_dispatcher_base.cpp index ddce41c646..2ca74d97b5 100644 --- a/interfaces/innerkits/task_dispatcher/src/dispatcher/parallel_task_dispatcher_base.cpp +++ b/interfaces/innerkits/task_dispatcher/src/dispatcher/parallel_task_dispatcher_base.cpp @@ -122,7 +122,7 @@ std::shared_ptr ParallelTaskDispatcherBase::DelayDispatch( return nullptr; } TracePointBeforePost(innerTask, true, DELAY_DISPATCHER_TAG); - std::function < void()> callback = std::bind(&ParallelTaskDispatcherBase::InterceptedExecute, shared_from_this(), innerTask); + std::function callback = std::bind(&ParallelTaskDispatcherBase::InterceptedExecute, shared_from_this(), innerTask); bool executeFlag = executor_->DelayExecute(callback, delayMs); if (!executeFlag) { APP_LOGE("ParallelTaskDispatcherBase::DelayDispatch execute failed"); diff --git a/interfaces/innerkits/task_dispatcher/src/dispatcher/serial_task_dispatcher.cpp b/interfaces/innerkits/task_dispatcher/src/dispatcher/serial_task_dispatcher.cpp index 42fc5720c7..48e37f068e 100644 --- a/interfaces/innerkits/task_dispatcher/src/dispatcher/serial_task_dispatcher.cpp +++ b/interfaces/innerkits/task_dispatcher/src/dispatcher/serial_task_dispatcher.cpp @@ -108,7 +108,7 @@ std::shared_ptr SerialTaskDispatcher::DelayDispatch(const std::shared } TracePointBeforePost(innerTask, true, DELAY_DISPATCHER_TAG); // bind parameter to avoid deconstruct. - std::function < void()> callback = std::bind(&SerialTaskDispatcher::OnNewTaskIn, this, innerTask); + std::function callback = std::bind(&SerialTaskDispatcher::OnNewTaskIn, this, innerTask); bool executeFlag = executor_->DelayExecute(callback, delayMs); if (!executeFlag) { APP_LOGE("SerialTaskDispatcher::DelayDispatch execute failed"); diff --git a/interfaces/innerkits/task_dispatcher/src/task/sync_task.cpp b/interfaces/innerkits/task_dispatcher/src/task/sync_task.cpp index bb005a0a77..211b825084 100644 --- a/interfaces/innerkits/task_dispatcher/src/task/sync_task.cpp +++ b/interfaces/innerkits/task_dispatcher/src/task/sync_task.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace AppExecFwk { // Help to calculate hash code of object. -template +template inline size_t CalculateHashCode(const T &obj) { std::hash calculateHashCode; diff --git a/interfaces/innerkits/task_dispatcher/src/threading/task_executor.cpp b/interfaces/innerkits/task_dispatcher/src/threading/task_executor.cpp index 197f1ae4e5..069a8dcdb6 100644 --- a/interfaces/innerkits/task_dispatcher/src/threading/task_executor.cpp +++ b/interfaces/innerkits/task_dispatcher/src/threading/task_executor.cpp @@ -94,7 +94,7 @@ std::shared_ptr TaskExecutor::GetTask(const std::shared_ptr std::shared_ptr nullRunnable = nullptr; std::shared_ptr next = nullptr; - for(;;) { + for(;;){ if (terminated_.load() && pendingTasks_->Empty()) { APP_LOGI("TaskExecutor::GetTask end: loop thread %{public}s is terminated", workerThread->GetThreadName().c_str()); @@ -204,7 +204,7 @@ bool TaskExecutor::EnsureConsumeStarted() void TaskExecutor::Consume() { - for(;;) { + for(;;){ if (terminated_.load() && delayTasks_->Empty()) { APP_LOGI("TaskExecutor::Consume delay task is empty"); break; diff --git a/interfaces/innerkits/task_dispatcher/src/threading/worker_pool.cpp b/interfaces/innerkits/task_dispatcher/src/threading/worker_pool.cpp index c1ae3c5a56..1505b10dcb 100644 --- a/interfaces/innerkits/task_dispatcher/src/threading/worker_pool.cpp +++ b/interfaces/innerkits/task_dispatcher/src/threading/worker_pool.cpp @@ -239,7 +239,7 @@ bool WorkerPool::AddWorker(const std::shared_ptr &delegate, const std: std::unique_lock mLock(poolLock_); std::shared_ptr newThread = nullptr; - for (;;) { + for(;;){ unsigned int value = control_.load(); int num = GetWorkingThreadNum(value); if (num >= thread_limit_) { @@ -327,7 +327,7 @@ int WorkerPool::GetStateFromControl(unsigned int ctl) void WorkerPool::AdvanceStateTo(unsigned int target) { APP_LOGI("WorkerPool::AdvanceStateTo begin"); - for (;;) { + for(;;){ unsigned int current = control_.load(); if ((current >= target) || CompareAndSet(control_, current, CombineToControl(target, GetWorkingThreadNum(current)))) { diff --git a/interfaces/innerkits/test/moduletest/task_dispatcher/global_task_dispatcher_module_test/global_task_dispatcher_module_test.cpp b/interfaces/innerkits/test/moduletest/task_dispatcher/global_task_dispatcher_module_test/global_task_dispatcher_module_test.cpp index 6abe4204c1..b86f8b0469 100644 --- a/interfaces/innerkits/test/moduletest/task_dispatcher/global_task_dispatcher_module_test/global_task_dispatcher_module_test.cpp +++ b/interfaces/innerkits/test/moduletest/task_dispatcher/global_task_dispatcher_module_test/global_task_dispatcher_module_test.cpp @@ -55,7 +55,6 @@ void GlobalTaskDispatcherModuleTest::TearDown() std::shared_ptr GlobalTaskDispatcherModuleTest::GetMtGlobalTaskDispatcher(TaskPriority priority) const { - // TaskDispatcherContext context; std::shared_ptr ptrGlobalTaskDispatcher = context->GetGlobalTaskDispatcher(priority); return ptrGlobalTaskDispatcher; } diff --git a/kits/appkit/napi/appMgr/app_mgr.cpp b/kits/appkit/napi/appMgr/app_mgr.cpp index a67924e897..bedc57148c 100755 --- a/kits/appkit/napi/appMgr/app_mgr.cpp +++ b/kits/appkit/napi/appMgr/app_mgr.cpp @@ -39,7 +39,7 @@ static napi_value ParseBundleName(napi_env env, std::string &bundleName, napi_va size_t len = 0; napi_get_value_string_utf8(env, args, buf, BUFFER_LENGTH_MAX, &len); HILOG_INFO("bundleName= [%{public}s].", buf); - bundleName = std::string{ buf }; + bundleName = std::string {buf}; // create result code napi_value result; status = napi_create_int32(env, 1, &result); @@ -75,7 +75,7 @@ napi_value NAPI_KillProcessesByBundleName(napi_env env, napi_callback_info info) } AsyncCallbackInfo *async_callback_info = - new AsyncCallbackInfo{ .env = env, .asyncWork = nullptr, .deferred = nullptr }; + new AsyncCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr }; std::string bundleName; ParseBundleName(env, bundleName, argv[0]); diff --git a/kits/appkit/napi/appMgr/native_module.cpp b/kits/appkit/napi/appMgr/native_module.cpp index 0e4c22c52e..f1e4c8ae9f 100644 --- a/kits/appkit/napi/appMgr/native_module.cpp +++ b/kits/appkit/napi/appMgr/native_module.cpp @@ -33,7 +33,8 @@ static napi_value Init(napi_env env, napi_value exports) * Propertise define */ napi_property_descriptor desc[] = { - DECLARE_NAPI_FUNCTION("killProcessesByBundleName", NAPI_KillProcessesByBundleName)}; + DECLARE_NAPI_FUNCTION("killProcessesByBundleName", NAPI_KillProcessesByBundleName), + }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); HILOG_INFO("native_module Init end..."); @@ -44,13 +45,15 @@ EXTERN_C_END /* * Module define */ -static napi_module _module = {.nm_version = 1, +static napi_module _module = { + .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, .nm_register_func = Init, .nm_modname = "napi_app_mgr", .nm_priv = ((void *)0), - .reserved = {0}}; + .reserved = {0}, + }; /* * Module register function */ diff --git a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp index 50ea510051..4245612309 100644 --- a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp +++ b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp @@ -464,6 +464,25 @@ static void ConvertAbilityInfo(napi_env env, napi_value objAbilityInfo, const Ab NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objAbilityInfo, "metaData", nMetaData)); } +static void ProcessAbilityInfos( + napi_env env, napi_value result, const std::vector abilityInfos) +{ + if (abilityInfos.size() > 0) { + HILOG_INFO("-----abilityInfos is not null-----"); + size_t index = 0; + for (const auto &item : abilityInfos) { + HILOG_INFO("name{%s} ", item.name.c_str()); + napi_value objAbilityInfo = nullptr; + napi_create_object(env, &objAbilityInfo); + ConvertAbilityInfo(env, objAbilityInfo, item); + napi_set_element(env, result, index, objAbilityInfo); + index++; + } + } else { + HILOG_INFO("-----abilityInfos is null-----"); + } +} + static void ConvertHapModuleInfo(napi_env env, napi_value objHapModuleInfo, const HapModuleInfo &hapModuleInfo) { napi_value nName; @@ -1031,8 +1050,13 @@ napi_value GetApplicationInfos(napi_env env, napi_callback_info info) applicationFlag = ApplicationFlag::GET_BASIC_APPLICATION_INFO; } - AsyncApplicationInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncApplicationInfosCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .applicationFlag = applicationFlag, .userId = userId}; + AsyncApplicationInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncApplicationInfosCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .applicationFlag = applicationFlag, + .userId = userId + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -1133,15 +1157,15 @@ napi_value GetApplicationInfos(napi_env env, napi_callback_info info) } } -// QueryAbilityInfo(want) -static bool InnerQueryAbilityInfo(napi_env env, const Want &want, AbilityInfo &abilityInfo) +// QueryAbilityInfos(want) +static bool InnerQueryAbilityInfos(napi_env env, const Want &want, std::vector &abilityInfos) { auto iBundleMgr = GetBundleMgr(); if (!iBundleMgr) { HILOG_ERROR("can not get iBundleMgr"); return false; } - return iBundleMgr->QueryAbilityInfo(want, abilityInfo); + return iBundleMgr->QueryAbilityInfos(want, abilityInfos); } static napi_value ParseWant(napi_env env, Want &want, napi_value args) @@ -1200,10 +1224,10 @@ static napi_value ParseWant(napi_env env, Want &want, napi_value args) /** * Promise and async callback */ -napi_value QueryAbilityInfo(napi_env env, napi_callback_info info) +napi_value QueryAbilityInfos(napi_env env, napi_callback_info info) { - HILOG_INFO("QueryAbilityInfo called"); + HILOG_INFO("QueryAbilityInfos called"); size_t argc = ARGS_SIZE_FOUR; napi_value argv[ARGS_SIZE_FOUR] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); @@ -1218,13 +1242,17 @@ napi_value QueryAbilityInfo(napi_env env, napi_callback_info info) ParseInt(env, bundleFlags, argv[PARAM1]); ParseInt(env, userId, argv[PARAM2]); - AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = - new AsyncAbilityInfoCallbackInfo{.env = env, .asyncWork = nullptr, .deferred = nullptr, .want = want}; + AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = new AsyncAbilityInfoCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .want = want + }; if (asyncCallbackInfo == nullptr) { return nullptr; } if (argc > (ARGS_SIZE_FOUR - CALLBACK_SIZE)) { - HILOG_INFO("QueryAbilityInfo asyncCallback."); + HILOG_INFO("QueryAbilityInfos asyncCallback."); napi_valuetype valuetype = napi_undefined; napi_typeof(env, argv[ARGS_SIZE_THREE], &valuetype); NAPI_ASSERT(env, valuetype == napi_function, "Wrong argument type. Function expected."); @@ -1232,7 +1260,7 @@ napi_value QueryAbilityInfo(napi_env env, napi_callback_info info) env, napi_create_reference(env, argv[ARGS_SIZE_THREE], NAPI_RETURN_ONE, &asyncCallbackInfo->callback)); napi_value resourceName; - napi_create_string_latin1(env, "QueryAbilityInfo", NAPI_AUTO_LENGTH, &resourceName); + napi_create_string_latin1(env, "QueryAbilityInfos", NAPI_AUTO_LENGTH, &resourceName); napi_create_async_work( env, nullptr, @@ -1240,7 +1268,7 @@ napi_value QueryAbilityInfo(napi_env env, napi_callback_info info) [](napi_env env, void *data) { AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = (AsyncAbilityInfoCallbackInfo *)data; asyncCallbackInfo->ret = - InnerQueryAbilityInfo(env, asyncCallbackInfo->want, asyncCallbackInfo->abilityInfo); + InnerQueryAbilityInfos(env, asyncCallbackInfo->want, asyncCallbackInfo->abilityInfos); }, [](napi_env env, napi_status status, void *data) { AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = (AsyncAbilityInfoCallbackInfo *)data; @@ -1249,8 +1277,8 @@ napi_value QueryAbilityInfo(napi_env env, napi_callback_info info) napi_value undefined = 0; napi_value callResult = 0; napi_get_undefined(env, &undefined); - napi_create_object(env, &result[PARAM1]); - ConvertAbilityInfo(env, result[PARAM1], asyncCallbackInfo->abilityInfo); + napi_create_array(env, &result[PARAM1]); + ProcessAbilityInfos(env, result[PARAM1], asyncCallbackInfo->abilityInfos); result[PARAM0] = GetCallbackErrorValue(env, asyncCallbackInfo->ret ? CODE_SUCCESS : CODE_FAILED); napi_get_reference_value(env, asyncCallbackInfo->callback, &callback); napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, &result[PARAM0], &callResult); @@ -1278,28 +1306,28 @@ napi_value QueryAbilityInfo(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_create_int32(env, NAPI_RETURN_ONE, &result)); return result; } else { - HILOG_INFO("QueryAbilityInfo promise."); + HILOG_INFO("QueryAbilityInfos promise."); napi_deferred deferred; napi_value promise; NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); asyncCallbackInfo->deferred = deferred; napi_value resourceName; - napi_create_string_latin1(env, "QueryAbilityInfo", NAPI_AUTO_LENGTH, &resourceName); + napi_create_string_latin1(env, "QueryAbilityInfos", NAPI_AUTO_LENGTH, &resourceName); napi_create_async_work( env, nullptr, resourceName, [](napi_env env, void *data) { AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = (AsyncAbilityInfoCallbackInfo *)data; - InnerQueryAbilityInfo(env, asyncCallbackInfo->want, asyncCallbackInfo->abilityInfo); + InnerQueryAbilityInfos(env, asyncCallbackInfo->want, asyncCallbackInfo->abilityInfos); }, [](napi_env env, napi_status status, void *data) { HILOG_INFO("=================load================="); AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = (AsyncAbilityInfoCallbackInfo *)data; napi_value result; - napi_create_object(env, &result); - ConvertAbilityInfo(env, result, asyncCallbackInfo->abilityInfo); + napi_create_array(env, &result); + ProcessAbilityInfos(env, result, asyncCallbackInfo->abilityInfos); napi_resolve_deferred(asyncCallbackInfo->env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); delete asyncCallbackInfo; @@ -1367,12 +1395,14 @@ napi_value GetApplicationInfo(napi_env env, napi_callback_info info) if (flag == static_cast(ApplicationFlag::GET_BASIC_APPLICATION_INFO)) { applicationFlag = ApplicationFlag::GET_BASIC_APPLICATION_INFO; } - AsyncApplicationInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncApplicationInfoCallbackInfo{.env = env, + AsyncApplicationInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncApplicationInfoCallbackInfo { + .env = env, .asyncWork = nullptr, .deferred = nullptr, .bundleName = bundleName, .applicationFlag = applicationFlag, - .userId = userId}; + .userId = userId + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -1539,8 +1569,12 @@ napi_value GetBundleInfos(napi_env env, napi_callback_info info) if (flag == static_cast(BundleFlag::GET_BUNDLE_DEFAULT)) { bundleFlag = BundleFlag::GET_BUNDLE_DEFAULT; } - AsyncBundleInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfosCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .bundleFlag = bundleFlag}; + AsyncBundleInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfosCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleFlag = bundleFlag + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -1673,8 +1707,13 @@ napi_value GetBundleInfo(napi_env env, napi_callback_info info) if (flag == static_cast(BundleFlag::GET_BUNDLE_DEFAULT)) { bundleFlag = BundleFlag::GET_BUNDLE_DEFAULT; } - AsyncBundleInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfoCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .param = bundleName, .bundleFlag = bundleFlag}; + AsyncBundleInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfoCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .param = bundleName, + .bundleFlag = bundleFlag + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -1808,8 +1847,13 @@ napi_value GetBundleArchiveInfo(napi_env env, napi_callback_info info) if (flag == static_cast(BundleFlag::GET_BUNDLE_DEFAULT)) { bundleFlag = BundleFlag::GET_BUNDLE_DEFAULT; } - AsyncBundleInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfoCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .param = hapFilePath, .bundleFlag = bundleFlag}; + AsyncBundleInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfoCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .param = hapFilePath, + .bundleFlag = bundleFlag + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -1995,8 +2039,12 @@ napi_value GetPermissionDef(napi_env env, napi_callback_info info) HILOG_INFO("argc = [%{public}zu]", argc); std::string permissionName; ParseString(env, permissionName, argv[PARAM0]); - AsyncPermissionDefCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncPermissionDefCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .permissionName = permissionName}; + AsyncPermissionDefCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncPermissionDefCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .permissionName = permissionName + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -2138,7 +2186,11 @@ napi_value GetBundleInstaller(napi_env env, napi_callback_info info) HILOG_INFO("argc = [%{public}zu]", argc); AsyncGetBundleInstallerCallbackInfo *asyncCallbackInfo = - new AsyncGetBundleInstallerCallbackInfo{.env = env, .asyncWork = nullptr, .deferred = nullptr}; + new AsyncGetBundleInstallerCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -2407,7 +2459,7 @@ napi_value Install(napi_env env, napi_callback_info info) ParseStringArray(env, bundleFilePaths, argv[PARAM0]); InstallParam installParam; ParseInstallParam(env, installParam, argv[PARAM1]); - AsyncInstallCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncInstallCallbackInfo{ + AsyncInstallCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncInstallCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr, @@ -2571,7 +2623,7 @@ napi_value Uninstall(napi_env env, napi_callback_info info) ParseString(env, bundleName, argv[PARAM0]); InstallParam installParam; ParseInstallParam(env, installParam, argv[PARAM1]); - AsyncInstallCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncInstallCallbackInfo{ + AsyncInstallCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncInstallCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr, @@ -2740,8 +2792,11 @@ napi_value GetAllFormsInfo(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data)); HILOG_INFO("ARGCSIZE is =%{public}zu.", argc); - AsyncFormInfosCallbackInfo *asyncCallbackInfo = - new AsyncFormInfosCallbackInfo{.env = env, .asyncWork = nullptr, .deferred = nullptr}; + AsyncFormInfosCallbackInfo *asyncCallbackInfo = new AsyncFormInfosCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -2867,8 +2922,13 @@ napi_value GetFormsInfoByModule(napi_env env, napi_callback_info info) ParseString(env, bundleName, argv[PARAM0]); ParseString(env, moduleName, argv[PARAM1]); - AsyncFormInfosByModuleCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncFormInfosByModuleCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .bundleName = bundleName, .moduleName = moduleName}; + AsyncFormInfosByModuleCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncFormInfosByModuleCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleName = bundleName, + .moduleName = moduleName + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -2993,8 +3053,12 @@ napi_value GetFormsInfoByApp(napi_env env, napi_callback_info info) std::string bundleName; ParseString(env, bundleName, argv[PARAM0]); - AsyncFormInfosByAppCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncFormInfosByAppCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .bundleName = bundleName}; + AsyncFormInfosByAppCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncFormInfosByAppCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleName = bundleName + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -3137,8 +3201,12 @@ napi_value GetShortcutInfos(napi_env env, napi_callback_info info) HILOG_INFO("ARGCSIZE is =%{public}zu.", argc); std::string bundleName; ParseString(env, bundleName, argv[PARAM0]); - AsyncShortcutInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncShortcutInfosCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .bundleName = bundleName}; + AsyncShortcutInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncShortcutInfosCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleName = bundleName + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -3281,8 +3349,12 @@ napi_value GetModuleUsageRecords(napi_env env, napi_callback_info info) HILOG_INFO("ARGCSIZE is =%{public}zu.", argc); int number; ParseInt(env, number, argv[PARAM0]); - AsyncModuleUsageRecordsCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncModuleUsageRecordsCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .number = number}; + AsyncModuleUsageRecordsCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncModuleUsageRecordsCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .number = number + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -3455,7 +3527,10 @@ static bool InnerRegisterPermissionsChanged(napi_env env, const std::vector lock(permissionsCallbackMutex); auto ret = permissionsCallback.emplace(permissonsKey, callback); @@ -3480,8 +3555,11 @@ napi_value RegisterAllPermissionsChanged(napi_env env, napi_callback_info info) if (permissionEvent == PERMISSION_CHANGE && argc == ARGS_SIZE_THREE) { std::vector uids; ParseInt32Array(env, uids, argv[ARGS_SIZE_ONE]); - AsyncRegisterPermissions *asyncCallbackInfo = - new (std::nothrow) AsyncRegisterPermissions{.env = env, .asyncWork = nullptr, .uids = uids}; + AsyncRegisterPermissions *asyncCallbackInfo = new (std::nothrow) AsyncRegisterPermissions { + .env = env, + .asyncWork = nullptr, + .uids = uids + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -3524,8 +3602,10 @@ napi_value RegisterAllPermissionsChanged(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_create_int32(env, NAPI_RETURN_ONE, &result)); return result; } else if (permissionEvent == ANY_PERMISSION_CHANGE && argc == ARGS_SIZE_TWO) { - AsyncRegisterAllPermissions *asyncCallbackInfo = - new (std::nothrow) AsyncRegisterAllPermissions{.env = env, .asyncWork = nullptr}; + AsyncRegisterAllPermissions *asyncCallbackInfo = new (std::nothrow) AsyncRegisterAllPermissions { + .env = env, + .asyncWork = nullptr + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -3651,7 +3731,7 @@ napi_value UnregisterPermissionsChanged(napi_env env, napi_callback_info info) ParseString(env, permissionEvent, argv[PARAM0]); if (permissionEvent == ANY_PERMISSION_CHANGE && argc == ARGS_SIZE_TWO) { - AsyncUnregisterPermissions *asyncCallbackInfo = new (std::nothrow) AsyncUnregisterPermissions{ + AsyncUnregisterPermissions *asyncCallbackInfo = new (std::nothrow) AsyncUnregisterPermissions { .env = env, .asyncWork = nullptr, }; @@ -3707,8 +3787,11 @@ napi_value UnregisterPermissionsChanged(napi_env env, napi_callback_info info) } else if (permissionEvent == PERMISSION_CHANGE && argc == ARGS_SIZE_THREE) { std::vector uids; ParseInt32Array(env, uids, argv[ARGS_SIZE_ONE]); - AsyncUnregisterPermissions *asyncCallbackInfo = - new AsyncUnregisterPermissions{.env = env, .asyncWork = nullptr, .uids = uids}; + AsyncUnregisterPermissions *asyncCallbackInfo = new AsyncUnregisterPermissions { + .env = env, + .asyncWork = nullptr, + .uids = uids + }; if (asyncCallbackInfo == nullptr) { return nullptr; } @@ -3793,8 +3876,13 @@ napi_value CheckPermission(napi_env env, napi_callback_info info) std::string permission; ParseString(env, permission, argv[PARAM1]); - AsyncPermissionCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncPermissionCallbackInfo{ - .env = env, .asyncWork = nullptr, .deferred = nullptr, .bundleName = bundleName, .permission = permission}; + AsyncPermissionCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncPermissionCallbackInfo { + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleName = bundleName, + .permission = permission + }; if (asyncCallbackInfo == nullptr) { return nullptr; } diff --git a/kits/appkit/napi/bundlemgr/bundle_mgr.h b/kits/appkit/napi/bundlemgr/bundle_mgr.h index e30e3fd3d7..d8c01e8db9 100644 --- a/kits/appkit/napi/bundlemgr/bundle_mgr.h +++ b/kits/appkit/napi/bundlemgr/bundle_mgr.h @@ -36,7 +36,7 @@ struct AsyncAbilityInfoCallbackInfo { napi_deferred deferred; napi_ref callback = 0; OHOS::AAFwk::Want want; - OHOS::AppExecFwk::AbilityInfo abilityInfo; + std::vector abilityInfos; bool ret = false; }; @@ -202,7 +202,7 @@ extern napi_value g_classBundleInstaller; napi_value GetApplicationInfos(napi_env env, napi_callback_info info); napi_value GetApplicationInfo(napi_env env, napi_callback_info info); -napi_value QueryAbilityInfo(napi_env env, napi_callback_info info); +napi_value QueryAbilityInfos(napi_env env, napi_callback_info info); napi_value GetBundleInfos(napi_env env, napi_callback_info info); napi_value GetBundleInfo(napi_env env, napi_callback_info info); napi_value GetBundleArchiveInfo(napi_env env, napi_callback_info info); diff --git a/kits/appkit/napi/bundlemgr/native_module.cpp b/kits/appkit/napi/bundlemgr/native_module.cpp index 344b5b0893..dc62bcdc96 100644 --- a/kits/appkit/napi/bundlemgr/native_module.cpp +++ b/kits/appkit/napi/bundlemgr/native_module.cpp @@ -90,7 +90,7 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("getBundleInfo", GetBundleInfo), DECLARE_NAPI_FUNCTION("getBundleArchiveInfo", GetBundleArchiveInfo), DECLARE_NAPI_FUNCTION("getPermissionDef", GetPermissionDef), - DECLARE_NAPI_FUNCTION("queryAbilityByWant", QueryAbilityInfo), + DECLARE_NAPI_FUNCTION("queryAbilityByWant", QueryAbilityInfos), DECLARE_NAPI_FUNCTION("getBundleInstaller", GetBundleInstaller), DECLARE_NAPI_FUNCTION("getFormsInfoByModule", GetFormsInfoByModule), DECLARE_NAPI_FUNCTION("getFormsInfo", GetFormsInfoByApp), diff --git a/kits/appkit/native/app/src/main_thread.cpp b/kits/appkit/native/app/src/main_thread.cpp index 6200031819..b04a2c5182 100644 --- a/kits/appkit/native/app/src/main_thread.cpp +++ b/kits/appkit/native/app/src/main_thread.cpp @@ -1226,7 +1226,7 @@ bool MainThread::ScanDir(const std::string &dirPath) } APP_LOGI("MainThread::ScanDir after opendir."); struct dirent *df = nullptr; - for (;;) { + for (; ; ) { APP_LOGI("MainThread::ScanDir before readdir."); df = readdir(dirp); APP_LOGI("MainThread::ScanDir after readdir."); diff --git a/services/appmgr/include/process_optimizer_uba.h b/services/appmgr/include/process_optimizer_uba.h index a3f6d1eadb..89c0440afd 100644 --- a/services/appmgr/include/process_optimizer_uba.h +++ b/services/appmgr/include/process_optimizer_uba.h @@ -147,7 +147,7 @@ private: std::variant; - template + template void RecordAbilityAction(ARGS... args) { abilityActionCache_[abilityActionCount_++].emplace(args...); diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 6dd7390cdd..2dba594b61 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -60,7 +60,7 @@ void AmsMgrScheduler::LoadAbility(const sptr &token, const sptr loadAbilityFunc = + std::function loadAbilityFunc = std::bind(&AppMgrServiceInner::LoadAbility, amsMgrServiceInner_, token, preToken, abilityInfo, appInfo); amsHandler_->PostTask(loadAbilityFunc, TASK_LOAD_ABILITY); @@ -71,7 +71,7 @@ void AmsMgrScheduler::UpdateAbilityState(const sptr &token, const if (!IsReady()) { return; } - std::function updateAbilityStateFunc = + std::function updateAbilityStateFunc = std::bind(&AppMgrServiceInner::UpdateAbilityState, amsMgrServiceInner_, token, state); amsHandler_->PostTask(updateAbilityStateFunc, TASK_UPDATE_ABILITY_STATE); } @@ -81,7 +81,7 @@ void AmsMgrScheduler::TerminateAbility(const sptr &token) if (!IsReady()) { return; } - std::function terminateAbilityFunc = + std::function terminateAbilityFunc = std::bind(&AppMgrServiceInner::TerminateAbility, amsMgrServiceInner_, token); amsHandler_->PostTask(terminateAbilityFunc, TASK_TERMINATE_ABILITY); } @@ -91,7 +91,7 @@ void AmsMgrScheduler::RegisterAppStateCallback(const sptr &ca if (!IsReady()) { return; } - std::function registerAppStateCallbackFunc = + std::function registerAppStateCallbackFunc = std::bind(&AppMgrServiceInner::RegisterAppStateCallback, amsMgrServiceInner_, callback); amsHandler_->PostTask(registerAppStateCallbackFunc, TASK_REGISTER_APP_STATE_CALLBACK); } @@ -101,7 +101,7 @@ void AmsMgrScheduler::Reset() if (!IsReady()) { return; } - std::function resetFunc = std::bind(&AppMgrServiceInner::StopAllProcess, amsMgrServiceInner_); + std::function resetFunc = std::bind(&AppMgrServiceInner::StopAllProcess, amsMgrServiceInner_); amsHandler_->PostTask(resetFunc, TASK_STOP_ALL_PROCESS); } @@ -111,7 +111,7 @@ void AmsMgrScheduler::AbilityBehaviorAnalysis(const sptr &token, if (!IsReady()) { return; } - std::function abilityBehaviorAnalysisFunc = std::bind(&AppMgrServiceInner::AbilityBehaviorAnalysis, + std::function abilityBehaviorAnalysisFunc = std::bind(&AppMgrServiceInner::AbilityBehaviorAnalysis, amsMgrServiceInner_, token, preToken, @@ -126,7 +126,7 @@ void AmsMgrScheduler::KillProcessByAbilityToken(const sptr &token if (!IsReady()) { return; } - std::function killProcessByAbilityTokenFunc = + std::function killProcessByAbilityTokenFunc = std::bind(&AppMgrServiceInner::KillProcessByAbilityToken, amsMgrServiceInner_, token); amsHandler_->PostTask(killProcessByAbilityTokenFunc, TASK_KILL_PROCESS_BY_ABILITYTOKEN); } diff --git a/services/appmgr/src/app_death_recipient.cpp b/services/appmgr/src/app_death_recipient.cpp index 9c841c0310..f094ad812e 100644 --- a/services/appmgr/src/app_death_recipient.cpp +++ b/services/appmgr/src/app_death_recipient.cpp @@ -42,7 +42,7 @@ void AppDeathRecipient::OnRemoteDied(const wptr &remote) return; } - std::function onRemoteDiedFunc = std::bind(&AppMgrServiceInner::OnRemoteDied, serviceInner, remote); + std::function onRemoteDiedFunc = std::bind(&AppMgrServiceInner::OnRemoteDied, serviceInner, remote); handler->PostTask(onRemoteDiedFunc, TASK_ON_REMOTE_DIED); } diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 8567b51095..7869d78bde 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -158,7 +158,7 @@ void AppMgrService::AttachApplication(const sptr &app) pid_t pid = IPCSkeleton::GetCallingPid(); AddAppDeathRecipient(pid); - std::function attachApplicationFunc = + std::function attachApplicationFunc = std::bind(&AppMgrServiceInner::AttachApplication, appMgrServiceInner_, pid, iface_cast(app)); handler_->PostTask(attachApplicationFunc, TASK_ATTACH_APPLICATION); } @@ -168,7 +168,7 @@ void AppMgrService::ApplicationForegrounded(const int32_t recordId) if (!IsReady()) { return; } - std::function applicationForegroundedFunc = + std::function applicationForegroundedFunc = std::bind(&AppMgrServiceInner::ApplicationForegrounded, appMgrServiceInner_, recordId); handler_->PostTask(applicationForegroundedFunc, TASK_APPLICATION_FOREGROUNDED); } @@ -178,7 +178,7 @@ void AppMgrService::ApplicationBackgrounded(const int32_t recordId) if (!IsReady()) { return; } - std::function applicationBackgroundedFunc = + std::function applicationBackgroundedFunc = std::bind(&AppMgrServiceInner::ApplicationBackgrounded, appMgrServiceInner_, recordId); handler_->PostTask(applicationBackgroundedFunc, TASK_APPLICATION_BACKGROUNDED); } @@ -188,7 +188,7 @@ void AppMgrService::ApplicationTerminated(const int32_t recordId) if (!IsReady()) { return; } - std::function applicationTerminatedFunc = + std::function applicationTerminatedFunc = std::bind(&AppMgrServiceInner::ApplicationTerminated, appMgrServiceInner_, recordId); handler_->PostTask(applicationTerminatedFunc, TASK_APPLICATION_TERMINATED); } @@ -198,7 +198,7 @@ void AppMgrService::AbilityCleaned(const sptr &token) if (!IsReady()) { return; } - std::function abilityCleanedFunc = + std::function abilityCleanedFunc = std::bind(&AppMgrServiceInner::AbilityTerminated, appMgrServiceInner_, token); handler_->PostTask(abilityCleanedFunc, TASK_ABILITY_CLEANED); } @@ -224,7 +224,7 @@ void AppMgrService::AddAppDeathRecipient(const pid_t pid) const sptr appDeathRecipient = new AppDeathRecipient(); appDeathRecipient->SetEventHandler(handler_); appDeathRecipient->SetAppMgrServiceInner(appMgrServiceInner_); - std::function addAppRecipientFunc = + std::function addAppRecipientFunc = std::bind(&AppMgrServiceInner::AddAppDeathRecipient, appMgrServiceInner_, pid, appDeathRecipient); handler_->PostTask(addAppRecipientFunc, TASK_ADD_APP_DEATH_RECIPIENT); } @@ -241,7 +241,7 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName) } int32_t uid = IPCSkeleton::GetCallingUid(); pid_t pid = IPCSkeleton::GetCallingPid(); - std::function clearUpApplicationDataFunc = + std::function clearUpApplicationDataFunc = std::bind(&AppMgrServiceInner::ClearUpApplicationData, appMgrServiceInner_, bundleName, uid, pid); handler_->PostTask(clearUpApplicationDataFunc, TASK_CLEAR_UP_APPLICATION_DATA); return ERR_OK; diff --git a/services/appmgr/src/cgroup_manager.cpp b/services/appmgr/src/cgroup_manager.cpp index 2fcea885bf..7bc65031fd 100644 --- a/services/appmgr/src/cgroup_manager.cpp +++ b/services/appmgr/src/cgroup_manager.cpp @@ -378,12 +378,12 @@ bool CgroupManager::RegisterLowMemoryMonitor(const int memoryEventFds[LOW_MEMORY static const char *levelName[] = {"low", "medium", "critical"}; if (snprintf_s(buf, - sizeof(buf), - sizeof(buf) - 1, - "%d %d %s", - memoryEventFds[level], - memoryPressureFds[level], - levelName[level]) < 0) { + sizeof(buf), + sizeof(buf) - 1, + "%d %d %s", + memoryEventFds[level], + memoryPressureFds[level], + levelName[level]) < 0) { return false; } diff --git a/services/appmgr/test/unittest/ams_service_load_ability_process_test/ams_service_load_ability_process_test.cpp b/services/appmgr/test/unittest/ams_service_load_ability_process_test/ams_service_load_ability_process_test.cpp index cb6a51447d..ce8d581848 100644 --- a/services/appmgr/test/unittest/ams_service_load_ability_process_test/ams_service_load_ability_process_test.cpp +++ b/services/appmgr/test/unittest/ams_service_load_ability_process_test/ams_service_load_ability_process_test.cpp @@ -37,10 +37,13 @@ using testing::Return; using testing::SetArgReferee; namespace OHOS { namespace AppExecFwk { -#define CHECK_POINTER_IS_NULLPTR(object) \ - if (object == nullptr) { \ - return; \ - } +#define CHECK_POINTER_IS_NULLPTR(object) \ + do { \ + if (object == nullptr) { \ + return; \ + } \ + } while (0) + class AmsServiceLoadAbilityProcessTest : public testing::Test { public: static void SetUpTestCase(); diff --git a/services/appmgr/test/unittest/app_mgr_service_event_handler_test/app_mgr_service_event_handler_test.cpp b/services/appmgr/test/unittest/app_mgr_service_event_handler_test/app_mgr_service_event_handler_test.cpp index bc565bfb56..c64e01a06e 100644 --- a/services/appmgr/test/unittest/app_mgr_service_event_handler_test/app_mgr_service_event_handler_test.cpp +++ b/services/appmgr/test/unittest/app_mgr_service_event_handler_test/app_mgr_service_event_handler_test.cpp @@ -34,7 +34,7 @@ public: MockAMSEventHandler(const std::shared_ptr &runner, const std::shared_ptr &ams); virtual ~MockAMSEventHandler(); - virtual void ProcessEvent(const InnerEvent::Pointer &event) override + void ProcessEvent(const InnerEvent::Pointer &event) override { if (event->GetInnerEventId() == 10) { eventHandlerFlag_ = true; @@ -164,6 +164,4 @@ HWTEST_F(AMSEventHandlerTest, app_mgr_service_event_handler_test_002, TestSize.L } } // namespace AppExecFwk - - } // namespace OHOS diff --git a/services/bundlemgr/include/bundle_data_storage.h b/services/bundlemgr/include/bundle_data_storage.h index 13a7cf551b..0ced4892e2 100644 --- a/services/bundlemgr/include/bundle_data_storage.h +++ b/services/bundlemgr/include/bundle_data_storage.h @@ -47,7 +47,7 @@ public: */ virtual bool DeleteStorageBundleInfo(const std::string &deviceId, const InnerBundleInfo &innerBundleInfo); - virtual bool ResetKvStore() { return true;} + virtual bool ResetKvStore() { return true; } private: bool KeyToDeviceAndName(const std::string &key, std::string &deviceId, std::string &bundleName) const; void DeviceAndNameToKey(const std::string &deviceId, const std::string &bundleName, std::string &key) const; diff --git a/services/bundlemgr/include/bundle_data_storage_database.h b/services/bundlemgr/include/bundle_data_storage_database.h index 2011167256..2387d6e102 100644 --- a/services/bundlemgr/include/bundle_data_storage_database.h +++ b/services/bundlemgr/include/bundle_data_storage_database.h @@ -63,8 +63,8 @@ private: DistributedKv::Status GetKvStore(); private: - const DistributedKv::AppId appId_{Constants::APP_ID}; - const DistributedKv::StoreId storeId_{Constants::STORE_ID}; + const DistributedKv::AppId appId_ {Constants::APP_ID}; + const DistributedKv::StoreId storeId_ {Constants::STORE_ID}; bool KeyToDeviceAndName(const std::string &key, std::string &deviceId, std::string &bundleName) const; void DeviceAndNameToKey(const std::string &deviceId, const std::string &bundleName, std::string &key) const; DistributedKv::DistributedKvDataManager dataManager_; diff --git a/services/bundlemgr/include/bundle_permissions_changed_monitor.h b/services/bundlemgr/include/bundle_permissions_changed_monitor.h index ff4bb61f41..e7db5394eb 100644 --- a/services/bundlemgr/include/bundle_permissions_changed_monitor.h +++ b/services/bundlemgr/include/bundle_permissions_changed_monitor.h @@ -42,8 +42,8 @@ public: { dataMgr_ = dataMgr; } - ~BundlePermissionsChangedMonitor(){ - if(!dataMgr_){ + ~BundlePermissionsChangedMonitor() { + if(!dataMgr_) { dataMgr_.reset(); } } @@ -52,7 +52,7 @@ public: OHOS::AAFwk::Want want = data.GetWant(); std::string action = want.GetAction(); int32_t uid = data.GetCode(); - if ( dataMgr_ != nullptr && uid >=0 ) { + if (dataMgr_ != nullptr && uid >=0) { dataMgr_->NotifyPermissionsChanged(uid); } } diff --git a/services/bundlemgr/include/common_profile.h b/services/bundlemgr/include/common_profile.h index b061ba67a2..a5a659e0c8 100644 --- a/services/bundlemgr/include/common_profile.h +++ b/services/bundlemgr/include/common_profile.h @@ -221,6 +221,9 @@ const uint32_t VALUE_SEARCHBOX = 1 << 1; const std::string KEY_HOME_SCREEN = "homeScreen"; const std::string KEY_SEARCHBOX = "searchbox"; + +const std::string BUNDLE_MODULE_PROFILE_KEY_JS_TYPE_ETS = "ets"; + static std::map formEntityMap; extern thread_local int32_t parseResult; diff --git a/services/bundlemgr/include/inner_bundle_info.h b/services/bundlemgr/include/inner_bundle_info.h index 437c66faa7..de34790d82 100644 --- a/services/bundlemgr/include/inner_bundle_info.h +++ b/services/bundlemgr/include/inner_bundle_info.h @@ -114,7 +114,7 @@ enum class ArrayType { NOT_ARRAY, }; -template +template void CheckArrayType( const nlohmann::json &jsonObject, const std::string &key, dataType &data, ArrayType arrayType, int32_t &parseResult) { @@ -167,7 +167,7 @@ void CheckArrayType( } } -template +template void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail::iter_impl &end, const std::string &key, dataType &data, JsonType jsonType, bool isNecessary, int32_t &parseResult, ArrayType arrayType) diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index 31d8536dd8..f0e0dcc058 100755 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -231,7 +231,7 @@ ErrCode BaseBundleInstaller::ProcessBundleInstall( return ERR_APPEXECFWK_INSTALL_BUNDLE_MGR_SERVICE_ERROR; } auto &mtx = dataMgr_->GetBundleMutex(bundleName_); - std::lock_guard lock{mtx}; + std::lock_guard lock {mtx}; isAppExist_ = dataMgr_->GetInnerBundleInfo(bundleName_, Constants::CURRENT_DEVICE_ID, oldInfo); if (isAppExist_) { APP_LOGI("app is exist"); @@ -260,7 +260,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUninstall( return ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR; } auto &mtx = dataMgr_->GetBundleMutex(bundleName); - std::lock_guard lock{mtx}; + std::lock_guard lock {mtx}; InnerBundleInfo oldInfo; if (!dataMgr_->GetInnerBundleInfo(bundleName, Constants::CURRENT_DEVICE_ID, oldInfo)) { APP_LOGE("uninstall bundle info missing"); @@ -312,7 +312,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUninstall( return ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR; } auto &mtx = dataMgr_->GetBundleMutex(bundleName); - std::lock_guard lock{mtx}; + std::lock_guard lock {mtx}; InnerBundleInfo oldInfo; if (!dataMgr_->GetInnerBundleInfo(bundleName, Constants::CURRENT_DEVICE_ID, oldInfo)) { APP_LOGE("uninstall bundle info missing"); diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 5bccc3f5c2..9c080158d9 100755 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -751,8 +751,8 @@ bool BundleDataMgr::GetLaunchWantForBundle(const std::string &bundleName, Want & bool BundleDataMgr::CheckIsSystemAppByUid(const int uid) const { - int maxSysUid{Constants::MAX_SYS_UID}; - int baseSysUid{Constants::ROOT_UID}; + int maxSysUid {Constants::MAX_SYS_UID}; + int baseSysUid {Constants::ROOT_UID}; if (uid >= baseSysUid && uid <= maxSysUid) { return true; } @@ -1267,7 +1267,7 @@ bool BundleDataMgr::NotifyBundleStatus(const std::string &bundleName, const std: want.SetElement(element); want.SetParam(Constants::UID, uid); APP_LOGI("want.SetParam uid %{public}d", uid); - EventFwk::CommonEventData commonData{want}; + EventFwk::CommonEventData commonData {want}; EventFwk::CommonEventManager::PublishCommonEvent(commonData); return true; } @@ -1278,7 +1278,7 @@ std::mutex &BundleDataMgr::GetBundleMutex(const std::string &bundleName) auto it = bundleMutexMap_.find(bundleName); if (it == bundleMutexMap_.end()) { bundleMutex_.unlock_shared(); - std::unique_lock lock{bundleMutex_}; + std::unique_lock lock {bundleMutex_}; return bundleMutexMap_[bundleName]; } bundleMutex_.unlock_shared(); diff --git a/services/bundlemgr/src/bundle_data_storage_database.cpp b/services/bundlemgr/src/bundle_data_storage_database.cpp index 40f1012439..de0ec698cb 100644 --- a/services/bundlemgr/src/bundle_data_storage_database.cpp +++ b/services/bundlemgr/src/bundle_data_storage_database.cpp @@ -246,7 +246,11 @@ Status BundleDataStorageDatabase::GetKvStore() { Status status; Options options = { - .createIfMissing = true, .encrypt = false, .autoSync = true, .kvStoreType = KvStoreType::SINGLE_VERSION}; + .createIfMissing = true, + .encrypt = false, + .autoSync = true, + .kvStoreType = KvStoreType::SINGLE_VERSION + }; dataManager_.GetSingleKvStore( options, appId_, storeId_, [this, &status](Status paramStatus, std::unique_ptr singleKvStore) { diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index a68c60b46b..03c8fed2c3 100755 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -486,8 +486,8 @@ bool BundleMgrHostImpl::RequestPermissionFromUser( APP_LOGI("send Permissions Changed event"); BundleInfo info; bool ret_getInfo = GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, info); - APP_LOGI("ret_getInfo = %{public}d",ret_getInfo); - if ( ret && ret_getInfo) { + APP_LOGI("ret_getInfo = %{public}d", ret_getInfo); + if (ret && ret_getInfo) { Want want; want.SetAction("PERMISSIONS_CHANGED_EVENT"); EventFwk::CommonEventData commonData; @@ -516,7 +516,7 @@ bool BundleMgrHostImpl::RegisterPermissionsChanged( APP_LOGE("DataMgr is nullptr"); return false; } - return dataMgr->RegisterPermissionsChanged(uids,callback); + return dataMgr->RegisterPermissionsChanged(uids, callback); } bool BundleMgrHostImpl::UnregisterPermissionsChanged(const sptr &callback) diff --git a/services/bundlemgr/src/bundle_profile.cpp b/services/bundlemgr/src/bundle_profile.cpp index 5e6df71eeb..472576be4b 100644 --- a/services/bundlemgr/src/bundle_profile.cpp +++ b/services/bundlemgr/src/bundle_profile.cpp @@ -29,23 +29,42 @@ namespace ProfileReader { thread_local int32_t parseResult; const std::map ABILITY_TYPE_MAP = { - {"page", AbilityType::PAGE}, {"service", AbilityType::SERVICE}, {"data", AbilityType::DATA}, {"form", AbilityType::FORM}}; + {"page", AbilityType::PAGE}, + {"service", AbilityType::SERVICE}, + {"data", AbilityType::DATA}, + {"form", AbilityType::FORM} +}; const std::map DISPLAY_ORIENTATION_MAP = { {"unspecified", DisplayOrientation::UNSPECIFIED}, {"landscape", DisplayOrientation::LANDSCAPE}, {"portrait", DisplayOrientation::PORTRAIT}, - {"followrecent", DisplayOrientation::FOLLOWRECENT}}; + {"followrecent", DisplayOrientation::FOLLOWRECENT} +}; const std::map LAUNCH_MODE_MAP = { - {"singleton", LaunchMode::SINGLETON}, {"singletop", LaunchMode::SINGLETOP}, {"standard", LaunchMode::STANDARD}}; -const std::map dimensionMap = {{"1*2", 1}, {"2*2", 2}, {"2*4", 3}, {"4*4", 4}}; -const std::map formTypeMap = {{"JS", FormType::JS}, {"Java", FormType::JAVA}}; + {"singleton", LaunchMode::SINGLETON}, + {"singletop", LaunchMode::SINGLETOP}, + {"standard", LaunchMode::STANDARD} +}; +const std::map dimensionMap = { + {"1*2", 1}, + {"2*2", 2}, + {"2*4", 3}, + {"4*4", 4} +}; +const std::map formTypeMap = { + {"JS", FormType::JS}, + {"Java", FormType::JAVA} +}; const std::map moduleColorMode = { {"auto", ModuleColorMode::AUTO}, {"dark", ModuleColorMode::DARK}, {"light", ModuleColorMode::LIGHT}, }; const std::map formColorModeMap = { - {"auto", FormsColorMode::AUTO_MODE}, {"dark", FormsColorMode::DARK_MODE}, {"light", FormsColorMode::LIGHT_MODE}}; + {"auto", FormsColorMode::AUTO_MODE}, + {"dark", FormsColorMode::DARK_MODE}, + {"light", FormsColorMode::LIGHT_MODE} +}; struct Version { int32_t code = 0; @@ -1916,8 +1935,10 @@ bool TransformToInfo( abilityInfo.kind = ability.type; abilityInfo.srcPath = ability.srcPath; abilityInfo.srcLanguage = ability.srcLanguage; - std::transform(abilityInfo.srcLanguage.begin(), abilityInfo.srcLanguage.end(), abilityInfo.srcLanguage.begin(), ::tolower); - if (abilityInfo.srcLanguage != ProfileReader::BUNDLE_MODULE_PROFILE_KEY_JS) { + std::transform( + abilityInfo.srcLanguage.begin(), abilityInfo.srcLanguage.end(), abilityInfo.srcLanguage.begin(), ::tolower); + if (abilityInfo.srcLanguage != ProfileReader::BUNDLE_MODULE_PROFILE_KEY_JS && + abilityInfo.srcLanguage != ProfileReader::BUNDLE_MODULE_PROFILE_KEY_JS_TYPE_ETS) { abilityInfo.isNativeAbility = true; } auto iterType = std::find_if(std::begin(ProfileReader::ABILITY_TYPE_MAP), @@ -1971,7 +1992,7 @@ bool TransformToInfo( abilityInfo.minFormWidth = ability.form.minWidth; abilityInfo.defaultFormWidth = ability.form.defaultWidth; GetMetaData(abilityInfo.metaData, ability.metaData); - abilityInfo.formEnabled = ability.formEnabled; + abilityInfo.formEnabled = ability.formsEnabled; return true; } diff --git a/services/bundlemgr/src/bundle_util.cpp b/services/bundlemgr/src/bundle_util.cpp index 9dd08b4590..e9e2476ed1 100644 --- a/services/bundlemgr/src/bundle_util.cpp +++ b/services/bundlemgr/src/bundle_util.cpp @@ -44,7 +44,7 @@ ErrCode BundleUtil::CheckFilePath(const std::string &bundlePath, std::string &re APP_LOGE("can not access the bundle file path: %{private}s", realPath.c_str()); return ERR_APPEXECFWK_INSTALL_INVALID_BUNDLE_FILE; } - if(!CheckFileSize(realPath, Constants::MAX_HAP_SIZE)) { + if (!CheckFileSize(realPath, Constants::MAX_HAP_SIZE)) { APP_LOGE("file size is larger than max size Max size is: %{public}d", Constants::MAX_HAP_SIZE); return ERR_APPEXECFWK_INSTALL_INVALID_HAP_SIZE; } @@ -84,10 +84,10 @@ bool BundleUtil::CheckFileName(const std::string &fileName) bool BundleUtil::CheckFileSize(const std::string &bundlePath, const int32_t fileSize) { struct stat fileInfo = { 0 }; - if (stat(bundlePath.c_str(), &fileInfo) != 0) { + if (stat(bundlePath.c_str(), &fileInfo) != 0) { APP_LOGE("call stat error"); - return false; - } + return false; + } if (fileInfo.st_size > fileSize) { return false; } diff --git a/services/bundlemgr/src/inner_bundle_info.cpp b/services/bundlemgr/src/inner_bundle_info.cpp index 7d66d2a402..787ac25d6e 100644 --- a/services/bundlemgr/src/inner_bundle_info.cpp +++ b/services/bundlemgr/src/inner_bundle_info.cpp @@ -703,7 +703,7 @@ int32_t InnerBundleInfo::FromJson(const nlohmann::json &jsonObject) true, ProfileReader::parseResult, ArrayType::NOT_ARRAY); - GetValueIfFindKey>(jsonObject, + GetValueIfFindKey>(jsonObject, jsonObjectEnd, MODULE_SHORTCUT, shortcutInfos_, @@ -1026,26 +1026,26 @@ void InnerBundleInfo::GetFormsInfoByModule(const std::string &moduleName, std::v for (const auto &data : formInfos_) { for (auto &form : data.second) { if (form.moduleName == moduleName) { - formInfos.emplace_back(form); + formInfos.emplace_back(form); } } - } + } } void InnerBundleInfo::GetFormsInfoByApp(std::vector &formInfos) const { for (const auto &data : formInfos_) { for (auto &form : data.second) { - formInfos.emplace_back(form); + formInfos.emplace_back(form); } - } + } } void InnerBundleInfo::GetShortcutInfos(std::vector &shortcutInfos) const { for (const auto &shortcut : shortcutInfos_) { shortcutInfos.emplace_back(shortcut.second); - } + } } std::optional InnerBundleInfo::GetInnerModuleInfoByModuleName(const std::string &moduleName) const diff --git a/services/bundlemgr/src/module_usage_data_storage.cpp b/services/bundlemgr/src/module_usage_data_storage.cpp index 40787115fe..060cea4451 100644 --- a/services/bundlemgr/src/module_usage_data_storage.cpp +++ b/services/bundlemgr/src/module_usage_data_storage.cpp @@ -319,7 +319,11 @@ Status ModuleUsageRecordStorage::GetKvStore() { Status status; Options options = { - .createIfMissing = true, .encrypt = false, .autoSync = true, .kvStoreType = KvStoreType::SINGLE_VERSION}; + .createIfMissing = true, + .encrypt = false, + .autoSync = true, + .kvStoreType = KvStoreType::SINGLE_VERSION + }; options.schema = SCHEMA_DEFINE; dataManager_.GetSingleKvStore( diff --git a/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp index 934053a40a..eddeb1af06 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp @@ -30,7 +30,7 @@ using namespace OHOS::AppExecFwk; using namespace OHOS::AppExecFwk::JsonConstants; namespace { -const std::string NORMAL_BUNDLE_NAME{"com.example.test"}; +const std::string NORMAL_BUNDLE_NAME {"com.example.test"}; } // namespace class BmsBundleDataStorageDatabaseTest : public testing::Test { diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp index bc05fcb44d..967887d6b1 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp @@ -246,10 +246,26 @@ void BmsBundleKitServiceTest::MockInstallBundle( moduleInfo.description = BUNDLE_DESCRIPTION; moduleInfo.colorMode = COLOR_MODE; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; FormInfo form = MockFormInfo(bundleName, moduleName, abilityName); @@ -262,8 +278,15 @@ void BmsBundleKitServiceTest::MockInstallBundle( innerBundleInfo.SetUid((bundleName == BUNDLE_NAME_TEST) ? TEST_UID : DEMO_UID); // for launch ability if (bundleName == BUNDLE_NAME_TEST) { - AppExecFwk::SkillUri uri{URI_SCHEME, URI_HOST}; - Skill skill{{ACTION}, {ENTITY}, {uri}}; + AppExecFwk::SkillUri uri { + URI_SCHEME, + URI_HOST + }; + Skill skill { + {ACTION}, + {ENTITY}, + {uri} + }; std::vector skills; skills.emplace_back(skill); innerBundleInfo.SetMainAbility(keyName); @@ -384,10 +407,26 @@ AbilityInfo BmsBundleKitServiceTest::MockAbilityInfo( abilityInfo.enabled = true; abilityInfo.supportPipMode = false; abilityInfo.targetAbility = TARGET_ABILITY; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; abilityInfo.metaData = metaData; return abilityInfo; } diff --git a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp index 8f1aa7514c..f00af36b41 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp @@ -82,8 +82,8 @@ const nlohmann::json CONFIG_JSON = R"( "icon": "$media:icon", "intents": [ { - "targetBundle": "com.huawei.hiworld.himusic", - "targetClass": "com.huawei.hiworld.himusic.entry.MainAbility" + "targetBundle": "com.demo.hiworld.himusic", + "targetClass": "com.demo.hiworld.himusic.entry.MainAbility" } ] } diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp index a0046249e0..e0e103aabe 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_test/bms_bundle_permission_test.cpp @@ -165,13 +165,15 @@ const DefPermission DEFPERMISSION_MUSIC = { .description = DEF_LABEL1, .descriptionId = 1 }; -const DefPermission DEFPERMISSION_APP = {.name = DEFPERMISSION_NAME_APP, +const DefPermission DEFPERMISSION_APP = { + .name = DEFPERMISSION_NAME_APP, .grantMode = "system_grant", .availableScope = {""}, .label = DEF_LABEL1, .labelId = 1, .description = DEF_LABEL1, - .descriptionId = 1}; + .descriptionId = 1 +}; const DefPermission DEFPERMISSION_WECHAT = { .name = DEFPERMISSION_NAME_WECHAT, .grantMode = "system_grant", @@ -417,10 +419,26 @@ void BmsBundlePermissionTest::MockDefPermissionBundleSystemGrant(InnerBundleInfo moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -461,10 +479,26 @@ void BmsBundlePermissionTest::MockUpdateDefPermissionBundleSystemGrant(InnerBund moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -505,10 +539,26 @@ void BmsBundlePermissionTest::MockDefPermissionBundleTestReqpermission(InnerBund moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -548,10 +598,26 @@ void BmsBundlePermissionTest::MockNoDefPermissionBundle(InnerBundleInfo &innerbu moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -592,10 +658,26 @@ void BmsBundlePermissionTest::MockNoAvailableScopeDefPermissionBundle(InnerBundl moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -641,10 +723,26 @@ void BmsBundlePermissionTest::MockDefPermissionBundleUserGrant(InnerBundleInfo & moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -686,10 +784,26 @@ void BmsBundlePermissionTest::MockSameDefPermissionNameBundleSystemGrant(InnerBu moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -730,10 +844,26 @@ void BmsBundlePermissionTest::MockDefPermissionBundleSame(InnerBundleInfo &inner moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -775,10 +905,26 @@ void BmsBundlePermissionTest::MockReqPermissionBundle(InnerBundleInfo &innerbund moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); @@ -819,10 +965,26 @@ void BmsBundlePermissionTest::MockOtherReqPermissionBundle(InnerBundleInfo &inne moduleInfo.moduleName = PACKAGE_NAME; moduleInfo.description = BUNDLE_DESCRIPTION; - AppExecFwk::Parameters parameters{"description", "name", "type"}; - AppExecFwk::Results results{"description", "name", "type"}; - AppExecFwk::CustomizeData customizeData{"name", "value", "extra"}; - MetaData metaData{{parameters}, {results}, {customizeData}}; + AppExecFwk::Parameters parameters { + "description", + "name", + "type" + }; + AppExecFwk::Results results { + "description", + "name", + "type" + }; + AppExecFwk::CustomizeData customizeData { + "name", + "value", + "extra" + }; + MetaData metaData { + {parameters}, + {results}, + {customizeData} + }; moduleInfo.metaData = metaData; innerbundleinfo.SetCurrentModulePackage(PACKAGE_NAME); innerbundleinfo.SetBaseApplicationInfo(appInfo); diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp index 4de4e6cd59..3ab3580bd5 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/bms_bundle_uninstaller_test.cpp @@ -296,11 +296,11 @@ void BmsBundleUninstallerTest::ClearBundleInfoInDb() return; } auto dataMgt = bundleMgrService_->GetDataMgr(); - if(dataMgt == nullptr) { + if (dataMgt == nullptr) { return; } auto dataStorage = dataMgt->GetDataStorage(); - if(dataStorage == nullptr) { + if (dataStorage == nullptr) { return; } InnerBundleInfo innerBundleInfo; diff --git a/services/bundlemgr/test/unittest/bms_service_startup_test/bms_service_startup_test.cpp b/services/bundlemgr/test/unittest/bms_service_startup_test/bms_service_startup_test.cpp index 5605132d41..3ea0d14f35 100755 --- a/services/bundlemgr/test/unittest/bms_service_startup_test/bms_service_startup_test.cpp +++ b/services/bundlemgr/test/unittest/bms_service_startup_test/bms_service_startup_test.cpp @@ -67,7 +67,7 @@ HWTEST_F(BmsServiceStartupTest, Startup_0100, Function | SmallTest | Level0) * @tc.desc: 1. the service is already initialized * 2. the initialized BMS service can be stopped */ -HWTEST_F(BmsServiceStartupTest, Startup_0200,Function | SmallTest | Level0) +HWTEST_F(BmsServiceStartupTest, Startup_0200, Function | SmallTest | Level0) { std::shared_ptr bms = DelayedSingleton::GetInstance(); bms->OnStart(); @@ -84,7 +84,7 @@ HWTEST_F(BmsServiceStartupTest, Startup_0200,Function | SmallTest | Level0) * @tc.desc: 1. the service is already initialized * 2. the stopped BMS service can be restarted */ -HWTEST_F(BmsServiceStartupTest, Startup_0300,Function | SmallTest | Level0) +HWTEST_F(BmsServiceStartupTest, Startup_0300, Function | SmallTest | Level0) { std::shared_ptr bms = DelayedSingleton::GetInstance(); bms->OnStart(); @@ -104,7 +104,7 @@ HWTEST_F(BmsServiceStartupTest, Startup_0300,Function | SmallTest | Level0) * @tc.desc: 1. the service is already initialized * 2. the recall start function will not affect the initialized BMS service */ -HWTEST_F(BmsServiceStartupTest, Startup_0400,Function | SmallTest | Level0) +HWTEST_F(BmsServiceStartupTest, Startup_0400, Function | SmallTest | Level0) { std::shared_ptr bms = DelayedSingleton::GetInstance(); bms->OnStart(); @@ -121,7 +121,7 @@ HWTEST_F(BmsServiceStartupTest, Startup_0400,Function | SmallTest | Level0) * @tc.desc: 1. the service is already initialized * 2. the dataMgr can be obtained */ -HWTEST_F(BmsServiceStartupTest, GetDataMgr_0100,Function | SmallTest | Level0) +HWTEST_F(BmsServiceStartupTest, GetDataMgr_0100, Function | SmallTest | Level0) { std::shared_ptr bms = DelayedSingleton::GetInstance(); bms->OnStart(); @@ -136,7 +136,7 @@ HWTEST_F(BmsServiceStartupTest, GetDataMgr_0100,Function | SmallTest | Level0) * @tc.desc: 1. the service is already initialized * 2. the installer can be obtained */ -HWTEST_F(BmsServiceStartupTest, GetBundleInstaller_0100,Function | SmallTest | Level0) +HWTEST_F(BmsServiceStartupTest, GetBundleInstaller_0100, Function | SmallTest | Level0) { std::shared_ptr bms = DelayedSingleton::GetInstance(); bms->OnStart(); diff --git a/services/formmgr/src/form_mgr_service.cpp b/services/formmgr/src/form_mgr_service.cpp index 8f25249579..7fb4a8e61f 100644 --- a/services/formmgr/src/form_mgr_service.cpp +++ b/services/formmgr/src/form_mgr_service.cpp @@ -351,7 +351,26 @@ ErrCode FormMgrService::Init() */ bool FormMgrService::CheckFormPermission() { - return true; + sptr iBundleMgr = FormBmsHelper::GetInstance().GetBundleMgr(); + if (iBundleMgr == nullptr) { + APP_LOGE("%{public}s, failed to get IBundleMgr.", __func__); + return false; + } + + int32_t uid = IPCSkeleton::GetCallingUid(); + if (!iBundleMgr->CheckIsSystemAppByUid(uid)) { + APP_LOGE("%{public}s fail, form is not system app. uid:%{public}d", __func__, uid); + return false; + } + + std::string bundleName; + bool result = iBundleMgr->GetBundleNameForUid(uid, bundleName); + if (!result || bundleName.empty()) { + APP_LOGE("%{public}s failed, cannot get bundle name by uid:%{public}d", __func__, uid); + return false; + } + + return CheckFormPermission(bundleName); } bool FormMgrService::CheckFormPermission(const std::string &bundleName) const diff --git a/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp b/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp index c268af9bdf..15e0e9b4bc 100755 --- a/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp +++ b/services/test/moduletest/common/ams/app_life_cycle_test/ams_app_life_cycle_module_test.cpp @@ -44,10 +44,12 @@ const int32_t INDEX_NUM_100 = 100; const int32_t INDEX_NUM_MAX = 100; const std::string TEST_APP_NAME = "test_app_"; const std::string TEST_ABILITY_NAME = "test_ability_"; -#define CHECK_POINTER_IS_NULLPTR(object) \ - if (object == nullptr) { \ - return; \ - } +#define CHECK_POINTER_IS_NULLPTR(object) \ + do { \ + if (object == nullptr) { \ + return; \ + } \ + } while (0) } // namespace namespace OHOS { diff --git a/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp b/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp index b0287ef45e..b17f871fe2 100644 --- a/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp +++ b/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp @@ -711,7 +711,7 @@ HWTEST_F(BmsCompatibleSystemTest, BMS_QueryAbilityInfoByUri_0200, Function | Med HWTEST_F(BmsCompatibleSystemTest, BMS_QueryAbilityInfoByUri_0300, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "START BMS_QueryAbilityInfoByUri_0300"; - std::string abilityUri = "err://com.huawei.demo.weatherfa.UserADataAbility"; + std::string abilityUri = "err://com.test.demo.weatherfa.UserADataAbility"; AbilityInfo abilityInfo; sptr bundleMgrProxy = GetBundleMgrProxy(); if (!bundleMgrProxy) { -- Gitee