diff --git a/frameworks/kits/ability/native/include/ability_impl.h b/frameworks/kits/ability/native/include/ability_impl.h index c1240698e951fdff2bafee00490f5f76c13a896c..eb2b473130227e2070e4ed0f2a15180e53547d2d 100755 --- a/frameworks/kits/ability/native/include/ability_impl.h +++ b/frameworks/kits/ability/native/include/ability_impl.h @@ -52,7 +52,7 @@ public: * @param useNewMission new mission flag. */ static void SetUseNewMission(bool useNewMission); - + /** * @brief Get if use new mission. * diff --git a/frameworks/kits/ability/native/include/ability_runtime/js_ability.h b/frameworks/kits/ability/native/include/ability_runtime/js_ability.h index 7c2d5204f3d97daf02c811743ef16c1700d720c0..dd59355bba7f11c2b12b85c6db6f913363cda121 100755 --- a/frameworks/kits/ability/native/include/ability_runtime/js_ability.h +++ b/frameworks/kits/ability/native/include/ability_runtime/js_ability.h @@ -63,6 +63,7 @@ protected: private: void CallObjectMethod(const char* name, NativeValue* const* argv = nullptr, size_t argc = 0); std::unique_ptr CreateAppWindowStage(); + void GetPageStackFromWant(const Want& want, std::string& pageStack); JsRuntime& jsRuntime_; std::unique_ptr jsAbilityObj_; diff --git a/frameworks/kits/ability/native/include/data_ability_result.h b/frameworks/kits/ability/native/include/data_ability_result.h index f6e8fe8e90c14c95ad7ca33977f7483c7e29ce51..7dc4304db20e1eaaaf8b7135a13be6eb908606d4 100644 --- a/frameworks/kits/ability/native/include/data_ability_result.h +++ b/frameworks/kits/ability/native/include/data_ability_result.h @@ -26,66 +26,66 @@ namespace AppExecFwk { class DataAbilityResult final : public Parcelable { public: /** - * @brief A constructor used to create a DataAbilityResult instance - * with the input parameter count specified. + * @brief A constructor used to create a DataAbilityResult instance + * with the input parameter count specified. */ DataAbilityResult(int count); - + /** - * @brief A constructor used to create a DataAbilityResult instance + * @brief A constructor used to create a DataAbilityResult instance * with the input parameter uri specified - */ + */ DataAbilityResult(const Uri &uri); - + /** - * @brief A constructor used to create a DataAbilityResult instance + * @brief A constructor used to create a DataAbilityResult instance * with a Parcel object specified. */ DataAbilityResult(Parcel &parcel); /** - * @brief A constructor used to create a DataAbilityResult instance - * with input parameters uri, count, and failure specified. + * @brief A constructor used to create a DataAbilityResult instance + * with input parameters uri, count, and failure specified. */ DataAbilityResult(const Uri &uri, int count); ~DataAbilityResult(); /** - * @brief Obtains the Uri object corresponding to the operation. - * @return Obtains the Uri object corresponding to the operation. + * @brief Obtains the Uri object corresponding to the operation. + * @return Obtains the Uri object corresponding to the operation. */ Uri GetUri(); /** - * @brief Obtains the number of rows affected by the operation. + * @brief Obtains the number of rows affected by the operation. * @return Returns the number of rows affected by the operation. */ int GetCount(); /** - * @brief Prints out a string containing the class object information. + * @brief Prints out a string containing the class object information. * @return Returns object information. */ std::string ToString(); /** - * @brief Marshals a DataAbilityResult object into a Parcel. + * @brief Marshals a DataAbilityResult object into a Parcel. * @param parcel Indicates the Parcel object for marshalling. * @return Returns true if the marshalling is successful; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const; /** - * @brief Unmarshals a DataAbilityResult object from a Parcel. + * @brief Unmarshals a DataAbilityResult object from a Parcel. * @param parcel Indicates the Parcel object for unmarshalling. * @return Returns true if the unmarshalling is successful; returns false otherwise. */ static DataAbilityResult *Unmarshalling(Parcel &parcel); /** - * @brief Creates a DataAbilityResult instance based on the given Parcel object. - * Used to transfer DataAbilityResult object using Parcel. + * @brief Creates a DataAbilityResult instance based on the given Parcel object. + * Used to transfer DataAbilityResult object using Parcel. * @param parcel Indicates the Parcel object. * @return Returns the DataAbilityResult object. */ @@ -93,7 +93,7 @@ public: private: Uri uri_; - int count_; + int count_; bool ReadFromParcel(Parcel &parcel); // no object in parcel diff --git a/frameworks/kits/ability/native/include/form_js_event_handler.h b/frameworks/kits/ability/native/include/form_js_event_handler.h index 8c70f8dc1ec86c40d8c24d10081cea029b0bf982..6de3d57b3c7f9ac7fdf3cd9f2ef410c3b39d7119 100644 --- a/frameworks/kits/ability/native/include/form_js_event_handler.h +++ b/frameworks/kits/ability/native/include/form_js_event_handler.h @@ -24,7 +24,7 @@ namespace OHOS { namespace AppExecFwk { class FormJsEventHandler : public EventHandler { public: - FormJsEventHandler(const std::shared_ptr &runner, + FormJsEventHandler(const std::shared_ptr &runner, const std::shared_ptr& ability, const FormJsInfo& formJsInfo); ~FormJsEventHandler() = default; diff --git a/frameworks/kits/ability/native/include/page_ability_impl.h b/frameworks/kits/ability/native/include/page_ability_impl.h index 7782fbe69dbd70654f3fe510014a78608d739cb8..2ddaee18949d03123139760940c3209273c52957 100644 --- a/frameworks/kits/ability/native/include/page_ability_impl.h +++ b/frameworks/kits/ability/native/include/page_ability_impl.h @@ -68,7 +68,7 @@ public: * */ bool AbilityTransactionNew(const Want &want, const AAFwk::LifeCycleStateInfo &targetState); - + /** * @brief Execution the KeyDown callback of the ability * @param keyEvent Indicates the key-down event. diff --git a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp index c844ef0089be68a459586da65643e5486b26309e..a52aaf2361309827b63b7b2ae5b5ef94dde0402a 100755 --- a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp @@ -291,6 +291,14 @@ std::unique_ptr JsAbility::CreateAppWindowStage() return jsRuntime_.LoadSystemModule("application.WindowStage", &jsWindowStage, 1); } +void JsAbility::GetPageStackFromWant(const Want& want, std::string& pageStack) +{ + auto stringObj = AAFwk::IString::Query(want.GetParams().GetParam(PAGE_STACK_PROPERTY_NAME)); + if (stringObj != nullptr) { + pageStack = AAFwk::String::Unbox(stringObj); + } +} + void JsAbility::DoOnForeground(const Want& want) { if (scene_ == nullptr) { @@ -303,7 +311,6 @@ void JsAbility::DoOnForeground(const Want& want) HILOG_ERROR("%{public}s error. failed to create WindowScene instance!", __func__); return; } - int32_t displayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID; if (setting_ != nullptr) { std::string strDisplayId = setting_->GetProperty( @@ -324,17 +331,16 @@ void JsAbility::DoOnForeground(const Want& want) HILOG_ERROR("%{public}s error. failed to init window scene!", __func__); return; } - // multi-instance ability continuation HILOG_INFO("lauch reason = %{public}d, contentStorage = %{public}p", launchParam_.launchReason, abilityContext_->GetContentStorage()); if (IsRestoredInContinuation()) { - std::string pageStack = AAFwk::String::Unbox( - AAFwk::IString::Query(want.GetParams().GetParam(PAGE_STACK_PROPERTY_NAME))); + std::string pageStack; + GetPageStackFromWant(want, pageStack); HandleScope handleScope(jsRuntime_); auto& engine = jsRuntime_.GetNativeEngine(); scene_->GetMainWindow()->SetUIContent(pageStack, &engine, - static_cast(abilityContext_->GetContentStorage())); + static_cast(abilityContext_->GetContentStorage()), true); OnSceneRestored(); NotityContinuationResult(want, true); } else { diff --git a/frameworks/kits/ability/native/src/js_service_extension.cpp b/frameworks/kits/ability/native/src/js_service_extension.cpp index f5aefbaf5b88148c64cd50610e3f2ad0da46e0eb..1abe9ce14fa2f2418cd1a21694186bf758c0ebd5 100755 --- a/frameworks/kits/ability/native/src/js_service_extension.cpp +++ b/frameworks/kits/ability/native/src/js_service_extension.cpp @@ -42,22 +42,22 @@ JsServiceExtension::JsServiceExtension(JsRuntime& jsRuntime) : jsRuntime_(jsRunt JsServiceExtension::~JsServiceExtension() = default; void JsServiceExtension::Init(const std::shared_ptr &record, - const std::shared_ptr &application, - std::shared_ptr &handler, + const std::shared_ptr &application, std::shared_ptr &handler, const sptr &token) { ServiceExtension::Init(record, application, handler, token); - std::string srcPath(Extension::abilityInfo_->package); - srcPath.append("/assets/js/"); - if (!Extension::abilityInfo_->srcPath.empty()) { - srcPath.append(Extension::abilityInfo_->srcPath); + if (Extension::abilityInfo_->srcEntrance.empty()) { + HILOG_ERROR("abilityInfo srcEntrance is empty"); + return; } - srcPath.append("/").append(Extension::abilityInfo_->name).append(".abc"); + std::string srcPath(Extension::abilityInfo_->moduleName + "/"); + srcPath.append(Extension::abilityInfo_->srcPath); + srcPath.erase(srcPath.rfind('.')); + srcPath.append(".abc"); std::string moduleName(Extension::abilityInfo_->moduleName); moduleName.append("::").append(abilityInfo_->name); - HILOG_INFO("JsServiceExtension::Init moduleName:%{public}s,srcPath:%{public}s.", - moduleName.c_str(), srcPath.c_str()); + HILOG_INFO("JsServiceExtension::Init module:%{public}s,srcPath:%{public}s.", moduleName.c_str(), srcPath.c_str()); HandleScope handleScope(jsRuntime_); auto& engine = jsRuntime_.GetNativeEngine(); diff --git a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h index b95b4560f873b5c9cabc5212c0965c95688a383d..39a54671e23caaae8700a245107508b20c74cec3 100755 --- a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_service.h @@ -135,8 +135,12 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); - + int RemoveMission(int id) override; int RemoveStack(int id) override; diff --git a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.cpp b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.cpp index 78551e8bc7863eaaa114caefb96562b2f8c7bc68..15b92e02b98c3947c22bba9a9562c8a70cf1fff6 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.cpp +++ b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.cpp @@ -53,8 +53,8 @@ bool BundleMgrProxy::GetFormsInfoByApp(const std::string &bundleName, std::vecto return true; } bool BundleMgrProxy::GetFormsInfoByModule( - const std::string &bundleName, - const std::string &moduleName, + const std::string &bundleName, + const std::string &moduleName, std::vector &formInfo) { return true; @@ -150,8 +150,8 @@ bool BundleMgrService::GetFormsInfoByApp(const std::string &bundleName, std::vec return true; } bool BundleMgrService::GetFormsInfoByModule( - const std::string &bundleName, - const std::string &moduleName, + const std::string &bundleName, + const std::string &moduleName, std::vector &formInfo) { FormInfo form; diff --git a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h index a00e7c19e76c4b23e52e2fe7d0c68aa9768fd6b2..40b7dab2c9ec2a6a27fb48de841669cca6fb2868 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_bundle_manager_form.h @@ -184,7 +184,7 @@ public: }; /** - * @brief Obtains information about the shortcuts of the application. + * @brief Obtains information about the shortcuts of the application. * @param bundleName Indicates the name of the bundle to shortcut. * @param form Indicates the callback a list to shortcutinfo. * @return Returns true if shortcutinfo get success @@ -396,7 +396,7 @@ public: }; /** - * @brief Obtains information about the shortcuts of the application. + * @brief Obtains information about the shortcuts of the application. * @param bundleName Indicates the name of the bundle to shortcut. * @param form Indicates the callback a list to shortcutinfo. * @return Returns true if shortcutinfo get success diff --git a/frameworks/kits/ability/native/test/mock/include/mock_form_mgr_service.h b/frameworks/kits/ability/native/test/mock/include/mock_form_mgr_service.h index 748b2c4208ea35331d0e94fecfb0b304b8f905f2..af854af336df2ba63612b948bba1085929d8b10c 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_form_mgr_service.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_form_mgr_service.h @@ -130,8 +130,8 @@ public: * @return Returns ERR_OK on success, others on failure. */ int NotifyWhetherVisibleForms( - const std::vector &formIds, - const sptr &callerToken, + const std::vector &formIds, + const sptr &callerToken, const int32_t formVisibleType) { if (formIds.size() == 1) { @@ -139,7 +139,7 @@ public: } return 1; } - + /** * @brief temp form to normal form. * @param formId The Id of the form. @@ -196,7 +196,7 @@ public: return ERR_OK; } else { return ERR_INVALID_VALUE; - } + } } /** @@ -207,8 +207,8 @@ public: * @return Returns ERR_OK on success, others on failure. */ int LifecycleUpdate( - const std::vector &formIds, - const sptr &callerToken, + const std::vector &formIds, + const sptr &callerToken, const int32_t updateType) { if (formIds.size() == 0) { diff --git a/frameworks/kits/ability/native/test/mock/include/mock_form_supply_callback.h b/frameworks/kits/ability/native/test/mock/include/mock_form_supply_callback.h index 4c1b5198dfe316ccc50f845b26bc857539573fbd..d21007196b3db157367ad970aec9c19a9ed54265 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_form_supply_callback.h +++ b/frameworks/kits/ability/native/test/mock/include/mock_form_supply_callback.h @@ -48,7 +48,7 @@ public: private: static std::mutex mutex; static sptr instance; - + DISALLOW_COPY_AND_MOVE(MockFormSupplyCallback); }; } // namespace AppExecFwk diff --git a/frameworks/kits/ability/native/test/unittest/ability_lifecycle_executor_test.cpp b/frameworks/kits/ability/native/test/unittest/ability_lifecycle_executor_test.cpp index 029a332446c067468007513182c3fce4cd0bb8c2..69fe2d829b7393472c713a52fc364f34eca5cc12 100644 --- a/frameworks/kits/ability/native/test/unittest/ability_lifecycle_executor_test.cpp +++ b/frameworks/kits/ability/native/test/unittest/ability_lifecycle_executor_test.cpp @@ -55,7 +55,7 @@ void AbilityLifecycleExecutorTest::TearDown(void) /** * @tc.number: AaFwk_AbilityLifecycleExecutor_GetState_0100 * @tc.name: GetState - * @tc.desc: Verify that the return value of getstate is UNINITIALIZED. + * @tc.desc: Verify that the return value of getstate is UNINITIALIZED. */ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_GetState_0100, Function | MediumTest | Level1) { @@ -71,8 +71,8 @@ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_GetState_0 /** * @tc.number: AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0100 * @tc.name: DispatchLifecycleState - * @tc.desc: Test whether attachbasecontext is called normally, - * and verify whether the return value of getdatabasedir is ACTIVE. + * @tc.desc: Test whether attachbasecontext is called normally, + * and verify whether the return value of getdatabasedir is ACTIVE. */ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0100, Function | MediumTest | Level1) { @@ -90,8 +90,8 @@ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLi /** * @tc.number: AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0200 * @tc.name: DispatchLifecycleState - * @tc.desc: Test whether attachbasecontext is called normally, - * and verify whether the return value of getdatabasedir is BACKGROUND. + * @tc.desc: Test whether attachbasecontext is called normally, + * and verify whether the return value of getdatabasedir is BACKGROUND. */ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0200, Function | MediumTest | Level1) { @@ -109,8 +109,8 @@ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLi /** * @tc.number: AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0300 * @tc.name: DispatchLifecycleState - * @tc.desc: Test whether attachbasecontext is called normally, - * and verify whether the return value of getdatabasedir is INACTIVE. + * @tc.desc: Test whether attachbasecontext is called normally, + * and verify whether the return value of getdatabasedir is INACTIVE. */ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0300, Function | MediumTest | Level1) { @@ -128,8 +128,8 @@ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLi /** * @tc.number: AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0400 * @tc.name: DispatchLifecycleState - * @tc.desc: Test whether attachbasecontext is called normally, - * and verify whether the return value of getdatabasedir is INITIAL. + * @tc.desc: Test whether attachbasecontext is called normally, + * and verify whether the return value of getdatabasedir is INITIAL. */ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0400, Function | MediumTest | Level1) { @@ -147,8 +147,8 @@ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLi /** * @tc.number: AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0500 * @tc.name: DispatchLifecycleState - * @tc.desc: Test whether attachbasecontext is called normally, - * and verify whether the return value of getdatabasedir is UNINITIALIZED. + * @tc.desc: Test whether attachbasecontext is called normally, + * and verify whether the return value of getdatabasedir is UNINITIALIZED. */ HWTEST_F(AbilityLifecycleExecutorTest, AaFwk_AbilityLifecycleExecutor_DispatchLifecycleState_0500, Function | MediumTest | Level1) { diff --git a/frameworks/kits/ability/native/test/unittest/data_ability_helper_test.cpp b/frameworks/kits/ability/native/test/unittest/data_ability_helper_test.cpp index dd227924b8eb1185454b86c3621adf4651e4d375..5767493533f83a53367591d302bf48e801fe7c51 100644 --- a/frameworks/kits/ability/native/test/unittest/data_ability_helper_test.cpp +++ b/frameworks/kits/ability/native/test/unittest/data_ability_helper_test.cpp @@ -67,7 +67,7 @@ void DataAbilityHelperForObserverTest::TearDown(void) HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetFileTypes_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_GetFileTypes_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -100,7 +100,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetFileTypes_ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetFileTypes_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_GetFileTypes_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -133,7 +133,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetFileTypes_ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenFile_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_OpenFile_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -163,7 +163,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenFile_0100 HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenFile_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_OpenFile_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -193,7 +193,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenFile_0200 HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Insert_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Insert_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -224,7 +224,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Insert_0100, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Insert_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Insert_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -255,7 +255,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Insert_0200, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Update_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Update_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -287,7 +287,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Update_0100, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Update_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Update_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -319,7 +319,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Update_0200, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Delete_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Delete_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -349,7 +349,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Delete_0100, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Delete_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Delete_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -379,7 +379,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Delete_0200, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Query_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Query_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -411,7 +411,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Query_0100, F HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Query_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Query_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -443,7 +443,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Query_0200, F HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetType_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_GetType_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -472,7 +472,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetType_0100, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetType_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_GetType_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -501,7 +501,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_GetType_0200, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenRawFile_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_OpenRawFile_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -531,7 +531,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenRawFile_0 HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenRawFile_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_OpenRawFile_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -561,7 +561,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_OpenRawFile_0 HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Reload_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Reload_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -588,7 +588,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Reload_0100, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Reload_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_Reload_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -615,7 +615,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_Reload_0200, HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_BatchInsert_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_BatchInsert_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -642,7 +642,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_BatchInsert_0 HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_BatchInsert_0200, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_BatchInsert_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -669,7 +669,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_BatchInsert_0 HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_NormalizeUri_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -677,7 +677,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_ std::make_shared("dataability://device_id/com.domainname.dataability.persondata/person/10"); std::shared_ptr dataAbilityHelper = DataAbilityHelper::Creator(context, uri); // Test to AbilityThread interface - auto returnNormalizeUri = [&](const Uri &uri) { + auto returnNormalizeUri = [&](const Uri &uri) { Uri uriValue("dataability://device_id/com.domainname.dataability."); return uriValue; }; @@ -686,7 +686,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_ .WillOnce(testing::Invoke(returnNormalizeUri)); dataAbilityHelper->NormalizeUri(*uri); - + GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_NormalizeUri_0100 end"; } @@ -698,7 +698,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_0200, Function | MediumTest | Level3) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_NormalizeUri_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -706,7 +706,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_ std::make_shared("dataability://device_id/com.domainname.dataability.persondata/person/10"); std::shared_ptr dataAbilityHelper = DataAbilityHelper::Creator(context); // Test to AbilityThread interface - auto returnNormalizeUri = [&](const Uri &uri) { + auto returnNormalizeUri = [&](const Uri &uri) { Uri uriValue("dataability://device_id/com.domainname.dataability."); return uriValue; }; @@ -727,7 +727,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_NormalizeUri_ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_DenormalizeUri_0100, Function | MediumTest | Level1) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_DenormalizeUri_0100 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -735,7 +735,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_DenormalizeUr std::make_shared("dataability://device_id/com.domainname.dataability.persondata/person/10"); std::shared_ptr dataAbilityHelper = DataAbilityHelper::Creator(context, uri); // Test to AbilityThread interface - auto returnDenormalizeUri = [&](const Uri &uri) { + auto returnDenormalizeUri = [&](const Uri &uri) { Uri uriValue("dataability://device_id/com.domainname.dataability."); return uriValue; }; @@ -756,7 +756,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_DenormalizeUr HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_DenormalizeUri_0200, Function | MediumTest | Level3) { GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_DenormalizeUri_0200 start"; - + std::shared_ptr mockTools = MockAbilitySchedulerTools::GetInstance(); mockTools->SetMockStatus(true); std::shared_ptr context = std::make_shared(); @@ -764,7 +764,7 @@ HWTEST_F(DataAbilityHelperForObserverTest, AaFwk_DataAbilityHelper_DenormalizeUr std::make_shared("dataability://device_id/com.domainname.dataability.persondata/person/10"); std::shared_ptr dataAbilityHelper = DataAbilityHelper::Creator(context); // Test to AbilityThread interface - auto returnDenormalizeUri = [&](const Uri &uri) { + auto returnDenormalizeUri = [&](const Uri &uri) { Uri uriValue("dataability://device_id/com.domainname.dataability."); return uriValue; }; diff --git a/frameworks/kits/ability/native/test/unittest/form_ability_test.cpp b/frameworks/kits/ability/native/test/unittest/form_ability_test.cpp index aad5d943bbcdb10123a5de0e2e77ba3cdaaf513f..3549b48d6e4f8f46fa5b5b570e6ab617948f9208 100644 --- a/frameworks/kits/ability/native/test/unittest/form_ability_test.cpp +++ b/frameworks/kits/ability/native/test/unittest/form_ability_test.cpp @@ -412,12 +412,12 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_DeleteForm_0100, Function | MediumTest | .SetElementName(deviceId2, bundleName2, abilityName2) .SetParam(Constants::PARAM_FORM_TEMPORARY_KEY, tempFormFlg2); std::shared_ptr callback_2; - + ability_->appCallbacks_.insert(std::make_pair(120L, callback1)); ability_->userReqParams_.insert(std::make_pair(120L, want1)); ability_->appCallbacks_.insert(std::make_pair(121L, callback_2)); ability_->userReqParams_.insert(std::make_pair(121L, want2)); - + int64_t formId = 120L; ability_->DeleteForm(formId); @@ -497,7 +497,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_DeleteForm_0400, Function | MediumTest | .SetElementName(deviceId2, bundleName2, abilityName2) .SetParam(Constants::PARAM_FORM_TEMPORARY_KEY, tempFormFlg2); std::shared_ptr callback2; - + ability_->appCallbacks_.insert(std::make_pair(120L, callback1)); ability_->userReqParams_.insert(std::make_pair(120L, want1)); ability_->appCallbacks_.insert(std::make_pair(121L, callback2)); @@ -1098,7 +1098,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_FmsDeathCallback_OnDeathReceived_0200, F .SetElementName(deviceId2, bundleName2, abilityName2) .SetParam(Constants::PARAM_FORM_TEMPORARY_KEY, tempFormFlg2); std::shared_ptr callback2; - + FormMgr::GetInstance().RegisterDeathCallback(ability_); int64_t formId1 = 200L; @@ -1157,7 +1157,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_FmsDeathCallback_OnDeathReceived_0300, F .SetElementName(deviceId2, bundleName2, abilityName2) .SetParam(Constants::PARAM_FORM_TEMPORARY_KEY, tempFormFlg2); std::shared_ptr callback2; - + FormMgr::GetInstance().RegisterDeathCallback(ability_); int64_t formId1 = 200L; diff --git a/frameworks/kits/ability/native/test/unittest/form_host_client_test.cpp b/frameworks/kits/ability/native/test/unittest/form_host_client_test.cpp index 3900a34b74407cef5ee263edf3490846512579c7..2413235ee239f40ab56e114653b3b21825423c52 100644 --- a/frameworks/kits/ability/native/test/unittest/form_host_client_test.cpp +++ b/frameworks/kits/ability/native/test/unittest/form_host_client_test.cpp @@ -33,7 +33,7 @@ using OHOS::Parcel; class FormHostClientTest : public testing::Test { public: - FormHostClientTest() + FormHostClientTest() {} ~FormHostClientTest() {} diff --git a/frameworks/kits/ability/native/test/unittest/form_provider_client_test.cpp b/frameworks/kits/ability/native/test/unittest/form_provider_client_test.cpp index fdaa12710bb044be19a641e741f50c3fb219cb36..79c0c40871e03ed3458011d1fd1005c5c4c9a1c2 100644 --- a/frameworks/kits/ability/native/test/unittest/form_provider_client_test.cpp +++ b/frameworks/kits/ability/native/test/unittest/form_provider_client_test.cpp @@ -35,7 +35,7 @@ const std::string FORM_SUPPLY_INFO = "com.form.supply.info.test"; class FormProviderClientTest : public testing::Test { public: - FormProviderClientTest() + FormProviderClientTest() {} ~FormProviderClientTest() {} @@ -71,9 +71,9 @@ void FormProviderClientTest::SetUp(void) Permission::PermissionKit::AddDefPermissions(permList); std::vector permnameList; permnameList.emplace_back(PERMISSION_NAME_REQUIRE_FORM); - Permission::PermissionKit::AddUserGrantedReqPermissions(FORM_MANAGER_SERVICE_BUNDLE_NAME, + Permission::PermissionKit::AddUserGrantedReqPermissions(FORM_MANAGER_SERVICE_BUNDLE_NAME, permnameList, 0); - Permission::PermissionKit::GrantUserGrantedPermission(FORM_MANAGER_SERVICE_BUNDLE_NAME, + Permission::PermissionKit::GrantUserGrantedPermission(FORM_MANAGER_SERVICE_BUNDLE_NAME, PERMISSION_NAME_REQUIRE_FORM, 0); } @@ -224,7 +224,7 @@ HWTEST_F(FormProviderClientTest, AaFwk_FormProviderClient_EventNotify_0100, Func // callerToken const sptr callerToken = MockFormSupplyCallback::GetInstance(); - + // want Want want; want.SetParam(Constants::PARAM_FORM_MANAGER_SERVICE_BUNDLENAME_KEY, FORM_MANAGER_SERVICE_BUNDLE_NAME) @@ -259,7 +259,7 @@ HWTEST_F(FormProviderClientTest, AaFwk_FormProviderClient_EventNotify_0200, Func // callerToken const sptr callerToken = MockFormSupplyCallback::GetInstance(); - + // want Want want; want.SetParam(Constants::PARAM_FORM_MANAGER_SERVICE_BUNDLENAME_KEY, FORM_MANAGER_SERVICE_BUNDLE_NAME) diff --git a/frameworks/kits/base/cpp/src/ohos/aafwk/base/user_object_wrapper.cpp b/frameworks/kits/base/cpp/src/ohos/aafwk/base/user_object_wrapper.cpp index 97488a565c448e3437f81504bcaf1211bf732620..f8aa58e926c6ad518c8cb3927be7952e5c476540 100644 --- a/frameworks/kits/base/cpp/src/ohos/aafwk/base/user_object_wrapper.cpp +++ b/frameworks/kits/base/cpp/src/ohos/aafwk/base/user_object_wrapper.cpp @@ -35,7 +35,7 @@ bool UserObject::Equals(IObject &other) UserObject *otherObj = static_cast(IUserObject::Query(&other)); if (otherObj == nullptr) { - return false; + return false; } if (value_->GetClassName() == otherObj->value_->GetClassName()) { return otherObj->value_->Equals(value_); diff --git a/frameworks/kits/content/cpp/test/unittest/common/want_params_test.cpp b/frameworks/kits/content/cpp/test/unittest/common/want_params_test.cpp index 443f7d4345a7c3c622e420a150a990f76b1e4e6a..197f5ac07bc412ae44f6e879a89860f5bb1e0ada 100644 --- a/frameworks/kits/content/cpp/test/unittest/common/want_params_test.cpp +++ b/frameworks/kits/content/cpp/test/unittest/common/want_params_test.cpp @@ -30,7 +30,7 @@ namespace OHOS { namespace AAFwk { class WantParamsBaseTest : public testing::Test { public: - WantParamsBaseTest() + WantParamsBaseTest() {} ~WantParamsBaseTest() { @@ -76,7 +76,7 @@ HWTEST_F(WantParamsBaseTest, AaFwk_WantParams_Parcelable_0100, Function | Medium wantParamsIn_->Marshalling(in); std::shared_ptr wantParamsOut_(WantParams::Unmarshalling(in)); EXPECT_EQ(valueStr, String::Unbox(IString::Query(wantParamsOut_->GetParam(keyStr)))); - } + } } /** @@ -95,7 +95,7 @@ HWTEST_F(WantParamsBaseTest, AaFwk_WantParams_Parcelable_0200, Function | Medium wantParamsIn_->Marshalling(in); std::shared_ptr wantParamsOut_(WantParams::Unmarshalling(in)); EXPECT_EQ(valueBool, Boolean::Unbox(IBoolean::Query(wantParamsOut_->GetParam(keyStr)))); - } + } } /** @@ -117,7 +117,7 @@ HWTEST_F(WantParamsBaseTest, AaFwk_WantParams_Parcelable_0300, Function | Medium right = Integer::Unbox(IInteger::Query(wantParamsOut_->GetParam(keyStr))); EXPECT_EQ(valueInteger, right); - wantParamsOut_ = nullptr; + wantParamsOut_ = nullptr; } } diff --git a/frameworks/kits/runtime/native/js_data_struct_converter.cpp b/frameworks/kits/runtime/native/js_data_struct_converter.cpp index b4a9583fba2f798800523bee9b4243f74e33cd85..bb26794ba1b53011487d6d9efd2eaf0917f41dac 100644 --- a/frameworks/kits/runtime/native/js_data_struct_converter.cpp +++ b/frameworks/kits/runtime/native/js_data_struct_converter.cpp @@ -78,11 +78,33 @@ NativeValue* CreateJsAbilityInfo(NativeEngine& engine, const AppExecFwk::Ability object->SetProperty("minFormWidth", CreateJsValue(engine, abilityInfo.minFormWidth)); object->SetProperty("defaultFormWidth", CreateJsValue(engine, abilityInfo.defaultFormWidth)); object->SetProperty("uri", CreateJsValue(engine, abilityInfo.uri)); - // customizeData: Map>; + object->SetProperty("metaData", CreateJsCustomizeDataArray(engine, abilityInfo.metaData.customizeData)); return objValue; } +NativeValue* CreateJsCustomizeData(NativeEngine& engine, const AppExecFwk::CustomizeData &Info) +{ + NativeValue *objValue = engine.CreateObject(); + NativeObject *object = ConvertNativeValueTo(objValue); + + object->SetProperty("name", CreateJsValue(engine, Info.name)); + object->SetProperty("value", CreateJsValue(engine, Info.value)); + object->SetProperty("extra", CreateJsValue(engine, Info.extra)); + return objValue; +} + +NativeValue* CreateJsCustomizeDataArray(NativeEngine& engine, const std::vector &info) +{ + NativeValue* arrayValue = engine.CreateArray(info.size()); + NativeArray* array = ConvertNativeValueTo(arrayValue); + uint32_t index = 0; + for (const auto& item : info) { + array->SetElement(index++, CreateJsCustomizeData(engine, item)); + } + return arrayValue; +} + NativeValue* CreateJsModuleInfo(NativeEngine& engine, const AppExecFwk::ModuleInfo &moduleInfo) { NativeValue *objValue = engine.CreateObject(); @@ -126,6 +148,10 @@ NativeValue* CreateJsApplicationInfo(NativeEngine& engine, const AppExecFwk::App } } object->SetProperty("moduleInfo", arrayValue); + // metaData: Map>; + for (auto &item : applicationInfo.metaData) { + object->SetProperty(item.first.c_str(), CreateJsCustomizeDataArray(engine, item.second)); + } return objValue; } diff --git a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h index ad5d44601d653a4298c0c7877e51381b259fb43d..74a58d225c8e667186505f0bdf212961e8df1b8f 100644 --- a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h +++ b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h @@ -115,6 +115,10 @@ public: MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + int MoveMissionToEnd(const sptr &token, const bool nonFirst) override; bool IsFirstInMission(const sptr &token) override; int CompelVerifyPermission(const std::string &permission, int pid, int uid, std::string &message) override; diff --git a/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h b/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h index 499e4d506f6b672f05e9b893849adef7f09ab292..152c4a308e9381314ca82e3f8617d7c0d6fca16d 100755 --- a/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h +++ b/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h @@ -110,7 +110,11 @@ public: MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); - + + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + int MoveMissionToEnd(const sptr &token, const bool nonFirst) override; bool IsFirstInMission(const sptr &token) override; int CompelVerifyPermission(const std::string &permission, int pid, int uid, std::string &message) override; diff --git a/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h b/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h index 2211492767c45ea0c6708fd06c3f9d35e123055f..fe32ccc474715d64c16ee6103e865619d4915344 100644 --- a/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h +++ b/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h @@ -72,7 +72,7 @@ public: return -1; } fd = fileno(fd2); - + return fd; } diff --git a/frameworks/kits/test/mock/DemoObServer/mock_ability_manager_client.h b/frameworks/kits/test/mock/DemoObServer/mock_ability_manager_client.h index fc44c7dda0a63b79ad9d8250cd5c43dd30745148..96997c597ddebd71233a1144b1fb5017ed15e6e4 100644 --- a/frameworks/kits/test/mock/DemoObServer/mock_ability_manager_client.h +++ b/frameworks/kits/test/mock/DemoObServer/mock_ability_manager_client.h @@ -37,7 +37,7 @@ public: DemoAbilityManagerClientData() {}; virtual ~DemoAbilityManagerClientData() {}; - std::map> data; + std::map> data; }; static DemoAbilityManagerClientData demoAbilityMgrClientData; @@ -52,9 +52,9 @@ sptr AAFwk::AbilityManagerClient::AcquireDataAbility( sptr abilityThread = AppExecFwk::MockCreateAbilityThread(); sptr remoteProxy(new (std::nothrow) AAFwk::AbilitySchedulerProxy(abilityThread)); demoAbilityMgrClientData.data.emplace(uri.ToString(), remoteProxy); - + retval = remoteProxy; - + if (retval == nullptr) { GTEST_LOG_(INFO) << "mock_ability_thread_for_data_observer:mock result retval is nullptr called"; } diff --git a/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_operation_module_test.cpp b/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_operation_module_test.cpp index c645ec882caa58d0a019da713976db3268e0fe3e..f02cd40c97bdf166f21b588323c23fc3f57aebaa 100644 --- a/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_operation_module_test.cpp +++ b/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_operation_module_test.cpp @@ -122,7 +122,7 @@ HWTEST_F(DataAbilityOperationModuleTest, AaFwk_DataAbilityOperation_AssertBuilde int count = operation->GetExpectedCount(); EXPECT_EQ(count, 2); - + GTEST_LOG_(INFO) << "AaFwk_DataAbilityOperation_AssertBuilder_0100"; } @@ -144,7 +144,7 @@ HWTEST_F(DataAbilityOperationModuleTest, AaFwk_DataAbilityOperation_DeleteBuilde EXPECT_NE(operation, nullptr); bool isDeleteOperation = operation->IsDeleteOperation(); EXPECT_TRUE(isDeleteOperation); - + GTEST_LOG_(INFO) << "AaFwk_DataAbilityOperation_DeleteBuilder_0100"; } diff --git a/interfaces/innerkits/ability_manager/BUILD.gn b/interfaces/innerkits/ability_manager/BUILD.gn index ea024b0226e2693dbc1e6546fe13f0ccf83e0602..405b2b9fbe2ffe55f5e55c736642a0bfa56f5b7b 100644 --- a/interfaces/innerkits/ability_manager/BUILD.gn +++ b/interfaces/innerkits/ability_manager/BUILD.gn @@ -48,10 +48,12 @@ ohos_shared_library("ability_manager") { "${services_path}/abilitymgr/src/ability_manager_stub.cpp", "${services_path}/abilitymgr/src/ability_mission_info.cpp", "${services_path}/abilitymgr/src/ability_record_info.cpp", + "${services_path}/abilitymgr/src/ability_running_info.cpp", "${services_path}/abilitymgr/src/ability_scheduler_proxy.cpp", "${services_path}/abilitymgr/src/ability_scheduler_stub.cpp", "${services_path}/abilitymgr/src/ability_start_setting.cpp", "${services_path}/abilitymgr/src/caller_info.cpp", + "${services_path}/abilitymgr/src/extension_running_info.cpp", "${services_path}/abilitymgr/src/image_info.cpp", "${services_path}/abilitymgr/src/launch_param.cpp", "${services_path}/abilitymgr/src/lifecycle_state_info.cpp", diff --git a/interfaces/innerkits/ability_manager/ability_manager_headers.gni b/interfaces/innerkits/ability_manager/ability_manager_headers.gni index 5913ebcafca8dcc11af8ee84109cdef13e7e2383..057a03e5b0569011fb058dbcb28b28d554626883 100644 --- a/interfaces/innerkits/ability_manager/ability_manager_headers.gni +++ b/interfaces/innerkits/ability_manager/ability_manager_headers.gni @@ -18,7 +18,9 @@ ability_manager_headers = { "ability_manager_client.h", "ability_manager_errors.h", "ability_manager_interface.h", + "ability_running_info.h", "ability_scheduler_interface.h", + "extension_running_info.h", "lifecycle_state_info.h", "mission_stack_info.h", "stack_info.h", diff --git a/interfaces/innerkits/ability_manager/include/ability_manager_client.h b/interfaces/innerkits/ability_manager/include/ability_manager_client.h index f427149344664adf6101e95ed826676814b7b720..a38b5f6097a20b9eea7091e182332b418bbccc97 100644 --- a/interfaces/innerkits/ability_manager/include/ability_manager_client.h +++ b/interfaces/innerkits/ability_manager/include/ability_manager_client.h @@ -131,8 +131,8 @@ public: * @param requestCode the resultCode of the ability to start. * @return Returns ERR_OK on success, others on failure. */ - ErrCode StartAbility(const Want &want, const StartOptions &startOptions, - const sptr &callerToken, int requestCode = DEFAULT_INVAL_VALUE); + ErrCode StartAbility(const Want &want, const StartOptions &startOptions, const sptr &callerToken, + int requestCode = DEFAULT_INVAL_VALUE); /** * TerminateAbility with want, return want from ability manager service. @@ -358,8 +358,7 @@ public: * mission. This parameter cannot be null. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SetMissionDescriptionInfo( - const sptr &token, const MissionDescriptionInfo &description); + ErrCode SetMissionDescriptionInfo(const sptr &token, const MissionDescriptionInfo &description); /** * get current system mission lock mode state. @@ -476,8 +475,8 @@ public: * @param wantParams, extended params. * @return Returns ERR_OK on success, others on failure. */ - ErrCode ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, - int32_t missionId, const sptr &callback, AAFwk::WantParams &wantParams); + ErrCode ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, + const sptr &callback, AAFwk::WantParams &wantParams); /** * start continuation. @@ -536,8 +535,7 @@ public: * * @return Returns ERR_OK on success, others on failure. */ - ErrCode RegisterMissionListener(const std::string &deviceId, - const sptr &listener); + ErrCode RegisterMissionListener(const std::string &deviceId, const sptr &listener); /** * @brief UnRegister mission listener from ability manager service. @@ -546,8 +544,7 @@ public: * * @return Returns ERR_OK on success, others on failure. */ - ErrCode UnRegisterMissionListener(const std::string &deviceId, - const sptr &listener); + ErrCode UnRegisterMissionListener(const std::string &deviceId, const sptr &listener); /** * @brief Get mission infos from ams. @@ -557,7 +554,7 @@ public: * * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetMissionInfos(const std::string& deviceId, int32_t numMax, std::vector &missionInfos); + ErrCode GetMissionInfos(const std::string &deviceId, int32_t numMax, std::vector &missionInfos); /** * @brief Get mission info by id. @@ -567,7 +564,7 @@ public: * * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetMissionInfo(const std::string& deviceId, int32_t missionId, MissionInfo &missionInfo); + ErrCode GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo); /** * @brief Get the Mission Snapshot Info object @@ -601,6 +598,12 @@ public: */ ErrCode MoveMissionToFront(int32_t missionId); + ErrCode GetAbilityRunningInfos(std::vector &info); + + ErrCode GetExtensionRunningInfos(int upperLimit, std::vector &info); + + ErrCode GetProcessRunningInfos(std::vector &info); + /** * Start synchronizing remote device mission * @param devId, deviceId. @@ -608,14 +611,14 @@ public: * @param tag, call tag. * @return Returns ERR_OK on success, others on failure. */ - ErrCode StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag); + ErrCode StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag); /** * Stop synchronizing remote device mission * @param devId, deviceId. * @return Returns ERR_OK on success, others on failure. */ - ErrCode StopSyncRemoteMissions(const std::string& devId); + ErrCode StopSyncRemoteMissions(const std::string &devId); /** * @brief start user. diff --git a/interfaces/innerkits/ability_manager/include/ability_manager_interface.h b/interfaces/innerkits/ability_manager/include/ability_manager_interface.h index 6e57722b2e60f72a2753a2b431c1034151d831dc..1c19b2fcbdcdfa1ff020032acde4e1e54f7ddb04 100755 --- a/interfaces/innerkits/ability_manager/include/ability_manager_interface.h +++ b/interfaces/innerkits/ability_manager/include/ability_manager_interface.h @@ -27,6 +27,8 @@ #include "foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmgr/configuration.h" #include "mission_snapshot.h" #include "ability_mission_info.h" +#include "ability_running_info.h" +#include "extension_running_info.h" #include "mission_option.h" #include "stack_info.h" #include "stack_setting.h" @@ -43,10 +45,10 @@ #include "snapshot.h" #include "start_options.h" #include "stop_user_callback.h" +#include "running_process_info.h" #include "remote_mission_listener_interface.h" #include "iability_controller.h" - namespace OHOS { namespace AAFwk { const std::string ABILITY_MANAGER_SERVICE_NAME = "AbilityManagerService"; @@ -99,8 +101,11 @@ public: * @param requestCode the resultCode of the ability to start. * @return Returns ERR_OK on success, others on failure. */ - virtual int StartAbility(const Want &want, const StartOptions &startOptions, - const sptr &callerToken, int requestCode = DEFAULT_INVAL_VALUE) { return 0; } + virtual int StartAbility(const Want &want, const StartOptions &startOptions, const sptr &callerToken, + int requestCode = DEFAULT_INVAL_VALUE) + { + return 0; + } /** * TerminateAbility, terminate the special ability. @@ -508,8 +513,8 @@ public: */ virtual void GetSystemMemoryAttr(AppExecFwk::SystemMemoryAttr &memoryInfo) = 0; - virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, - int32_t missionId, const sptr &callBack, AAFwk::WantParams &wantParams) = 0; + virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, + const sptr &callBack, AAFwk::WantParams &wantParams) = 0; virtual int ContinueAbility(const std::string &deviceId, int32_t missionId) = 0; @@ -527,11 +532,10 @@ public: virtual int UnRegisterMissionListener(const sptr &listener) = 0; - virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax, - std::vector &missionInfos) = 0; + virtual int GetMissionInfos( + const std::string &deviceId, int32_t numMax, std::vector &missionInfos) = 0; - virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId, - MissionInfo &missionInfo) = 0; + virtual int GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo) = 0; virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot) = 0; @@ -545,6 +549,12 @@ public: virtual int StopUser(int userId, const sptr &callback) = 0; + virtual int GetAbilityRunningInfos(std::vector &info) = 0; + + virtual int GetExtensionRunningInfos(int upperLimit, std::vector &info) = 0; + + virtual int GetProcessRunningInfos(std::vector &info) = 0; + /** * Start synchronizing remote device mission * @param devId, deviceId. @@ -552,21 +562,20 @@ public: * @param tag, call tag. * @return Returns ERR_OK on success, others on failure. */ - virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) = 0; + virtual int StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag) = 0; /** * Stop synchronizing remote device mission * @param devId, deviceId. * @return Returns ERR_OK on success, others on failure. */ - virtual int StopSyncRemoteMissions(const std::string& devId) = 0; + virtual int StopSyncRemoteMissions(const std::string &devId) = 0; - virtual int RegisterMissionListener(const std::string &deviceId, - const sptr &listener) = 0; + virtual int RegisterMissionListener(const std::string &deviceId, const sptr &listener) = 0; virtual int UnRegisterMissionListener(const std::string &deviceId, const sptr &listener) = 0; - + /** * Set ability controller. * @@ -706,7 +715,7 @@ public: // ipc id for minimize ability (38) MINIMIZE_ABILITY, - // ipc id for lock mission for cleanup operation (39) + // ipc id for lock mission for cleanup operation (39) LOCK_MISSION_FOR_CLEANUP, // ipc id for unlock mission for cleanup operation (40) @@ -718,7 +727,7 @@ public: // ipc id for unregister mission listener (42) UNREGISTER_MISSION_LISTENER, - // ipc id for get mission infos (43) + // ipc id for get mission infos (43) GET_MISSION_INFOS, // ipc id for get mission info by id (44) @@ -796,6 +805,12 @@ public: GET_SYSTEM_MEMORY_ATTR, + GET_ABILITY_RUNNING_INFO, + + GET_EXTENSION_RUNNING_INFO, + + GET_PROCESS_RUNNING_INFO, + CLEAR_UP_APPLICATION_DATA, START_ABILITY_FOR_OPTIONS, @@ -817,6 +832,7 @@ public: START_SYNC_MISSIONS = 1112, STOP_SYNC_MISSIONS = 1113, REGISTER_SNAPSHOT_HANDLER = 1114, + GET_MISSION_SNAPSHOT_INFO = 1115, // ipc id 2001-3000 for tools // ipc id for dumping state (2001) diff --git a/interfaces/innerkits/ability_manager/include/ability_running_info.h b/interfaces/innerkits/ability_manager/include/ability_running_info.h new file mode 100644 index 0000000000000000000000000000000000000000..1e4de26867a1f4790c1f99103a7e41d5c1d9e892 --- /dev/null +++ b/interfaces/innerkits/ability_manager/include/ability_running_info.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 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. + */ + +#ifndef OHOS_AAFWK_INTERFACES_INNERKITS_RUNNING_ABILITY_INFO_H +#define OHOS_AAFWK_INTERFACES_INNERKITS_RUNNING_ABILITY_INFO_H + +#include "parcel.h" +#include "ability_info.h" +#include "element_name.h" +#include "iremote_object.h" + +namespace OHOS { +namespace AAFwk { +/** + * @struct AbilityRunningInfo + * AbilityRunningInfo is used to save informations about running ability. + */ +struct AbilityRunningInfo : public Parcelable { +public: + AppExecFwk::ElementName ability; + int pid; + int uid; + std::string processName; + int64_t startTime; + int abilityState; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static AbilityRunningInfo *Unmarshalling(Parcel &parcel); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_AAFWK_INTERFACES_INNERKITS_RUNNING_ABILITY_INFO_H \ No newline at end of file diff --git a/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h b/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h index d66d7020974c25b676e139ce4b8ebb7f6af439bc..b6301dc8437f13fc93b4fbccdac5e19631f3303a 100644 --- a/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h +++ b/interfaces/innerkits/ability_manager/include/ability_scheduler_interface.h @@ -328,13 +328,13 @@ public: // ipc id for dataAbilityObServer Reguster SCHEDULE_REGISTEROBSERVER, - + // ipc id for dataAbilityObServer UnReguster SCHEDULE_UNREGISTEROBSERVER, - - // ipc id for dataAbilityObServer change + + // ipc id for dataAbilityObServer change SCHEDULE_NOTIFYCHANGE, - + // ipc id for scheduling multi window changed MULTI_WIN_CHANGED, @@ -348,8 +348,8 @@ public: // ipc id for scheduling DenormalizeUri SCHEDULE_DENORMALIZEURI, - - // ipc id for scheduling ExecuteBatch + + // ipc id for scheduling ExecuteBatch SCHEDULE_EXECUTEBATCH, // ipc id for notify continuation result diff --git a/interfaces/innerkits/ability_manager/include/extension_running_info.h b/interfaces/innerkits/ability_manager/include/extension_running_info.h new file mode 100644 index 0000000000000000000000000000000000000000..80b39e797a114be44443c554ae101bc1604de645 --- /dev/null +++ b/interfaces/innerkits/ability_manager/include/extension_running_info.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +#ifndef OHOS_AAFWK_INTERFACES_INNERKITS_EXTENSION_RUNNING_INFO_H +#define OHOS_AAFWK_INTERFACES_INNERKITS_EXTENSION_RUNNING_INFO_H + +#include "parcel.h" +#include "element_name.h" +#include "iremote_object.h" + +namespace OHOS { +namespace AAFwk { +/** + * @struct ExtensionRunningInfo + * ExtensionRunningInfo is used to save informations about extension. + */ +struct ExtensionRunningInfo : public Parcelable { +public: + AppExecFwk::ElementName extension; + int pid; + int uid; + std::string processName; + int64_t startTime; + std::vector clientPackage; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static ExtensionRunningInfo *Unmarshalling(Parcel &parcel); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_AAFWK_INTERFACES_INNERKITS_EXTENSION_RUNNING_INFO_H \ No newline at end of file diff --git a/interfaces/innerkits/runtime/include/js_data_struct_converter.h b/interfaces/innerkits/runtime/include/js_data_struct_converter.h index 739234ffd28951c31cdc3adb093c3d124dab91b3..67b41a09c7f6514047d10450ef06952411cea9cc 100644 --- a/interfaces/innerkits/runtime/include/js_data_struct_converter.h +++ b/interfaces/innerkits/runtime/include/js_data_struct_converter.h @@ -32,6 +32,8 @@ NativeValue* CreateJsAbilityInfo(NativeEngine& engine, const AppExecFwk::Ability NativeValue* CreateJsModuleInfo(NativeEngine& engine, const AppExecFwk::ModuleInfo &moduleInfo); NativeValue* CreateJsApplicationInfo(NativeEngine& engine, const AppExecFwk::ApplicationInfo &applicationInfo); NativeValue* CreateJsLaunchParam(NativeEngine& engine, const AAFwk::LaunchParam& launchParam); +NativeValue* CreateJsCustomizeData(NativeEngine& engine, const AppExecFwk::CustomizeData &Info); +NativeValue* CreateJsCustomizeDataArray(NativeEngine& engine, const std::vector &info); } // namespace AbilityRuntime } // namespace OHOS #endif // ABILITY_RUNTIME_JS_DATA_STRUCT_CONVERTER_H \ No newline at end of file diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 5c89216ac9dcc3eaac36b74d3fb26dfabf1bd515..d90371ddf608e0d5dcb257c13afe4f916c35d10d 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -18,6 +18,7 @@ group("napi_packages") { "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/ability:ability_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/abilityManager:abilitymanager", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/ability_context:abilitycontext_napi", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/ability_manager:abilitymanager_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/dataUriUtils:datauriutils", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/extensioncontext:extensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/featureAbility:featureability", diff --git a/interfaces/kits/napi/aafwk/ability_manager/BUILD.gn b/interfaces/kits/napi/aafwk/ability_manager/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f7cf0c91e29f75e227e02e3a5cbccce3fb8f8599 --- /dev/null +++ b/interfaces/kits/napi/aafwk/ability_manager/BUILD.gn @@ -0,0 +1,63 @@ +# Copyright (c) 2021 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/ohos.gni") + +ohos_shared_library("abilitymanager_napi") { + include_dirs = [] + + sources = [ + "ability_manager_module.cpp", + "js_ability_manager.cpp", + "js_ability_manager_utils.cpp", + ] + + configs = [ "//foundation/aafwk/standard/services/common:common_config" ] + + include_dirs = [ + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/ability_manager", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common", + "//base/global/resmgr_standard/interfaces/innerkits/include", + "//third_party/icu/icu4c/source/common", + "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/kits", + "//foundation/communication/ipc/ipc/native/src/napi/include", + ] + + deps = [ + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", + "//foundation/aafwk/standard/interfaces/innerkits/base:base", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/ace/napi:ace_napi", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//utils/native/base:utils", + ] + + external_deps = [ + "aafwk_standard:ability_manager", + "aafwk_standard:runtime", + "aafwk_standard:want", + "appexecfwk_standard:appexecfwk_base", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "ipc_js:rpc", + ] + + relative_install_dir = "module/application" + + subsystem_name = "aafwk" + part_name = "aafwk_standard" +} diff --git a/interfaces/kits/napi/aafwk/ability_manager/ability_manager_module.cpp b/interfaces/kits/napi/aafwk/ability_manager/ability_manager_module.cpp new file mode 100644 index 0000000000000000000000000000000000000000..261cba341f053ad4b60460a78c7dfe9f37f11ccf --- /dev/null +++ b/interfaces/kits/napi/aafwk/ability_manager/ability_manager_module.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 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 "native_engine/native_engine.h" +#include "js_ability_manager.h" + +extern "C" __attribute__((constructor)) +void NAPI_application_AbilityManager_AutoRegister() +{ + auto moduleManager = NativeModuleManager::GetInstance(); + NativeModule newModuleInfo = { + .name = "application.AbilityManager", + .fileName = "application/abilitymanager_napi.so/ability_manager.js", + .registerCallback = OHOS::AbilityRuntime::JsAbilityManagerInit, + }; + + moduleManager->Register(&newModuleInfo); +} \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager.cpp b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a86da7106b1d18cd24bd7cb255ea996b32047ae6 --- /dev/null +++ b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2021 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 "js_ability_manager.h" + +#include + +#include "ability_manager_client.h" +#include "hilog_wrapper.h" +#include "js_runtime.h" +#include "js_runtime_utils.h" +#include "napi/native_api.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" +#include "js_ability_manager_utils.h" +#include "event_runner.h" + +namespace OHOS { +namespace AbilityRuntime { +using AbilityManagerClient = AAFwk::AbilityManagerClient; +namespace { +class JsAbilityManager final { +public: + JsAbilityManager() = default; + ~JsAbilityManager() = default; + + static void Finalizer(NativeEngine* engine, void* data, void* hint) + { + HILOG_INFO("JsAbilityManager::Finalizer is called"); + std::unique_ptr(static_cast(data)); + } + + static NativeValue* GetAbilityRunningInfos(NativeEngine* engine, NativeCallbackInfo* info) + { + JsAbilityManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnGetAbilityRunningInfos(*engine, *info) : nullptr; + } + + static NativeValue* GetExtensionRunningInfos(NativeEngine* engine, NativeCallbackInfo* info) + { + JsAbilityManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnGetExtensionRunningInfos(*engine, *info) : nullptr; + } + +private: + NativeValue* OnGetAbilityRunningInfos(NativeEngine &engine, NativeCallbackInfo &info) + { + HILOG_INFO("%{public}s is called", __FUNCTION__); + AsyncTask::CompleteCallback complete = + [](NativeEngine &engine, AsyncTask &task, int32_t status) { + std::vector infos; + auto errcode = AbilityManagerClient::GetInstance()->GetAbilityRunningInfos(infos); + if (errcode == 0) { + task.Resolve(engine, CreateJsAbilityRunningInfoArray(engine, infos)); + } else { + task.Reject(engine, CreateJsError(engine, errcode, "Get mission infos failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 0) ? nullptr : info.argv[0]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } + + NativeValue* OnGetExtensionRunningInfos(NativeEngine &engine, NativeCallbackInfo &info) + { + HILOG_INFO("%{public}s is called", __FUNCTION__); + if (info.argc == 0) { + HILOG_ERROR("Not enough params"); + return engine.CreateUndefined(); + } + int upperLimit = -1; + if (!ConvertFromJsValue(engine, info.argv[0], upperLimit)) { + HILOG_ERROR("Parse missionId failed"); + return engine.CreateUndefined(); + } + + AsyncTask::CompleteCallback complete = + [upperLimit](NativeEngine &engine, AsyncTask &task, int32_t status) { + std::vector infos; + auto errcode = AbilityManagerClient::GetInstance()->GetExtensionRunningInfos(upperLimit, infos); + if (errcode == 0) { + task.Resolve(engine, CreateJsExtensionRunningInfoArray(engine, infos)); + } else { + task.Reject(engine, CreateJsError(engine, errcode, "Get mission infos failed.")); + } + }; + + NativeValue* lastParam = (info.argc == 1) ? nullptr : info.argv[1]; + NativeValue* result = nullptr; + AsyncTask::Schedule( + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } +}; +} // namespace + +NativeValue* JsAbilityManagerInit(NativeEngine* engine, NativeValue* exportObj) +{ + HILOG_INFO("JsAbilityManagerInit is called"); + + if (engine == nullptr || exportObj == nullptr) { + HILOG_INFO("engine or exportObj null"); + return nullptr; + } + + NativeObject* object = ConvertNativeValueTo(exportObj); + if (object == nullptr) { + HILOG_INFO("object null"); + return nullptr; + } + + std::unique_ptr jsAbilityManager = std::make_unique(); + object->SetNativePointer(jsAbilityManager.release(), JsAbilityManager::Finalizer, nullptr); + + HILOG_INFO("JsAbilityManagerInit BindNativeFunction called"); + BindNativeFunction(*engine, *object, "getAbilityRunningInfos", JsAbilityManager::GetAbilityRunningInfos); + BindNativeFunction(*engine, *object, "getExtensionRunningInfos", JsAbilityManager::GetExtensionRunningInfos); + HILOG_INFO("JsAbilityManagerInit end"); + return engine->CreateUndefined(); +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager.h b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..d209c8dd966d5c05d2125a608d435e4e7b3927d5 --- /dev/null +++ b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021 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 "native_engine/native_engine.h" +#include "event_handler.h" + +#ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_H +#define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_H + +namespace OHOS { +namespace AbilityRuntime { +NativeValue* JsAbilityManagerInit(NativeEngine* engine, NativeValue* exportObj); +} // namespace AbilityRuntime +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_H \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager_utils.cpp b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager_utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..191503be7b458dcc0fd8728c36c05bd9a8523ba7 --- /dev/null +++ b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager_utils.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2021 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 "js_ability_manager_utils.h" + +#include + +#include "hilog_wrapper.h" +#include "napi_common_want.h" +#include "napi_remote_object.h" +#include "js_runtime.h" +#include "js_runtime_utils.h" + +namespace OHOS { +namespace AbilityRuntime { +napi_value CreateJSToken(napi_env env, const sptr target) +{ + napi_value tokenClass = nullptr; + auto constructorcb = [](napi_env env, napi_callback_info info) -> napi_value { + napi_value thisVar = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); + return thisVar; + }; + napi_define_class( + env, "TokenClass", NAPI_AUTO_LENGTH, constructorcb, nullptr, 0, nullptr, &tokenClass); + napi_value jsToken = nullptr; + napi_new_instance(env, tokenClass, 0, nullptr, &jsToken); + auto finalizecb = [](napi_env env, void *data, void *hint) {}; + napi_wrap(env, jsToken, (void *)target.GetRefPtr(), finalizecb, nullptr, nullptr); + return jsToken; +} + +NativeValue* CreateJsAbilityRunningInfoArray( + NativeEngine &engine, const std::vector &infos) +{ + NativeValue* arrayValue = engine.CreateArray(infos.size()); + NativeArray* array = ConvertNativeValueTo(arrayValue); + uint32_t index = 0; + for (const auto &runningInfo : infos) { + array->SetElement(index++, CreateJsAbilityRunningInfo(engine, runningInfo)); + } + return arrayValue; +} + +NativeValue* CreateJsExtensionRunningInfoArray( + NativeEngine &engine, const std::vector &infos) +{ + NativeValue* arrayValue = engine.CreateArray(infos.size()); + NativeArray* array = ConvertNativeValueTo(arrayValue); + uint32_t index = 0; + for (const auto &runningInfo : infos) { + array->SetElement(index++, CreateJsExtensionRunningInfo(engine, runningInfo)); + } + return arrayValue; +} + +NativeValue* CreateJsAbilityRunningInfo(NativeEngine &engine, const AAFwk::AbilityRunningInfo &info) +{ + NativeValue* objValue = engine.CreateObject(); + NativeObject* object = ConvertNativeValueTo(objValue); + + napi_value napiElementName = + OHOS::AppExecFwk::WrapElementName(reinterpret_cast(&engine), info.ability); + object->SetProperty("ability", reinterpret_cast(napiElementName)); + object->SetProperty("pid", CreateJsValue(engine, info.pid)); + object->SetProperty("uid", CreateJsValue(engine, info.uid)); + object->SetProperty("processName", CreateJsValue(engine, info.processName)); + object->SetProperty("startTime", CreateJsValue(engine, info.startTime)); + object->SetProperty("abilityState", CreateJsValue(engine, info.abilityState)); + return objValue; +} + +NativeValue* CreateJsExtensionRunningInfo(NativeEngine &engine, const AAFwk::ExtensionRunningInfo &info) +{ + NativeValue* objValue = engine.CreateObject(); + NativeObject* object = ConvertNativeValueTo(objValue); + + napi_value napiElementName = + OHOS::AppExecFwk::WrapElementName(reinterpret_cast(&engine), info.extension); + object->SetProperty("extension", reinterpret_cast(napiElementName)); + object->SetProperty("pid", CreateJsValue(engine, info.pid)); + object->SetProperty("uid", CreateJsValue(engine, info.uid)); + object->SetProperty("processName", CreateJsValue(engine, info.processName)); + object->SetProperty("startTime", CreateJsValue(engine, info.startTime)); + object->SetProperty("clientPackage", CreateNativeArray(engine, info.clientPackage)); + return objValue; +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager_utils.h b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..855a34720f7fffd1d975fcc8e326e68315169fce --- /dev/null +++ b/interfaces/kits/napi/aafwk/ability_manager/js_ability_manager_utils.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021 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 "ability_running_info.h" +#include "extension_running_info.h" +#include "native_engine/native_engine.h" + +#ifndef OHOS_APPEXECFWK_RUNTIME_APP_MANAGER_UTILS_H +#define OHOS_APPEXECFWK_RUNTIME_APP_MANAGER_UTILS_H + +namespace OHOS { +namespace AbilityRuntime { +NativeValue* CreateJsAbilityRunningInfoArray( + NativeEngine &engine, const std::vector &infos); +NativeValue* CreateJsExtensionRunningInfoArray( + NativeEngine &engine, const std::vector &infos); +NativeValue* CreateJsAbilityRunningInfo(NativeEngine &engine, const AAFwk::AbilityRunningInfo &info); +NativeValue* CreateJsExtensionRunningInfo(NativeEngine &engine, const AAFwk::ExtensionRunningInfo &info); +} // namespace AbilityRuntime +} // namespace OHOS +#endif // OHOS_APPEXECFWK_RUNTIME_APP_MANAGER_UTILS_H \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn b/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn index 7b26afe1bcb503dfff9dc905c98a0c4f3f15d733..122801a7f38d205e3916749c931075f48f8b12fc 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn +++ b/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn @@ -25,13 +25,20 @@ ohos_shared_library("missionmanager_napi") { configs = [ "//foundation/aafwk/standard/services/common:common_config" ] - include_dirs = - [ "//foundation/multimedia/image_standard/interfaces/innerkits/include" ] + include_dirs = [ + "//foundation/multimedia/image_standard/interfaces/innerkits/include", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common", + "//base/global/resmgr_standard/interfaces/innerkits/include", + "//third_party/icu/icu4c/source/common", + "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/kits", + "//foundation/communication/ipc/ipc/native/src/napi/include", + ] deps = [ - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", "//foundation/aafwk/standard/interfaces/innerkits/base:base", "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", "//foundation/aafwk/standard/services/abilitymgr:abilityms", "//foundation/ace/napi:ace_napi", "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", @@ -41,11 +48,13 @@ ohos_shared_library("missionmanager_napi") { ] external_deps = [ + "aafwk_standard:ability_manager", "aafwk_standard:runtime", "aafwk_standard:want", "appexecfwk_standard:appexecfwk_base", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc_js:rpc", "multimedia_image_standard:image", ] diff --git a/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.cpp b/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.cpp index 5b20d9c5eb75c964da31eb6b1859bd04b6c3af1f..dcbe084b7d1750cfcd78b0bb8f4025c13fff6fc9 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.cpp +++ b/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.cpp @@ -16,6 +16,8 @@ #include "js_mission_info_utils.h" #include "hilog_wrapper.h" +#include "napi_common_want.h" +#include "napi_remote_object.h" #include "ohos/aafwk/base/array_wrapper.h" #include "ohos/aafwk/base/bool_wrapper.h" #include "ohos/aafwk/base/byte_wrapper.h" diff --git a/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.h b/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.h index 1b66f6744282f610bb9a674d0ed5889b0780a507..00c01039dd7e76e0d9fe8a797c2dad2883f97522 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.h +++ b/interfaces/kits/napi/aafwk/mission_manager/js_mission_info_utils.h @@ -16,6 +16,9 @@ #include "js_runtime_utils.h" #include "mission_info.h" #include "mission_snapshot.h" +#include "ability_running_info.h" +#include "extension_running_info.h" +#include "running_process_info.h" #include "native_engine/native_engine.h" #include "ohos/aafwk/content/want_params_wrapper.h" #include "want.h" diff --git a/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp b/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp index 3f9a59de06d0b5193ea1cb7913dd463ac851f804..f51690175ab83c13eb263c36da13fde47aea01b2 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp +++ b/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp @@ -33,7 +33,7 @@ using namespace OHOS::AppExecFwk; using AbilityManagerClient = AAFwk::AbilityManagerClient; namespace { constexpr int32_t ARG_COUNT_TWO = 1; - constexpr int32_t ARG_COUNT_THREE = 1; + constexpr int32_t ARG_COUNT_THREE = 3; } class JsMissionManager { public: @@ -256,7 +256,7 @@ private: return engine.CreateUndefined(); } int32_t missionId = -1; - if (!ConvertFromJsValue(engine, info.argv[0], missionId)) { + if (!ConvertFromJsValue(engine, info.argv[1], missionId)) { HILOG_ERROR("missionSnapshot: Parse missionId failed"); return engine.CreateUndefined(); } @@ -460,6 +460,7 @@ NativeValue* JsMissionManagerInit(NativeEngine* engine, NativeValue* exportObj) BindNativeFunction(*engine, *object, "clearMission", JsMissionManager::ClearMission); BindNativeFunction(*engine, *object, "clearAllMissions", JsMissionManager::ClearAllMissions); BindNativeFunction(*engine, *object, "moveMissionToFront", JsMissionManager::MoveMissionToFront); + BindNativeFunction(*engine, *object, "moveMissionToFront", JsMissionManager::MoveMissionToFront); return engine->CreateUndefined(); } } // namespace AbilityRuntime diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 2d3bd5854bdfad0680fa01803e3712a4be24fe54..b30fa110e49b89727a117719fcfebdc76d9d5171 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -92,6 +92,7 @@ ohos_shared_library("abilityms") { "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index af51d4df38b0aef77286c0918c3875c5761f7450..4778cad548697599f32b8ebed37fa90d0837671a 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -39,6 +39,8 @@ abilityms_files = [ "${services_path}/abilitymgr/src/lifecycle_state_info.cpp", "${services_path}/abilitymgr/src/stack_info.cpp", "${services_path}/abilitymgr/src/mission_stack_info.cpp", + "${services_path}/abilitymgr/src/ability_running_info.cpp", + "${services_path}/abilitymgr/src/extension_running_info.cpp", "${services_path}/abilitymgr/src/mission_record_info.cpp", "${services_path}/abilitymgr/src/ability_record_info.cpp", "${services_path}/abilitymgr/src/ability_mission_info.cpp", diff --git a/services/abilitymgr/include/ability_connect_manager.h b/services/abilitymgr/include/ability_connect_manager.h index e5f8ceb6b409004928e03c5c4fad224b2cff8d44..8be56f1feb5dc5e668f29e8cda53e98edf28fbc7 100644 --- a/services/abilitymgr/include/ability_connect_manager.h +++ b/services/abilitymgr/include/ability_connect_manager.h @@ -23,6 +23,8 @@ #include "ability_connect_callback_interface.h" #include "ability_event_handler.h" #include "ability_record.h" +#include "ability_running_info.h" +#include "extension_running_info.h" #include "connection_record.h" #include "element_name.h" #include "ohos/aafwk/content/want.h" @@ -181,6 +183,10 @@ public: ConnectListType GetConnectRecordListByCallback(sptr callback); void RemoveAll(); + void GetExtensionRunningInfos(int upperLimit, std::vector &info); + + void GetAbilityRunningInfos(std::vector &info); + /** * SetEventHandler. * diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 9255eb5f31ad727db261685e741cf8d5ac9f802f..1f576801c81ff368a4e41227dd9078f9e3b46db7 100755 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -525,12 +525,18 @@ public: virtual int StopUser(int userId, const sptr &callback) override; + virtual int GetAbilityRunningInfos(std::vector &info) override; + + virtual int GetExtensionRunningInfos(int upperLimit, std::vector &info) override; + + virtual int GetProcessRunningInfos(std::vector &info) override; + virtual int RegisterMissionListener(const std::string &deviceId, const sptr &listener) override; virtual int UnRegisterMissionListener(const std::string &deviceId, const sptr &listener) override; - + /** * Set ability controller. * @@ -552,7 +558,7 @@ public: virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot) override; private: - template + template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); bool WriteInterfaceToken(MessageParcel &data); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index f6c2176e8201055b639d0a01c21375befc90eb39..1eef5b5ca3ade7d9f0f4159f0832d7ec08733d8b 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -679,6 +679,10 @@ public: std::shared_ptr GetConfiguration(); + virtual int GetAbilityRunningInfos(std::vector &info) override; + virtual int GetExtensionRunningInfos(int upperLimit, std::vector &info) override; + virtual int GetProcessRunningInfos(std::vector &info) override; + int GetMissionSaveTime() const; /** @@ -897,6 +901,10 @@ private: void InitDataAbilityManager(int32_t userId, bool switchUser); void InitPendWantManager(int32_t userId, bool switchUser); + int32_t GetAbilityInfoFromExtension(const Want &want, AppExecFwk::AbilityInfo& abilityInfo); + int32_t InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo, + AppExecFwk::AbilityInfo &abilityInfo); + // multi user void StartFreezingScreen(); void StopFreezingScreen(); @@ -933,7 +941,6 @@ private: std::unordered_map> missionListManagers_; std::shared_ptr currentMissionListManager_; std::shared_ptr kernalAbilityManager_; - sptr snapshotHandler_; std::shared_ptr userController_; sptr abilityController_ = nullptr; bool controllerIsAStabilityTest_ = false; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 1f377e1bfb476c1e452dec1e98e33b8645781dfa..fe39b4845ce30b030aa49349c76b8527595cb877 100755 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -125,6 +125,9 @@ private: int MoveMissionToFrontInner(MessageParcel &data, MessageParcel &reply); int StartUserInner(MessageParcel &data, MessageParcel &reply); int StopUserInner(MessageParcel &data, MessageParcel &reply); + int GetAbilityRunningInfosInner(MessageParcel &data, MessageParcel &reply); + int GetExtensionRunningInfosInner(MessageParcel &data, MessageParcel &reply); + int GetProcessRunningInfosInner(MessageParcel &data, MessageParcel &reply); int StartSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply); int StopSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply); diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 2f088545156760191c1dcf791e86046282d2c81b..2b72c2df772637976e081a2d85ba049717c15001 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -28,6 +28,7 @@ #include "refbase.h" #include "singleton.h" #include "system_memory_attr.h" +#include "running_process_info.h" namespace OHOS { namespace AAFwk { @@ -223,11 +224,14 @@ public: */ void GetSystemMemoryAttr(AppExecFwk::SystemMemoryAttr &memoryInfo, std::string &strConfig); + void GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info); /** * Start a resident process */ void StartupResidentProcess(); + int GetProcessRunningInfos(std::vector &info); + protected: /** * OnAbilityRequestDone, app manager service call this interface after ability request done. diff --git a/services/abilitymgr/include/data_ability_manager.h b/services/abilitymgr/include/data_ability_manager.h index b3286f03df1bbe77a3c2d2062f0955aaee4e3010..13b5a91517eeeac46a211aa551501b9ec304fcc2 100644 --- a/services/abilitymgr/include/data_ability_manager.h +++ b/services/abilitymgr/include/data_ability_manager.h @@ -22,6 +22,7 @@ #include #include "ability_record.h" +#include "ability_running_info.h" #include "data_ability_record.h" #include "nocopyable.h" @@ -46,6 +47,7 @@ public: std::shared_ptr GetAbilityRecordByScheduler(const sptr &scheduler); void Dump(const char *func, int line); void DumpState(std::vector &info, const std::string &args = "") const; + void GetAbilityRunningInfos(std::vector &info); private: using DataAbilityRecordPtr = std::shared_ptr; diff --git a/services/abilitymgr/include/kernal_ability_manager.h b/services/abilitymgr/include/kernal_ability_manager.h index 45cae4e58a4a225812dd9c3d8c0a020ed7dff4a0..dd1ec48af3479ab646a32644bba386d48f7674fb 100644 --- a/services/abilitymgr/include/kernal_ability_manager.h +++ b/services/abilitymgr/include/kernal_ability_manager.h @@ -20,6 +20,7 @@ #include #include "ability_record.h" +#include "ability_running_info.h" #include "want.h" namespace OHOS { @@ -91,6 +92,8 @@ public: void RestartAbility(const std::shared_ptr abilityRecord); + void GetAbilityRunningInfos(std::vector &info); + private: /** * StartAbilityLocked. diff --git a/services/abilitymgr/include/mission_data_storage.h b/services/abilitymgr/include/mission_data_storage.h index ebced052d7beb228fa431da3941aa581c2d06fbf..f7e234267bf0cbfe2a8ee85ae7a907123e1ab473 100644 --- a/services/abilitymgr/include/mission_data_storage.h +++ b/services/abilitymgr/include/mission_data_storage.h @@ -22,6 +22,7 @@ #include "event_handler.h" #include "inner_mission_info.h" +#include "mission_snapshot.h" namespace OHOS { namespace AAFwk { @@ -29,6 +30,7 @@ const std::string TASK_DATA_FILE_BASE_PATH = "/data/service/el1/public/AbilityMa const std::string MISSION_DATA_FILE_PATH = "MissionInfo"; const std::string MISSION_JSON_FILE_PREFIX = "mission"; const std::string JSON_FILE_SUFFIX = ".json"; +const std::string PNG_FILE_SUFFIX = ".png"; class MissionDataStorage : public std::enable_shared_from_this { public: @@ -56,11 +58,19 @@ public: */ void DeleteMissionInfo(int missionId); + void SaveMissionSnapshot(int missionId, const MissionSnapshot& missionSnapshot); + + bool GetMissionSnapshot(int missionId, MissionSnapshot& missionSnapshot); + + bool WriteToPng(const char* fileName, uint32_t width, uint32_t height, const uint8_t* data); + private: std::string GetMissionDataDirPath(); std::string GetMissionDataFilePath(int missionId); + std::string GetMissionSnapshotPath(int missionId); + bool CheckFileNameValid(const std::string &fileName); private: diff --git a/services/abilitymgr/include/mission_info_mgr.h b/services/abilitymgr/include/mission_info_mgr.h index b41b2af41170c2e6f42b3816c42eeb2165d9110b..790e05fad5679ee4fb96552b00dac46bca53eca3 100644 --- a/services/abilitymgr/include/mission_info_mgr.h +++ b/services/abilitymgr/include/mission_info_mgr.h @@ -22,6 +22,8 @@ #include "inner_mission_info.h" #include "mission_listener_controller.h" +#include "mission_snapshot.h" +#include "snapshot.h" #include "task_data_persistence_mgr.h" namespace OHOS { @@ -120,6 +122,32 @@ public: * @param info dump result. */ void Dump(std::vector &info); + + /** + * @brief update mission snapshot + * @param missionId mission id + * @param abilityToken abilityToken to get current mission snapshot + * @param missionSnapshot result of snapshot + * @return return true if update mission snapshot success, else false + */ + bool UpdateMissionSnapshot(int32_t missionId, const sptr& abilityToken, + MissionSnapshot& missionSnapshot) const; + + /** + * @brief get the mission snapshot object + * @param missionId mission id + * @param abilityToken abilityToken to get current mission snapshot + * @param missionSnapshot result of snapshot + * @return true return true if get mission snapshot success, else false + */ + bool GetMissionSnapshot(int32_t missionId, const sptr& abilityToken, + MissionSnapshot& missionSnapshot) const; + + /** + * @brief register snapshotHandler + * @param handler the snapshotHandler + */ + void RegisterSnapshotHandler(const sptr& handler); private: /** * @brief Boot query mission info. @@ -131,6 +159,7 @@ private: std::unordered_map missionIdMap_; // key:distributed misisonid, vaule: has been saved std::list missionInfoList_; std::shared_ptr taskDataPersistenceMgr_; + sptr snapshotHandler_; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/mission_list.h b/services/abilitymgr/include/mission_list.h index fe2008febc1cdd5d6c219df175f9891f8a708f9b..0a3911245c9c5be8b62518b9fbc437b310da0d15 100644 --- a/services/abilitymgr/include/mission_list.h +++ b/services/abilitymgr/include/mission_list.h @@ -170,7 +170,7 @@ private: std::string GetTypeName(); MissionListType type_; - std::list> missions_; + std::list> missions_ {}; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission_list_manager.h index fe7b0590606ce2f3328f5ca148f4125ab6f4ac79..331dbbdb5a4e2299a0c39399c18228b490c9546e 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -20,9 +20,12 @@ #include #include +#include "ability_running_info.h" #include "mission_list.h" #include "mission_listener_controller.h" #include "mission_info.h" +#include "mission_snapshot.h" +#include "snapshot.h" #include "want.h" namespace OHOS { @@ -249,6 +252,22 @@ public: * @param info dump result. */ void DumpMissionInfos(std::vector &info); + + /** + * @brief register snapshotHandler + * @param handler the snapshotHandler + */ + void RegisterSnapshotHandler(const sptr& handler); + + /** + * @brief Get the Mission Snapshot object + * @param missionId mission id + * @param abilityToken abilityToken to get current mission snapshot + * @param missionSnapshot result of snapshot + */ + void GetMissionSnapshot(int32_t missionId, const sptr& abilityToken, + MissionSnapshot& missionSnapshot); + void GetAbilityRunningInfos(std::vector &info); private: int StartAbilityLocked(const std::shared_ptr ¤tTopAbility, const std::shared_ptr &callerAbility, const AbilityRequest &abilityRequest); diff --git a/services/abilitymgr/include/task_data_persistence_mgr.h b/services/abilitymgr/include/task_data_persistence_mgr.h index db3c2e1e004b6f359ca5e6208e2b54088ba74863..3e8aae52068fa7ea67cd144aee45efaebba3faba 100644 --- a/services/abilitymgr/include/task_data_persistence_mgr.h +++ b/services/abilitymgr/include/task_data_persistence_mgr.h @@ -28,6 +28,8 @@ namespace AAFwk { const std::string THREAD_NAME = "TaskDataStorage"; const std::string SAVE_MISSION_INFO = "SaveMissionInfo"; const std::string DELETE_MISSION_INFO = "DeleteMissionInfo"; +const std::string SAVE_MISSION_SNAPSHOT = "SaveMissionSnapshot"; +const std::string GET_MISSION_SNAPSHOT = "GetMissionSnapshot"; class TaskDataPersistenceMgr : public std::enable_shared_from_this { DECLARE_DELAYED_SINGLETON(TaskDataPersistenceMgr) @@ -66,6 +68,22 @@ public: */ bool RemoveUserDir(int32_t userId); + /** + * @brief save mission snapshot + * @param missionId id of mission + * @param snapshot result of snapshot + * @return return true if update mission snapshot success, else false + */ + bool SaveMissionSnapshot(int missionId, const MissionSnapshot& snapshot); + + /** + * @brief get the mission snapshot object + * @param missionId id of mission + * @param missionSnapshot + * @return return true if update mission snapshot success, else false + */ + bool GetMissionSnapshot(int missionId, MissionSnapshot& missionSnapshot); + private: std::unordered_map> missionDataStorageMgr_; std::shared_ptr currentMissionDataStorage_; diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 43665d4d33a0ee943c5f11af58dad7f18eebc73c..b276cdeb63d101aeec3be311ba8d922d29e4f1c0 100755 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -941,5 +941,62 @@ void AbilityConnectManager::DumpState(std::vector &info, const std: } } } + +void AbilityConnectManager::GetExtensionRunningInfos(int upperLimit, std::vector &info) +{ + HILOG_INFO("Get extension running info."); + std::lock_guard guard(Lock_); + auto queryInfo = [&info, upperLimit](ServiceMapType::reference service) { + if (static_cast(info.size()) >= upperLimit) { + return; + } + auto abilityRecord = service.second; + CHECK_POINTER(abilityRecord); + ExtensionRunningInfo extensionInfo; + AppExecFwk::RunningProcessInfo processInfo; + extensionInfo.extension = abilityRecord->GetWant().GetElement(); + DelayedSingleton::GetInstance()-> + GetRunningProcessInfoByToken(abilityRecord->GetToken(), processInfo); + extensionInfo.pid = processInfo.pid_; + extensionInfo.uid = processInfo.uid_; + extensionInfo.processName = processInfo.processName_; + extensionInfo.startTime = abilityRecord->GetStartTime(); + ConnectListType connectRecordList = abilityRecord->GetConnectRecordList(); + for (auto &connectRecord : connectRecordList) { + CHECK_POINTER(connectRecord); + auto callerAbilityRecord = Token::GetAbilityRecordByToken(connectRecord->GetToken()); + CHECK_POINTER(callerAbilityRecord); + std::string package = callerAbilityRecord->GetAbilityInfo().bundleName; + extensionInfo.clientPackage.emplace_back(package); + } + info.emplace_back(extensionInfo); + // extension type + }; + std::for_each(serviceMap_.begin(), serviceMap_.end(), queryInfo); +} + +void AbilityConnectManager::GetAbilityRunningInfos(std::vector &info) +{ + HILOG_INFO("Query running ability infos."); + std::lock_guard guard(Lock_); + + auto queryInfo = [&info](ServiceMapType::reference service) { + auto abilityRecord = service.second; + CHECK_POINTER(abilityRecord); + AbilityRunningInfo runningInfo; + AppExecFwk::RunningProcessInfo processInfo; + runningInfo.ability = abilityRecord->GetWant().GetElement(); + DelayedSingleton::GetInstance()-> + GetRunningProcessInfoByToken(abilityRecord->GetToken(), processInfo); + runningInfo.pid = processInfo.pid_; + runningInfo.uid = processInfo.uid_; + runningInfo.processName = processInfo.processName_; + runningInfo.startTime = abilityRecord->GetStartTime(); + runningInfo.abilityState = static_cast(abilityRecord->GetAbilityState()); + info.emplace_back(runningInfo); + }; + + std::for_each(serviceMap_.begin(), serviceMap_.end(), queryInfo); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index c54f280f0dbb3be3544f592e1e572c3ffd15c99f..704e52b82d7354ac1b23acb997d5b4e382aab0ce 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -753,6 +753,27 @@ ErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId) return abms->MoveMissionToFront(missionId); } +ErrCode AbilityManagerClient::GetAbilityRunningInfos(std::vector &info) +{ + CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); + sptr abms = iface_cast(remoteObject_); + return abms->GetAbilityRunningInfos(info); +} + +ErrCode AbilityManagerClient::GetExtensionRunningInfos(int upperLimit, std::vector &info) +{ + CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); + sptr abms = iface_cast(remoteObject_); + return abms->GetExtensionRunningInfos(upperLimit, info); +} + +ErrCode AbilityManagerClient::GetProcessRunningInfos(std::vector &info) +{ + CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); + sptr abms = iface_cast(remoteObject_); + return abms->GetProcessRunningInfos(info); +} + /** * Start synchronizing remote device mission * @param devId, deviceId. @@ -760,37 +781,32 @@ ErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId) * @param tag, call tag. * @return Returns ERR_OK on success, others on failure. */ -ErrCode AbilityManagerClient::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) +ErrCode AbilityManagerClient::StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag) { CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); auto abms = iface_cast(remoteObject_); return abms->StartSyncRemoteMissions(devId, fixConflict, tag); } - /** * Stop synchronizing remote device mission * @param devId, deviceId. * @return Returns ERR_OK on success, others on failure. */ -ErrCode AbilityManagerClient::StopSyncRemoteMissions(const std::string& devId) +ErrCode AbilityManagerClient::StopSyncRemoteMissions(const std::string &devId) { CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); auto abms = iface_cast(remoteObject_); return abms->StopSyncRemoteMissions(devId); } - ErrCode AbilityManagerClient::StartUser(int accountId) { CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); - sptr abms = iface_cast(remoteObject_); return abms->StartUser(accountId); } - ErrCode AbilityManagerClient::StopUser(int accountId, const sptr &callback) { CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); - sptr abms = iface_cast(remoteObject_); return abms->StopUser(accountId, callback); } @@ -810,4 +826,4 @@ ErrCode AbilityManagerClient::GetMissionSnapshot(const std::string& deviceId, in return abms->GetMissionSnapshot(deviceId, missionId, snapshot); } } // namespace AAFwk -} // namespace OHOS +} // namespace AAFwk diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index fc3a387d67efe68b9bc7755cfc4a11b68d41654a..97636e4866821e5cae590f0901c6fbd4eab09dd9 100755 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -131,8 +131,8 @@ int AbilityManagerProxy::StartAbility(const Want &want, const sptr &callerToken, int requestCode) +int AbilityManagerProxy::StartAbility( + const Want &want, const StartOptions &startOptions, const sptr &callerToken, int requestCode) { int error; MessageParcel data; @@ -592,7 +592,7 @@ int AbilityManagerProxy::GetAllStackInfo(StackInfo &stackInfo) return result; } -template +template int AbilityManagerProxy::GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos) { int32_t infoSize = reply.ReadInt32(); @@ -684,7 +684,7 @@ int AbilityManagerProxy::GetMissionSnapshot(const std::string& deviceId, int32_t HILOG_ERROR("missionId write failed."); return ERR_INVALID_VALUE; } - error = Remote()->SendRequest(IAbilityManager::GET_MISSION_SNAPSHOT, data, reply, option); + error = Remote()->SendRequest(IAbilityManager::GET_MISSION_SNAPSHOT_INFO, data, reply, option); if (error != NO_ERROR) { HILOG_ERROR("Send request error: %{public}d", error); return error; @@ -1983,6 +1983,80 @@ int AbilityManagerProxy::StopUser(int userId, const sptr &cal return reply.ReadInt32(); } +int AbilityManagerProxy::GetAbilityRunningInfos(std::vector &info) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!WriteInterfaceToken(data)) { + return INNER_ERR; + } + + auto error = Remote()->SendRequest(IAbilityManager::GET_ABILITY_RUNNING_INFO, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("Get ability running info, error: %{public}d", error); + return error; + } + error = GetParcelableInfos(reply, info); + if (error != NO_ERROR) { + HILOG_ERROR("GetParcelableInfos fail, error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + +int AbilityManagerProxy::GetExtensionRunningInfos(int upperLimit, std::vector &info) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!WriteInterfaceToken(data)) { + return INNER_ERR; + } + + if (!data.WriteInt32(upperLimit)) { + HILOG_ERROR("upperLimit write failed."); + return INNER_ERR; + } + + auto error = Remote()->SendRequest(IAbilityManager::GET_EXTENSION_RUNNING_INFO, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("Get extension running info failed., error: %{public}d", error); + return error; + } + error = GetParcelableInfos(reply, info); + if (error != NO_ERROR) { + HILOG_ERROR("GetParcelableInfos fail, error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + +int AbilityManagerProxy::GetProcessRunningInfos(std::vector &info) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!WriteInterfaceToken(data)) { + return INNER_ERR; + } + + auto error = Remote()->SendRequest(IAbilityManager::GET_PROCESS_RUNNING_INFO, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("Get process running info, error: %{public}d", error); + return error; + } + error = GetParcelableInfos(reply, info); + if (error != NO_ERROR) { + HILOG_ERROR("GetParcelableInfos fail, error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + int AbilityManagerProxy::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) { HILOG_INFO("called"); @@ -2131,4 +2205,4 @@ bool AbilityManagerProxy::IsUserAStabilityTest() return reply.ReadBool(); } } // namespace AAFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index b4837a790348f793d37f1e298d88e099486f5efe..94d8b8364e97d3dcda1e373bfb6617f3f8a200bb 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -28,6 +28,7 @@ #include "ability_manager_errors.h" #include "ability_util.h" #include "bytrace.h" +#include "bundle_mgr_client.h" #include "configuration_distributor.h" #include "hilog_wrapper.h" #include "if_system_ability_manager.h" @@ -40,6 +41,7 @@ #include "softbus_bus_center.h" #include "string_ex.h" #include "system_ability_definition.h" +#include "png.h" using OHOS::AppExecFwk::ElementName; @@ -231,25 +233,27 @@ int AbilityManagerService::StartAbility( if (callerToken != nullptr && !VerificationToken(callerToken)) { return ERR_INVALID_VALUE; } - + HILOG_INFO("%{public}s 1111111111", __func__); AbilityRequest abilityRequest; int result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken); if (result != ERR_OK) { HILOG_ERROR("Generate ability request error."); return result; } + HILOG_INFO("%{public}s 2222222", __func__); auto abilityInfo = abilityRequest.abilityInfo; result = AbilityUtil::JudgeAbilityVisibleControl(abilityInfo, callerUid); if (result != ERR_OK) { HILOG_ERROR("%{public}s JudgeAbilityVisibleControl error.", __func__); return result; } + HILOG_INFO("%{public}s 3333333", __func__); auto type = abilityInfo.type; if (type == AppExecFwk::AbilityType::DATA) { HILOG_ERROR("Cannot start data ability, use 'AcquireDataAbility()' instead."); return ERR_INVALID_VALUE; } - + HILOG_INFO("%{public}s 4444444", __func__); if (!AbilityUtil::IsSystemDialogAbility(abilityInfo.bundleName, abilityInfo.name)) { result = PreLoadAppDataAbilities(abilityInfo.bundleName); if (result != ERR_OK) { @@ -2005,8 +2009,12 @@ int AbilityManagerService::GenerateAbilityRequest( bms->QueryAbilityInfo(want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, request.abilityInfo); if (request.abilityInfo.name.empty() || request.abilityInfo.bundleName.empty()) { - HILOG_ERROR("Get ability info failed."); - return RESOLVE_ABILITY_ERR; + // try to find extension + int ret = GetAbilityInfoFromExtension(want, request.abilityInfo); + if (!ret) { + HILOG_ERROR("Get ability info failed."); + return RESOLVE_ABILITY_ERR; + } } HILOG_DEBUG("Query ability name: %{public}s,", request.abilityInfo.name.c_str()); if (request.abilityInfo.type == AppExecFwk::AbilityType::SERVICE) { @@ -2799,6 +2807,59 @@ int AbilityManagerService::StopUser(int userId, const sptr &c return 0; } +int AbilityManagerService::GetAbilityRunningInfos(std::vector &info) +{ + HILOG_DEBUG("Get running ability infos."); + auto bundleMgr = GetBundleManager(); + if (!bundleMgr) { + HILOG_ERROR("bundleMgr is nullptr."); + return INNER_ERR; + } + + auto callerUid = IPCSkeleton::GetCallingUid(); + auto isSystem = bundleMgr->CheckIsSystemAppByUid(callerUid); + HILOG_DEBUG("callerUid : %{public}d, isSystem : %{public}d", callerUid, static_cast(isSystem)); + + if (!isSystem) { + HILOG_ERROR("callar is not system app."); + return INNER_ERR; + } + + currentMissionListManager_->GetAbilityRunningInfos(info); + kernalAbilityManager_->GetAbilityRunningInfos(info); + connectManager_->GetAbilityRunningInfos(info); + dataAbilityManager_->GetAbilityRunningInfos(info); + + return ERR_OK; +} + +int AbilityManagerService::GetExtensionRunningInfos(int upperLimit, std::vector &info) +{ + HILOG_DEBUG("Get extension infos, upperLimit : %{public}d", upperLimit); + auto bundleMgr = GetBundleManager(); + if (!bundleMgr) { + HILOG_ERROR("bundleMgr is nullptr."); + return INNER_ERR; + } + + auto callerUid = IPCSkeleton::GetCallingUid(); + auto isSystem = bundleMgr->CheckIsSystemAppByUid(callerUid); + HILOG_DEBUG("callerUid : %{public}d, isSystem : %{public}d", callerUid, static_cast(isSystem)); + + if (!isSystem) { + HILOG_ERROR("callar is not system app."); + return INNER_ERR; + } + + connectManager_->GetExtensionRunningInfos(upperLimit, info); + return ERR_OK; +} + +int AbilityManagerService::GetProcessRunningInfos(std::vector &info) +{ + return DelayedSingleton::GetInstance()->GetProcessRunningInfos(info); +} + void AbilityManagerService::ClearUserData(int32_t userId) { HILOG_DEBUG("%{public}s", __func__); @@ -2810,8 +2871,12 @@ void AbilityManagerService::ClearUserData(int32_t userId) int AbilityManagerService::RegisterSnapshotHandler(const sptr& handler) { + if (!currentMissionListManager_) { + HILOG_ERROR("snapshot: currentMissionListManager_ is nullptr."); + return 0; + } + currentMissionListManager_->RegisterSnapshotHandler(handler); HILOG_INFO("snapshot: AbilityManagerService register snapshot handler success."); - snapshotHandler_ = handler; return 0; } @@ -2822,15 +2887,14 @@ int32_t AbilityManagerService::GetMissionSnapshot(const std::string& deviceId, i HILOG_INFO("get remote mission snapshot."); return GetRemoteMissionSnapshotInfo(deviceId, missionId, missionSnapshot); } - HILOG_INFO("get local mission snapshot."); - if (!snapshotHandler_) { - return 0; + if (!currentMissionListManager_) { + HILOG_ERROR("snapshot: currentMissionListManager_ is nullptr."); + return -1; } - Snapshot snapshot; - int32_t result = snapshotHandler_->GetSnapshot(GetAbilityTokenByMissionId(missionId), snapshot); - missionSnapshot.snapshot = snapshot.GetPixelMap(); - return result; + auto token = GetAbilityTokenByMissionId(missionId); + currentMissionListManager_->GetMissionSnapshot(missionId, token, missionSnapshot); + return 0; } int32_t AbilityManagerService::GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, @@ -2981,5 +3045,72 @@ bool AbilityManagerService::IsAbilityControllerResuming(const std::string &bundl } return true; } + +int32_t AbilityManagerService::InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo, + AppExecFwk::AbilityInfo &abilityInfo) +{ + abilityInfo.bundleName = extensionInfo.bundleName; + abilityInfo.package = extensionInfo.moduleName; + abilityInfo.moduleName = extensionInfo.moduleName; + abilityInfo.name = extensionInfo.name; + abilityInfo.srcEntrance = extensionInfo.srcEntrance; + abilityInfo.srcPath = extensionInfo.srcEntrance; + abilityInfo.iconPath = extensionInfo.icon; + abilityInfo.iconId = extensionInfo.iconId; + abilityInfo.label = extensionInfo.label; + abilityInfo.labelId = extensionInfo.labelId; + abilityInfo.description = extensionInfo.description; + abilityInfo.descriptionId = extensionInfo.descriptionId; + abilityInfo.permissions = extensionInfo.permissions; + abilityInfo.readPermission = extensionInfo.readPermission; + abilityInfo.writePermission = extensionInfo.writePermission; + abilityInfo.extensionAbilityType = extensionInfo.type; + abilityInfo.visible = extensionInfo.visible; + abilityInfo.applicationInfo = extensionInfo.applicationInfo; + abilityInfo.resourcePath = extensionInfo.resourcePath; + abilityInfo.enabled = extensionInfo.enabled; + switch (extensionInfo.type) { + case AppExecFwk::ExtensionAbilityType::FORM: + abilityInfo.type = AppExecFwk::AbilityType::FORM; + break; + case AppExecFwk::ExtensionAbilityType::SERVICE: + abilityInfo.type = AppExecFwk::AbilityType::SERVICE; + break; + case AppExecFwk::ExtensionAbilityType::DATASHARE: + abilityInfo.type = AppExecFwk::AbilityType::DATA; + break; + default: + abilityInfo.type = AppExecFwk::AbilityType::EXTENSION; + break; + } + return 0; +} + +int32_t AbilityManagerService::GetAbilityInfoFromExtension(const Want &want, AppExecFwk::AbilityInfo &abilityInfo) +{ + ElementName elementName = want.GetElement(); + std::string bundleName = elementName.GetBundleName(); + std::string abilityName = elementName.GetAbilityName(); + AppExecFwk::BundleMgrClient bundleClient; + AppExecFwk::BundleInfo bundleInfo; + if (!bundleClient.GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO, bundleInfo)) { + HILOG_ERROR("Failed to get bundle info when generate ability request."); + return RESOLVE_APP_ERR; + } + bool found = false; + + for (auto &extensionInfo: bundleInfo.extensionInfos) { + if (extensionInfo.name != abilityName) { + continue; + } + found = true; + HILOG_DEBUG("GetExtensionAbilityInfo, extension ability info found, name=%{public}s", abilityName.c_str()); + abilityInfo.applicationName = bundleInfo.applicationInfo.name; + InitAbilityInfoFromExtension(extensionInfo, abilityInfo); + break; + } + + return found; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index b94cf6b91ae2e39a3bfdf0b6ab463621966317a3..0982a6f03cfb7f658756dd4238e34ec569728cbd 100755 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -125,8 +125,12 @@ void AbilityManagerStub::SecondStepInit() requestFuncMap_[MOVE_MISSION_TO_FRONT] = &AbilityManagerStub::MoveMissionToFrontInner; requestFuncMap_[START_USER] = &AbilityManagerStub::StartUserInner; requestFuncMap_[STOP_USER] = &AbilityManagerStub::StopUserInner; + requestFuncMap_[GET_ABILITY_RUNNING_INFO] = &AbilityManagerStub::GetAbilityRunningInfosInner; + requestFuncMap_[GET_EXTENSION_RUNNING_INFO] = &AbilityManagerStub::GetExtensionRunningInfosInner; + requestFuncMap_[GET_PROCESS_RUNNING_INFO] = &AbilityManagerStub::GetProcessRunningInfosInner; requestFuncMap_[SET_ABILITY_CONTROLLER] = &AbilityManagerStub::SetAbilityControllerInner; requestFuncMap_[IS_USER_A_STABILITY_TEST] = &AbilityManagerStub::IsUserAStabilityTestInner; + requestFuncMap_[GET_MISSION_SNAPSHOT_INFO] = &AbilityManagerStub::GetMissionSnapshotInfoInner; } int AbilityManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) @@ -1125,6 +1129,55 @@ int AbilityManagerStub::StopUserInner(MessageParcel &data, MessageParcel &reply) return NO_ERROR; } +int AbilityManagerStub::GetAbilityRunningInfosInner(MessageParcel &data, MessageParcel &reply) +{ + std::vector abilityRunningInfos; + auto result = GetAbilityRunningInfos(abilityRunningInfos); + reply.WriteInt32(abilityRunningInfos.size()); + for (auto &it : abilityRunningInfos) { + if (!reply.WriteParcelable(&it)) { + return ERR_INVALID_VALUE; + } + } + if (!reply.WriteInt32(result)) { + return ERR_INVALID_VALUE; + } + return result; +} + +int AbilityManagerStub::GetExtensionRunningInfosInner(MessageParcel &data, MessageParcel &reply) +{ + auto upperLimit = data.ReadInt32(); + std::vector infos; + auto result = GetExtensionRunningInfos(upperLimit, infos); + reply.WriteInt32(infos.size()); + for (auto &it : infos) { + if (!reply.WriteParcelable(&it)) { + return ERR_INVALID_VALUE; + } + } + if (!reply.WriteInt32(result)) { + return ERR_INVALID_VALUE; + } + return result; +} + +int AbilityManagerStub::GetProcessRunningInfosInner(MessageParcel &data, MessageParcel &reply) +{ + std::vector infos; + auto result = GetProcessRunningInfos(infos); + reply.WriteInt32(infos.size()); + for (auto &it : infos) { + if (!reply.WriteParcelable(&it)) { + return ERR_INVALID_VALUE; + } + } + if (!reply.WriteInt32(result)) { + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} + int AbilityManagerStub::StartSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply) { std::string deviceId = data.ReadString(); diff --git a/services/abilitymgr/src/ability_running_info.cpp b/services/abilitymgr/src/ability_running_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7ea5da7739c5088dfe6b3ad64009c680d5852239 --- /dev/null +++ b/services/abilitymgr/src/ability_running_info.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2021 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 "ability_running_info.h" +#include "hilog_wrapper.h" +#include "nlohmann/json.hpp" +#include "string_ex.h" + +namespace OHOS { +namespace AAFwk { +bool AbilityRunningInfo::ReadFromParcel(Parcel &parcel) +{ + std::unique_ptr abilityInfo(parcel.ReadParcelable()); + if (abilityInfo == nullptr) { + return false; + } + ability = *abilityInfo; + pid = parcel.ReadInt32(); + uid = parcel.ReadInt32(); + processName = Str16ToStr8(parcel.ReadString16()); + startTime = parcel.ReadInt64(); + abilityState = parcel.ReadInt32(); + return true; +} + +AbilityRunningInfo *AbilityRunningInfo::Unmarshalling(Parcel &parcel) +{ + AbilityRunningInfo *info = new (std::nothrow) AbilityRunningInfo(); + if (info == nullptr) { + return nullptr; + } + + if (!info->ReadFromParcel(parcel)) { + delete info; + info = nullptr; + } + return info; +} + +bool AbilityRunningInfo::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteParcelable(&ability)) { + return false; + } + if (!parcel.WriteInt32(pid)) { + return false; + } + if (!parcel.WriteInt32(uid)) { + return false; + } + if (!parcel.WriteString16(Str8ToStr16(processName))) { + return false; + } + if (!parcel.WriteInt64(startTime)) { + return false; + } + if (!parcel.WriteInt32(abilityState)) { + return false; + } + return true; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/ability_stack_manager.cpp b/services/abilitymgr/src/ability_stack_manager.cpp index 45eb0cc89beb8dd81fba9a5d6d1bb92455914151..bce2de61c806c0276b2dd99f98eb78ac6a3ef67f 100644 --- a/services/abilitymgr/src/ability_stack_manager.cpp +++ b/services/abilitymgr/src/ability_stack_manager.cpp @@ -4433,7 +4433,7 @@ int AbilityStackManager::GetMissionSnapshot(int32_t missionId, MissionPixelMap & CHECK_POINTER_AND_RETURN_LOG(topAbilityRecord, REMOVE_MISSION_ID_NOT_EXIST, "top ability is invalid."); auto windowInfo = topAbilityRecord->GetWindowInfo(); int windowID = 0; - if(windowInfo){ + if (windowInfo) { windowID = windowInfo->windowToken_; HILOG_INFO("windowID is %{public}d", windowID); } diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index a9b95559f757d363a640f25be28c6c7cc57d71f7..3e27e3db9c4c002136d300a62403fef0cad80bbf 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -242,10 +242,22 @@ void AppScheduler::GetSystemMemoryAttr(AppExecFwk::SystemMemoryAttr &memoryInfo, appMgrClient_->GetSystemMemoryAttr(memoryInfo, strConfig); } +void AppScheduler::GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info) +{ + CHECK_POINTER(appMgrClient_); + appMgrClient_->GetRunningProcessInfoByToken(token, info); +} + void AppScheduler::StartupResidentProcess() { CHECK_POINTER(appMgrClient_); appMgrClient_->StartupResidentProcess(); } + +int AppScheduler::GetProcessRunningInfos(std::vector &info) +{ + CHECK_POINTER_AND_RETURN(appMgrClient_, INNER_ERR); + return static_cast(appMgrClient_->GetAllRunningProcesses(info)); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/data_ability_manager.cpp b/services/abilitymgr/src/data_ability_manager.cpp index db89bf074aedbb1002c7e7658dbedf0005271151..898e3847432908a4e92934b7cc2df321dd19082e 100644 --- a/services/abilitymgr/src/data_ability_manager.cpp +++ b/services/abilitymgr/src/data_ability_manager.cpp @@ -494,5 +494,38 @@ void DataAbilityManager::DumpState(std::vector &info, const std::st } return; } + +void DataAbilityManager::GetAbilityRunningInfos(std::vector &info) +{ + HILOG_INFO("Get ability running infos"); + std::lock_guard locker(mutex_); + + auto queryInfo = [&info](DataAbilityRecordPtrMap::reference data) { + auto dataAbilityRecord = data.second; + if (!dataAbilityRecord) { + return; + } + + auto abilityRecord = dataAbilityRecord->GetAbilityRecord(); + if (!abilityRecord) { + return; + } + + AbilityRunningInfo runningInfo; + AppExecFwk::RunningProcessInfo processInfo; + runningInfo.ability = abilityRecord->GetWant().GetElement(); + DelayedSingleton::GetInstance()-> + GetRunningProcessInfoByToken(abilityRecord->GetToken(), processInfo); + runningInfo.pid = processInfo.pid_; + runningInfo.uid = processInfo.uid_; + runningInfo.processName = processInfo.processName_; + runningInfo.startTime = abilityRecord->GetStartTime(); + runningInfo.abilityState = static_cast(abilityRecord->GetAbilityState()); + info.emplace_back(runningInfo); + }; + + std::for_each(dataAbilityRecordsLoading_.begin(), dataAbilityRecordsLoading_.end(), queryInfo); + std::for_each(dataAbilityRecordsLoaded_.begin(), dataAbilityRecordsLoaded_.end(), queryInfo); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/extension_running_info.cpp b/services/abilitymgr/src/extension_running_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f6123a3357a9036c401c5f0eb82c8ed51d608c3 --- /dev/null +++ b/services/abilitymgr/src/extension_running_info.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 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 "extension_running_info.h" +#include "hilog_wrapper.h" +#include "nlohmann/json.hpp" +#include "string_ex.h" + +namespace OHOS { +namespace AAFwk { +bool ExtensionRunningInfo::ReadFromParcel(Parcel &parcel) +{ + std::unique_ptr readExtension(parcel.ReadParcelable()); + if (readExtension == nullptr) { + return false; + } + extension = *readExtension; + pid = parcel.ReadInt32(); + uid = parcel.ReadInt32(); + processName = Str16ToStr8(parcel.ReadString16()); + startTime = parcel.ReadInt32(); + int32_t clientPackageSize = parcel.ReadInt32(); + for (int32_t i = 0; i < clientPackageSize; i++) { + clientPackage.emplace_back(Str16ToStr8(parcel.ReadString16())); + } + return true; +} + +ExtensionRunningInfo *ExtensionRunningInfo::Unmarshalling(Parcel &parcel) +{ + ExtensionRunningInfo *info = new (std::nothrow) ExtensionRunningInfo(); + if (info == nullptr) { + return nullptr; + } + + if (!info->ReadFromParcel(parcel)) { + delete info; + info = nullptr; + } + return info; +} + +bool ExtensionRunningInfo::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteParcelable(&extension)) { + return false; + } + if (!parcel.WriteInt32(pid)) { + return false; + } + if (!parcel.WriteInt32(uid)) { + return false; + } + if (!parcel.WriteString16(Str8ToStr16(processName))) { + return false; + } + if (!parcel.WriteInt32(startTime)) { + return false; + } + int32_t clientPackageSize = static_cast(clientPackage.size()); + if (!parcel.WriteInt32(clientPackageSize)) { + return false; + } + for (std::string package : clientPackage) { + if (!parcel.WriteString16(Str8ToStr16(package))) { + return false; + } + } + return true; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/kernal_ability_manager.cpp b/services/abilitymgr/src/kernal_ability_manager.cpp index e1dcd5ec2c4bd7dec363c5f713e8e756fbeadb88..1667b8db46f95499b988c02d8de7ada0ac92dd51 100644 --- a/services/abilitymgr/src/kernal_ability_manager.cpp +++ b/services/abilitymgr/src/kernal_ability_manager.cpp @@ -375,6 +375,32 @@ void KernalAbilityManager::OnTimeOut(uint32_t msgId, int64_t eventId) } } +void KernalAbilityManager::GetAbilityRunningInfos(std::vector &info) +{ + HILOG_DEBUG("Get ability running infos"); + std::lock_guard guard(stackLock_); + + for (auto &ability : abilities_) { + if (!ability) { + HILOG_DEBUG("ability is nullptr."); + continue; + } + + AbilityRunningInfo runningInfo; + AppExecFwk::RunningProcessInfo processInfo; + runningInfo.ability = ability->GetWant().GetElement(); + DelayedSingleton::GetInstance()-> + GetRunningProcessInfoByToken(ability->GetToken(), processInfo); + runningInfo.pid = processInfo.pid_; + runningInfo.uid = processInfo.uid_; + runningInfo.processName = processInfo.processName_; + runningInfo.startTime = ability->GetStartTime(); + runningInfo.abilityState = static_cast(ability->GetAbilityState()); + info.emplace_back(runningInfo); + } +} + + void KernalAbilityManager::RestartAbility(const std::shared_ptr abilityRecord) { CHECK_POINTER(abilityRecord); diff --git a/services/abilitymgr/src/mission_data_storage.cpp b/services/abilitymgr/src/mission_data_storage.cpp index 99a0e658b38db9f69cef19aedc9ba57e156c961d..c4977bd4c9384e44d6656352ccd56288bcfd2df5 100644 --- a/services/abilitymgr/src/mission_data_storage.cpp +++ b/services/abilitymgr/src/mission_data_storage.cpp @@ -19,6 +19,9 @@ #include "file_util.h" #include "hilog_wrapper.h" +#include "image_source.h" +#include "media_errors.h" +#include "png.h" namespace OHOS { namespace AAFwk { @@ -125,5 +128,99 @@ bool MissionDataStorage::CheckFileNameValid(const std::string &fileName) return true; } + +void MissionDataStorage::SaveMissionSnapshot(int32_t missionId, const MissionSnapshot& missionSnapshot) +{ + std::string filePath = GetMissionSnapshotPath(missionId); + std::string dirPath = OHOS::HiviewDFX::FileUtil::ExtractFilePath(filePath); + if (!OHOS::HiviewDFX::FileUtil::FileExists(dirPath)) { + bool createDir = OHOS::HiviewDFX::FileUtil::ForceCreateDirectory(dirPath); + if (!createDir) { + HILOG_ERROR("snapshot: create dir %{public}s failed.", dirPath.c_str()); + return; + } + } + const uint8_t* data = missionSnapshot.snapshot->GetPixels(); + bool saveMissionFile = WriteToPng(filePath.c_str(), missionSnapshot.snapshot->GetWidth(), + missionSnapshot.snapshot->GetHeight(), data); + if (!saveMissionFile) { + HILOG_ERROR("snapshot: save mission snapshot failed, path = %{public}s.", filePath.c_str()); + } +} + +bool MissionDataStorage::GetMissionSnapshot(int missionId, MissionSnapshot& missionSnapshot) +{ + std::string filePath = GetMissionSnapshotPath(missionId); + if (!OHOS::HiviewDFX::FileUtil::FileExists(filePath)) { + HILOG_INFO("snapshot: storage snapshot not exists, missionId = %{public}d", missionId); + return false; + } + uint32_t errCode = 0; + Media::SourceOptions sourceOptions; + auto imageSource = Media::ImageSource::CreateImageSource(filePath, sourceOptions, errCode); + if (errCode != OHOS::Media::SUCCESS) { + HILOG_ERROR("snapshot: CreateImageSource failed, errCode = %{public}d", errCode); + return false; + } + Media::DecodeOptions decodeOptions; + auto pixelMap = imageSource->CreatePixelMap(decodeOptions, errCode); + if (errCode != OHOS::Media::SUCCESS) { + HILOG_ERROR("snapshot: CreatePixelMap failed, errCode = %{public}d", errCode); + return false; + } + missionSnapshot.snapshot = std::move(pixelMap); + return true; +} + +std::string MissionDataStorage::GetMissionSnapshotPath(int missionId) +{ + return GetMissionDataDirPath() + "/" + + MISSION_JSON_FILE_PREFIX + "_" + std::to_string(missionId) + PNG_FILE_SUFFIX; +} + +bool MissionDataStorage::WriteToPng(const char* fileName, uint32_t width, uint32_t height, const uint8_t* data) +{ + const int BITMAP_DEPTH = 8; // color depth + const int BPP = 4; // bytes per pixel + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); + if (png_ptr == nullptr) { + HILOG_ERROR("snapshot: png_create_write_struct error, nullptr!\n"); + return false; + } + png_infop info_ptr = png_create_info_struct(png_ptr); + if (png_ptr == nullptr) { + HILOG_ERROR("snapshot: png_create_info_struct error, nullptr!\n"); + png_destroy_write_struct(&png_ptr, nullptr); + return false; + } + FILE *fp = fopen(fileName, "wb"); + if (fp == nullptr) { + HILOG_ERROR("snapshot: open file [%s] error, nullptr!\n", fileName); + png_destroy_write_struct(&png_ptr, &info_ptr); + return false; + } + png_init_io(png_ptr, fp); + + // set png header + png_set_IHDR(png_ptr, info_ptr, + width, height, + BITMAP_DEPTH, + PNG_COLOR_TYPE_RGBA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, + PNG_FILTER_TYPE_BASE); + png_set_packing(png_ptr); + png_write_info(png_ptr, info_ptr); + + for (uint32_t i = 0; i < height; i++) { + png_write_row(png_ptr, data + (i * width * BPP)); + } + png_write_end(png_ptr, info_ptr); + + // free memory + png_destroy_write_struct(&png_ptr, &info_ptr); + (void)fclose(fp); + return true; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/mission_info_mgr.cpp b/services/abilitymgr/src/mission_info_mgr.cpp index e3282cc3ac2a107277d442b1078ac868e4939feb..ed8bbf3ab91548e3be60bb2bad10b0787f1f5fc2 100644 --- a/services/abilitymgr/src/mission_info_mgr.cpp +++ b/services/abilitymgr/src/mission_info_mgr.cpp @@ -305,5 +305,61 @@ void MissionInfoMgr::Dump(std::vector &info) innerMissionInfo.Dump(info); } } + +void MissionInfoMgr::RegisterSnapshotHandler(const sptr& handler) +{ + snapshotHandler_ = handler; +} + +bool MissionInfoMgr::UpdateMissionSnapshot(int32_t missionId, const sptr& abilityToken, + MissionSnapshot& missionSnapshot) const +{ + auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) { + return missionId == info.missionInfo.id; + }); + if (it == missionInfoList_.end()) { + HILOG_ERROR("snapshot: get mission failed, missionId %{public}d not exists", missionId); + return false; + } + Snapshot snapshot; + int32_t result = snapshotHandler_->GetSnapshot(abilityToken, snapshot); + if (result != 0) { + HILOG_ERROR("snapshot: get WMS snapshot failed, result = %{public}d", result); + return false; + } + if (!taskDataPersistenceMgr_) { + HILOG_ERROR("snapshot: taskDataPersistenceMgr_ is nullptr"); + return false; + } + missionSnapshot.snapshot = snapshot.GetPixelMap(); + missionSnapshot.topAbility = it->missionInfo.want.GetElement(); + if (!taskDataPersistenceMgr_->SaveMissionSnapshot(missionId, missionSnapshot)) { + HILOG_ERROR("snapshot: save mission snapshot failed"); + return false; + } + return true; +} + +bool MissionInfoMgr::GetMissionSnapshot(int32_t missionId, const sptr& abilityToken, + MissionSnapshot& missionSnapshot) const +{ + auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) { + return missionId == info.missionInfo.id; + }); + if (it == missionInfoList_.end()) { + HILOG_ERROR("snapshot: get mission failed, missionId %{public}d not exists", missionId); + return false; + } + if (!taskDataPersistenceMgr_) { + HILOG_ERROR("snapshot: taskDataPersistenceMgr_ is nullptr"); + return false; + } + if (taskDataPersistenceMgr_->GetMissionSnapshot(missionId, missionSnapshot)) { + missionSnapshot.topAbility = it->missionInfo.want.GetElement(); + return true; + } + HILOG_INFO("snapshot: storage mission snapshot not exists, create new snapshot"); + return UpdateMissionSnapshot(missionId, abilityToken, missionSnapshot); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index c934493732e873220a6fd281aee0fd0d352fba87..2746ac91b0febe1eeb73d3dfd125b43ac9b75f0c 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -751,6 +751,17 @@ void MissionListManager::CompleteBackground(const std::shared_ptr terminateAbility->Terminate(timeoutTask); } } + auto mission = abilityRecord->GetMission(); + if (!mission) { + HILOG_ERROR("snapshot: GetMission failed"); + return; + } + MissionSnapshot snapshot; + DelayedSingleton::GetInstance()->UpdateMissionSnapshot(mission->GetMissionId(), + abilityRecord->GetToken(), snapshot); + if (listenerController_) { + listenerController_->NotifyMissionSnapshotChanged(mission->GetMissionId()); + } } int MissionListManager::TerminateAbility(const std::shared_ptr &abilityRecord, @@ -1494,5 +1505,60 @@ void MissionListManager::DumpMission(int missionId, std::vector &in } innerMissionInfo.Dump(info); } + +void MissionListManager::RegisterSnapshotHandler(const sptr& handler) +{ + DelayedSingleton::GetInstance()->RegisterSnapshotHandler(handler); +} + +void MissionListManager::GetMissionSnapshot(int32_t missionId, const sptr& abilityToken, + MissionSnapshot& missionSnapshot) +{ + DelayedSingleton::GetInstance()->GetMissionSnapshot(missionId, abilityToken, missionSnapshot); +} + +void MissionListManager::GetAbilityRunningInfos(std::vector &info) +{ + std::lock_guard guard(managerLock_); + + auto func = [&info](const std::shared_ptr &mission) { + if (!mission) { + return; + } + + auto ability = mission->GetAbilityRecord(); + if (!ability) { + return; + } + + AbilityRunningInfo runningInfo; + AppExecFwk::RunningProcessInfo processInfo; + + runningInfo.ability = ability->GetWant().GetElement(); + runningInfo.startTime = ability->GetStartTime(); + runningInfo.abilityState = static_cast(ability->GetAbilityState()); + + DelayedSingleton::GetInstance()-> + GetRunningProcessInfoByToken(ability->GetToken(), processInfo); + runningInfo.pid = processInfo.pid_; + runningInfo.uid = processInfo.uid_; + runningInfo.processName = processInfo.processName_; + info.emplace_back(runningInfo); + }; + if (!(defaultStandardList_->GetAllMissions().empty())) { + auto list = defaultStandardList_->GetAllMissions(); + std::for_each(list.begin(), list.end(), func); + } + if (!(defaultSingleList_->GetAllMissions().empty())) { + auto list = defaultSingleList_->GetAllMissions(); + std::for_each(list.begin(), list.end(), func); + } + for (auto missionList : currentMissionLists_) { + if (!(missionList->GetAllMissions().empty())) { + auto list = missionList->GetAllMissions(); + std::for_each(list.begin(), list.end(), func); + } + } +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/task_data_persistence_mgr.cpp b/services/abilitymgr/src/task_data_persistence_mgr.cpp index 47fac5416c4ac4ceef4bd1984274ba5e4f08e828..382259f0a90e9c96def42d125ad58f545ba570f9 100644 --- a/services/abilitymgr/src/task_data_persistence_mgr.cpp +++ b/services/abilitymgr/src/task_data_persistence_mgr.cpp @@ -105,5 +105,25 @@ bool TaskDataPersistenceMgr::RemoveUserDir(int32_t userId) } return true; } + +bool TaskDataPersistenceMgr::SaveMissionSnapshot(int missionId, const MissionSnapshot& snapshot) +{ + if (!handler_ || !currentMissionDataStorage_) { + HILOG_ERROR("snapshot: handler_ or currentMissionDataStorage_ is nullptr"); + return false; + } + std::function SaveMissionSnapshotFunc = std::bind(&MissionDataStorage::SaveMissionSnapshot, + currentMissionDataStorage_, missionId, snapshot); + return handler_->PostTask(SaveMissionSnapshotFunc, SAVE_MISSION_SNAPSHOT); +} + +bool TaskDataPersistenceMgr::GetMissionSnapshot(int missionId, MissionSnapshot& snapshot) +{ + if (!currentMissionDataStorage_) { + HILOG_ERROR("snapshot: currentMissionDataStorage_ is nullptr"); + return false; + } + return currentMissionDataStorage_->GetMissionSnapshot(missionId, snapshot); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h b/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h index 648a2fa206d3470256b00881209b79cab46e783b..d911ef15d0a2bf06c273b82d61e9c62f15542fc3 100644 --- a/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h +++ b/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h @@ -495,7 +495,7 @@ public: GET_ALL_FORMS_INFO, GET_FORMS_INFO_BY_APP, GET_FORMS_INFO_BY_MODULE, - GET_MODULE_USAGE_RECORD, + GET_MODULE_USAGE_RECORD, GET_SHORTCUT_INFO, GET_ALL_COMMON_EVENT_INFO, GET_BUNDLE_INSTALLER, diff --git a/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h b/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h index dce7b43aec785d0c5d4d2f637111f076cf70b5ee..e7b572911db278d4503fdbc1bb3641f614e464df 100644 --- a/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h +++ b/services/abilitymgr/test/mock/libs/appexecfwk_core/include/bundlemgr/mock_bundle_manager.h @@ -36,6 +36,7 @@ const std::string COM_IX_HIRADIO = "com.ix.hiRadio"; const std::string COM_IX_HISERVICE = "com.ix.hiService"; const std::string COM_IX_MUSICSERVICE = "com.ix.musicService"; const std::string COM_IX_HIDATA = "com.ix.hiData"; +const std::string COM_IX_HIEXTENSION = "com.ix.hiExtension"; constexpr int32_t MAX_SYS_UID = 2899; constexpr int32_t ROOT_UID = 0; @@ -123,6 +124,16 @@ auto HiDataInfo = [](std::string bundleName, AbilityInfo &abilityInfo, ElementNa abilityInfo.process = "p6"; return true; }; + +auto HiExtensionInfo = [](std::string bundleName, AbilityInfo &abilityInfo, ElementName &elementTemp) { + abilityInfo.name = elementTemp.GetAbilityName(); + abilityInfo.bundleName = elementTemp.GetBundleName(); + abilityInfo.applicationInfo.bundleName = elementTemp.GetBundleName(); + abilityInfo.applicationName = "hiExtension"; + abilityInfo.applicationInfo.name = "hiExtension"; + abilityInfo.type = AbilityType::EXTENSION; + return true; +}; } // namespace class BundleMgrProxy : public IRemoteProxy { public: diff --git a/services/abilitymgr/test/mock/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp b/services/abilitymgr/test/mock/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp index 84145783d0b52bde7d77fcf58f352d5c85ec898d..45dedded486b3473c1e8d5698ce4cc0c4bcf60ce 100644 --- a/services/abilitymgr/test/mock/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp +++ b/services/abilitymgr/test/mock/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp @@ -164,5 +164,16 @@ void AppScheduler::StartupResidentProcess() { HILOG_INFO("Test AppScheduler::StartupResidentProcess()"); } + +int AppScheduler::GetProcessRunningInfos(std::vector &info) +{ + HILOG_INFO("Test AppScheduler::GetProcessRunningInfos()"); + return 0; +} + +void AppScheduler::GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info) +{ + HILOG_INFO("Test AppScheduler::GetRunningProcessInfoByToken()"); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/test/mock/libs/appexecfwk_core/src/bundlemgr/mock_bundle_manager.cpp b/services/abilitymgr/test/mock/libs/appexecfwk_core/src/bundlemgr/mock_bundle_manager.cpp index 989dfbfbef47e1d92fa2e55057dbf46b176c7d9f..2b08969a3bfbdf7f61da222f16c35b759ead9c23 100644 --- a/services/abilitymgr/test/mock/libs/appexecfwk_core/src/bundlemgr/mock_bundle_manager.cpp +++ b/services/abilitymgr/test/mock/libs/appexecfwk_core/src/bundlemgr/mock_bundle_manager.cpp @@ -88,6 +88,7 @@ BundleMgrService::BundleMgrService() abilityInfoMap_.emplace(COM_IX_HISERVICE, HiServiceInfo); abilityInfoMap_.emplace(COM_IX_MUSICSERVICE, MusicServiceInfo); abilityInfoMap_.emplace(COM_IX_HIDATA, HiDataInfo); + abilityInfoMap_.emplace(COM_IX_HIEXTENSION, HiExtensionInfo); GTEST_LOG_(INFO) << "BundleMgrService()"; } diff --git a/services/abilitymgr/test/unittest/phone/ability_connect_callback_proxy_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_connect_callback_proxy_test/BUILD.gn index 94aa03013e1aed0899e866a9d444402dd74c2fbe..37ad73e8f96b017e405fe47b1b8d6c35ae61da4e 100644 --- a/services/abilitymgr/test/unittest/phone/ability_connect_callback_proxy_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_connect_callback_proxy_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("ability_connect_callback_proxy_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/BUILD.gn index fd1cd1f9e76814dde76cc135e2eaa5965aadab6b..8fb042732d8319719c928f4963b93d12cccb4a53 100644 --- a/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/BUILD.gn @@ -52,6 +52,8 @@ ohos_unittest("ability_connect_callback_stub_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_connect_manage_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_connect_manage_test/BUILD.gn index ba350b68f5a7645e7b08c1cc8a085b9013bf541d..9c9b2b9cd09fc28ead50444b52c707375ea240e7 100644 --- a/services/abilitymgr/test/unittest/phone/ability_connect_manage_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_connect_manage_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("ability_connect_manage_test") { "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_dump_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_dump_test/BUILD.gn index 498cebb9e6f0861ae4e4eb12eaae95bbc0c03a61..de1f5a28126c3efc0afd741b329b6e3b61371ddb 100644 --- a/services/abilitymgr/test/unittest/phone/ability_dump_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_dump_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ability_dump_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_dump_test/ability_dump_test.cpp b/services/abilitymgr/test/unittest/phone/ability_dump_test/ability_dump_test.cpp index 9138ccb82b82783813ee3d8a61b11c8b857f61e2..d4ca810e656a95d3418b6ef265c6be667b501925 100644 --- a/services/abilitymgr/test/unittest/phone/ability_dump_test/ability_dump_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_dump_test/ability_dump_test.cpp @@ -118,9 +118,9 @@ void AbilityDumpTest::OnStartAms() if (g_abilityMs->state_ == ServiceRunningState::STATE_RUNNING) { return; } - + g_abilityMs->state_ = ServiceRunningState::STATE_RUNNING; - + g_abilityMs->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(g_abilityMs->eventLoop_); @@ -139,7 +139,7 @@ void AbilityDumpTest::OnStartAms() g_abilityMs->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(g_abilityMs->pendingWantManager_); - + int userId = g_abilityMs->GetUserId(); g_abilityMs->SetStackManager(userId, true); g_abilityMs->systemAppManager_ = std::make_shared(userId); @@ -189,7 +189,7 @@ void AbilityDumpTest::StartAbilityes() if (currentTopAbilityRecord) { currentTopAbilityRecord->SetAbilityState(AbilityState::ACTIVE); } - + startAbility6(); startAbility1(); startAbility2(); diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/BUILD.gn index c9544c35af733640f3e26751a660681b94403f79..095d037a8e57e7b47c71a12395ab70e36979372a 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_manager_proxy_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h index 4bbdfa5e31e0846ed1db806081b09fa7d0955d3c..ba9b246a54df36136b1e92f261d5a44935939d0b 100755 --- a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_stub_mock.h @@ -379,6 +379,9 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_service_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_manager_service_test/BUILD.gn index 4c94d19bef9daadb266d85ff173ae888a1c7c4fa..6d449bc22a2b6ae07ee62da4c54d58adf4d8b12b 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_service_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_manager_service_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("ability_manager_service_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp b/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp index 1bea8f98ddf65ec7042119143fa0edf6c6f55404..13a60978f665e84197a241f299c3f4919e042af0 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_manager_service_test/ability_manager_service_test.cpp @@ -120,9 +120,9 @@ void AbilityManagerServiceTest::OnStartAms() if (abilityMs_->state_ == ServiceRunningState::STATE_RUNNING) { return; } - + abilityMs_->state_ = ServiceRunningState::STATE_RUNNING; - + abilityMs_->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(abilityMs_->eventLoop_); @@ -730,7 +730,7 @@ HWTEST_F(AbilityManagerServiceTest, Interface_017, TestSize.Level1) wantLuncher.SetElement(elementLun); abilityMs_->StartAbility(wantLuncher); WaitUntilTaskFinished(); - + Want want; ElementName element("device", "com.ix.music", "MusicAbility"); want.SetElement(element); @@ -2013,7 +2013,7 @@ HWTEST_F(AbilityManagerServiceTest, handleloadtimeout_001, TestSize.Level1) AbilityRecordInfo barAbilityInfo; barAbility->GetAbilityRecordInfo(barAbilityInfo); auto dialogtoken = barAbility->GetToken(); - + OHOS::sptr scheduler = new AbilityScheduler(); EXPECT_EQ(abilityMs_->AttachAbilityThread(scheduler, dialogtoken), OHOS::ERR_OK); EXPECT_TRUE(barAbility->GetAbilityInfo().bundleName == AbilityConfig::SYSTEM_UI_BUNDLE_NAME); @@ -2254,12 +2254,12 @@ HWTEST_F(AbilityManagerServiceTest, handleloadtimeout_008, TestSize.Level1) auto abilityToken = ability->GetToken(); EXPECT_TRUE(ability->GetAbilityInfo().bundleName == COM_IX_HIWORLD); - + ElementName elementTv("device", "com.ix.hiTv", "TvAbility"); want.SetElement(elementTv); auto resultTv = StartAbility(want); EXPECT_EQ(OHOS::ERR_OK, resultTv); - + // helloAbility inactive stackManager->CompleteInactive(ability); @@ -2305,7 +2305,7 @@ HWTEST_F(AbilityManagerServiceTest, handleloadtimeout_009, TestSize.Level1) want.SetElement(elementTv); auto resultTv = StartAbility(want); EXPECT_EQ(OHOS::ERR_OK, resultTv); - + // helloAbility inactive stackManager->CompleteInactive(ability); @@ -2403,7 +2403,7 @@ HWTEST_F(AbilityManagerServiceTest, handleloadtimeout_011, TestSize.Level1) auto abilityTv = stackManagerTv->GetCurrentTopAbility(); abilityMs_->HandleLoadTimeOut(INT32_MAX); - + auto newStackManager = abilityMs_->GetStackManager(); auto newAbility = newStackManager->GetCurrentTopAbility(); EXPECT_TRUE(newAbility->GetAbilityInfo().bundleName == "com.ix.hiTv"); diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/BUILD.gn index 60c946931fbbdc25292ae7289e1256195c3f4914..ee4be35b2dfc227b79b1d6c6624c6da33d32cdc9 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_manager_stub_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h index 0075b557b5048753cb402b27dc740e2fe664555f..c41f2b3dee77d5aaada261e5b80f3c41d2a28c8e 100755 --- a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_impl_mock.h @@ -46,7 +46,7 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr &target, std::shared_ptr &want)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); - + MOCK_METHOD3(StartContinuation, int(const Want &want, const sptr &abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, const int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string &srcDeviceId, const std::string &dstDeviceId, @@ -54,6 +54,10 @@ public: MOCK_METHOD2(ContinueAbility, int(const std::string &deviceId, int32_t missionId)); MOCK_METHOD3(NotifyCompleteContinuation, void(const std::string &deviceId, int32_t sessionId, bool isSuccess)); + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + int InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { code_ = code; diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h b/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h index 2ed83816db6f8b2a5dcade0925a03d31ffc6c1f3..a9c0d71074a5ae26842436505ff9ed1752523b38 100755 --- a/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h +++ b/services/abilitymgr/test/unittest/phone/ability_manager_test/ability_manager_stub_mock.h @@ -98,6 +98,11 @@ public: MOCK_METHOD1(TerminateAbilityTest, void(int id)); MOCK_METHOD1(MoveMissionToEnd, int(int id)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + virtual int StartUser(int userId) override { return 0; diff --git a/services/abilitymgr/test/unittest/phone/ability_record_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_record_test/BUILD.gn index 247113d0853a0e8482c9c252bd41feeeda6391c6..32d1844caabd029326a7b7cd09c4dd623d728507 100644 --- a/services/abilitymgr/test/unittest/phone/ability_record_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_record_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("ability_record_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/BUILD.gn index 5de3fc977c2293da59dfa7b8b23f1be1a8ffcd65..33ee48a537411ef54cfdd98615399014e3182a4c 100644 --- a/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_scheduler_proxy_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/BUILD.gn index c2f31b6f33de0442fb5140716da1ecc111aec26f..da974991a02ac76f7946179ed2127fdb0679a96f 100644 --- a/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("ability_scheduler_stub_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_service_start_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_service_start_test/BUILD.gn index 2bf3808316fe0f34273cd78d1b4c8dce28384f21..6066274e1a4d845270bca37014b7741f14f61c08 100644 --- a/services/abilitymgr/test/unittest/phone/ability_service_start_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_service_start_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("ability_service_start_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/BUILD.gn index e070ffda7ab99d8a4e80cf2fb0751668fd155515..5ed561ec3609613f5a9ebaba0256ec98789a6c1f 100644 --- a/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ability_stack_manager_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp b/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp index 81a9e35663616d1f5e3061296b1c2095f5f60cee..4cf99861e8b47eb27cc5a62e77f68cc1c315082e 100644 --- a/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp @@ -79,7 +79,7 @@ void AbilityStackManagerTest::OnStartabilityMs() } abilityMs_->state_ = ServiceRunningState::STATE_RUNNING; - + abilityMs_->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(abilityMs_->eventLoop_); @@ -98,7 +98,7 @@ void AbilityStackManagerTest::OnStartabilityMs() abilityMs_->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(abilityMs_->pendingWantManager_); - + int userId = abilityMs_->GetUserId(); abilityMs_->SetStackManager(userId, true); abilityMs_->systemAppManager_ = std::make_shared(userId); @@ -1502,7 +1502,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_042, TestSize. stackManager_->UninstallApp("com.ix.hiMusic"); // process died stackManager_->OnAbilityDied(thirdTopAbility); - + auto topAbility = stackManager_->GetCurrentTopAbility(); EXPECT_TRUE(topAbility); EXPECT_EQ("MusicAbility", topAbility->GetAbilityInfo().name); @@ -2487,7 +2487,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_067, TestSize. MissionOption missionOption; missionOption.missionId = musicMissionRecord->GetMissionRecordId(); missionOption.winModeKey = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FLOATING; - + auto ref = stackManager_->MoveMissionToFloatingStack(missionOption); EXPECT_EQ(ref, ERR_NONE); @@ -3240,7 +3240,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_087, TestSize. auto ref = stackManager_->GenerateMissinOptionsOfSplitScreen(primary, secondary, options); EXPECT_EQ(ERR_INVALID_DATA, ref); } - + /* * Feature: AbilityStackManager * Function: GenerateMissinOptionsOfSplitScreen @@ -3353,12 +3353,12 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_091, TestSize. EXPECT_EQ(0, result); auto firstTopAbility = stackManager_->GetCurrentTopAbility(); firstTopAbility->SetAbilityState(OHOS::AAFwk::ACTIVE); - + result = stackManager_->StartAbility(musicAbilityRequest_); EXPECT_EQ(0, result); auto musicAbility = stackManager_->GetCurrentTopAbility(); musicAbility->SetAbilityState(OHOS::AAFwk::ACTIVE); - + // start split screen auto abilityStartSetting = AbilityStartSetting::GetEmptySetting(); // Set floating window identification @@ -3904,7 +3904,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0108, TestSize TerminatingAbility musicTerminateAbility; musicTerminateAbility.abilityRecord = musicAbilityRecord; - + TerminatingAbility musicSaTerminateAbility; musicSaTerminateAbility.abilityRecord = musicSaAbilityRecord; @@ -4077,7 +4077,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0112, TestSize TerminatingAbility musicTerminateAbility; musicTerminateAbility.abilityRecord = musicAbilityRecord; - + TerminatingAbility radioSaTerminateAbility; radioSaTerminateAbility.abilityRecord = radioAbilityRecord; @@ -4281,7 +4281,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0117, TestSize EXPECT_TRUE(abilityStartSetting); radioAbilityRequest_.startSetting = abilityStartSetting; - + result = stackManager_->StartAbility(radioTonAbilityRequest_); EXPECT_EQ(0, result); auto radioAbility = stackManager_->GetCurrentTopAbility(); @@ -4542,7 +4542,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0125, TestSize option.missionId = 2; option.winModeKey = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_PRIMARY; targetMissionRecord->SetMissionOption(option); - + stackManager_->MoveMissionAndAbility(currentAbility, targetAbility, targetMissionRecord); auto ability = targetMissionRecord->GetTopAbilityRecord(); @@ -4695,7 +4695,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0129, TestSize EXPECT_TRUE(ability); ability->SetMovingBackgroundFlag(true); - + stackManager_->CompleteActive(ability); EXPECT_EQ(ability->GetAbilityState(), AbilityState::ACTIVE); } @@ -4723,7 +4723,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0130, TestSize EXPECT_TRUE(ability); ability->SetMovingBackgroundFlag(true); - + stackManager_->CompleteInactive(ability); EXPECT_EQ(ability->GetAbilityState(), AbilityState::MOVING_BACKGROUND); @@ -4755,9 +4755,9 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_0131, TestSize ability->SetAbilityState(AbilityState::MOVING_BACKGROUND); ability->SetMovingBackgroundFlag(true); - + stackManager_->CompleteBackground(ability); - + EXPECT_EQ(ability->GetAbilityState(), AbilityState::BACKGROUND); } diff --git a/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/BUILD.gn index 320add42c3312439bbc91b31c4e13b380d177d90..1ff24e62116951f8b78a14459fc2963d60d2cc7c 100644 --- a/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("ability_token_proxy_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_token_stub_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_token_stub_test/BUILD.gn index 4d1e01ba33e329f00ca675ce1b7de7714bae6e19..6002fafcbad50b390dee356a5d36d1d9b105dc26 100644 --- a/services/abilitymgr/test/unittest/phone/ability_token_stub_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_token_stub_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("ability_token_stub_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_with_applications_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/ability_with_applications_test/BUILD.gn index 408f698d25981ae0ec66ee2ef0895a093917de4b..08eb166132cf83a05079a651e313afcd548a2b68 100644 --- a/services/abilitymgr/test/unittest/phone/ability_with_applications_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/ability_with_applications_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_with_applications_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/ability_with_applications_test/ability_with_applications_test.cpp b/services/abilitymgr/test/unittest/phone/ability_with_applications_test/ability_with_applications_test.cpp index 5c607239cebecb00b23c073997712ed5995dd10f..69deb03c469230b2f66d433c68c33f53f68c68b6 100644 --- a/services/abilitymgr/test/unittest/phone/ability_with_applications_test/ability_with_applications_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_with_applications_test/ability_with_applications_test.cpp @@ -89,7 +89,7 @@ void AbilityWithApplicationsTest::OnStartabilityAms() } abilityMs_->state_ = ServiceRunningState::STATE_RUNNING; - + abilityMs_->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(abilityMs_->eventLoop_); @@ -108,7 +108,7 @@ void AbilityWithApplicationsTest::OnStartabilityAms() abilityMs_->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(abilityMs_->pendingWantManager_); - + int userId = abilityMs_->GetUserId(); abilityMs_->SetStackManager(userId, true); abilityMs_->systemAppManager_ = std::make_shared(userId); diff --git a/services/abilitymgr/test/unittest/phone/abilityms_appms_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/abilityms_appms_test/BUILD.gn index 7bcd6966c88723297f90c90e235fc208904bd207..865d1eba59a12027b2fef9243876c439c3da80cc 100644 --- a/services/abilitymgr/test/unittest/phone/abilityms_appms_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/abilityms_appms_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("abilityms_appms_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp b/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp index c9174c773c7ae78305ae31eeef696c363361136a..575c01216761c917a3233bb9a5dcfb364857b51b 100644 --- a/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp +++ b/services/abilitymgr/test/unittest/phone/abilityms_appms_test/abilityms_appms_test.cpp @@ -98,7 +98,7 @@ void AbilityMsAppmsTest::OnStartabilityAms() } abilityMs_->state_ = ServiceRunningState::STATE_RUNNING; - + abilityMs_->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(abilityMs_->eventLoop_); @@ -117,7 +117,7 @@ void AbilityMsAppmsTest::OnStartabilityAms() abilityMs_->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(abilityMs_->pendingWantManager_); - + int userId = abilityMs_->GetUserId(); abilityMs_->SetStackManager(userId, true); abilityMs_->systemAppManager_ = std::make_shared(userId); diff --git a/services/abilitymgr/test/unittest/phone/app_scheduler_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/app_scheduler_test/BUILD.gn index f843d15dbe84ac40b9bf1a4dc8515f9df01df21f..793950db2896d2d596946e446ac1db60c73d662a 100644 --- a/services/abilitymgr/test/unittest/phone/app_scheduler_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/app_scheduler_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("app_scheduler_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp b/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp index 01ce62816282bbc9869c892f8315e66fb4ae8def..1dcc730a1d08da2f582af98aa30a05e3e95716f3 100644 --- a/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp +++ b/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp @@ -253,7 +253,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_008, TestSize.Level1) HWTEST_F(AppSchedulerTest, AppScheduler_oprator_009, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); - + std::string deviceName = "device"; std::string abilityName = "FirstAbility"; std::string appName = "FirstApp"; diff --git a/services/abilitymgr/test/unittest/phone/configuration_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/configuration_test/BUILD.gn index 29157e5b794881fbc078e754826a04ef2b4cee1e..e66c6ff89b21e542d1e95b2c64e27285142210c0 100644 --- a/services/abilitymgr/test/unittest/phone/configuration_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/configuration_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("configuration_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/connection_record_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/connection_record_test/BUILD.gn index 66529649fc93fa49587d5aa23566b9bdb7700bae..914f7657b697e08d1992c42a7f8036a26f7a8a3c 100644 --- a/services/abilitymgr/test/unittest/phone/connection_record_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/connection_record_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("connection_record_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/data_ability_manager_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/data_ability_manager_test/BUILD.gn index 10ae2540c82ab1e64a91b5fe345a112158aac010..f96cd272adab10f858b14b2bbeef3c4cd7d2ab6c 100644 --- a/services/abilitymgr/test/unittest/phone/data_ability_manager_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/data_ability_manager_test/BUILD.gn @@ -60,6 +60,7 @@ ohos_unittest("data_ability_manager_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/data_ability_record_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/data_ability_record_test/BUILD.gn index 70c3105f017f00f54bbc62310b997541b2b2dda5..04b09fa63cd05e22e56718737aee057de535ec88 100644 --- a/services/abilitymgr/test/unittest/phone/data_ability_record_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/data_ability_record_test/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("data_ability_record_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/info_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/info_test/BUILD.gn index 41dbdd2586e7466d75baf28b1ea9a61a7f00dec2..53605add2390d17b84682749fead8183597994d6 100644 --- a/services/abilitymgr/test/unittest/phone/info_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/info_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("info_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/kernal_system_app_manager_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/kernal_system_app_manager_test/BUILD.gn index 4e172d30e5fc55c08fefe3e56987747d50a778d0..445c61c5baca99828b54c3ba86e424c329e82daf 100644 --- a/services/abilitymgr/test/unittest/phone/kernal_system_app_manager_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/kernal_system_app_manager_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("kernal_system_app_mgr_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] external_deps = [ diff --git a/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/BUILD.gn index 8edba73096b0a9de29723792f1c408dae29a80b6..d97b57e27a65ffc359ea0bb66b04fa261fa54298 100644 --- a/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("lifecycle_deal_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/lifecycle_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/lifecycle_test/BUILD.gn index 2c7297675cbe1b6aa6e43183425911325935e6f7..9ea108ccee1ad15d41b144b9a0381ad0012827ba 100644 --- a/services/abilitymgr/test/unittest/phone/lifecycle_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/lifecycle_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("lifecycle_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp b/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp index 448828a40f04b1f6bc33501ab59fad5606688f42..faf28f22b83a48fb3f1372543bc16ebc8b156af6 100644 --- a/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp +++ b/services/abilitymgr/test/unittest/phone/lifecycle_test/lifecycle_test.cpp @@ -98,7 +98,7 @@ void LifecycleTest::OnStartabilityAms() } abilityMs_->state_ = ServiceRunningState::STATE_RUNNING; - + abilityMs_->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(abilityMs_->eventLoop_); @@ -117,7 +117,7 @@ void LifecycleTest::OnStartabilityAms() abilityMs_->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(abilityMs_->pendingWantManager_); - + int userId = abilityMs_->GetUserId(); abilityMs_->SetStackManager(userId, true); abilityMs_->systemAppManager_ = std::make_shared(userId); diff --git a/services/abilitymgr/test/unittest/phone/lock_screen_white_list_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/lock_screen_white_list_test/BUILD.gn index 80a2dc77c963742205df81b5207242022e76a898..d6337a6ea1cb4fb89d71c2a7a58bc263e833ad30 100644 --- a/services/abilitymgr/test/unittest/phone/lock_screen_white_list_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/lock_screen_white_list_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("lock_screen_white_list_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/mission_list_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/mission_list_test/BUILD.gn index 454dab4eda115436ca31ec73d052b9cd6623e169..40c526053c30a7644f128b3594bfe462de3e177a 100644 --- a/services/abilitymgr/test/unittest/phone/mission_list_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/mission_list_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("mission_list_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/mission_record_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/mission_record_test/BUILD.gn index 6c37b041dd437123b817bf91b1d30dc3fc4ba8fe..0306eb0ace38fd8467e4a0bf90749e29d8df4dde 100644 --- a/services/abilitymgr/test/unittest/phone/mission_record_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/mission_record_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("mission_record_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/mission_stack_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/mission_stack_test/BUILD.gn index 13a234b25d506a4681849cf70125d2a4ba62e709..4e6a9c5c093f64d31fd1037a5380d164ee4ff1fa 100644 --- a/services/abilitymgr/test/unittest/phone/mission_stack_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/mission_stack_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("mission_stack_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp b/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp index b9885ce96be3f50b546d62ee2767fe9508ae23e6..7723987fb75dca0a2116aa0679fc79206fe5a37e 100644 --- a/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp +++ b/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp @@ -468,7 +468,7 @@ HWTEST_F(MissionStackTest, MS_oprator_019, TestSize.Level1) auto missionRecordOne = std::make_shared("test_one"); auto missionRecordTwo = std::make_shared("test_two"); - + MissionOption option; option.winModeKey = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_PRIMARY; missionRecordOne->SetMissionOption(option); @@ -500,7 +500,7 @@ HWTEST_F(MissionStackTest, MS_oprator_020, TestSize.Level1) auto missionRecordOne = std::make_shared("test_one"); auto missionRecordTwo = std::make_shared("test_two"); - + EXPECT_EQ(0, (int)missionStack_->missions_.size()); missionStack_->AddMissionRecordToEnd(missionRecordOne); @@ -527,7 +527,7 @@ HWTEST_F(MissionStackTest, MS_oprator_021, TestSize.Level1) auto missionRecordOne = std::make_shared("test_one"); auto missionRecordTwo = std::make_shared("test_two"); - + MissionOption option; option.winModeKey = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_PRIMARY; missionRecordOne->SetMissionOption(option); diff --git a/services/abilitymgr/test/unittest/phone/mission_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/mission_test/BUILD.gn index 489cfdde2bd558f05b868dc095b882b43c7c4399..9ef8d14a1b63d738794f689fbd9adb474c01b869 100644 --- a/services/abilitymgr/test/unittest/phone/mission_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/mission_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("mission_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/pending_want_key_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/pending_want_key_test/BUILD.gn index 3191ad1751c6e9207128f55990f09282e86c91be..ef1b22976f356fd3a68421408588941d529287c6 100644 --- a/services/abilitymgr/test/unittest/phone/pending_want_key_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/pending_want_key_test/BUILD.gn @@ -45,6 +45,7 @@ ohos_unittest("pending_want_key_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/pending_want_manager_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/pending_want_manager_test/BUILD.gn index e29d3b5d95f38b98d3134029a4982c51cacb8756..770458137d58918d094fd6c4484661c573cda302 100644 --- a/services/abilitymgr/test/unittest/phone/pending_want_manager_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/pending_want_manager_test/BUILD.gn @@ -49,6 +49,7 @@ ohos_unittest("pending_want_manager_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/pending_want_record_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/pending_want_record_test/BUILD.gn index 114ee6fe3d62a5fe84522d8c39164f6da7ec178a..dc8e25a50ee0d43cead0b8171b9be4eed7b10396 100644 --- a/services/abilitymgr/test/unittest/phone/pending_want_record_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/pending_want_record_test/BUILD.gn @@ -49,6 +49,7 @@ ohos_unittest("pending_want_record_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/resume_mission_container_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/resume_mission_container_test/BUILD.gn index c4c685ffc5cf5e9fc9c4db6fd84d150639100a44..f5262af69239eb662e9c01dfb5a7753fc7616412 100644 --- a/services/abilitymgr/test/unittest/phone/resume_mission_container_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/resume_mission_container_test/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("resume_mission_container_test") { "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/screenshot_handler_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/screenshot_handler_test/BUILD.gn index c4c5034a2b0e45855ad54ae3880108780763270d..47273c185e73c2eb3a8c08a9ae8a9c348171a05a 100644 --- a/services/abilitymgr/test/unittest/phone/screenshot_handler_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/screenshot_handler_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ability_screenshot_handler_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/sender_info_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/sender_info_test/BUILD.gn index 0bfa842aa6701cab6c022295209ac60f31c61bc6..29e60f12338010a383ae774319e8df0232b5c25f 100644 --- a/services/abilitymgr/test/unittest/phone/sender_info_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/sender_info_test/BUILD.gn @@ -49,6 +49,7 @@ ohos_unittest("sender_info_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/terminate_ability_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/terminate_ability_test/BUILD.gn index 18b4afcebafb3629a8decd33bc058626cb2882bb..a25847b0f1d26b75ebb853155f0a8d74d3fad4ca 100644 --- a/services/abilitymgr/test/unittest/phone/terminate_ability_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/terminate_ability_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("terminate_ability_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/terminate_ability_test/terminate_ability_test.cpp b/services/abilitymgr/test/unittest/phone/terminate_ability_test/terminate_ability_test.cpp index cc10093f633bb9fa5d89855d433fe8ef71176839..40393466348fff30df8df7a3a60fcebe80f5e210 100644 --- a/services/abilitymgr/test/unittest/phone/terminate_ability_test/terminate_ability_test.cpp +++ b/services/abilitymgr/test/unittest/phone/terminate_ability_test/terminate_ability_test.cpp @@ -130,9 +130,9 @@ void TerminateAbilityTest::OnStartAms() if (g_aams->state_ == ServiceRunningState::STATE_RUNNING) { return; } - + g_aams->state_ = ServiceRunningState::STATE_RUNNING; - + g_aams->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(g_aams->eventLoop_); @@ -151,7 +151,7 @@ void TerminateAbilityTest::OnStartAms() g_aams->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(g_aams->pendingWantManager_); - + int userId = g_aams->GetUserId(); g_aams->SetStackManager(userId, true); g_aams->systemAppManager_ = std::make_shared(userId); @@ -224,7 +224,7 @@ bool TerminateAbilityTest::StartAbility( GTEST_LOG_(ERROR) << "new token is nullptr"; return false; } - + abilityScheduler = new AbilityScheduler(); if (g_aams->AttachAbilityThread(abilityScheduler, token) != 0) { GTEST_LOG_(ERROR) << "fail to AttachAbilityThread"; @@ -772,7 +772,7 @@ HWTEST_F(TerminateAbilityTest, AAFWK_g_aamsTerminateAbility_014, TestSize.Level1 std::shared_ptr testAbilityRecordB = stackManager->GetCurrentTopAbility(); EXPECT_EQ(g_aams->AttachAbilityThread(new AbilityScheduler(), tokenB), 0); - + testAbilityRecordA->SetAbilityState(OHOS::AAFwk::AbilityState::INACTIVE); testAbilityRecordB->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE); diff --git a/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/BUILD.gn index 86e08792cf6f3d0800c348781290a4c3e3dd4a3d..1ddb2ea80012699561227586d73c813739ce6f39 100644 --- a/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("want_receiver_proxy_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/BUILD.gn index 5cbc3bd8ff3973488c1b350b01806fe07164f605..b6fdcf500361972029fa8162684ccbaa0339d29b 100644 --- a/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("want_receiver_stub_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/want_sender_info_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/want_sender_info_test/BUILD.gn index 19c4dfb8ae604f2a02468bf86b961ad9eeb828ae..1cba48b84cf898c96c44500947eab5c2cd324623 100644 --- a/services/abilitymgr/test/unittest/phone/want_sender_info_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/want_sender_info_test/BUILD.gn @@ -49,6 +49,7 @@ ohos_unittest("want_sender_info_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/BUILD.gn index ea4c4fb58c388ef81791454f2d0d84e7a2a25333..5d37c08ac99af62dcc2ef4fda4d349caf98a05db 100644 --- a/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("want_sender_proxy_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/want_sender_stub_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/want_sender_stub_test/BUILD.gn index ad4e608abb33f1628bb2949b3b42b16561a28abf..7f63edf2eb614ffef26d930b96a1f9ad5c18eff9 100644 --- a/services/abilitymgr/test/unittest/phone/want_sender_stub_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/want_sender_stub_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("want_sender_stub_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/wants_info_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/wants_info_test/BUILD.gn index 8ce4376366cb4ba38847705192d5b63cd50de6ee..2a391855962c28337143679544b573b93c72ecc8 100644 --- a/services/abilitymgr/test/unittest/phone/wants_info_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/wants_info_test/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("wants_info_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/abilitymgr/test/unittest/phone/window_info_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/window_info_test/BUILD.gn index ce5cbf6dbfd12a1200d1c8b4e7ea173c7e9cf5c6..49dd4c0440218e50c28c8b2c08a13c67ec70fe86 100644 --- a/services/abilitymgr/test/unittest/phone/window_info_test/BUILD.gn +++ b/services/abilitymgr/test/unittest/phone/window_info_test/BUILD.gn @@ -42,6 +42,8 @@ ohos_unittest("window_info_test") { "//foundation/aafwk/standard/services/abilitymgr:abilityms", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", + "//utils/native/base:utils", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] diff --git a/services/test/mock/include/mock_ability_mgr_service.h b/services/test/mock/include/mock_ability_mgr_service.h index a95f9080f8163e01ddb6a3d5c06c176b90b8cb06..ada77c0675ef43c9b504f0c5458e8192190c1831 100755 --- a/services/test/mock/include/mock_ability_mgr_service.h +++ b/services/test/mock/include/mock_ability_mgr_service.h @@ -109,6 +109,10 @@ public: MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + virtual int StartUser(int userId) override { return 0; diff --git a/services/test/moduletest/ability_mgr_service_test/BUILD.gn b/services/test/moduletest/ability_mgr_service_test/BUILD.gn index da3fc8dad7424fba8cfd37536ccc8f7e13caed30..bb104a19bff9cb2bb5750e57cced2ff87d19b85b 100644 --- a/services/test/moduletest/ability_mgr_service_test/BUILD.gn +++ b/services/test/moduletest/ability_mgr_service_test/BUILD.gn @@ -98,6 +98,7 @@ ohos_moduletest("ability_mgr_module_test") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/test/moduletest/ability_record_test/BUILD.gn b/services/test/moduletest/ability_record_test/BUILD.gn index 613042090198d96bd970b40180d331938d82fefb..3c3a0c2ece4202a44ae27ca5cc55460220cdba26 100644 --- a/services/test/moduletest/ability_record_test/BUILD.gn +++ b/services/test/moduletest/ability_record_test/BUILD.gn @@ -100,6 +100,7 @@ ohos_moduletest("AbilityRecordModuleTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", + "//third_party/libpng:libpng", "//utils/native/base:utilsbase", ] diff --git a/services/test/moduletest/ability_record_test/ability_record_module_test.cpp b/services/test/moduletest/ability_record_test/ability_record_module_test.cpp index 46e23d75fc931f1dc2bd220cced03365c83e49fc..855992b51bdfb45bc2b43352047829a96004fba9 100644 --- a/services/test/moduletest/ability_record_test/ability_record_module_test.cpp +++ b/services/test/moduletest/ability_record_test/ability_record_module_test.cpp @@ -319,7 +319,7 @@ HWTEST_F(AbilityRecordModuleTest, AbilityScheduler_001, TestSize.Level3) for (int i = 0; i < COUNT; ++i) { EXPECT_CALL(*mockAbilityScheduerStub, ScheduleSaveAbilityState()).Times(1); - + // Activate auto mockActivateHandler = [&](const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo) { testResult = (lifeCycleStateInfo.state == AbilityLifeCycleState::ABILITY_STATE_ACTIVE); diff --git a/services/test/moduletest/ability_stack_test/BUILD.gn b/services/test/moduletest/ability_stack_test/BUILD.gn index 1ff05c1af5d08ed7f30ee190d9be7a24730271c3..5d60bb524ced318abafdb8fd54f2091fa47bc7ab 100644 --- a/services/test/moduletest/ability_stack_test/BUILD.gn +++ b/services/test/moduletest/ability_stack_test/BUILD.gn @@ -98,6 +98,7 @@ ohos_moduletest("ability_stack_module_test") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/test/moduletest/dump_module_test/BUILD.gn b/services/test/moduletest/dump_module_test/BUILD.gn index 264dc4050016263e4f81748793d46072deec4ed4..73b00910693e0cb25a3f60d29661d5911c71a8c4 100644 --- a/services/test/moduletest/dump_module_test/BUILD.gn +++ b/services/test/moduletest/dump_module_test/BUILD.gn @@ -57,6 +57,7 @@ ohos_moduletest("dump_module_test") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/test/moduletest/dump_module_test/dump_module_test.cpp b/services/test/moduletest/dump_module_test/dump_module_test.cpp index 894ad09e12fe09de28d2045b077f7a4272b2ea38..68943019cac041436adca66c4d22ecc655faad5f 100644 --- a/services/test/moduletest/dump_module_test/dump_module_test.cpp +++ b/services/test/moduletest/dump_module_test/dump_module_test.cpp @@ -118,9 +118,9 @@ void DumpModuleTest::OnStartAms() if (g_abilityMs->state_ == ServiceRunningState::STATE_RUNNING) { return; } - + g_abilityMs->state_ = ServiceRunningState::STATE_RUNNING; - + g_abilityMs->eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE); EXPECT_TRUE(g_abilityMs->eventLoop_); @@ -135,7 +135,7 @@ void DumpModuleTest::OnStartAms() g_abilityMs->pendingWantManager_ = std::make_shared(); EXPECT_TRUE(g_abilityMs->pendingWantManager_); - + int userId = g_abilityMs->GetUserId(); g_abilityMs->SetStackManager(userId, true); g_abilityMs->systemAppManager_ = std::make_shared(userId); diff --git a/services/test/moduletest/ipc_ability_connect_test/BUILD.gn b/services/test/moduletest/ipc_ability_connect_test/BUILD.gn index 4b226686fbd6413373f3a72119fb415a783291c1..b6fe45e85c17e738530d2f0be373310c0917daa4 100644 --- a/services/test/moduletest/ipc_ability_connect_test/BUILD.gn +++ b/services/test/moduletest/ipc_ability_connect_test/BUILD.gn @@ -34,6 +34,7 @@ ohos_moduletest("IpcAbilityConnectModuleTest") { "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", + "//third_party/libpng:libpng", "//utils/native/base:utilsbase", ] diff --git a/services/test/moduletest/ipc_ability_mgr_test/BUILD.gn b/services/test/moduletest/ipc_ability_mgr_test/BUILD.gn index a07b9f281d4f3eae1b2655c7d2129e32db9204f0..5852e222c0db97cd64018bc8cacc34029b1f4ebe 100644 --- a/services/test/moduletest/ipc_ability_mgr_test/BUILD.gn +++ b/services/test/moduletest/ipc_ability_mgr_test/BUILD.gn @@ -39,6 +39,7 @@ ohos_moduletest("IpcAbilityMgrServiceModuleTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/services/test/moduletest/ipc_ability_scheduler_test/BUILD.gn b/services/test/moduletest/ipc_ability_scheduler_test/BUILD.gn index 568dec71797392027c1271c4b85fe910d8b849a3..8da1c89d01e8bb44b69314005a6e808e2f47a081 100644 --- a/services/test/moduletest/ipc_ability_scheduler_test/BUILD.gn +++ b/services/test/moduletest/ipc_ability_scheduler_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_moduletest("IpcAbilitySchedulerModuleTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", + "//third_party/libpng:libpng", "//utils/native/base:utilsbase", ] diff --git a/services/test/moduletest/panding_want_manager_test/BUILD.gn b/services/test/moduletest/panding_want_manager_test/BUILD.gn index 36928d3e212e23b322af12170fc953e014337374..5c2d10f4bc9795d4ccc2088e1fb6a33faa3997f8 100644 --- a/services/test/moduletest/panding_want_manager_test/BUILD.gn +++ b/services/test/moduletest/panding_want_manager_test/BUILD.gn @@ -63,6 +63,7 @@ ohos_moduletest("PandingWantMgrTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", + "//third_party/libpng:libpng", "//utils/native/base:utils", ] diff --git a/test/resource/tools/ohos_test.xml b/test/resource/tools/ohos_test.xml index d94a2929fc9a28d2730d52594ccb0acd12dd326e..cf80c8cf2983f96784a448c15bd63f79d3c9fd28 100644 --- a/test/resource/tools/ohos_test.xml +++ b/test/resource/tools/ohos_test.xml @@ -16,20 +16,20 @@ - - - - - - \ No newline at end of file diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 73fe0ad0e5b38a59abbda26b9bf1d1340ef3d177..9f7ce482a959c5225c8731fef16be4d4da9bcd83 100755 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -133,6 +133,10 @@ public: MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string &)); + MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector &info)); + MOCK_METHOD1(GetProcessRunningInfos, int(std::vector &info)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); virtual int StartUser(int userId) override { diff --git a/tools/zip/include/zip_reader.h b/tools/zip/include/zip_reader.h index f2da18cad56c9369c80619c54b8c0c969e79bf69..540d052fcd6aa1dcef980d3ec2109ae7008791d2 100644 --- a/tools/zip/include/zip_reader.h +++ b/tools/zip/include/zip_reader.h @@ -56,7 +56,7 @@ public: using SuccessCallback = std::function; // A callback that is called when the operation fails. using FailureCallback = std::function; - + using ProgressCallback = std::function; // This class represents information of an entry (file or directory) in