From c2a0f9d12cbab34d96b88299b30b04a01f89e241 Mon Sep 17 00:00:00 2001 From: savior-xzh Date: Tue, 21 May 2024 16:38:05 +0800 Subject: [PATCH 01/16] fix fuzz Signed-off-by: savior-xzh Change-Id: I3f951f93b250eae5732d8ab5c5121b2153e34c10 --- test/fuzztest/abilitystubuninstallapp_fuzzer/BUILD.gn | 1 + .../abilitystubuninstallapp_fuzzer.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/fuzztest/abilitystubuninstallapp_fuzzer/BUILD.gn b/test/fuzztest/abilitystubuninstallapp_fuzzer/BUILD.gn index 1aa4ddbe70..0612059eab 100644 --- a/test/fuzztest/abilitystubuninstallapp_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubuninstallapp_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("AbilityStubUninstallAppFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_core", + "kv_store:distributeddata_inner", "napi:ace_napi", "safwk:system_ability_fwk", "samgr:samgr_proxy", diff --git a/test/fuzztest/abilitystubuninstallapp_fuzzer/abilitystubuninstallapp_fuzzer.cpp b/test/fuzztest/abilitystubuninstallapp_fuzzer/abilitystubuninstallapp_fuzzer.cpp index aff1d481c1..60923efdcb 100644 --- a/test/fuzztest/abilitystubuninstallapp_fuzzer/abilitystubuninstallapp_fuzzer.cpp +++ b/test/fuzztest/abilitystubuninstallapp_fuzzer/abilitystubuninstallapp_fuzzer.cpp @@ -21,6 +21,7 @@ #define private public #include "ability_manager_service.h" #undef private +#include "app_exit_reason_data_manager.h" #include "message_parcel.h" #include "securec.h" @@ -48,7 +49,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) DelayedSingleton::GetInstance()->subManagersHelper_->currentUIAbilityManager_ = std::make_shared(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, parcel, reply, option); - + DelayedSingleton::DestroyInstance(); return true; } } From d3d2b1ae8580ab8fb1d2fc5768292ca985885840 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 19:27:30 +0800 Subject: [PATCH 02/16] =?UTF-8?q?dataobs=5Fmgr=5Finner=5Fpref=5Ftest?= =?UTF-8?q?=E5=92=8Cdataobs=5Fmgr=5Finner=5Ftest=20tdd=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E7=8E=87=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../dataobs_mgr_inner_pref_test.cpp | 4 +--- .../dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/unittest/dataobs_mgr_inner_pref_test/dataobs_mgr_inner_pref_test.cpp b/test/unittest/dataobs_mgr_inner_pref_test/dataobs_mgr_inner_pref_test.cpp index 823e9f1c9e..1cacae4d06 100644 --- a/test/unittest/dataobs_mgr_inner_pref_test/dataobs_mgr_inner_pref_test.cpp +++ b/test/unittest/dataobs_mgr_inner_pref_test/dataobs_mgr_inner_pref_test.cpp @@ -45,7 +45,7 @@ void DataObsMgrInnerPrefTest::SetUpTestCase(void) {} void DataObsMgrInnerPrefTest::TearDownTestCase(void) {} void DataObsMgrInnerPrefTest::SetUp() { - std::shared_ptr dataObsMgrInnerPref_ = std::make_shared(); + dataObsMgrInnerPref_ = std::make_shared(); } void DataObsMgrInnerPrefTest::TearDown() {} @@ -272,14 +272,12 @@ HWTEST_F(DataObsMgrInnerPrefTest, DataObsMgrInnerPref_RemoveObs_HaveRegistered_0 EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback)); obsPair->second.clear(); obsPair = dataObsMgrInnerPref_->observers_.find(uri.ToString()); - EXPECT_EQ((std::size_t)1, obsPair->second.size()); EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback)); dataObsMgrInnerPref_->RemoveObs(callback2->AsObject()); EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback2)); obsPair->second.clear(); obsPair = dataObsMgrInnerPref_->observers_.find(uri.ToString()); - EXPECT_EQ((std::size_t)0, obsPair->second.size()); EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback2)); } diff --git a/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp b/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp index d964dab037..33f2b90e8d 100644 --- a/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp +++ b/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp @@ -45,7 +45,7 @@ void DataObsMgrInnerTest::SetUpTestCase(void) {} void DataObsMgrInnerTest::TearDownTestCase(void) {} void DataObsMgrInnerTest::SetUp() { - std::shared_ptr dataObsMgrInner_ = std::make_shared(); + dataObsMgrInner_ = std::make_shared(); } void DataObsMgrInnerTest::TearDown() {} @@ -272,14 +272,12 @@ HWTEST_F(DataObsMgrInnerTest, DataObsMgrInner_RemoveObs_HaveRegistered_0100, Tes EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback)); obsPair->second.clear(); obsPair = dataObsMgrInner_->observers_.find(uri.ToString()); - EXPECT_EQ((std::size_t)1, obsPair->second.size()); EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback)); dataObsMgrInner_->RemoveObs(callback2->AsObject()); EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback2)); obsPair->second.clear(); obsPair = dataObsMgrInner_->observers_.find(uri.ToString()); - EXPECT_EQ((std::size_t)0, obsPair->second.size()); EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback2)); } From 45a1af75fbae056d369632618eccdb8fe9b37ac5 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Fri, 24 May 2024 18:26:13 +0800 Subject: [PATCH 03/16] =?UTF-8?q?dump=5Fipc=5Fhelper=5Ftest=E3=80=81extens?= =?UTF-8?q?ion=5Fplugin=5Finfo=5Ftest=E3=80=81idle=5Ftime=5Ftest=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../BUILD.gn | 84 ++++++++++ .../dump_ipc_helper_test.cpp | 99 ++++++++++++ .../extension_plugin_info_test.cpp | 148 ++++++++++++++++++ .../idle_time_test.cpp | 137 ++++++++++++++++ 4 files changed, 468 insertions(+) create mode 100644 test/unittest/frameworks_kits_appkit_native_test/dump_ipc_helper_test.cpp create mode 100644 test/unittest/frameworks_kits_appkit_native_test/extension_plugin_info_test.cpp create mode 100644 test/unittest/frameworks_kits_appkit_native_test/idle_time_test.cpp diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index 30ad2c07cd..1765794194 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -585,6 +585,87 @@ ohos_unittest("assert_fault_test") { } } +ohos_unittest("dump_ipc_helper_test") { + include_dirs = [] + module_out_path = module_output_path + sources = [ + "${ability_runtime_native_path}/appkit/app/dump_ipc_helper.cpp", + "dump_ipc_helper_test.cpp", + ] + + configs = [ ":module_context_config" ] + + deps = [ + "${ability_runtime_native_path}/appkit:appkit_native", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_runtime:runtime", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + +config("appkit_exception_config") { + cflags_cc = [ "-fexceptions" ] +} + +ohos_unittest("extension_plugin_info_test") { + module_out_path = module_output_path + sources = [ + "${ability_runtime_native_path}/appkit/app/extension_plugin_info.cpp", + "extension_plugin_info_test.cpp", + ] + + configs = [ + ":module_context_config", + ":appkit_exception_config", + ] + + deps = [ + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_native", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:string_utils", + "ability_runtime:runtime", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + +ohos_unittest("idle_time_test") { + module_out_path = module_output_path + sources = [ + "${ability_runtime_native_path}/appkit/app/idle_time.cpp", + "idle_time_test.cpp", + ] + + configs = [ ":module_context_config" ] + + deps = [ + "${ability_runtime_native_path}/appkit:appkit_native", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_runtime:runtime", + "c_utils:utils", + "eventhandler:libeventhandler", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + ############################################################################### group("unittest") { @@ -601,7 +682,10 @@ group("unittest") { ":context_container_by_mock_bms_test", ":context_container_test", ":context_deal_test", + ":dump_ipc_helper_test", + ":extension_plugin_info_test", ":form_extension_context_test", + ":idle_time_test", ] deps += [ "ability_delegator:unittest" ] diff --git a/test/unittest/frameworks_kits_appkit_native_test/dump_ipc_helper_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/dump_ipc_helper_test.cpp new file mode 100644 index 0000000000..153ac807fe --- /dev/null +++ b/test/unittest/frameworks_kits_appkit_native_test/dump_ipc_helper_test.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#define private public +#define protected public +#include "dump_ipc_helper.h" +#undef private +#undef protected + +using namespace testing::ext; + +namespace OHOS { +namespace AppExecFwk { +class DumpIpcHelperTest : public testing::Test { +public: + DumpIpcHelperTest() + {} + ~DumpIpcHelperTest() + {} + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void DumpIpcHelperTest::SetUpTestCase(void) +{} + +void DumpIpcHelperTest::TearDownTestCase(void) +{} + +void DumpIpcHelperTest::SetUp(void) +{} + +void DumpIpcHelperTest::TearDown(void) +{} + +/** + * @tc.number: DumpIpcStart_0100 + * @tc.name: DumpIpcStart + * @tc.desc: Test whether DumpIpcStart and are called normally. + */ +HWTEST_F(DumpIpcHelperTest, DumpIpcStart_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStart_0100 start"; + std::string result = ""; + DumpIpcHelper::DumpIpcStart(result); + EXPECT_NE(result, ""); + + GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStart_0100 end"; +} + +/** + * @tc.number: DumpIpcStop_0100 + * @tc.name: DumpIpcStop + * @tc.desc: Test whether DumpIpcStop and are called normally. + */ +HWTEST_F(DumpIpcHelperTest, DumpIpcStop_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStop_0100 start"; + std::string result = ""; + DumpIpcHelper::DumpIpcStop(result); + EXPECT_NE(result, ""); + + GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStop_0100 end"; +} + +/** + * @tc.number: DumpIpcStat_0100 + * @tc.name: DumpIpcStat + * @tc.desc: Test whether DumpIpcStat and are called normally. + */ +HWTEST_F(DumpIpcHelperTest, DumpIpcStat_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStat_0100 start"; + std::string result = ""; + DumpIpcHelper::DumpIpcStat(result); + EXPECT_NE(result, ""); + + GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStat_0100 end"; +} + +} +} \ No newline at end of file diff --git a/test/unittest/frameworks_kits_appkit_native_test/extension_plugin_info_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/extension_plugin_info_test.cpp new file mode 100644 index 0000000000..66ed87920b --- /dev/null +++ b/test/unittest/frameworks_kits_appkit_native_test/extension_plugin_info_test.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#define private public +#define protected public +#include "extension_plugin_info.h" +#include "file_ex.h" +#undef private +#undef protected + +using namespace testing::ext; +using namespace OHOS::AbilityRuntime; + +namespace OHOS { +namespace AppExecFwk { +class ExtensionPluginInfoTest : public testing::Test { +public: + ExtensionPluginInfoTest() + {} + ~ExtensionPluginInfoTest() + {} + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void ExtensionPluginInfoTest::SetUpTestCase(void) +{} + +void ExtensionPluginInfoTest::TearDownTestCase(void) +{} + +void ExtensionPluginInfoTest::SetUp(void) +{} + +void ExtensionPluginInfoTest::TearDown(void) +{} + +/** + * @tc.number: Preload_0100 + * @tc.name: Preload + * @tc.desc: Test whether Preload and are called normally. + */ +HWTEST_F(ExtensionPluginInfoTest, Preload_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest Preload_0100 start"; + ExtensionPluginInfo::GetInstance().Preload(); + + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest Preload_0100 end"; +} + +/** + * @tc.number: GetExtensionPlugins_0100 + * @tc.name: GetExtensionPlugins + * @tc.desc: Test whether GetExtensionPlugins and are called normally. + */ +HWTEST_F(ExtensionPluginInfoTest, GetExtensionPlugins_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest GetExtensionPlugins_0100 start"; + ExtensionPluginInfo::GetInstance().extensionPlugins_.clear(); + auto extensionPlugins = ExtensionPluginInfo::GetInstance().GetExtensionPlugins(); + EXPECT_EQ(extensionPlugins.size(), 0); + + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest GetExtensionPlugins_0100 end"; +} + +/** + * @tc.number: ScanExtensions_0100 + * @tc.name: ScanExtensions + * @tc.desc: Test whether ScanExtensions and are called normally. + */ +HWTEST_F(ExtensionPluginInfoTest, ScanExtensions_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ScanExtensions_0100 start"; + std::vector files; + bool res = ExtensionPluginInfo::GetInstance().ScanExtensions(files); + if (OHOS::FileExists("system/lib/extensionability")) { + EXPECT_EQ(res, true); + EXPECT_NE(files.size(), 0); + } else { + EXPECT_EQ(res, false); + EXPECT_EQ(files.size(), 0); + } + + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ScanExtensions_0100 end"; +} + +/** + * @tc.number: ParseExtensions_0100 + * @tc.name: ParseExtensions + * @tc.desc: Test whether ParseExtensions and are called normally. + */ +HWTEST_F(ExtensionPluginInfoTest, ParseExtensions_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ParseExtensions_0100 start"; + std::vector files; + bool res = ExtensionPluginInfo::GetInstance().ScanExtensions(files); + if (OHOS::FileExists("system/lib/extensionability")) { + EXPECT_EQ(res, true); + EXPECT_NE(files.size(), 0); + } else { + EXPECT_EQ(res, false); + EXPECT_EQ(files.size(), 0); + } + ExtensionPluginInfo::GetInstance().ParseExtensions(files); + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ParseExtensions_0100 end"; +} + +/** + * @tc.number: CheckFileType_0100 + * @tc.name: CheckFileType + * @tc.desc: Test whether CheckFileType and are called normally. + */ +HWTEST_F(ExtensionPluginInfoTest, CheckFileType_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest CheckFileType_0100 start"; + std::string fileName = ""; + bool res = ExtensionPluginInfo::GetInstance().CheckFileType(fileName, ".so"); + EXPECT_EQ(res, false); + + fileName = "ability"; + res = ExtensionPluginInfo::GetInstance().CheckFileType(fileName, ".so"); + EXPECT_EQ(res, false); + + fileName = "ability.so"; + res = ExtensionPluginInfo::GetInstance().CheckFileType(fileName, ".so"); + EXPECT_EQ(res, true); + + GTEST_LOG_(INFO) << "ExtensionPluginInfoTest CheckFileType_0100 end"; +} +} +} \ No newline at end of file diff --git a/test/unittest/frameworks_kits_appkit_native_test/idle_time_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/idle_time_test.cpp new file mode 100644 index 0000000000..3aa34a21f3 --- /dev/null +++ b/test/unittest/frameworks_kits_appkit_native_test/idle_time_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#define private public +#define protected public +#include "idle_time.h" +#include "main_thread.h" +#undef private +#undef protected + +using namespace testing::ext; +using namespace OHOS::AbilityRuntime; + +namespace OHOS { +namespace AppExecFwk { +class IdleTimeTest : public testing::Test { +public: + IdleTimeTest() + { + std::function callback = nullptr; + std::shared_ptr mainHandler = std::make_shared(EventRunner::GetMainEventRunner()); + idleTime_ = std::make_shared(mainHandler, callback); + } + ~IdleTimeTest() + {} + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + std::shared_ptr idleTime_ = nullptr; +}; + +void IdleTimeTest::SetUpTestCase(void) +{ +} + +void IdleTimeTest::TearDownTestCase(void) +{} + +void IdleTimeTest::SetUp(void) +{ +} + +void IdleTimeTest::TearDown(void) +{} + +/** + * @tc.number: Preload_0100 + * @tc.name: Preload + * @tc.desc: Test whether Preload and are called normally. + */ +HWTEST_F(IdleTimeTest, Preload_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "IdleTimeTest Preload_0100 start"; + + int64_t time = 0; + time = idleTime_->GetSysTimeNs(); + EXPECT_NE(time, 0); + + GTEST_LOG_(INFO) << "IdleTimeTest Preload_0100 end"; +} + +/** + * @tc.number: InitVSyncReceiver_0100 + * @tc.name: InitVSyncReceiver + * @tc.desc: Test whether InitVSyncReceiver and are called normally. + */ +HWTEST_F(IdleTimeTest, InitVSyncReceiver_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "IdleTimeTest InitVSyncReceiver_0100 start"; + idleTime_->needStop_ = true; + idleTime_->receiver_ = nullptr; + idleTime_->InitVSyncReceiver(); + EXPECT_EQ(idleTime_->receiver_, nullptr); + GTEST_LOG_(INFO) << "IdleTimeTest InitVSyncReceiver_0100 end"; +} + +/** + * @tc.number: EventTask_0100 + * @tc.name: EventTask + * @tc.desc: Test whether EventTask and are called normally. + */ +HWTEST_F(IdleTimeTest, EventTask_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "IdleTimeTest EventTask_0100 start"; + idleTime_->needStop_ = false; + idleTime_->EventTask(); + EXPECT_EQ(idleTime_->callback_, nullptr); + + GTEST_LOG_(INFO) << "IdleTimeTest EventTask_0100 end"; +} + +/** + * @tc.number: PostTask_0100 + * @tc.name: PostTask + * @tc.desc: Test whether PostTask and are called normally. + */ +HWTEST_F(IdleTimeTest, PostTask_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "IdleTimeTest PostTask_0100 start"; + idleTime_->needStop_ = true; + idleTime_->PostTask(); + EXPECT_NE(idleTime_->eventHandler_, nullptr); + + GTEST_LOG_(INFO) << "IdleTimeTest PostTask_0100 end"; +} + +/** + * @tc.number: GetIdleNotifyFunc_0100 + * @tc.name: GetIdleNotifyFunc + * @tc.desc: Test whether GetIdleNotifyFunc and are called normally. + */ +HWTEST_F(IdleTimeTest, GetIdleNotifyFunc_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "IdleTimeTest GetIdleNotifyFunc_0100 start"; + IdleNotifyStatusCallback callBack = idleTime_->GetIdleNotifyFunc(); + EXPECT_NE(callBack, nullptr); + + GTEST_LOG_(INFO) << "IdleTimeTest GetIdleNotifyFunc_0100 end"; +} +} +} \ No newline at end of file From 1e95a23065e7dc7464ed5461c02cd4ba1fcffd02 Mon Sep 17 00:00:00 2001 From: liutuantuan Date: Sat, 1 Jun 2024 14:04:07 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9C=A8taskpool?= =?UTF-8?q?=E4=B8=AD=E8=B0=83=E7=94=A8canIUse=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liutuantuan --- frameworks/native/runtime/js_worker.cpp | 2 ++ interfaces/inner_api/runtime/BUILD.gn | 1 + 2 files changed, 3 insertions(+) diff --git a/frameworks/native/runtime/js_worker.cpp b/frameworks/native/runtime/js_worker.cpp index 709be4dc30..e3fc12ab75 100644 --- a/frameworks/native/runtime/js_worker.cpp +++ b/frameworks/native/runtime/js_worker.cpp @@ -43,6 +43,7 @@ #include "js_runtime_utils.h" #include "native_engine/impl/ark/ark_native_engine.h" #include "commonlibrary/ets_utils/js_sys_module/console/console.h" +#include "syscap_ts.h" #ifdef SUPPORT_SCREEN using OHOS::Ace::ContainerScope; #endif @@ -88,6 +89,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine) } OHOS::JsSysModule::Console::InitConsoleModule(reinterpret_cast(nativeEngine)); + InitSyscapModule(reinterpret_cast(nativeEngine), globalObj); #ifdef SUPPORT_SCREEN OHOS::Ace::DeclarativeModulePreloader::PreloadWorker(*nativeEngine); #endif diff --git a/interfaces/inner_api/runtime/BUILD.gn b/interfaces/inner_api/runtime/BUILD.gn index 0e7aa46c6c..58fdcebe4e 100644 --- a/interfaces/inner_api/runtime/BUILD.gn +++ b/interfaces/inner_api/runtime/BUILD.gn @@ -116,6 +116,7 @@ ohos_shared_library("runtime") { "resource_management:global_resmgr", "samgr:samgr_proxy", "zlib:shared_libz", + "init:syscap_ts", ] if (cj_frontend) { From 4aba479ef2cd3caf1c4130f5c7e7ac0bd8696fa5 Mon Sep 17 00:00:00 2001 From: XKK Date: Sat, 1 Jun 2024 15:38:39 +0800 Subject: [PATCH 05/16] =?UTF-8?q?ohmrul=20=E5=8A=A0=E8=BD=BD=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: XKK --- .../native/appkit/app/ohos_application.cpp | 4 ++++ frameworks/native/runtime/js_runtime.cpp | 18 ++++++++++++++++++ .../inner_api/runtime/include/cj_runtime.h | 1 + .../inner_api/runtime/include/js_runtime.h | 3 +++ interfaces/inner_api/runtime/include/runtime.h | 1 + .../mock_runtime.h | 2 ++ 6 files changed, 29 insertions(+) diff --git a/frameworks/native/appkit/app/ohos_application.cpp b/frameworks/native/appkit/app/ohos_application.cpp index 482e999eca..c008933695 100644 --- a/frameworks/native/appkit/app/ohos_application.cpp +++ b/frameworks/native/appkit/app/ohos_application.cpp @@ -679,6 +679,10 @@ std::shared_ptr OHOSApplication::AddAbilityStage( TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo is nullptr"); return nullptr; } + if (runtime_) { + runtime_->UpdatePkgContextInfoJson( + hapModuleInfo->moduleName, hapModuleInfo->hapPath, hapModuleInfo->packageName); + } SetAppEnv(hapModuleInfo->appEnvironments); if (abilityInfo->applicationInfo.multiProjects) { diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index d11c3fb7fc..07920e3ae0 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -757,6 +757,8 @@ bool JsRuntime::Initialize(const Options& options) panda::JSNApi::SetHmsModuleList(vm, systemKitsMap); std::map>> pkgContextInfoMap; std::map pkgAliasMap; + pkgContextInfoJsonStringMap_ = options.pkgContextInfoJsonStringMap; + packageNameList_ = options.packageNameList; GetPkgContextInfoListMap(options.pkgContextInfoJsonStringMap, pkgContextInfoMap, pkgAliasMap); panda::JSNApi::SetpkgContextInfoList(vm, pkgContextInfoMap); panda::JSNApi::SetPkgAliasList(vm, pkgAliasMap); @@ -1695,5 +1697,21 @@ std::shared_ptr JsRuntime::GetChildOptions() TAG_LOGD(AAFwkTag::JSRUNTIME, "called"); return childOptions_; } + +void JsRuntime::UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) +{ + auto iterator = pkgContextInfoJsonStringMap_.find(moduleName); + if (iterator == pkgContextInfoJsonStringMap_.end()) { + pkgContextInfoJsonStringMap_[moduleName] = hapPath; + packageNameList_[moduleName] = packageName; + auto vm = GetEcmaVm(); + std::map>> pkgContextInfoMap; + std::map pkgAliasMap; + GetPkgContextInfoListMap(pkgContextInfoJsonStringMap_, pkgContextInfoMap, pkgAliasMap); + panda::JSNApi::SetpkgContextInfoList(vm, pkgContextInfoMap); + panda::JSNApi::SetPkgAliasList(vm, pkgAliasMap); + panda::JSNApi::SetPkgNameList(vm, packageNameList_); + } +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/runtime/include/cj_runtime.h b/interfaces/inner_api/runtime/include/cj_runtime.h index da662066aa..3c229c5c1c 100644 --- a/interfaces/inner_api/runtime/include/cj_runtime.h +++ b/interfaces/inner_api/runtime/include/cj_runtime.h @@ -66,6 +66,7 @@ public: void AllowCrossThreadExecution() override {}; void GetHeapPrepare() override {}; void RegisterUncaughtExceptionHandler(const CJUncaughtExceptionInfo& uncaughtExceptionInfo); + void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override {}; private: bool StartDebugger(); bool LoadCJAppLibrary(const AppLibPathVec& appLibPaths); diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 3b8d83d7d2..ae5769fc06 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -133,6 +133,7 @@ public: std::unique_ptr LoadSystemModule( const std::string& moduleName, const napi_value* argv = nullptr, size_t argc = 0); void SetDeviceDisconnectCallback(const std::function &cb) override; + void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override; private: void FinishPreload() override; @@ -156,6 +157,8 @@ private: uint32_t instanceId_ = 0; std::string bundleName_; int32_t apiTargetVersion_ = 0; + std::map pkgContextInfoJsonStringMap_; + std::map packageNameList_; static std::atomic hasInstance; diff --git a/interfaces/inner_api/runtime/include/runtime.h b/interfaces/inner_api/runtime/include/runtime.h index 162605255e..baa3b6a7b3 100644 --- a/interfaces/inner_api/runtime/include/runtime.h +++ b/interfaces/inner_api/runtime/include/runtime.h @@ -106,6 +106,7 @@ public: virtual void DoCleanWorkAfterStageCleaned() = 0; virtual void SetModuleLoadChecker(const std::shared_ptr& moduleCheckerDelegate) const {} virtual void SetDeviceDisconnectCallback(const std::function &cb) = 0; + virtual void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) = 0; Runtime(const Runtime&) = delete; Runtime(Runtime&&) = delete; Runtime& operator=(const Runtime&) = delete; diff --git a/test/mock/frameworks_kits_runtime_test/mock_runtime.h b/test/mock/frameworks_kits_runtime_test/mock_runtime.h index ac5ce22596..a5066a21bf 100644 --- a/test/mock/frameworks_kits_runtime_test/mock_runtime.h +++ b/test/mock/frameworks_kits_runtime_test/mock_runtime.h @@ -121,6 +121,8 @@ public: void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, std::vector tidVec) override {} void ForceFullGC(uint32_t tid) override {} + + void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override {}; public: Language language; }; From 8f16431a73a9176d20992de7d35c8a019ad8c664 Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Mon, 3 Jun 2024 03:03:01 +0000 Subject: [PATCH 06/16] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!8?= =?UTF-8?q?571=20:=20jsheap=E6=96=87=E4=BB=B6=E8=90=BD=E7=9B=98=E8=87=B3/d?= =?UTF-8?q?ata/log/hidumper=E7=9B=AE=E5=BD=95'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/native/appkit/app/main_thread.cpp | 11 +--- frameworks/native/runtime/js_runtime.cpp | 5 +- .../include/appmgr/app_jsheap_mem_info.h | 5 -- .../src/appmgr/app_jsheap_mem_info.cpp | 64 ++----------------- .../inner_api/runtime/include/cj_runtime.h | 3 +- .../inner_api/runtime/include/js_runtime.h | 3 +- .../inner_api/runtime/include/runtime.h | 3 +- .../mock_runtime.h | 3 +- .../unittest/runtime_test/js_runtime_test.cpp | 4 +- 9 files changed, 14 insertions(+), 87 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index cc23fc92c5..061749855c 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -644,16 +644,7 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) return; } if (info.needSnapshot == true) { - std::vector fdVec; - for (auto &fd : info.fdVec) { - uint32_t newFd = dup(fd); - if (newFd == -1) { - TAG_LOGE(AAFwkTag::APPKIT, "dup failed."); - return; - } - fdVec.push_back(newFd); - } - runtime->DumpHeapSnapshot(info.tid, info.needGc, fdVec, info.tidVec); + runtime->DumpHeapSnapshot(info.tid, info.needGc); } else { if (info.needGc == true) { runtime->ForceFullGC(info.tid); diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index d11c3fb7fc..5644ab1357 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -1197,12 +1197,11 @@ void JsRuntime::DumpHeapSnapshot(bool isPrivate) nativeEngine->DumpHeapSnapshot(true, DumpFormat::JSON, isPrivate, false); } -void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, - std::vector tidVec) +void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC) { auto vm = GetEcmaVm(); CHECK_POINTER(vm); - DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid, fdVec, tidVec); + DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid); } void JsRuntime::ForceFullGC(uint32_t tid) diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h b/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h index 6791cf79fb..e720f38282 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h @@ -16,21 +16,16 @@ #ifndef OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H #define OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H -#include #include "parcel.h" #include "iremote_object.h" namespace OHOS { namespace AppExecFwk { struct JsHeapDumpInfo : public Parcelable { - ~JsHeapDumpInfo(); uint32_t pid; uint32_t tid; bool needGc; bool needSnapshot; - std::vector fdVec; - std::vector tidVec; - bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; static JsHeapDumpInfo *Unmarshalling(Parcel &parcel); }; diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp index 619f615ccb..02b4333129 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp @@ -19,61 +19,10 @@ namespace OHOS { namespace AppExecFwk { -namespace { -constexpr int32_t MAX_TID_COUNT = 40; -} - -JsHeapDumpInfo::~JsHeapDumpInfo() -{ - TAG_LOGI(AAFwkTag::APPMGR, "~JsHeapDumpInfo start"); - for (auto &fd : fdVec) { - close(fd); - } - fdVec.clear(); - tidVec.clear(); -} - bool JsHeapDumpInfo::Marshalling(Parcel &parcel) const { - bool res = (parcel.WriteUint32(pid) && parcel.WriteUint32(tid) - && parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot) - && parcel.WriteUInt32Vector(fdVec) && parcel.WriteUInt32Vector(tidVec)); - - auto msgParcel = static_cast(&parcel); - if (msgParcel == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Dump Marshalling msgParcel==nullptr"); - return false; - } - for (auto &fd : fdVec) { - msgParcel->WriteFileDescriptor(fd); - } - return res; -} - -bool JsHeapDumpInfo::ReadFromParcel(Parcel &parcel) -{ - pid = parcel.ReadUint32(); - tid = parcel.ReadUint32(); - needGc = parcel.ReadBool(); - needSnapshot = parcel.ReadBool(); - if (fdVec.size() > MAX_TID_COUNT || tidVec.size() > MAX_TID_COUNT) { - TAG_LOGE(AAFwkTag::APPMGR, "fdVec or tidVec size more than 40."); - return false; - } - parcel.ReadUInt32Vector(&fdVec); - parcel.ReadUInt32Vector(&tidVec); - - auto msgParcel = static_cast(&parcel); - if (msgParcel == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadFromParcel failed."); - return false; - } - fdVec.clear(); - for (auto &tid : tidVec) { - uint32_t parcelFd = static_cast(msgParcel->ReadFileDescriptor()); - fdVec.push_back(parcelFd); - } - return true; + return (parcel.WriteUint32(pid) && parcel.WriteUint32(tid) + && parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot)); } JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel) @@ -83,11 +32,10 @@ JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel) TAG_LOGE(AAFwkTag::APPMGR, "info nullptr"); return nullptr; } - if (info && !info->ReadFromParcel(parcel)) { - TAG_LOGE(AAFwkTag::APPMGR, "JsHeapDumpInfo failed, because ReadFromParcel failed"); - delete info; - info = nullptr; - } + info->pid = parcel.ReadUint32(); + info->tid = parcel.ReadUint32(); + info->needGc = parcel.ReadBool(); + info->needSnapshot = parcel.ReadBool(); return info; } } // namespace AppExecFwk diff --git a/interfaces/inner_api/runtime/include/cj_runtime.h b/interfaces/inner_api/runtime/include/cj_runtime.h index da662066aa..e5610f06fb 100644 --- a/interfaces/inner_api/runtime/include/cj_runtime.h +++ b/interfaces/inner_api/runtime/include/cj_runtime.h @@ -60,8 +60,7 @@ public: void DestroyHeapProfiler() override {}; void ForceFullGC() override {}; void ForceFullGC(uint32_t tid) override {}; - void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, - std::vector tidVec) override {}; + void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {}; void DumpCpuProfile(bool isPrivate) override {}; void AllowCrossThreadExecution() override {}; void GetHeapPrepare() override {}; diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 3b8d83d7d2..430fc46c48 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -85,8 +85,7 @@ public: void DestroyHeapProfiler() override; void ForceFullGC() override; void ForceFullGC(uint32_t tid) override; - void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, - std::vector tidVec) override; + void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override; void AllowCrossThreadExecution() override; void GetHeapPrepare() override; void NotifyApplicationState(bool isBackground) override; diff --git a/interfaces/inner_api/runtime/include/runtime.h b/interfaces/inner_api/runtime/include/runtime.h index 162605255e..0406005cdc 100644 --- a/interfaces/inner_api/runtime/include/runtime.h +++ b/interfaces/inner_api/runtime/include/runtime.h @@ -89,8 +89,7 @@ public: virtual void DestroyHeapProfiler() = 0; virtual void ForceFullGC() = 0; virtual void ForceFullGC(uint32_t tid) = 0; - virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, - std::vector tidVec) = 0; + virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC) = 0; virtual void AllowCrossThreadExecution() = 0; virtual void GetHeapPrepare() = 0; virtual void NotifyApplicationState(bool isBackground) = 0; diff --git a/test/mock/frameworks_kits_runtime_test/mock_runtime.h b/test/mock/frameworks_kits_runtime_test/mock_runtime.h index ac5ce22596..35892761f3 100644 --- a/test/mock/frameworks_kits_runtime_test/mock_runtime.h +++ b/test/mock/frameworks_kits_runtime_test/mock_runtime.h @@ -118,8 +118,7 @@ public: void StartProfiler(const DebugOption debugOption) override {} void DoCleanWorkAfterStageCleaned() override {} - void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, - std::vector tidVec) override {} + void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {} void ForceFullGC(uint32_t tid) override {} public: Language language; diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index db9704a387..d3fbd09064 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -1492,9 +1492,7 @@ HWTEST_F(JsRuntimeTest, DumpHeapSnapshot_0200, TestSize.Level1) auto jsRuntime = std::make_unique(); uint32_t tid = 1; bool isFullGC = true; - std::vector fdVec; - std::vector tidVec; - jsRuntime->DumpHeapSnapshot(tid, isFullGC, fdVec, tidVec); + jsRuntime->DumpHeapSnapshot(tid, isFullGC); EXPECT_TRUE(jsRuntime != nullptr); } From a6004e5cd522b14464e16c82f3dd6163beb85ddb Mon Sep 17 00:00:00 2001 From: savior-xzh Date: Fri, 31 May 2024 15:18:38 +0800 Subject: [PATCH 07/16] load ability task Signed-off-by: savior-xzh Change-Id: I937eeafa07be841f7ebb629ce9639e963ae0df65 --- .../appmgr/include/app_mgr_service_inner.h | 11 ++++ services/appmgr/src/ams_mgr_scheduler.cpp | 22 ++++++++ services/appmgr/src/app_mgr_service_inner.cpp | 55 +++++++++++++++---- 3 files changed, 76 insertions(+), 12 deletions(-) diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 68d0f7f5aa..c845210aec 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -77,6 +77,7 @@ namespace AppExecFwk { using OHOS::AAFwk::Want; class WindowFocusChangedListener; class WindowVisibilityChangedListener; +using LoabAbilityTaskFunc = std::function; class AppMgrServiceInner : public std::enable_shared_from_this { public: @@ -1100,6 +1101,14 @@ public: bool IsAppProcessesAllCached(const std::string &bundleName, int32_t uid, const std::set> &cachedSet); + + bool GetSceneBoardAttachFlag() const; + + void SetSceneBoardAttachFlag(bool flag); + + void CacheLoabAbilityTask(const LoabAbilityTaskFunc& func); + + void SubmitCacheLoabAbilityTask(); private: std::string FaultTypeToString(FaultDataType type); @@ -1525,6 +1534,8 @@ private: std::shared_ptr dfxTaskHandler_; std::shared_ptr otherTaskHandler_; std::shared_ptr appPreloader_; + std::atomic sceneBoardAttachFlag_ = true; + std::vector loadAbilityTaskFuncList_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index c2225881dc..76628bca56 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -44,6 +44,10 @@ constexpr const char* TASK_ATTACH_PID_TO_PARENT = "AttachPidToParent"; constexpr const char* TASK_KILL_APPLICATION = "KillApplicationTask"; constexpr const char* TASK_CLEAR_PROCESS_BY_ABILITY_TOKEN = "ClearProcessByAbilityTokenTask"; constexpr const char* FOUNDATION_NAME = "foundation"; +constexpr const char* SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard"; +constexpr const char* SCENEBOARD_ABILITY_NAME = "com.ohos.sceneboard.MainAbility"; +constexpr const char* TASK_SCENE_BOARD_ATTACH_TIMEOUT = "sceneBoardAttachTimeoutTask"; +constexpr int32_t SCENE_BOARD_ATTACH_TIMEOUT_TASK_TIME = 1000; }; // namespace AmsMgrScheduler::AmsMgrScheduler( @@ -81,6 +85,24 @@ void AmsMgrScheduler::LoadAbility(const sptr &token, const sptrGetSceneBoardAttachFlag() && abilityInfo->bundleName != SCENE_BOARD_BUNDLE_NAME) { + amsMgrServiceInner_->CacheLoabAbilityTask(loadAbilityFunc); + return; + } + if (abilityInfo->bundleName == SCENE_BOARD_BUNDLE_NAME && abilityInfo->name == SCENEBOARD_ABILITY_NAME) { + amsMgrServiceInner_->SetSceneBoardAttachFlag(false); + // set scene board attach timeout task + std::weak_ptr amsMgrServiceInner = amsMgrServiceInner_; + auto timeoutTask = [amsMgrServiceInner]() { + auto inner = amsMgrServiceInner.lock(); + if (inner != nullptr) { + inner->SetSceneBoardAttachFlag(true); + } + }; + amsHandler_->SubmitTask(timeoutTask, TASK_SCENE_BOARD_ATTACH_TIMEOUT, SCENE_BOARD_ATTACH_TIMEOUT_TASK_TIME); + } + amsHandler_->SubmitTask(loadAbilityFunc); } diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 59f1390baa..b9e68d608d 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -110,6 +110,12 @@ namespace { return ERR_PERMISSION_DENIED; \ } +#define CHECK_POINTER_AND_RETURN_LOG(object, log) \ + if (!object) { \ + TAG_LOGE(AAFwkTag::APPMGR, "%{public}s", log); \ + return; \ + } + // NANOSECONDS mean 10^9 nano second constexpr int64_t NANOSECONDS = 1000000000; // MICROSECONDS mean 10^6 milli second @@ -829,10 +835,7 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptrGetApplicationInfo(); AAFwk::EventInfo eventInfo; if (!applicationInfo) { @@ -845,16 +848,10 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr appDeathRecipient = new (std::nothrow) AppDeathRecipient(); - if (appDeathRecipient == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to create death recipient."); - return; - } + CHECK_POINTER_AND_RETURN_LOG(appDeathRecipient, "Failed to create death recipient."); appDeathRecipient->SetTaskHandler(taskHandler_); appDeathRecipient->SetAppMgrServiceInner(shared_from_this()); auto object = appScheduler->AsObject(); @@ -868,6 +865,12 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptrGetState() == ApplicationState::APP_STATE_CREATE) { LaunchApplication(appRecord); } + + // submit cached load ability task after scene board attach + if (appRecord->GetBundleName() == SCENE_BOARD_BUNDLE_NAME) { + sceneBoardAttachFlag_ = true; + SubmitCacheLoabAbilityTask(); + } eventInfo.pid = appRecord->GetPriorityObject()->GetPid(); eventInfo.processName = appRecord->GetProcessName(); AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_ATTACH, HiSysEventType::BEHAVIOR, eventInfo); @@ -6893,5 +6896,33 @@ bool AppMgrServiceInner::IsAppProcessesAllCached(const std::string &bundleName, } return appRunningManager_->IsAppProcessesAllCached(bundleName, uid, cachedSet); } + +void AppMgrServiceInner::CacheLoabAbilityTask(const LoabAbilityTaskFunc& func) +{ + loadAbilityTaskFuncList_.emplace_back(func); +} + +void AppMgrServiceInner::SubmitCacheLoabAbilityTask() +{ + std::weak_ptr taskHandler = taskHandler_; + for_each(loadAbilityTaskFuncList_.begin(), loadAbilityTaskFuncList_.end(), + [taskHandler](LoabAbilityTaskFunc loadAbilityFunc) { + auto LoadAbilityhandler = taskHandler.lock(); + if (LoadAbilityhandler != nullptr && loadAbilityFunc) { + LoadAbilityhandler->SubmitTask(loadAbilityFunc); + } + }); + loadAbilityTaskFuncList_.clear(); +} + +bool AppMgrServiceInner::GetSceneBoardAttachFlag() const +{ + return sceneBoardAttachFlag_; +} + +void AppMgrServiceInner::SetSceneBoardAttachFlag(bool flag) +{ + sceneBoardAttachFlag_ = flag; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file From f57efcd643e83229b87e748324407899d127043f Mon Sep 17 00:00:00 2001 From: hhl Date: Sat, 1 Jun 2024 14:43:22 +0800 Subject: [PATCH 08/16] fix apprecovery White screen issue Signed-off-by: hhl --- services/abilitymgr/src/ability_record.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index ef713e822e..026e56348a 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -26,6 +26,7 @@ #include "ability_resident_process_rdb.h" #include "ability_scheduler_stub.h" #include "ability_util.h" +#include "app_exit_reason_data_manager.h" #include "app_utils.h" #include "appfreeze_manager.h" #include "array_wrapper.h" @@ -1270,6 +1271,12 @@ int AbilityRecord::TerminateAbility() AAFwk::EventInfo eventInfo; eventInfo.bundleName = GetAbilityInfo().bundleName; eventInfo.abilityName = GetAbilityInfo().name; + if (clearMissionFlag_) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "deleteAbilityRecoverInfo before clearMission."); + (void)DelayedSingleton::GetInstance()-> + DeleteAbilityRecoverInfo(GetAbilityInfo().applicationInfo.accessTokenId, GetAbilityInfo().moduleName, + GetAbilityInfo().name); + } AAFwk::EventReport::SendAbilityEvent(AAFwk::EventName::TERMINATE_ABILITY, HiSysEventType::BEHAVIOR, eventInfo); eventInfo.errCode = DelayedSingleton::GetInstance()->TerminateAbility(token_, clearMissionFlag_); if (eventInfo.errCode != ERR_OK) { From 12d705bc3727f0ee2e310ae751912bdeaa24c0c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Jun 2024 16:20:38 +0800 Subject: [PATCH 09/16] fix getcallingreal Signed-off-by: unknown --- .../distributed_client.cpp | 2 +- .../src/ability_connect_manager.cpp | 2 +- .../src/ability_manager_service.cpp | 18 +++++----- services/abilitymgr/src/ability_record.cpp | 2 +- .../abilitymgr/src/app_exit_reason_helper.cpp | 2 +- .../src/assert_fault_callback_death_mgr.cpp | 2 +- services/abilitymgr/src/connection_record.cpp | 2 +- .../abilitymgr/src/data_ability_manager.cpp | 4 +-- .../abilitymgr/src/data_ability_record.cpp | 2 +- .../src/implicit_start_processor.cpp | 2 +- .../ecological_rule_interceptor.cpp | 2 +- .../start_other_app_interceptor.cpp | 4 +-- services/appmgr/src/ams_mgr_scheduler.cpp | 4 +-- services/appmgr/src/app_mgr_event.cpp | 2 +- services/appmgr/src/app_mgr_service.cpp | 24 ++++++------- services/appmgr/src/app_mgr_service_inner.cpp | 36 +++++++++---------- .../src/uri_permission_manager_stub_impl.cpp | 2 +- 17 files changed, 56 insertions(+), 56 deletions(-) diff --git a/frameworks/native/ability/native/distributed_ability_runtime/distributed_client.cpp b/frameworks/native/ability/native/distributed_ability_runtime/distributed_client.cpp index 96303d6dc7..3be1e2d402 100644 --- a/frameworks/native/ability/native/distributed_ability_runtime/distributed_client.cpp +++ b/frameworks/native/ability/native/distributed_ability_runtime/distributed_client.cpp @@ -503,7 +503,7 @@ bool DistributedClient::WriteInfosToParcel(MessageParcel& data, const OHOS::AAFw const sptr& connect) { int32_t callerUid = IPCSkeleton::GetCallingUid(); - int32_t callerPid = IPCSkeleton::GetCallingRealPid(); + int32_t callerPid = IPCSkeleton::GetCallingPid(); uint32_t accessToken = IPCSkeleton::GetCallingTokenID(); if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) { return false; diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 3981f0e983..099cfdbc64 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -2889,7 +2889,7 @@ EventInfo AbilityConnectManager::BuildEventInfo(const std::shared_ptr( std::chrono::system_clock::now().time_since_epoch()).count(); auto callerPid = abilityRecord->GetWant().GetIntParam(Want::PARAM_RESV_CALLER_PID, -1); - eventInfo.callerPid = callerPid == -1 ? IPCSkeleton::GetCallingRealPid() : callerPid; + eventInfo.callerPid = callerPid == -1 ? IPCSkeleton::GetCallingPid() : callerPid; DelayedSingleton::GetInstance()->GetRunningProcessInfoByPid(eventInfo.callerPid, processInfo); eventInfo.callerPid = processInfo.pid_; eventInfo.callerProcessName = processInfo.processName_; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index f6d19d10a3..8c81f659bb 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -1823,7 +1823,7 @@ int32_t AbilityManagerService::ReportDrawnCompleted(const sptr &c EventInfo eventInfo; eventInfo.userId = IPCSkeleton::GetCallingUid() / BASE_USER_RANGE; - eventInfo.pid = IPCSkeleton::GetCallingRealPid(); + eventInfo.pid = IPCSkeleton::GetCallingPid(); eventInfo.bundleName = abilityInfo.bundleName; eventInfo.moduleName = abilityInfo.moduleName; eventInfo.abilityName = abilityInfo.name; @@ -5992,7 +5992,7 @@ int32_t AbilityManagerService::UpgradeApp(const std::string &bundleName, const i int32_t AbilityManagerService::UninstallAppInner(const std::string &bundleName, const int32_t uid, const bool isUpgrade, const std::string &exitMsg) { - pid_t callingPid = IPCSkeleton::GetCallingRealPid(); + pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t pid = getprocpid(); if (callingPid != pid) { TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: Not bundleMgr call.", __func__); @@ -7608,7 +7608,7 @@ int AbilityManagerService::DelegatorDoAbilityForeground(const sptrGetPid(); TAG_LOGD(AAFwkTag::ABILITYMGR, "callerPid: %{public}d, appPid: %{public}d", callerPid, appPid); if (callerPid != appPid) { @@ -7644,7 +7644,7 @@ int AbilityManagerService::DelegatorDoAbilityBackground(const sptrGetPid(); - int32_t callerPid = IPCSkeleton::GetCallingRealPid(); + int32_t callerPid = IPCSkeleton::GetCallingPid(); TAG_LOGD(AAFwkTag::ABILITYMGR, "callerPid: %{public}d, appPid: %{public}d", callerPid, appPid); if (callerPid != appPid) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not the application itself"); @@ -7721,7 +7721,7 @@ void AbilityManagerService::UpdateCallerInfo(Want& want, const sptr(IPCSkeleton::GetCallingTokenID()); int32_t callerUid = IPCSkeleton::GetCallingUid(); - int32_t callerPid = IPCSkeleton::GetCallingRealPid(); + int32_t callerPid = IPCSkeleton::GetCallingPid(); want.RemoveParam(Want::PARAM_RESV_CALLER_TOKEN); want.SetParam(Want::PARAM_RESV_CALLER_TOKEN, tokenId); want.RemoveParam(Want::PARAM_RESV_CALLER_UID); @@ -8897,7 +8897,7 @@ int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityReq return ERR_OK; } } else { - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); DelayedSingleton::GetInstance()->GetRunningProcessInfoByPid(callerPid, processInfo); if (processInfo.processName_.empty()) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Can not find caller application by callerPid: %{private}d.", callerPid); @@ -9069,7 +9069,7 @@ int AbilityManagerService::CheckDlpForExtension( bool AbilityManagerService::JudgeSelfCalled(const std::shared_ptr &abilityRecord) { - if (IPCSkeleton::GetCallingRealPid() == getprocpid()) { + if (IPCSkeleton::GetCallingPid() == getprocpid()) { return true; } @@ -10165,7 +10165,7 @@ int32_t AbilityManagerService::SetResidentProcessEnabled(const std::string &bund std::string callerName; int32_t uid = 0; - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); DelayedSingleton::GetInstance()->GetBundleNameByPid(callerPid, callerName, uid); if (callerName.empty()) { HILOG_ERROR("Failed to obtain caller name."); @@ -10559,7 +10559,7 @@ void AbilityManagerService::ReportPreventStartAbilityResult(const AppExecFwk::Ab const AppExecFwk::AbilityInfo &abilityInfo) { int32_t callerUid = IPCSkeleton::GetCallingUid(); - int32_t callerPid = IPCSkeleton::GetCallingRealPid(); + int32_t callerPid = IPCSkeleton::GetCallingPid(); int32_t extensionAbilityType = static_cast(abilityInfo.extensionAbilityType); TAG_LOGD(AAFwkTag::ABILITYMGR, "Prevent start ability debug log CALLER_BUNDLE_NAME %{public}s CALLEE_BUNDLE_NAME" diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index ef713e822e..5d9f043338 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -1439,7 +1439,7 @@ void AbilityRecord::SetScheduler(const sptr &scheduler) if (IsSceneBoard()) { TAG_LOGI(AAFwkTag::ABILITYMGR, "Sceneboard DeathRecipient Added"); } - pid_ = static_cast(IPCSkeleton::GetCallingRealPid()); // set pid when ability attach to service. + pid_ = static_cast(IPCSkeleton::GetCallingPid()); // set pid when ability attach to service. // add collaborator mission bind pid NotifyMissionBindPid(); HandleDlpAttached(); diff --git a/services/abilitymgr/src/app_exit_reason_helper.cpp b/services/abilitymgr/src/app_exit_reason_helper.cpp index 9261cb2602..b5608752fe 100644 --- a/services/abilitymgr/src/app_exit_reason_helper.cpp +++ b/services/abilitymgr/src/app_exit_reason_helper.cpp @@ -49,7 +49,7 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason) return ERR_INVALID_VALUE; } - auto pid = IPCSkeleton::GetCallingRealPid(); + auto pid = IPCSkeleton::GetCallingPid(); AppExecFwk::ApplicationInfo application; bool debug = false; auto ret = IN_PROCESS_CALL(DelayedSingleton::GetInstance()->GetApplicationInfoByProcessID(pid, diff --git a/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp b/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp index ef60320c6f..c9d92d6913 100644 --- a/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp +++ b/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp @@ -56,7 +56,7 @@ void AssertFaultCallbackDeathMgr::AddAssertFaultCallback(sptr &re }); remote->AddDeathRecipient(deathRecipient); - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); uint64_t assertFaultSessionId = reinterpret_cast(remote.GetRefPtr()); std::unique_lock lock(assertFaultSessionMutex_); assertFaultSessionDialogs_[assertFaultSessionId] = {callerPid, remote, deathRecipient, callback}; diff --git a/services/abilitymgr/src/connection_record.cpp b/services/abilitymgr/src/connection_record.cpp index f7abd410dd..34d08b5df2 100644 --- a/services/abilitymgr/src/connection_record.cpp +++ b/services/abilitymgr/src/connection_record.cpp @@ -270,7 +270,7 @@ void ConnectionRecord::AttachCallerInfo() } callerUid_ = static_cast(IPCSkeleton::GetCallingUid()); - callerPid_ = static_cast(IPCSkeleton::GetCallingRealPid()); + callerPid_ = static_cast(IPCSkeleton::GetCallingPid()); callerName_ = ConnectionStateManager::GetProcessNameByPid(callerPid_); } diff --git a/services/abilitymgr/src/data_ability_manager.cpp b/services/abilitymgr/src/data_ability_manager.cpp index bc2c661188..6d61a7d52a 100644 --- a/services/abilitymgr/src/data_ability_manager.cpp +++ b/services/abilitymgr/src/data_ability_manager.cpp @@ -683,7 +683,7 @@ void DataAbilityManager::ReportDataAbilityAcquired(const sptr &cl { DataAbilityCaller caller; caller.isNotHap = isNotHap; - caller.callerPid = IPCSkeleton::GetCallingRealPid(); + caller.callerPid = IPCSkeleton::GetCallingPid(); caller.callerUid = IPCSkeleton::GetCallingUid(); caller.callerToken = client; if (client && !isNotHap) { @@ -703,7 +703,7 @@ void DataAbilityManager::ReportDataAbilityReleased(const sptr &cl { DataAbilityCaller caller; caller.isNotHap = isNotHap; - caller.callerPid = IPCSkeleton::GetCallingRealPid(); + caller.callerPid = IPCSkeleton::GetCallingPid(); caller.callerUid = IPCSkeleton::GetCallingUid(); caller.callerToken = client; DelayedSingleton::GetInstance()->RemoveDataAbilityConnection(caller, record); diff --git a/services/abilitymgr/src/data_ability_record.cpp b/services/abilitymgr/src/data_ability_record.cpp index 45e27de820..12bb7e70ef 100644 --- a/services/abilitymgr/src/data_ability_record.cpp +++ b/services/abilitymgr/src/data_ability_record.cpp @@ -228,7 +228,7 @@ int DataAbilityRecord::AddClient(const sptr &client, bool tryBind clientInfo.client = client; clientInfo.tryBind = tryBind; clientInfo.isNotHap = isNotHap; - clientInfo.clientPid = IPCSkeleton::GetCallingRealPid(); + clientInfo.clientPid = IPCSkeleton::GetCallingPid(); return ERR_OK; } diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index eefc114f4d..f79620afd2 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -633,7 +633,7 @@ void ImplicitStartProcessor::GetEcologicalCallerInfo(const Want &want, ErmsCalle { callerInfo.packageName = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); callerInfo.uid = want.GetIntParam(Want::PARAM_RESV_CALLER_UID, IPCSkeleton::GetCallingUid()); - callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingRealPid()); + callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingPid()); callerInfo.targetAppType = ErmsCallerInfo::TYPE_INVALID; callerInfo.callerAppType = ErmsCallerInfo::TYPE_INVALID; diff --git a/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp b/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp index 10b9bd0271..e18970b521 100644 --- a/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp +++ b/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp @@ -181,7 +181,7 @@ void EcologicalRuleInterceptor::InitErmsCallerInfo(Want &want, ErmsCallerInfo &c { callerInfo.packageName = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); callerInfo.uid = want.GetIntParam(Want::PARAM_RESV_CALLER_UID, IPCSkeleton::GetCallingUid()); - callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingRealPid()); + callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingPid()); callerInfo.targetAppType = ErmsCallerInfo::TYPE_INVALID; callerInfo.callerAppType = ErmsCallerInfo::TYPE_INVALID; callerInfo.targetLinkFeature = want.GetStringParam("send_to_erms_targetLinkFeature"); diff --git a/services/abilitymgr/src/interceptor/start_other_app_interceptor.cpp b/services/abilitymgr/src/interceptor/start_other_app_interceptor.cpp index ef080dbe79..53e11a8874 100644 --- a/services/abilitymgr/src/interceptor/start_other_app_interceptor.cpp +++ b/services/abilitymgr/src/interceptor/start_other_app_interceptor.cpp @@ -110,7 +110,7 @@ bool StartOtherAppInterceptor::GetApplicationInfo(const sptr &cal AppExecFwk::ApplicationInfo &applicationInfo) { if (callerToken == nullptr) { - int32_t callerPid = IPCSkeleton::GetCallingRealPid(); + int32_t callerPid = IPCSkeleton::GetCallingPid(); auto appScheduler = DelayedSingleton::GetInstance(); bool debug; if (appScheduler != nullptr && @@ -148,7 +148,7 @@ bool StartOtherAppInterceptor::IsDelegatorCall(const Want want) { AppExecFwk::RunningProcessInfo processInfo; DelayedSingleton::GetInstance()-> - GetRunningProcessInfoByPid(IPCSkeleton::GetCallingRealPid(), processInfo); + GetRunningProcessInfoByPid(IPCSkeleton::GetCallingPid(), processInfo); if (processInfo.isTestProcess && want.GetBoolParam(IS_DELEGATOR_CALL, false)) { return true; } diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index bb8f322331..df0d8c8db8 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -211,7 +211,7 @@ void AmsMgrScheduler::KillProcessesByPids(std::vector &pids) return; } - pid_t callingPid = IPCSkeleton::GetCallingRealPid(); + pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t pid = getprocpid(); if (callingPid != pid) { TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call."); @@ -229,7 +229,7 @@ void AmsMgrScheduler::AttachPidToParent(const sptr &token, const return; } - pid_t callingPid = IPCSkeleton::GetCallingRealPid(); + pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t pid = getprocpid(); if (callingPid != pid) { TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call."); diff --git a/services/appmgr/src/app_mgr_event.cpp b/services/appmgr/src/app_mgr_event.cpp index c6c2934032..c322a74081 100644 --- a/services/appmgr/src/app_mgr_event.cpp +++ b/services/appmgr/src/app_mgr_event.cpp @@ -104,7 +104,7 @@ bool AppMgrEventUtil::SendProcessStartEvent(const std::shared_ptrGetBundleName().empty()) { eventInfo.callerBundleName = callerAppRecord->GetName(); diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index e4e2f58c4c..7ead769cd1 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -213,7 +213,7 @@ void AppMgrService::AttachApplication(const sptr &app) return; } - pid_t pid = IPCSkeleton::GetCallingRealPid(); + pid_t pid = IPCSkeleton::GetCallingPid(); std::function attachApplicationFunc = std::bind(&AppMgrServiceInner::AttachApplication, appMgrServiceInner_, pid, iface_cast(app)); taskHandler_->SubmitTask(attachApplicationFunc, AAFwk::TaskAttribute{ @@ -318,7 +318,7 @@ void AppMgrService::StartupResidentProcess(const std::vectorClearUpApplicationData(bundleName, uid, pid, userId); return ERR_OK; } @@ -380,7 +380,7 @@ int32_t AppMgrService::ClearUpApplicationDataBySelf(int32_t userId) return ERR_INVALID_OPERATION; } int32_t uid = IPCSkeleton::GetCallingUid(); - pid_t pid = IPCSkeleton::GetCallingRealPid(); + pid_t pid = IPCSkeleton::GetCallingPid(); return appMgrServiceInner_->ClearUpApplicationDataBySelf(uid, pid, userId); } @@ -619,7 +619,7 @@ int AppMgrService::FinishUserTest(const std::string &msg, const int64_t &resultC TAG_LOGE(AAFwkTag::APPMGR, "GetBundleName failed: %{public}d.", result); return ERR_INVALID_OPERATION; } - pid_t callingPid = IPCSkeleton::GetCallingRealPid(); + pid_t callingPid = IPCSkeleton::GetCallingPid(); std::function finishUserTestProcessFunc = std::bind(&AppMgrServiceInner::FinishUserTest, appMgrServiceInner_, msg, resultCode, bundleName, callingPid); taskHandler_->SubmitTask(finishUserTestProcessFunc, TASK_FINISH_USER_TEST); @@ -916,7 +916,7 @@ int32_t AppMgrService::PreStartNWebSpawnProcess() return ERR_INVALID_OPERATION; } - return appMgrServiceInner_->PreStartNWebSpawnProcess(IPCSkeleton::GetCallingRealPid()); + return appMgrServiceInner_->PreStartNWebSpawnProcess(IPCSkeleton::GetCallingPid()); } int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, @@ -927,7 +927,7 @@ int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_ return ERR_INVALID_OPERATION; } - return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingRealPid(), + return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingPid(), renderParam, ipcFd, sharedFd, crashFd, renderPid, isGPU); } @@ -939,7 +939,7 @@ void AppMgrService::AttachRenderProcess(const sptr &scheduler) return; } - auto pid = IPCSkeleton::GetCallingRealPid(); + auto pid = IPCSkeleton::GetCallingPid(); auto fun = std::bind(&AppMgrServiceInner::AttachRenderProcess, appMgrServiceInner_, pid, iface_cast(scheduler)); taskHandler_->SubmitTask(fun, AAFwk::TaskAttribute{ @@ -955,7 +955,7 @@ void AppMgrService::SaveBrowserChannel(sptr browser) return; } - appMgrServiceInner_->SaveBrowserChannel(IPCSkeleton::GetCallingRealPid(), browser); + appMgrServiceInner_->SaveBrowserChannel(IPCSkeleton::GetCallingPid(), browser); } int32_t AppMgrService::GetRenderProcessTerminationStatus(pid_t renderPid, int &status) @@ -1326,7 +1326,7 @@ int32_t AppMgrService::StartChildProcess(const std::string &srcEntry, pid_t &chi TAG_LOGE(AAFwkTag::APPMGR, "StartChildProcess failed, AppMgrService not ready."); return ERR_INVALID_OPERATION; } - return appMgrServiceInner_->StartChildProcess(IPCSkeleton::GetCallingRealPid(), srcEntry, childPid, + return appMgrServiceInner_->StartChildProcess(IPCSkeleton::GetCallingPid(), srcEntry, childPid, childProcessCount, isStartWithDebug); } @@ -1350,7 +1350,7 @@ void AppMgrService::AttachChildProcess(const sptr &childScheduler TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is null."); return; } - pid_t pid = IPCSkeleton::GetCallingRealPid(); + pid_t pid = IPCSkeleton::GetCallingPid(); std::function task = std::bind(&AppMgrServiceInner::AttachChildProcess, appMgrServiceInner_, pid, iface_cast(childScheduler)); taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{ @@ -1369,7 +1369,7 @@ void AppMgrService::ExitChildProcessSafely() TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is null."); return; } - pid_t pid = IPCSkeleton::GetCallingRealPid(); + pid_t pid = IPCSkeleton::GetCallingPid(); std::function task = std::bind(&AppMgrServiceInner::ExitChildProcessSafelyByChildPid, appMgrServiceInner_, pid); taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{ diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index c8364bb870..7e57c246bb 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -969,7 +969,7 @@ void AppMgrServiceInner::ApplicationForegrounded(const int32_t recordId) eventInfo.processName = appRecord->GetProcessName(); eventInfo.processType = static_cast(appRecord->GetProcessType()); int32_t callerPid = appRecord->GetCallerPid() == -1 ? - IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid(); + IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid(); auto callerRecord = GetAppRunningRecordByPid(callerPid); if (callerRecord != nullptr) { eventInfo.callerBundleName = callerRecord->GetBundleName(); @@ -1237,7 +1237,7 @@ int32_t AppMgrServiceInner::KillApplicationSelf() return ERR_NO_INIT; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(callerPid); if (!appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid); @@ -1574,7 +1574,7 @@ int32_t AppMgrServiceInner::GetProcessRunningInformation(RunningProcessInfo &inf TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr"); return ERR_NO_INIT; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(callerPid); if (!appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid); @@ -2080,7 +2080,7 @@ void AppMgrServiceInner::SetBundleManagerHelper(const std::shared_ptr &callback) { - pid_t callingPid = IPCSkeleton::GetCallingRealPid(); + pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t pid = getprocpid(); if (callingPid != pid) { TAG_LOGE(AAFwkTag::APPMGR, "%{public}s: Not abilityMgr call.", __func__); @@ -2925,7 +2925,7 @@ bool AppMgrServiceInner::SendCreateAtomicServiceProcessEvent(const std::shared_p return false; } TAG_LOGI(AAFwkTag::APPMGR, "to report create atomic service process event."); - auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid(); + auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid(); auto callerAppRecord = GetAppRunningRecordByPid(callerPid); return AppMgrEventUtil::SendCreateAtomicServiceProcessEvent(callerAppRecord, appRecord, moduleName, abilityName); } @@ -2937,7 +2937,7 @@ bool AppMgrServiceInner::SendProcessStartEvent(const std::shared_ptrGetCallerPid() == -1 ? IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid(); + auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid(); auto callerAppRecord = GetAppRunningRecordByPid(callerPid); AppMgrEventUtil::SendProcessStartEvent(callerAppRecord, appRecord, eventInfo); SendReStartProcessEvent(eventInfo, appRecord->GetUid()); @@ -3897,7 +3897,7 @@ void AppMgrServiceInner::RegisterStartSpecifiedAbilityResponse(const sptrIsSACall(); - auto callingPid = IPCSkeleton::GetCallingRealPid(); + auto callingPid = IPCSkeleton::GetCallingPid(); if (!isSaCall && callingPid != pid) { TAG_LOGE(AAFwkTag::APPMGR, "Permission verify failed."); return ERR_PERMISSION_DENIED; @@ -4342,7 +4342,7 @@ int AppMgrServiceInner::VerifyProcessPermission(const std::string &bundleName) c auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission( AAFwk::PermissionConstants::PERMISSION_CLEAN_BACKGROUND_PROCESSES); if (isCallingPerm) { - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(callerPid); if (!appRecord || appRecord->GetBundleName() != bundleName) { TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed."); @@ -4392,7 +4392,7 @@ bool AppMgrServiceInner::CheckCallerIsAppGallery() TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr"); return false; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callerPid); if (!appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "Get app running record by calling pid failed. callingPId: %{public}d", callerPid); @@ -4426,7 +4426,7 @@ bool AppMgrServiceInner::VerifyAPL() const return false; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callerPid); if (!appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "Get app running record by calling pid failed. callingPId: %{public}d", callerPid); @@ -5113,7 +5113,7 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData) { TAG_LOGD(AAFwkTag::APPMGR, "called."); int32_t callerUid = IPCSkeleton::GetCallingUid(); - int32_t pid = IPCSkeleton::GetCallingRealPid(); + int32_t pid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(pid); if (appRecord == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord"); @@ -6155,7 +6155,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfoForSelf(ChildProcessInfo &info) TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is null"); return ERR_NO_INIT; } - auto callingPid = IPCSkeleton::GetCallingRealPid(); + auto callingPid = IPCSkeleton::GetCallingPid(); if (appRunningManager_->GetAppRunningRecordByPid(callingPid)) { TAG_LOGD(AAFwkTag::APPMGR, "record of callingPid is not child record."); return ERR_NAME_NOT_FOUND; @@ -6464,7 +6464,7 @@ void AppMgrServiceInner::SendAppLaunchEvent(const std::shared_ptrGetProcessName(); int32_t callerPid = appRecord->GetCallerPid() == -1 ? - IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid(); + IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid(); auto callerRecord = GetAppRunningRecordByPid(callerPid); if (callerRecord != nullptr) { eventInfo.callerBundleName = callerRecord->GetBundleName(); @@ -6488,7 +6488,7 @@ bool AppMgrServiceInner::IsFinalAppProcessByBundleName(const std::string &bundle auto name = bundleName; if (bundleName.empty()) { - auto callingPid = IPCSkeleton::GetCallingRealPid(); + auto callingPid = IPCSkeleton::GetCallingPid(); auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callingPid); if (appRecord == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "Get app running record is nullptr."); @@ -6583,7 +6583,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(bool flag) return; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(callerPid); if (appRecord == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", callerPid); @@ -6602,7 +6602,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(bool flag) int32_t AppMgrServiceInner::UpdateRenderState(pid_t renderPid, int32_t state) { - int32_t hostPid = IPCSkeleton::GetCallingRealPid(); + int32_t hostPid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(hostPid); if (!appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord, hostPid:%{public}d", hostPid); @@ -6794,7 +6794,7 @@ int32_t AppMgrServiceInner::SetSupportedProcessCacheSelf(bool isSupport) return result; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); auto appRecord = GetAppRunningRecordByPid(callerPid); if (!appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid); diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index ce4413a425..2545463055 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -220,7 +220,7 @@ int32_t UriPermissionManagerStubImpl::CheckCalledBySandBox() TAG_LOGE(AAFwkTag::URIPERMMGR, "Get BundleManager failed!"); return INNER_ERR; } - auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto callerPid = IPCSkeleton::GetCallingPid(); bool isSandbox = false; if (appMgr_->JudgeSandboxByPid(callerPid, isSandbox) != ERR_OK) { TAG_LOGE(AAFwkTag::URIPERMMGR, "JudgeSandboxByPid failed."); From b28b0edae01b2f16b95dcd557d87b4e50495d6af Mon Sep 17 00:00:00 2001 From: donglin Date: Mon, 3 Jun 2024 05:00:04 +0000 Subject: [PATCH 10/16] fix lock error Signed-off-by: donglin Change-Id: I35bcc2a079714acd3e5841ba8c62f92e8cf0ce94 --- .../interceptor/ability_interceptor_executer.h | 3 +++ .../src/interceptor/ability_interceptor_executer.cpp | 12 +++++++++--- .../src/interceptor/screen_unlock_interceptor.cpp | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/services/abilitymgr/include/interceptor/ability_interceptor_executer.h b/services/abilitymgr/include/interceptor/ability_interceptor_executer.h index 2ca232a9d1..d0c8faf495 100644 --- a/services/abilitymgr/include/interceptor/ability_interceptor_executer.h +++ b/services/abilitymgr/include/interceptor/ability_interceptor_executer.h @@ -22,6 +22,7 @@ namespace OHOS { namespace AAFwk { +using InterceptorMap = std::unordered_map>; /** * @class AbilityInterceptorExecuter * AbilityInterceptorExecuter excute the interceptors. @@ -47,6 +48,8 @@ public: ErrCode DoProcess(AbilityInterceptorParam param); void SetTaskHandler(std::shared_ptr taskHandler); +private: + InterceptorMap GetInterceptorMapCopy(); private: std::mutex interceptorMapLock_; std::unordered_map> interceptorMap_; diff --git a/services/abilitymgr/src/interceptor/ability_interceptor_executer.cpp b/services/abilitymgr/src/interceptor/ability_interceptor_executer.cpp index 71f341b93b..be44f64183 100644 --- a/services/abilitymgr/src/interceptor/ability_interceptor_executer.cpp +++ b/services/abilitymgr/src/interceptor/ability_interceptor_executer.cpp @@ -41,9 +41,9 @@ ErrCode AbilityInterceptorExecuter::DoProcess(AbilityInterceptorParam param) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); int32_t result = ERR_OK; - std::lock_guard lock(interceptorMapLock_); - auto item = interceptorMap_.begin(); - while (item != interceptorMap_.end()) { + auto interceptorMap = GetInterceptorMapCopy(); + auto item = interceptorMap.begin(); + while (item != interceptorMap.end()) { result = (*item).second->DoProcess(param); if (result != ERR_OK) { break; @@ -66,5 +66,11 @@ void AbilityInterceptorExecuter::SetTaskHandler(std::shared_ptrSetTaskHandler(taskHandler); } } + +InterceptorMap AbilityInterceptorExecuter::GetInterceptorMapCopy() +{ + std::lock_guard lock(interceptorMapLock_); + return interceptorMap_; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp b/services/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp index 7c9472fd19..75cd22448c 100644 --- a/services/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp +++ b/services/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp @@ -46,6 +46,12 @@ ErrCode ScreenUnlockInterceptor::DoProcess(AbilityInterceptorParam param) } IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(param.want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, param.userId, targetAbilityInfo)); + if (targetAbilityInfo.applicationInfo.name.empty() || + targetAbilityInfo.applicationInfo.bundleName.empty()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Cannot find targetAbilityInfo, element uri: %{public}s", + param.want.GetElement().GetURI().c_str()); + return ERR_OK; + } } // temp add isSystemApp pass, remove after systemapp adjust From 3ecad7f963cd85b66d80ba36bbb4625b14167fca Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Mon, 3 Jun 2024 17:54:31 +0800 Subject: [PATCH 11/16] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- js_environment/test/unittest/BUILD.gn | 1 - .../unittest/js_env_log_unit_test/BUILD.gn | 37 ------ .../js_env_log_unit_test.cpp | 122 ------------------ .../ability_manager_service_first_test.cpp | 1 + 4 files changed, 1 insertion(+), 160 deletions(-) delete mode 100644 js_environment/test/unittest/js_env_log_unit_test/BUILD.gn delete mode 100644 js_environment/test/unittest/js_env_log_unit_test/js_env_log_unit_test.cpp diff --git a/js_environment/test/unittest/BUILD.gn b/js_environment/test/unittest/BUILD.gn index 04a5773ea1..8121c7edde 100644 --- a/js_environment/test/unittest/BUILD.gn +++ b/js_environment/test/unittest/BUILD.gn @@ -18,7 +18,6 @@ group("unittest") { testonly = true deps = [ - "js_env_log_unit_test:unittest", "js_environment_test:unittest", "source_map_test:unittest", "uncaught_exception_callback_test:unittest", diff --git a/js_environment/test/unittest/js_env_log_unit_test/BUILD.gn b/js_environment/test/unittest/js_env_log_unit_test/BUILD.gn deleted file mode 100644 index 33831d1803..0000000000 --- a/js_environment/test/unittest/js_env_log_unit_test/BUILD.gn +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/test.gni") -import("../../../js_environment.gni") - -module_output_path = "ability_runtime/js_environment" - -ohos_unittest("js_env_log_test") { - module_out_path = module_output_path - include_dirs = [ "${utils_path}/include" ] - sources = [ "js_env_log_unit_test.cpp" ] - - configs = [] - - external_deps = [ - "ability_runtime:js_environment", - "c_utils:utils", - "hilog:libhilog", - ] -} - -group("unittest") { - testonly = true - - deps = [ ":js_env_log_test" ] -} diff --git a/js_environment/test/unittest/js_env_log_unit_test/js_env_log_unit_test.cpp b/js_environment/test/unittest/js_env_log_unit_test/js_env_log_unit_test.cpp deleted file mode 100644 index 2842a632c4..0000000000 --- a/js_environment/test/unittest/js_env_log_unit_test/js_env_log_unit_test.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "js_env_logger.h" -#include "hilog/log.h" -#include - -using namespace testing; -using namespace testing::ext; - -#ifndef ENV_LOG_DOMAIN -#define ENV_LOG_DOMAIN 0xD001300 -#endif - -#ifndef ENV_LOG_TAG -#define ENV_LOG_TAG "JsEnv" -#endif - -namespace OHOS { -namespace JsEnv { -void Logger(JsEnvLogLevel level, const char* fileName, const char* functionName, int line, - const char* fmt, ...) -{ - std::string cFormat = "[%{public}s(%{public}s:%{public}d)]"; - cFormat += fmt; - va_list printArgs; - va_start(printArgs, fmt); - switch (level) { - case JsEnvLogLevel::DEBUG: - HILOG_IMPL(LOG_CORE, LOG_DEBUG, ENV_LOG_DOMAIN, ENV_LOG_TAG, - cFormat.c_str(), fileName, functionName, line, printArgs); - break; - case JsEnvLogLevel::INFO: - HILOG_IMPL(LOG_CORE, LOG_INFO, ENV_LOG_DOMAIN, ENV_LOG_TAG, - cFormat.c_str(), fileName, functionName, line, printArgs); - break; - case JsEnvLogLevel::WARN: - HILOG_IMPL(LOG_CORE, LOG_WARN, ENV_LOG_DOMAIN, ENV_LOG_TAG, - cFormat.c_str(), fileName, functionName, line, printArgs); - break; - case JsEnvLogLevel::ERROR: - HILOG_IMPL(LOG_CORE, LOG_ERROR, ENV_LOG_DOMAIN, ENV_LOG_TAG, - cFormat.c_str(), fileName, functionName, line, printArgs); - break; - case JsEnvLogLevel::FATAL: - HILOG_IMPL(LOG_CORE, LOG_FATAL, ENV_LOG_DOMAIN, ENV_LOG_TAG, - cFormat.c_str(), fileName, functionName, line, printArgs); - break; - default: - break; - } - va_end(printArgs); -} - -class JsEnvLogTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; -}; - -void JsEnvLogTest::SetUpTestCase() -{ - JsEnvLogger::logger = Logger; -} - -void JsEnvLogTest::TearDownTestCase() -{} - -void JsEnvLogTest::SetUp() -{} - -void JsEnvLogTest::TearDown() -{} - -/** - * @tc.name: Logger_0100 - * @tc.desc: Logger_0100 Test - * @tc.type: FUNC - * @tc.require: issueI6I13A - */ -HWTEST_F(JsEnvLogTest, Logger_0100, TestSize.Level0) -{ - JSENV_LOG_D(">>>>>>>>TestDebug<<<<<<<<<<<"); - JSENV_LOG_I(">>>>>>>>TestInfo<<<<<<<<<<<"); - JSENV_LOG_W(">>>>>>>>TestWarning<<<<<<<<<<<"); - JSENV_LOG_E(">>>>>>>>TestError<<<<<<<<<<<"); - JSENV_LOG_F(">>>>>>>>TestFatal<<<<<<<<<<<"); -} - -/** - * @tc.name: Logger_0200 - * @tc.desc: Logger_0200 Test - * @tc.type: FUNC - * @tc.require: issueI6I13A - */ -HWTEST_F(JsEnvLogTest, Logger_0200, TestSize.Level0) -{ - JSENV_LOG_D(">>>>>>>>TestDebug<<<<<<<<<<< + %s", "with string"); - JSENV_LOG_I(">>>>>>>>TestInfo<<<<<<<<<<< + %s", "with string"); - JSENV_LOG_W(">>>>>>>>TestWarning<<<<<<<<<<< + %s", "with string"); - JSENV_LOG_E(">>>>>>>>TestError<<<<<<<<<<< + %s + %d", "with int", 32); - JSENV_LOG_F(">>>>>>>>TestFatal<<<<<<<<<<< + %s", "with string"); -} -} // namespace JsEnv -} // namespace OHOS diff --git a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp index 6a7a635413..dc1fa5528e 100644 --- a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp +++ b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp @@ -1329,6 +1329,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, AppRecoverKill_001, TestSize.Level1) abilityMs_->AppRecoverKill(pid, StateReason::JS_ERROR); abilityMs_->AppRecoverKill(pid, StateReason::LIFECYCLE); abilityMs_->AppRecoverKill(pid, StateReason::APP_FREEZE); + EXPECT_TRUE(abilityMs_ != nullptr); } /* From d1b9427d31eba28b5c260e46a052ac42f97add87 Mon Sep 17 00:00:00 2001 From: xia Date: Mon, 3 Jun 2024 17:26:38 +0800 Subject: [PATCH 12/16] =?UTF-8?q?401=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xia --- .../ability_manager/js_ability_manager.cpp | 44 +++++++------- .../app/js_app_manager/js_app_manager.cpp | 58 +++++++++---------- .../js_app_manager/js_app_manager_utils.cpp | 6 +- .../js_dialog_request/js_dialog_request.cpp | 18 +++--- .../js_mission_manager/mission_manager.cpp | 40 ++++++------- .../native/js_service_extension_context.cpp | 32 +++++----- .../serviceroutermgr/service_router_mgr.cpp | 2 +- 7 files changed, 99 insertions(+), 101 deletions(-) diff --git a/frameworks/js/napi/ability_manager/js_ability_manager.cpp b/frameworks/js/napi/ability_manager/js_ability_manager.cpp index 1d67686f66..18a3ba11f8 100644 --- a/frameworks/js/napi/ability_manager/js_ability_manager.cpp +++ b/frameworks/js/napi/ability_manager/js_ability_manager.cpp @@ -157,7 +157,7 @@ private: } if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param."); - ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver."); return CreateJsUndefined(env); } @@ -165,7 +165,7 @@ private: if (type == ON_OFF_TYPE_ABILITY_FOREGROUND_STATE) { return OnOnAbilityForeground(env, argc, argv); } - ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState"); + ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState."); return CreateJsUndefined(env); } @@ -203,7 +203,7 @@ private: } if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param."); - ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver."); return CreateJsUndefined(env); } @@ -211,7 +211,7 @@ private: if (type == ON_OFF_TYPE_ABILITY_FOREGROUND_STATE) { return OnOffAbilityForeground(env, argc, argv); } - ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState"); + ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState."); return CreateJsUndefined(env); } @@ -243,19 +243,19 @@ private: std::string assertSessionStr; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], assertSessionStr) || !CheckIsNumString(assertSessionStr)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error."); - ThrowInvalidParamError(env, "Parse param sessionId failed, must be a string"); + ThrowInvalidParamError(env, "Parse param sessionId failed, must be a string."); return CreateJsUndefined(env); } uint64_t assertSessionId = std::stoull(assertSessionStr); if (assertSessionId == 0) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id failed."); - ThrowInvalidParamError(env, "Parse param sessionId failed, value must not be equal to zero"); + ThrowInvalidParamError(env, "Parse param sessionId failed, value must not be equal to zero."); return CreateJsUndefined(env); } int32_t userStatus; if (!ConvertFromJsValue(env, argv[INDEX_ONE], userStatus)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed."); - ThrowInvalidParamError(env, "Parse param status failed, must be a UserStatus"); + ThrowInvalidParamError(env, "Parse param status failed, must be a UserStatus."); return CreateJsUndefined(env); } @@ -346,7 +346,7 @@ private: int upperLimit = -1; if (!ConvertFromJsValue(env, info.argv[0], upperLimit)) { #ifdef ENABLE_ERRCODE - ThrowInvalidParamError(env, "Parse param upperLimit failed, must be a number"); + ThrowInvalidParamError(env, "Parse param upperLimit failed, must be a number."); #endif return CreateJsUndefined(env); } @@ -397,7 +397,7 @@ private: AppExecFwk::Configuration changeConfig; if (!UnwrapConfiguration(env, info.argv[0], changeConfig)) { #ifdef ENABLE_ERRCODE - ThrowInvalidParamError(env, "Parse param config failed, must be a Configuration"); + ThrowInvalidParamError(env, "Parse param config failed, must be a Configuration."); #else complete = [](napi_env env, NapiAsyncTask& task, int32_t status) { task.Reject(env, CreateJsError(env, ERR_INVALID_VALUE, "config is invalid.")); @@ -467,7 +467,7 @@ private: } int32_t missionId = -1; if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], missionId)) { - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return CreateJsUndefined(env); } napi_value lastParam = info.argc > ARGC_ONE ? info.argv[INDEX_ONE] : nullptr; @@ -515,7 +515,7 @@ private: int reqCode = 0; if (!ConvertFromJsValue(env, info.argv[1], reqCode)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Get requestCode param error"); - ThrowInvalidParamError(env, "Parse param requestCode failed, must be a number"); + ThrowInvalidParamError(env, "Parse param requestCode failed, must be a number."); break; } @@ -523,7 +523,7 @@ private: int resultCode = ERR_OK; if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[0], resultCode, want)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Unrwrap abilityResult param error"); - ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult"); + ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult."); break; } @@ -580,17 +580,15 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName) || bundleName.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error."); - auto errMsg = "Non empty package name needs to be provided"; - ThrowError(env, static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), errMsg); + TAG_LOGE(AAFwkTag::ABILITYMGR, "Parse param bundleName failed, must be a string."); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } bool enableState = false; if (!ConvertFromJsValue(env, argv[INDEX_ONE], enableState)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed."); - auto errMsg = "The second parameter needs to provide a Boolean type setting value"; - ThrowError(env, static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), errMsg); + TAG_LOGE(AAFwkTag::ABILITYMGR, "Parse param enable failed, must be a boolean."); + ThrowInvalidParamError(env, "Parse param enable failed, must be a boolean."); return CreateJsUndefined(env); } @@ -633,27 +631,27 @@ private: bool stageMode = false; napi_status status = OHOS::AbilityRuntime::IsStageContext(env, info.argv[0], stageMode); if (status != napi_ok || !stageMode) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "it is not a stage mode"); - ThrowInvalidParamError(env, "Parse param context failed, must be stageMode"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "it is not a context of stageMode"); + ThrowInvalidParamError(env, "Parse param context failed, must be a context of stageMode."); return CreateJsUndefined(env); } auto context = OHOS::AbilityRuntime::GetStageModeContext(env, info.argv[0]); if (context == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get context failed"); - ThrowInvalidParamError(env, "Parse param context failed, must not be nullptr"); + ThrowInvalidParamError(env, "Parse param context failed, must not be nullptr."); return CreateJsUndefined(env); } auto uiAbilityContext = AbilityRuntime::Context::ConvertTo(context); if (uiAbilityContext == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "convert to UIAbility context failed"); - ThrowInvalidParamError(env, "Parse param context failed, must be UIAbilityContext"); + ThrowInvalidParamError(env, "Parse param context failed, must be UIAbilityContext."); return CreateJsUndefined(env); } std::string appId; if (!ConvertFromJsValue(env, info.argv[1], appId)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "OnOpenAtomicService, parse appId failed."); - ThrowInvalidParamError(env, "Parse param appId failed, must be a string"); + ThrowInvalidParamError(env, "Parse param appId failed, must be a string."); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index fe67b114f0..01ee913081 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -254,7 +254,7 @@ private: if (!CheckOnOffType(env, argc, argv)) { ThrowInvalidParamError(env, "Parse param type failed, must be a string," - "value must be applicationState, appForegroundState or abilityFirstFrameState"); + "value must be applicationState, appForegroundState or abilityFirstFrameState."); return CreateJsUndefined(env); } @@ -300,7 +300,7 @@ private: } if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid param"); - ThrowInvalidParamError(env, "Parse param observer failed, must be a ApplicationStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a ApplicationStateObserver."); return CreateJsUndefined(env); } std::vector bundleNameList; @@ -343,7 +343,7 @@ private: } if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid param."); - ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver."); return CreateJsUndefined(env); } if (observerForeground_ == nullptr) { @@ -406,7 +406,7 @@ private: if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object) || !IsJSFunctionExist(env, argv[INDEX_ONE], "onAbilityFirstFrameDrawn")) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid param."); - ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver."); return CreateJsUndefined(env); } std::string bundleName; @@ -414,7 +414,7 @@ private: if (!IsParasNullOrUndefined(env, argv[INDEX_TWO]) && (!ConvertFromJsValue(env, argv[INDEX_TWO], bundleName) || bundleName.empty())) { TAG_LOGE(AAFwkTag::APPMGR, "Get bundleName error or bundleName empty!"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } } @@ -460,7 +460,7 @@ private: (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object) || !IsJSFunctionExist(env, argv[INDEX_ONE], "onAbilityFirstFrameDrawn"))) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid param."); - ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver."); return CreateJsUndefined(env); } } @@ -485,20 +485,20 @@ private: } if (!CheckOnOffType(env, argc, argv)) { ThrowInvalidParamError(env, "Parse param type failed, must be a string," - "value must be applicationState, appForegroundState or abilityFirstFrameState"); + "value must be applicationState, appForegroundState or abilityFirstFrameState."); return CreateJsUndefined(env); } int64_t observerId = -1; napi_get_value_int64(env, argv[INDEX_ONE], &observerId); if (observer_ == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "observer is nullptr, please register first"); - ThrowInvalidParamError(env, "observer is nullptr, please register first"); + TAG_LOGE(AAFwkTag::APPMGR, "observer is nullptr, please register first."); + ThrowInvalidParamError(env, "observer is nullptr, please register first."); return CreateJsUndefined(env); } if (!observer_->FindObserverByObserverId(observerId)) { TAG_LOGE(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast(observerId)); - ThrowInvalidParamError(env, "not find observerId"); + ThrowInvalidParamError(env, "not find observerId."); return CreateJsUndefined(env); } TAG_LOGD(AAFwkTag::APPMGR, "find observer exist observer:%{public}d", static_cast(observerId)); @@ -540,7 +540,7 @@ private: int32_t observerId = -1; if (!ConvertFromJsValue(env, argv[INDEX_ONE], observerId)) { TAG_LOGE(AAFwkTag::APPMGR, "Parse observerId failed"); - ThrowInvalidParamError(env, "Parse param observerId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param observerId failed, must be a number."); return CreateJsUndefined(env); } @@ -551,7 +551,7 @@ private: } if (!observerSync_->FindObserverByObserverId(observerId)) { TAG_LOGE(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast(observerId)); - ThrowInvalidParamError(env, "not find observerId"); + ThrowInvalidParamError(env, "not find observerId."); return CreateJsUndefined(env); } int32_t ret = appManager_->UnregisterApplicationStateObserver(observerSync_); @@ -575,7 +575,7 @@ private: } if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid param."); - ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver"); + ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver."); return CreateJsUndefined(env); } if (observerForeground_ == nullptr || appManager_ == nullptr) { @@ -673,7 +673,7 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } auto info = std::make_shared(); @@ -713,12 +713,12 @@ private: int32_t bundleType = -1; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleType)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleType error!"); - ThrowInvalidParamError(env, "failed to get bundleType"); + ThrowInvalidParamError(env, "Parse param bundleType failed, must be a BundleType."); return CreateJsUndefined(env); } if (bundleType < 0) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid bundle type:%{public}d", bundleType); - ThrowInvalidParamError(env, "invalid bundle type"); + ThrowInvalidParamError(env, "Parse param bundleType failed, must not be less then zero."); return CreateJsUndefined(env); } NapiAsyncTask::CompleteCallback complete = @@ -779,7 +779,7 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleName error!"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } @@ -818,7 +818,7 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } @@ -856,14 +856,14 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleName wrong!"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } uint32_t versionCode = 0; if (!ConvertFromJsValue(env, argv[1], versionCode)) { TAG_LOGE(AAFwkTag::APPMGR, "get versionCode failed!"); - ThrowInvalidParamError(env, "Parse param versionCode failed, must be a number"); + ThrowInvalidParamError(env, "Parse param versionCode failed, must be a number."); return CreateJsUndefined(env); } @@ -898,13 +898,13 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "Parse bundleName failed"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } int32_t accountId = -1; if (!ConvertFromJsValue(env, argv[1], accountId)) { TAG_LOGE(AAFwkTag::APPMGR, "Parse userId failed"); - ThrowInvalidParamError(env, "Parse param accountId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param accountId failed, must be a number."); return CreateJsUndefined(env); } @@ -984,7 +984,7 @@ private: int32_t pid; if (!ConvertFromJsValue(env, argv[0], pid)) { TAG_LOGE(AAFwkTag::APPMGR, "get pid failed"); - ThrowInvalidParamError(env, "Parse param pid failed, must be a number"); + ThrowInvalidParamError(env, "Parse param pid failed, must be a number."); return CreateJsUndefined(env); } @@ -1023,7 +1023,7 @@ private: bool isPromiseType = false; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "First parameter must be string"); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } if (argc == ARGC_ONE) { @@ -1035,11 +1035,11 @@ private: } else if (argc == ARGC_THREE) { if (!ConvertFromJsValue(env, argv[1], userId)) { TAG_LOGW(AAFwkTag::APPMGR, "Must input userid and use callback when argc is three."); - ThrowInvalidParamError(env, "Parse param userId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param userId failed, must be a number."); return CreateJsUndefined(env); } } else { - ThrowInvalidParamError(env, "The number of param exceeded"); + ThrowInvalidParamError(env, "The number of param exceeded."); return CreateJsUndefined(env); } @@ -1076,7 +1076,7 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "Get bundle name wrong."); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } @@ -1121,13 +1121,13 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "Get bundle name wrong."); - ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } int32_t appCloneIndex = 0; if (argc > ARGC_ONE && !ConvertFromJsValue(env, argv[1], appCloneIndex)) { TAG_LOGE(AAFwkTag::APPMGR, "Get appCloneIndex wrong."); - ThrowInvalidParamError(env, "Parse param appCloneIndex failed, must be a string"); + ThrowInvalidParamError(env, "Parse param appCloneIndex failed, must be a string."); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index f339fa22e8..f2f016bfe7 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -276,12 +276,12 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, { if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], param.bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param bundleName failed."); - errorMsg = "Param bundleName must be a valid string."; + errorMsg = "Parse param bundleName failed, must be a valid string."; return false; } if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], param.userId)) { TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param userId failed."); - errorMsg = "Param userId must be a valid number."; + errorMsg = "Parse param userId failed, must be a valid number."; return false; } if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], param.preloadMode) @@ -292,7 +292,7 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, } if (argc > ARG_INDEX_3 && !ConvertFromJsValue(env, argv[ARG_INDEX_3], param.appIndex)) { TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param appIndex failed."); - errorMsg = "Param appIndex must be a valid number."; + errorMsg = "Parse param appIndex failed, must be a valid number."; return false; } return true; diff --git a/frameworks/js/napi/js_dialog_request/js_dialog_request.cpp b/frameworks/js/napi/js_dialog_request/js_dialog_request.cpp index ff9d5239f5..717af3c4dc 100755 --- a/frameworks/js/napi/js_dialog_request/js_dialog_request.cpp +++ b/frameworks/js/napi/js_dialog_request/js_dialog_request.cpp @@ -86,15 +86,15 @@ private: OHOS::AAFwk::Want want; if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) { - TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid."); - ThrowInvalidParamError(env, "Parameter error: The input want is invalid."); + TAG_LOGE(AAFwkTag::DIALOG, "Parse param want failed, must be a Want."); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return CreateJsUndefined(env); } sptr callerToken = want.GetRemoteObject(RequestConstants::REQUEST_TOKEN_KEY); if (!callerToken) { - TAG_LOGE(AAFwkTag::DIALOG, "Can not get token from target want."); - ThrowInvalidParamError(env, "Parameter error: Can not get token from target want."); + TAG_LOGE(AAFwkTag::DIALOG, "get token from target want failed."); + ThrowInvalidParamError(env, "Parameter error: get token from target want failed."); return CreateJsUndefined(env); } int32_t left = want.GetIntParam(RequestConstants::WINDOW_RECTANGLE_LEFT_KEY, 0); @@ -105,8 +105,8 @@ private: auto requestInfo = new RequestInfo(callerToken, left, top, width, height); auto jsRequestInfo = RequestInfo::WrapRequestInfo(env, requestInfo); if (jsRequestInfo == nullptr) { - TAG_LOGE(AAFwkTag::DIALOG, "Can not wrap request info from target request."); - ThrowInvalidParamError(env, "Parameter error: Can not wrap request info from target request."); + TAG_LOGE(AAFwkTag::DIALOG, "Wrap Param requestInfo failed, must be a RequestInfo."); + ThrowInvalidParamError(env, "Wrap Param requestInfo failed, must be a RequestInfo."); return CreateJsUndefined(env); } @@ -125,14 +125,14 @@ private: OHOS::AAFwk::Want want; if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) { TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid."); - ThrowInvalidParamError(env, "Parameter error: The input want is invalid."); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return CreateJsUndefined(env); } sptr remoteObj = want.GetRemoteObject(RequestConstants::REQUEST_CALLBACK_KEY); if (!remoteObj) { - TAG_LOGE(AAFwkTag::DIALOG, "Can not get callback from target want."); - ThrowInvalidParamError(env, "Parameter error: Can not get callback from target want."); + TAG_LOGE(AAFwkTag::DIALOG, "Wrap Param requestCallback failed, must be a RequestCallback."); + ThrowInvalidParamError(env, "Wrap Param requestCallback failed, must be a RequestCallback."); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/js_mission_manager/mission_manager.cpp b/frameworks/js/napi/js_mission_manager/mission_manager.cpp index aea7139e60..4bf647d335 100755 --- a/frameworks/js/napi/js_mission_manager/mission_manager.cpp +++ b/frameworks/js/napi/js_mission_manager/mission_manager.cpp @@ -146,7 +146,7 @@ private: } if (!CheckOnOffType(env, argc, argv)) { - ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission"); + ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission."); return CreateJsUndefined(env); } @@ -183,7 +183,7 @@ private: } if (!AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_object)) { TAG_LOGE(AAFwkTag::MISSION, "Invalid param"); - ThrowInvalidParamError(env, "Parse param listener failed, must be a MissionListener"); + ThrowInvalidParamError(env, "Parse param listener failed, must be a MissionListener."); return CreateJsUndefined(env); } @@ -230,14 +230,14 @@ private: } if (!CheckOnOffType(env, argc, argv)) { - ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission"); + ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission."); return CreateJsUndefined(env); } int32_t missionListenerId = -1; if (!ConvertFromJsValue(env, argv[ARGC_ONE], missionListenerId)) { TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed"); - ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number."); return CreateJsUndefined(env); } @@ -282,7 +282,7 @@ private: int32_t missionListenerId = -1; if (!ConvertFromJsValue(env, argv[INDEX_ONE], missionListenerId)) { TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed"); - ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number."); return CreateJsUndefined(env); } @@ -326,13 +326,13 @@ private: std::string deviceId; if (!ConvertFromJsValue(env, argv[0], deviceId)) { TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed"); - ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string"); + ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string."); return CreateJsUndefined(env); } int numMax = -1; if (!ConvertFromJsValue(env, argv[1], numMax)) { TAG_LOGE(AAFwkTag::MISSION, "Parse numMax failed"); - ThrowInvalidParamError(env, "Parse param numMax failed, must be a number"); + ThrowInvalidParamError(env, "Parse param numMax failed, must be a number."); return CreateJsUndefined(env); } @@ -366,13 +366,13 @@ private: std::string deviceId; if (!ConvertFromJsValue(env, argv[0], deviceId)) { TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed"); - ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string"); + ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string."); return CreateJsUndefined(env); } int32_t missionId = -1; if (!ConvertFromJsValue(env, argv[1], missionId)) { TAG_LOGE(AAFwkTag::MISSION, "Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return CreateJsUndefined(env); } @@ -467,13 +467,13 @@ private: if (!ConvertFromJsValue(env, argv[0], deviceId)) { TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse deviceId failed"); - ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string"); + ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string."); return false; } if (!ConvertFromJsValue(env, argv[1], missionId)) { TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return false; } @@ -491,7 +491,7 @@ private: int32_t missionId = -1; if (!ConvertFromJsValue(env, argv[0], missionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return CreateJsUndefined(env); } @@ -524,7 +524,7 @@ private: int32_t missionId = -1; if (!ConvertFromJsValue(env, argv[0], missionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return CreateJsUndefined(env); } @@ -557,7 +557,7 @@ private: int32_t missionId = -1; if (!ConvertFromJsValue(env, argv[0], missionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return CreateJsUndefined(env); } @@ -611,7 +611,7 @@ private: int32_t missionId = -1; if (!ConvertFromJsValue(env, argv[0], missionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param missionId failed, must be a number."); return CreateJsUndefined(env); } decltype(argc) unwrapArgc = 1; @@ -654,7 +654,7 @@ private: napi_get_array_length(env, argv[0], &nativeArrayLen); if (nativeArrayLen == 0) { TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground MissionId is null"); - ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero"); + ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero."); return CreateJsUndefined(env); } napi_value element = nullptr; @@ -663,7 +663,7 @@ private: napi_get_element(env, argv[0], i, &element); if (!ConvertFromJsValue(env, element, missionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse missionId failed"); - ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number"); + ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number."); return CreateJsUndefined(env); } missionIds.push_back(missionId); @@ -674,7 +674,7 @@ private: if (argc > ARGC_ONE && AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_number)) { if (!ConvertFromJsValue(env, argv[1], topMissionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse topMissionId failed"); - ThrowInvalidParamError(env, "Parse param topMission failed, must be a number"); + ThrowInvalidParamError(env, "Parse param topMission failed, must be a number."); return CreateJsUndefined(env); } unwrapArgc++; @@ -713,7 +713,7 @@ private: napi_get_array_length(env, argv[0], &nativeArrayLen); if (nativeArrayLen == 0) { TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground MissionId is null"); - ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero"); + ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero."); return CreateJsUndefined(env); } napi_value element = nullptr; @@ -722,7 +722,7 @@ private: napi_get_element(env, argv[0], i, &element); if (!ConvertFromJsValue(env, element, missionId)) { TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Parse topMissionId failed"); - ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number"); + ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number."); return CreateJsUndefined(env); } missionIds.push_back(missionId); diff --git a/frameworks/native/ability/native/js_service_extension_context.cpp b/frameworks/native/ability/native/js_service_extension_context.cpp index b06713a41b..4b1d09b6a0 100644 --- a/frameworks/native/ability/native/js_service_extension_context.cpp +++ b/frameworks/native/ability/native/js_service_extension_context.cpp @@ -277,12 +277,12 @@ private: if (!CheckTypeForNapiValue(env, info.argv[ARGC_ZERO], napi_string)) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "link must be string"); - ThrowInvalidParamError(env, "Parse param link failed, must be a string"); + ThrowInvalidParamError(env, "Parse param link failed, must be a string."); return false; } if (!ConvertFromJsValue(env, info.argv[ARGC_ZERO], linkValue) || !CheckUrl(linkValue)) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "link parameter invalid"); - ThrowInvalidParamError(env, "link parameter invalid"); + ThrowInvalidParamError(env, "link parameter invalid."); return false; } @@ -290,7 +290,7 @@ private: TAG_LOGD(AAFwkTag::SERVICE_EXT, "OpenLinkOptions is used."); if (!AppExecFwk::UnwrapOpenLinkOptions(env, info.argv[INDEX_ONE], openLinkOptions, want)) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "OpenLinkOptions parse failed"); - ThrowInvalidParamError(env, "Parse param options failed, must be a OpenLinkOptions"); + ThrowInvalidParamError(env, "Parse param options failed, must be a OpenLinkOptions."); return false; } } @@ -405,7 +405,7 @@ private: unwrapArgc = ARGC_ZERO; // Check input want if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) { - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return false; } ++unwrapArgc; @@ -467,7 +467,7 @@ private: napi_env env, NapiCallbackInfo& info, AAFwk::Want& want, int32_t& accountId) { if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) { - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return false; } @@ -475,12 +475,12 @@ private: if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_number)) { if (!ConvertFromJsValue(env, info.argv[1], accountId)) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "check input param accountId failed"); - ThrowInvalidParamError(env, "Parse param accountId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param accountId failed, must be a number."); return false; } } else { TAG_LOGE(AAFwkTag::SERVICE_EXT, "input parameter type invalid"); - ThrowInvalidParamError(env, "Parse param accountId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param accountId failed, must be a number."); return false; } } @@ -624,12 +624,12 @@ private: unwrapArgc = ARGC_ZERO; // Check input want if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) { - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return false; } ++unwrapArgc; if (!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) { - ThrowInvalidParamError(env, "Parse param accountId failed, must be a number"); + ThrowInvalidParamError(env, "Parse param accountId failed, must be a number."); return false; } ++unwrapArgc; @@ -677,11 +677,11 @@ private: AAFwk::Want want; sptr connection = new JSServiceExtensionConnection(env); if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) { - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return CreateJsUndefined(env); } if (!CheckConnectionParam(env, info.argv[1], connection, want)) { - ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions"); + ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions."); return CreateJsUndefined(env); } int64_t connectId = connection->GetConnectionId(); @@ -726,7 +726,7 @@ private: return CreateJsUndefined(env); } if (!CheckConnectionParam(env, info.argv[INDEX_TWO], connection, want, accountId)) { - ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions"); + ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions."); return CreateJsUndefined(env); } int64_t connectId = connection->GetConnectionId(); @@ -792,7 +792,7 @@ private: } int64_t connectId = -1; if (!AppExecFwk::UnwrapInt64FromJS2(env, info.argv[INDEX_ZERO], connectId)) { - ThrowInvalidParamError(env, "Parse param connection failed, must be a number"); + ThrowInvalidParamError(env, "Parse param connection failed, must be a number."); return CreateJsUndefined(env); } @@ -862,7 +862,7 @@ private: } AAFwk::Want want; if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) { - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return CreateJsUndefined(env); } @@ -937,7 +937,7 @@ private: } AAFwk::Want want; if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) { - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return CreateJsUndefined(env); } @@ -1014,7 +1014,7 @@ private: AAFwk::Want want; if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to parse want!"); - ThrowInvalidParamError(env, "Parse param want failed, must be a Want"); + ThrowInvalidParamError(env, "Parse param want failed, must be a Want."); return CreateJsUndefined(env); } diff --git a/service_router_framework/interfaces/kits/js/serviceroutermgr/service_router_mgr.cpp b/service_router_framework/interfaces/kits/js/serviceroutermgr/service_router_mgr.cpp index 707aeb640c..339ba92d43 100755 --- a/service_router_framework/interfaces/kits/js/serviceroutermgr/service_router_mgr.cpp +++ b/service_router_framework/interfaces/kits/js/serviceroutermgr/service_router_mgr.cpp @@ -238,7 +238,7 @@ napi_value QueryBusinessAbilityInfos(napi_env env, napi_callback_info info) if (args.GetMaxArgc() >= ARGS_SIZE_ONE) { if (!ParseBusinessAbilityInfo(env, args[ARGS_POS_ZERO], asyncCallbackInfo->filter)) { BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, TYPE_BUSINESS_AIBILITY_FILTER, - TYPE_STRING); + "BusinessAbilityFilter"); return nullptr; } if (args.GetMaxArgc() == ARGS_SIZE_TWO) { From 5e6c34d805f1a5d80710bbdf5de7f9af7eb4d8cd Mon Sep 17 00:00:00 2001 From: XKK Date: Mon, 3 Jun 2024 21:14:09 +0800 Subject: [PATCH 13/16] =?UTF-8?q?appIndex=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: XKK --- services/abilitymgr/src/ability_manager_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index f6d19d10a3..01c952d385 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -10741,7 +10741,7 @@ void AbilityManagerService::GetRunningMultiAppIndex(const std::string &bundleNam TAG_LOGW(AAFwkTag::ABILITYMGR, "GetAppMgr failed"); return; } - auto ret = appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo); + auto ret = IN_PROCESS_CALL(appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo)); if (ret != ERR_OK) { TAG_LOGW(AAFwkTag::ABILITYMGR, "GetRunningMultiAppInfo failed bundleName = %{public}s", bundleName.c_str()); From ed3d77d1e5d2bd65ea3d069d1f879df012d4ef23 Mon Sep 17 00:00:00 2001 From: XKK Date: Mon, 3 Jun 2024 21:33:40 +0800 Subject: [PATCH 14/16] remove Signed-off-by: XKK --- services/abilitymgr/src/ability_manager_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 01c952d385..f6d19d10a3 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -10741,7 +10741,7 @@ void AbilityManagerService::GetRunningMultiAppIndex(const std::string &bundleNam TAG_LOGW(AAFwkTag::ABILITYMGR, "GetAppMgr failed"); return; } - auto ret = IN_PROCESS_CALL(appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo)); + auto ret = appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo); if (ret != ERR_OK) { TAG_LOGW(AAFwkTag::ABILITYMGR, "GetRunningMultiAppInfo failed bundleName = %{public}s", bundleName.c_str()); From ce4cd5aa5201680eb95d9bb2d977bd9f5c6357ed Mon Sep 17 00:00:00 2001 From: jiangzhijun8 Date: Mon, 3 Jun 2024 22:41:55 +0800 Subject: [PATCH 15/16] add autostartup Application identity identification bug fix Signed-off-by: jiangzhijun8 --- services/abilitymgr/src/ability_auto_startup_data_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/abilitymgr/src/ability_auto_startup_data_manager.cpp b/services/abilitymgr/src/ability_auto_startup_data_manager.cpp index 5d82797912..a262d5338d 100644 --- a/services/abilitymgr/src/ability_auto_startup_data_manager.cpp +++ b/services/abilitymgr/src/ability_auto_startup_data_manager.cpp @@ -413,6 +413,10 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV info.appCloneIndex = jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get(); } + if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) { + info.accessTokenId = jsonObject.at(JSON_KEY_ACCESS_TOKENID).get(); + } + nlohmann::json jsonValueObject = nlohmann::json::parse(value.ToString(), nullptr, false); if (jsonValueObject.is_discarded()) { TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to parse jsonValueObject."); From 9438e6185487dc95696304409fee352b30f99ff2 Mon Sep 17 00:00:00 2001 From: jiangzhijun8 Date: Mon, 3 Jun 2024 22:41:55 +0800 Subject: [PATCH 16/16] add autostartup Application identity identification bug fix Signed-off-by: jiangzhijun8 --- .../abilitymgr/src/ability_auto_startup_data_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/abilitymgr/src/ability_auto_startup_data_manager.cpp b/services/abilitymgr/src/ability_auto_startup_data_manager.cpp index 5d82797912..ac73e712b8 100644 --- a/services/abilitymgr/src/ability_auto_startup_data_manager.cpp +++ b/services/abilitymgr/src/ability_auto_startup_data_manager.cpp @@ -413,6 +413,10 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV info.appCloneIndex = jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get(); } + if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) { + info.accessTokenId = jsonObject.at(JSON_KEY_ACCESS_TOKENID).get(); + } + nlohmann::json jsonValueObject = nlohmann::json::parse(value.ToString(), nullptr, false); if (jsonValueObject.is_discarded()) { TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to parse jsonValueObject."); @@ -422,10 +426,6 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV if (jsonValueObject.contains(JSON_KEY_TYPE_NAME) && jsonValueObject[JSON_KEY_TYPE_NAME].is_string()) { info.abilityTypeName = jsonValueObject.at(JSON_KEY_TYPE_NAME).get(); } - - if (jsonValueObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonValueObject[JSON_KEY_ACCESS_TOKENID].is_string()) { - info.accessTokenId = jsonValueObject.at(JSON_KEY_ACCESS_TOKENID).get(); - } return info; }