diff --git a/frameworks/kits/ability/ability_runtime/include/ability_context.h b/frameworks/kits/ability/ability_runtime/include/ability_context.h index 45a54360f7113cddfa1ebd5aa4856946056bdfff..762a30c605fa5d66182fc19b3edcf244d9ac8c6f 100644 --- a/frameworks/kits/ability/ability_runtime/include/ability_context.h +++ b/frameworks/kits/ability/ability_runtime/include/ability_context.h @@ -64,9 +64,6 @@ public: virtual ErrCode StartAbilityForResult(const AAFwk::Want &Want, int requestCode, RuntimeTask &&task) = 0; - virtual ErrCode StartAbilityForResult(const AAFwk::Want &Want, const AAFwk::StartOptions &startOptions, - int requestCode, RuntimeTask &&task) = 0; - virtual ErrCode TerminateAbilityWithResult(const AAFwk::Want &want, int resultCode) = 0; virtual ErrCode RestoreWindowStage(void* contentStorage) = 0; diff --git a/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h b/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h index e1a8b273084c22c0c895a719e511d38e8ecf55e0..2d2515cdf2ca960aa24d835531dd5aeb03fa09b8 100644 --- a/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h +++ b/frameworks/kits/ability/ability_runtime/include/ability_context_impl.h @@ -43,8 +43,6 @@ public: ErrCode StartAbility(const AAFwk::Want &want, int requestCode) override; ErrCode StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions, int requestCode) override; ErrCode StartAbilityForResult(const AAFwk::Want &want, int requestCode, RuntimeTask &&task) override; - ErrCode StartAbilityForResult(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions, - int requestCode, RuntimeTask &&task) override; ErrCode TerminateAbilityWithResult(const AAFwk::Want &want, int resultCode) override; void OnAbilityResult(int requestCode, int resultCode, const AAFwk::Want &resultData) override; bool ConnectAbility(const AAFwk::Want &want, diff --git a/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp b/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp index 544403720a5de3b111027b8c117f0d65453c4e71..0ba7d64147a0081f8420d8f68c91ebc8af36a064 100644 --- a/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp +++ b/frameworks/kits/ability/ability_runtime/src/ability_context_impl.cpp @@ -86,15 +86,6 @@ ErrCode AbilityContextImpl::StartAbilityForResult(const AAFwk::Want &want, int r return err; } -ErrCode AbilityContextImpl::StartAbilityForResult(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions, - int requestCode, RuntimeTask &&task) -{ - HILOG_DEBUG("%{public}s. Start calling StartAbilityForResult.", __func__); - resultCallbacks_.insert(make_pair(requestCode, std::move(task))); - ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_, requestCode); - HILOG_INFO("%{public}s. End calling StartAbilityForResult. ret=%{public}d", __func__, err); - return err; -} ErrCode AbilityContextImpl::TerminateAbilityWithResult(const AAFwk::Want &want, int resultCode) { diff --git a/frameworks/kits/ability/native/BUILD.gn b/frameworks/kits/ability/native/BUILD.gn index 1f2bbb6e553414a077483c45bd86e9f1024c8c59..2db54135e167b09cb89ab8c4252287eca78cfc62 100644 --- a/frameworks/kits/ability/native/BUILD.gn +++ b/frameworks/kits/ability/native/BUILD.gn @@ -205,6 +205,7 @@ ohos_shared_library("abilitykit_native") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//foundation/multimodalinput/input/frameworks/proxy:libmmi-common", + "//foundation/windowmanager/wm:libwmutil", "//third_party/icu/icu4c:shared_icuuc", ] diff --git a/frameworks/kits/ability/native/include/ability.h b/frameworks/kits/ability/native/include/ability.h index 3cdcb7dfadd114945adc9b6eb8ab4f240d38ccca..24de34701d1ea0e7b2edfbf7c84782c6044fe83a 100755 --- a/frameworks/kits/ability/native/include/ability.h +++ b/frameworks/kits/ability/native/include/ability.h @@ -107,7 +107,7 @@ public: int TerminateAbility(Want &want); /** - * @brief By binding an action, you can set different action parameters in want to present different initial + * @brief By binding an action, you can set different action parameters in Intent to present different initial * pages. You must register actions in the profile file. * * @param action Indicates the action to bind. @@ -199,8 +199,8 @@ public: * Starts a new ability with specific start settings. * A Page or Service ability uses this method to start a specific ability. * The system locates the target ability from installed abilities based on - * the value of the want parameter and then starts it. You can specify the - * ability to start using the want parameter. + * the value of the intent parameter and then starts it. You can specify the + * ability to start using the intent parameter. * * @param want Indicates the ability to start. * @param abilityStartSetting Indicates the setting ability used to start. @@ -387,7 +387,7 @@ public: * * @param windowOption Indicates the window option defined by the user. */ - virtual void InitWindow(Rosen::WindowType winType, int32_t displayId, sptr option); + virtual void InitWindow(Rosen::WindowType winType); /** * @brief Get the window belong to the ability. @@ -850,10 +850,10 @@ public: /** * @brief A Page or Service ability uses this method to start a specific ability. The system locates the target - * ability from installed abilities based on the value of the want parameter and then starts it. You can specify - * the ability to start using the want parameter. + * ability from installed abilities based on the value of the intent parameter and then starts it. You can specify + * the ability to start using the intent parameter. * - * @param want Indicates the ability to start. + * @param intent Indicates the ability to start. * * @return errCode ERR_OK on success, others on failure. */ @@ -1492,10 +1492,10 @@ private: // Keep consistent with DMS defines. Used to callback to DMS. static const std::string DMS_SESSION_ID; - // The originating deviceId passed by DMS using want param. + // The originating deviceId passed by DMS using intent param. static const std::string DMS_ORIGIN_DEVICE_ID; - // If session id cannot get from want, assign it as default. + // If session id cannot get from intent, assign it as default. static const int DEFAULT_DMS_SESSION_ID; std::vector lostedByReconnectTempForms_; diff --git a/frameworks/kits/ability/native/include/ability_window.h b/frameworks/kits/ability/native/include/ability_window.h index 69b5005901dfde25e5486ec41c169991c16cc28b..c69f8abda961bf665d39f1a1b06188b551fc977d 100644 --- a/frameworks/kits/ability/native/include/ability_window.h +++ b/frameworks/kits/ability/native/include/ability_window.h @@ -51,7 +51,7 @@ public: */ bool InitWindow(Rosen::WindowType winType, std::shared_ptr &abilityContext, - sptr &listener, int32_t displayId, sptr option); + sptr &listener); /** * @brief Called when this ability is started. diff --git a/frameworks/kits/ability/native/src/ability.cpp b/frameworks/kits/ability/native/src/ability.cpp index 88337ec48340121277eafc3165d06792297ee5c9..bf319e8e9b55617470c20763c89c6a037948d240 100755 --- a/frameworks/kits/ability/native/src/ability.cpp +++ b/frameworks/kits/ability/native/src/ability.cpp @@ -194,16 +194,11 @@ void Ability::OnStart(const Want &want) winType = Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW; } - int defualtDisplayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID; - int displayId = want.GetIntParam(StartOptions::STRING_DISPLAY_ID, defualtDisplayId); - APP_LOGI("Ability::OnStart bundleName:%{public}s, abilityName:%{public}s, config.type:%{public}d, " - "displayId:%{public}d", + APP_LOGI("Ability::OnStart bundleName:%{public}s abilityName:%{public}s: set config.type = %{public}d", abilityInfo_->bundleName.c_str(), abilityInfo_->name.c_str(), - winType, - displayId); - auto option = GetWindowOption(want); - InitWindow(winType, displayId, option); + winType); + InitWindow(winType); if (abilityWindow_ != nullptr) { APP_LOGI("%{public}s begin abilityWindow_->OnPostAbilityStart.", __func__); @@ -677,7 +672,7 @@ void Ability::SetUIContent(int layoutRes, std::shared_ptr &context, int * * @param windowOption Indicates the window option defined by the user. */ -void Ability::InitWindow(Rosen::WindowType winType, int32_t displayId, sptr option) +void Ability::InitWindow(Rosen::WindowType winType) { if (abilityWindow_ == nullptr) { APP_LOGE("Ability::InitWindow abilityWindow_ is nullptr"); @@ -686,11 +681,11 @@ void Ability::InitWindow(Rosen::WindowType winType, int32_t displayId, sptrInitWindow.", __func__); if (useNewMission) { - abilityWindow_->InitWindow(winType, abilityContext_, sceneListener_, displayId, option); + abilityWindow_->InitWindow(winType, abilityContext_, sceneListener_); } else { std::shared_ptr context = nullptr; sptr listener = nullptr; - abilityWindow_->InitWindow(winType, context, listener, displayId, option); + abilityWindow_->InitWindow(winType, context, listener); } APP_LOGI("%{public}s end abilityWindow_->InitWindow.", __func__); } @@ -2606,7 +2601,7 @@ bool Ability::LifecycleUpdate(std::vector formIds, int32_t updateType) * * This method must be called when the application has detected that a system setting item (such as the language, * resolution, or screen orientation) being listened for has changed. Upon receiving the update request, the form - * supplier automatically updates the form data (if there is any update) through the form framework, with the update + * provider automatically updates the form data (if there is any update) through the form framework, with the update * process being unperceivable by the application. * * @param formId Indicates the ID of the form to update. @@ -3247,7 +3242,7 @@ sptr Ability::GetWindowOption(const Want &want) APP_LOGE("Ability::GetWindowOption option is null."); return nullptr; } - auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, + auto windowMode = want.GetIntParam(StartOptions::STRING_WINDOW_MODE, AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED); APP_LOGI("Ability::GetWindowOption window mode is %{public}d.", windowMode); option->SetWindowMode(static_cast(windowMode)); 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 d4f1113f74b42daa1e059a1e76650ef9dbc7325d..4c9134f4741c2262f787f3a91b56d3e067b21500 100755 --- a/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_ability.cpp @@ -319,7 +319,7 @@ void JsAbility::DoOnForeground(const Want& want) } } auto option = GetWindowOption(want); - Rosen::WMError ret = scene_->Init(displayId, abilityContext_, sceneListener_, option); + Rosen::WMError ret = scene_->Init(displayId, abilityContext_, sceneListener_); if (ret != Rosen::WMError::WM_OK) { HILOG_ERROR("%{public}s error. failed to init window scene!", __func__); return; diff --git a/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp b/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp index dde6a512da66174a0266d0575f7c5076458e5f6c..52a8a8bc64ec7b0a5d1600b84796e6ef79023841 100644 --- a/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp +++ b/frameworks/kits/ability/native/src/ability_runtime/js_ability_context.cpp @@ -152,16 +152,8 @@ NativeValue* JsAbilityContext::OnStartAbilityForResult(NativeEngine& engine, Nat HILOG_ERROR("%s Failed to parse want!", __func__); return engine.CreateUndefined(); } - decltype(info.argc) unwrapArgc = 1; - AAFwk::StartOptions startOptions; - if (info.argc > ARGC_ONE && info.argv[1]->TypeOf() == NATIVE_OBJECT) { - HILOG_INFO("OnStartAbilityForResult start options is used."); - AppExecFwk::UnwrapStartOptions(reinterpret_cast(&engine), - reinterpret_cast(info.argv[1]), startOptions); - unwrapArgc++; - } - NativeValue* lastParam = info.argc == unwrapArgc ? nullptr : info.argv[unwrapArgc]; + NativeValue* lastParam = info.argc == 1 ? nullptr : info.argv[1]; NativeValue* result = nullptr; std::unique_ptr uasyncTask = CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, nullptr, &result); @@ -183,8 +175,7 @@ NativeValue* JsAbilityContext::OnStartAbilityForResult(NativeEngine& engine, Nat asyncTask->Reject(engine, CreateJsError(engine, 1, "context is released!")); } else { curRequestCode_ = (curRequestCode_ == INT_MAX) ? 0 : (curRequestCode_ + 1); - (unwrapArgc == 1) ? context->StartAbilityForResult(want, curRequestCode_, std::move(task)) : - context->StartAbilityForResult(want, startOptions, curRequestCode_, std::move(task)); + context->StartAbilityForResult(want, curRequestCode_, std::move(task)); } HILOG_INFO("OnStartAbilityForResult is called end"); return result; diff --git a/frameworks/kits/ability/native/src/ability_window.cpp b/frameworks/kits/ability/native/src/ability_window.cpp index c595e1b722747ebdb523f1bc04c3970f7198bdb4..e3a7174ffbede9dd4e0b2067838fc771887b5a4a 100644 --- a/frameworks/kits/ability/native/src/ability_window.cpp +++ b/frameworks/kits/ability/native/src/ability_window.cpp @@ -50,10 +50,10 @@ void AbilityWindow::Init(std::shared_ptr& handler, std::shared_p */ bool AbilityWindow::InitWindow(Rosen::WindowType winType, std::shared_ptr &abilityContext, - sptr &listener, int32_t displayId, sptr option) + sptr &listener) { APP_LOGI("%{public}s begin.", __func__); - auto ret = windowScene_->Init(displayId, abilityContext, listener, option); + auto ret = windowScene_->Init(Rosen::WindowScene::DEFAULT_DISPLAY_ID, abilityContext, listener); if (ret != OHOS::Rosen::WMError::WM_OK) { APP_LOGE("%{public}s error. failed to init window scene!", __func__); return false; 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..336769c7e2e42c9cc95142b4616fd8458329e50c 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,6 +135,10 @@ 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; @@ -228,17 +232,6 @@ public: return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - enum RequestCode { E_STATE_INITIAL = 0, E_STATE_INACTIVE, diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp index fee16ccbf447f803c870d81d28b547401f3743eb..ffe84090a3ac8739e5fa5f45d0171bdd6fa8a488 100644 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp @@ -66,8 +66,6 @@ const std::string Want::OCT_SEMICOLON("073"); // ';' const std::string Want::MIME_TYPE("mime-type"); const std::string Want::WANT_HEADER("#Intent;"); -const std::string Want::PARAM_RESV_WINDOW_MODE("ohos.aafwk.param.windowMode"); - /** * @description:Default construcotr of Want class, which is used to initialzie flags and URI. * @param None 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..3ff6a70c202f1b119bdd5a4c76ebd9f4ec41d4a6 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; @@ -195,17 +199,6 @@ public: return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - AbilityLifeCycleState curstate_ = AbilityLifeCycleState::ABILITY_STATE_INITIAL; sptr abilityScheduler_; // kit interface used to schedule ability life Want want_; 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..3198dbc1f02b0aa64603b4a7536969df21e64baa 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; @@ -211,17 +215,6 @@ public: return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - sptr abilityScheduler_ = nullptr; // kit interface used to schedule ability life Want want_; bool startAbility = false; diff --git a/interfaces/innerkits/ability_manager/BUILD.gn b/interfaces/innerkits/ability_manager/BUILD.gn index ea024b0226e2693dbc1e6546fe13f0ccf83e0602..e6600ff63a044076518ffc980bf4793796c0a27b 100644 --- a/interfaces/innerkits/ability_manager/BUILD.gn +++ b/interfaces/innerkits/ability_manager/BUILD.gn @@ -63,6 +63,8 @@ ohos_shared_library("ability_manager") { "${services_path}/abilitymgr/src/mission_record_info.cpp", "${services_path}/abilitymgr/src/mission_snapshot.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/remote_mission_listener_proxy.cpp", "${services_path}/abilitymgr/src/remote_mission_listener_stub.cpp", "${services_path}/abilitymgr/src/sender_info.cpp", diff --git a/interfaces/innerkits/ability_manager/ability_manager_headers.gni b/interfaces/innerkits/ability_manager/ability_manager_headers.gni index 5913ebcafca8dcc11af8ee84109cdef13e7e2383..e5021289e2faff48427ccd43f4fca457cd37ca5e 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", @@ -39,4 +41,4 @@ ability_manager_headers = { "shared_memory.h", ] header_base = "interfaces/innerkits/ability_manager/include" -} +} \ No newline at end of file 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..9da64bb7daf7fc0fb0a11eaa8f50a398fc938fb2 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,9 +45,8 @@ #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 { @@ -99,8 +100,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 +512,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 +531,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 +548,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,36 +561,19 @@ 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. - * - * @param abilityController, The ability controller. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) = 0; - - /** - * Is user a stability test. - * - * @return Returns true if user is a stability test. - */ - virtual bool IsUserAStabilityTest() = 0; + virtual int UnRegisterMissionListener( + const std::string &deviceId, const sptr &listener) = 0; /** * @brief Register the snapshot handler @@ -706,7 +698,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 +710,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) @@ -742,12 +734,6 @@ public: // ipc id for move mission to front (50) STOP_USER, - // ipc id for set ability controller (51) - SET_ABILITY_CONTROLLER, - - // ipc id for get stability test flag (52) - IS_USER_A_STABILITY_TEST, - // ipc id 1001-2000 for DMS // ipc id for starting ability (1001) START_ABILITY = 1001, @@ -796,6 +782,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, 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/extension_running_info.h b/interfaces/innerkits/ability_manager/include/extension_running_info.h new file mode 100644 index 0000000000000000000000000000000000000000..56a3429d66192ad9c3d878d29819a2a3bfa34cb7 --- /dev/null +++ b/interfaces/innerkits/ability_manager/include/extension_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_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; + // ExtensionType type; + + 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/ability_manager/include/start_options.h b/interfaces/innerkits/ability_manager/include/start_options.h index 82fe7cd47f70d11565949bff267bab297c8fa8a7..4c5ebdbbffd9358e5a5bbf2c36adb25bea0b2b3d 100644 --- a/interfaces/innerkits/ability_manager/include/start_options.h +++ b/interfaces/innerkits/ability_manager/include/start_options.h @@ -20,12 +20,12 @@ #include "ability_window_configuration.h" #include "parcel.h" + namespace OHOS { namespace AAFwk { class StartOptions : public Parcelable { public: - static const std::string STRING_DISPLAY_ID; - const int32_t DEFAULT_DISPLAY_ID {0}; + static const std::string STRING_WINDOW_MODE; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; @@ -33,12 +33,8 @@ public: void SetWindowMode(int32_t windowMode); int32_t GetWindowMode() const; - - void SetDisplayID(int32_t displayId); - int32_t GetDisplayID() const; private: int32_t windowMode_ = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED; - int32_t displayId_ = DEFAULT_DISPLAY_ID; }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/innerkits/want/include/ohos/aafwk/content/want.h b/interfaces/innerkits/want/include/ohos/aafwk/content/want.h index 315916ac39c3f7f0afa07ef12c0573107b5cd7e4..0127fedd27838ad0535f84011dfd7888aa17f401 100644 --- a/interfaces/innerkits/want/include/ohos/aafwk/content/want.h +++ b/interfaces/innerkits/want/include/ohos/aafwk/content/want.h @@ -787,9 +787,6 @@ public: static constexpr int HEX_STRING_BUF_LEN = 36; static constexpr int HEX_STRING_LEN = 10; - // reserved param definition - static const std::string PARAM_RESV_WINDOW_MODE; - private: WantParams parameters_; Operation operation_; diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 4f3a620bf6988d642b4d95b02e7c34c9b9763114..469b176f4084f7cfeaff58baf9d8655f3fb88e63 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", @@ -26,8 +27,8 @@ group("napi_packages") { "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/form_extension:formextension_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/form_extension_context:formextensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:distributedmissionmanager", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:missionmanager_napi", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:missionregistration_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/particleAbility:particleability", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/service_extension_context:serviceextensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/serviceextension:serviceextension_napi", diff --git a/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp b/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp index 63dbcc6530773c55e7492e2927dc53285cae191c..0a458fc94ae189594fc93e0b686999235506afac 100644 --- a/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp +++ b/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp @@ -46,7 +46,6 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("queryRecentAbilityMissionInfos", NAPI_QueryRecentAbilityMissionInfos), DECLARE_NAPI_FUNCTION("getPreviousAbilityMissionInfos", NAPI_GetPreviousAbilityMissionInfos), DECLARE_NAPI_FUNCTION("removeMission", NAPI_RemoveMission), - DECLARE_NAPI_FUNCTION("removeRecentTask", NAPI_RemoveMission), DECLARE_NAPI_FUNCTION("removeMissions", NAPI_RemoveMissions), DECLARE_NAPI_FUNCTION("deleteMissions", NAPI_RemoveMissions), DECLARE_NAPI_FUNCTION("clearMissions", NAPI_ClearMissions), 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/inner/napi_common/napi_common_ability.cpp b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp index 5e5fb1cd7a55fa7b1579b66a04248d6e56227417..44db7fee4cfaabb58ac621830c41d97fca571196 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp +++ b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp @@ -2322,19 +2322,14 @@ void StartAbilityExecuteCB(napi_env env, void *data) return; } - ErrCode ret = ERR_OK; if (asyncCallbackInfo->param.setting == nullptr) { HILOG_INFO("%{public}s param.setting == nullptr call StartAbility.", __func__); - ret = asyncCallbackInfo->ability->StartAbility(asyncCallbackInfo->param.want); + asyncCallbackInfo->ability->StartAbility(asyncCallbackInfo->param.want); } else { HILOG_INFO("%{public}s param.setting != nullptr call StartAbility.", __func__); - ret = asyncCallbackInfo->ability->StartAbility(asyncCallbackInfo->param.want, - *(asyncCallbackInfo->param.setting)); + asyncCallbackInfo->ability->StartAbility(asyncCallbackInfo->param.want, *(asyncCallbackInfo->param.setting)); } - if (ret != ERR_OK) { - asyncCallbackInfo->errCode = ret; - } - HILOG_INFO("%{public}s end. ret:%{public}d", __func__, ret); + HILOG_INFO("%{public}s end.", __func__); } void StartAbilityCallbackCompletedCB(napi_env env, napi_status status, void *data) diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_start_options.cpp b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_start_options.cpp index 1289113e26f29d9fb2fa90beab26a6ce357f8b5b..f2961d49680fcb3cf4fe404b6d9d44758c9750d5 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_start_options.cpp +++ b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_start_options.cpp @@ -37,12 +37,6 @@ bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &sta startOptions.SetWindowMode(windowMode); } - int32_t displayId = 0; - if (UnwrapInt32ByPropertyName(env, param, "displayId", displayId)) { - HILOG_INFO("get display id ok displayId %{public}d", displayId); - startOptions.SetDisplayID(displayId); - } - return true; } EXTERN_C_END diff --git a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp index 9dff21cbd37d74ba198927c30e7e09cfda5094cb..5829d942c022f8cd1afa881cfe350ee6132e8470 100644 --- a/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp +++ b/interfaces/kits/napi/aafwk/inner/napi_common/napi_common_want.cpp @@ -708,10 +708,6 @@ bool UnwrapWantParams(napi_env env, napi_value param, AAFwk::WantParams &wantPar NAPI_CALL_BASE(env, napi_get_element(env, jsProNameList, index, &jsProName), false); std::string strProName = UnwrapStringFromJS(env, jsProName); - /* skip reserved param */ - if (strProName == Want::PARAM_RESV_WINDOW_MODE) { - continue; - } HILOG_INFO("%{public}s called. Property name=%{public}s.", __func__, strProName.c_str()); NAPI_CALL_BASE(env, napi_get_named_property(env, param, strProName.c_str(), &jsProValue), false); NAPI_CALL_BASE(env, napi_typeof(env, jsProValue, &jsValueType), false); diff --git a/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn b/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn index 7b26afe1bcb503dfff9dc905c98a0c4f3f15d733..b4e4c472918afbeac8fe7f84308c7f4354335fd8 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn +++ b/interfaces/kits/napi/aafwk/mission_manager/BUILD.gn @@ -25,27 +25,36 @@ 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/interfaces/innerkits/base:base", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", "//foundation/ace/napi:ace_napi", + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", "//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", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", "//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", "multimedia_image_standard:image", ] @@ -55,7 +64,7 @@ ohos_shared_library("missionmanager_napi") { part_name = "aafwk_standard" } -ohos_shared_library("distributedmissionmanager") { +ohos_shared_library("missionregistration_napi") { include_dirs = [ "//third_party/libuv/include", "//third_party/node/src", 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..8da52d39ad14f2fa9fa901c83bf3b61b83a123f9 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp +++ b/interfaces/kits/napi/aafwk/mission_manager/mission_manager.cpp @@ -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/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp b/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp index a4f22de58646c13089ace7fd5404e757efb2ddf6..c4e1e70c117635e61a7600a3b3a2448d8b3da843 100644 --- a/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp +++ b/interfaces/kits/napi/aafwk/mission_manager/napi_mission_registration.cpp @@ -1395,7 +1395,7 @@ static napi_module missionModule = { .nm_flags = 0, .nm_filename = nullptr, .nm_register_func = DistributedMissionManagerExport, - .nm_modname = "distributedMissionManager", + .nm_modname = "missionRegistration", .nm_priv = ((void*)0), .reserved = {0} }; 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..fc8bf28c657b0f22bc0bd58997715b86739ff10c 100755 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -525,34 +525,24 @@ 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. - * - * @param abilityController, The ability controller. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override; - - /** - * Is user a stability test. - * - * @return Returns true if user is a stability test. - */ - virtual bool IsUserAStabilityTest() override; virtual int RegisterSnapshotHandler(const sptr& handler) override; 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..17e208cdb4c3358028ba06837ee07a12eb9656be 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -46,7 +46,6 @@ namespace OHOS { namespace AAFwk { enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; -using OHOS::AppExecFwk::IAbilityController; class PendingWantManager; /** @@ -679,6 +678,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; /** @@ -715,25 +718,6 @@ public: virtual int32_t GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot) override; - /** - * Set ability controller. - * - * @param abilityController, The ability controller. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int SetAbilityController(const sptr &abilityController, bool imAStabilityTest) override; - - /** - * Is user a stability test. - * - * @return Returns true if user is a stability test. - */ - virtual bool IsUserAStabilityTest() override; - - bool IsAbilityControllerStarting(const Want &want, const std::string &bundleName); - - bool IsAbilityControllerResuming(const std::string &bundleName); - // MSG 0 - 20 represents timeout message static constexpr uint32_t LOAD_TIMEOUT_MSG = 0; static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1; @@ -873,8 +857,6 @@ private: std::vector &missionInfos); int GetRemoteMissionInfo(const std::string& deviceId, int32_t missionId, MissionInfo &missionInfo); - int32_t GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, - MissionSnapshot& missionSnapshot); void DumpInner(const std::string &args, std::vector &info); void DumpStackListInner(const std::string &args, std::vector &info); @@ -935,9 +917,6 @@ private: std::shared_ptr kernalAbilityManager_; sptr snapshotHandler_; std::shared_ptr userController_; - sptr abilityController_ = nullptr; - bool controllerIsAStabilityTest_ = false; - std::recursive_mutex globalLock_; }; } // namespace AAFwk diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 1f377e1bfb476c1e452dec1e98e33b8645781dfa..79a17e722cb34ae91023f343c516700d7334032e 100755 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -125,15 +125,15 @@ 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); int RegisterSnapshotHandlerInner(MessageParcel &data, MessageParcel &reply); int GetMissionSnapshotInfoInner(MessageParcel &data, MessageParcel &reply); - int SetAbilityControllerInner(MessageParcel &data, MessageParcel &reply); - int IsUserAStabilityTestInner(MessageParcel &data, MessageParcel &reply); - using RequestFuncType = int (AbilityManagerStub::*)(MessageParcel &data, MessageParcel &reply); std::map requestFuncMap_; }; 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_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..25d5b2433f3a6a6a25c7d19cf2451e7b286e3c79 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -20,6 +20,7 @@ #include #include +#include "ability_running_info.h" #include "mission_list.h" #include "mission_listener_controller.h" #include "mission_info.h" @@ -249,6 +250,8 @@ public: * @param info dump result. */ void DumpMissionInfos(std::vector &info); + + 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/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 43665d4d33a0ee943c5f11af58dad7f18eebc73c..243804717bdec2660c360a98a6df9eb19f4a1068 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(extensionInfo.token, 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(runningInfo.token, 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..cefb2d4583874a55db03e44c478b7e873823e27e 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(); @@ -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"); @@ -2085,50 +2159,5 @@ int AbilityManagerProxy::RegisterSnapshotHandler(const sptr& h } return reply.ReadInt32(); } - -int AbilityManagerProxy::SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) -{ - if (!abilityController) { - HILOG_ERROR("abilityController nullptr"); - return ERR_INVALID_VALUE; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - return INNER_ERR; - } - if (!data.WriteRemoteObject(abilityController->AsObject())) { - HILOG_ERROR("abilityController write failed."); - return ERR_INVALID_VALUE; - } - if (!data.WriteBool(imAStabilityTest)) { - HILOG_ERROR("imAStabilityTest write failed."); - return ERR_INVALID_VALUE; - } - auto error = Remote()->SendRequest(IAbilityManager::SET_ABILITY_CONTROLLER, data, reply, option); - if (error != NO_ERROR) { - HILOG_ERROR("Send request error: %{public}d", error); - return error; - } - return reply.ReadInt32(); -} - -bool AbilityManagerProxy::IsUserAStabilityTest() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - return false; - } - auto error = Remote()->SendRequest(IAbilityManager::IS_USER_A_STABILITY_TEST, data, reply, option); - if (error != NO_ERROR) { - HILOG_ERROR("Send request error: %{public}d", error); - return false; - } - 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..c947f002aab590313d636dad3e849bd2837f47c5 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -231,25 +231,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) { @@ -264,10 +266,6 @@ int AbilityManagerService::StartAbility( return connectManager_->StartAbility(abilityRequest); } - if (!IsAbilityControllerStarting(want, abilityInfo.bundleName)) { - return ERR_WOULD_BLOCK; - } - if (useNewMission_) { if (IsSystemUiApp(abilityRequest.abilityInfo)) { return kernalAbilityManager_->StartAbility(abilityRequest); @@ -325,15 +323,11 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett HILOG_ERROR("Only support for page type ability."); return ERR_INVALID_VALUE; } - - if (!IsAbilityControllerStarting(want, abilityInfo.bundleName)) { - return ERR_WOULD_BLOCK; - } - if (useNewMission_) { if (IsSystemUiApp(abilityRequest.abilityInfo)) { return kernalAbilityManager_->StartAbility(abilityRequest); } + return currentMissionListManager_->StartAbility(abilityRequest); } else { if (IsSystemUiApp(abilityRequest.abilityInfo)) { @@ -382,9 +376,6 @@ int AbilityManagerService::StartAbility(const Want &want, const StartOptions &st } } - if (!IsAbilityControllerStarting(want, abilityInfo.bundleName)) { - return ERR_WOULD_BLOCK; - } if (IsSystemUiApp(abilityRequest.abilityInfo)) { if (useNewMission_) { return kernalAbilityManager_->StartAbility(abilityRequest); @@ -393,8 +384,8 @@ int AbilityManagerService::StartAbility(const Want &want, const StartOptions &st } } - abilityRequest.want.SetParam(StartOptions::STRING_DISPLAY_ID, startOptions.GetDisplayID()); - abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_MODE, startOptions.GetWindowMode()); + abilityRequest.want.SetParam(StartOptions::STRING_WINDOW_MODE, startOptions.GetWindowMode()); + if (useNewMission_) { return currentMissionListManager_->StartAbility(abilityRequest); } else { @@ -442,10 +433,6 @@ int AbilityManagerService::TerminateAbility(const sptr &token, in RequestPermission(resultWant); } - if (!IsAbilityControllerResuming(abilityRecord->GetAbilityInfo().bundleName)) { - return ERR_WOULD_BLOCK; - } - if (useNewMission_) { return currentMissionListManager_->TerminateAbility(abilityRecord, resultCode, resultWant); } else { @@ -584,17 +571,11 @@ int AbilityManagerService::TerminateAbilityByCaller(const sptr &c case AppExecFwk::AbilityType::EXTENSION: { auto result = connectManager_->TerminateAbility(abilityRecord, requestCode); if (result == NO_FOUND_ABILITY_BY_CALLER) { - if (!IsAbilityControllerResuming(abilityRecord->GetAbilityInfo().bundleName)) { - return ERR_WOULD_BLOCK; - } return currentStackManager_->TerminateAbility(abilityRecord, requestCode); } return result; } case AppExecFwk::AbilityType::PAGE: { - if (!IsAbilityControllerResuming(abilityRecord->GetAbilityInfo().bundleName)) { - return ERR_WOULD_BLOCK; - } auto result = currentStackManager_->TerminateAbility(abilityRecord, requestCode); if (result == NO_FOUND_ABILITY_BY_CALLER) { return connectManager_->TerminateAbility(abilityRecord, requestCode); @@ -627,10 +608,6 @@ int AbilityManagerService::MinimizeAbility(const sptr &token) return ERR_INVALID_VALUE; } - if (!IsAbilityControllerResuming(abilityRecord->GetAbilityInfo().bundleName)) { - return ERR_WOULD_BLOCK; - } - if (useNewMission_) { return currentMissionListManager_->MinimizeAbility(token); } else { @@ -2590,7 +2567,7 @@ void AbilityManagerService::StartSystemApplication() HILOG_INFO("start mms"); StartingMmsAbility(); } - + // Location may change DelayedSingleton::GetInstance()->StartupResidentProcess(); } @@ -2799,6 +2776,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__); @@ -2818,12 +2848,6 @@ int AbilityManagerService::RegisterSnapshotHandler(const sptr& int32_t AbilityManagerService::GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& missionSnapshot) { - if (CheckIsRemote(deviceId)) { - HILOG_INFO("get remote mission snapshot."); - return GetRemoteMissionSnapshotInfo(deviceId, missionId, missionSnapshot); - } - - HILOG_INFO("get local mission snapshot."); if (!snapshotHandler_) { return 0; } @@ -2833,25 +2857,6 @@ int32_t AbilityManagerService::GetMissionSnapshot(const std::string& deviceId, i return result; } -int32_t AbilityManagerService::GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, - MissionSnapshot& missionSnapshot) -{ - HILOG_INFO("GetRemoteMissionSnapshotInfo begin"); - sptr dmsProxy = GetDmsProxy(); - if (dmsProxy == nullptr) { - HILOG_ERROR("GetRemoteMissionSnapshotInfo failed to get dms."); - return ERR_INVALID_VALUE; - } - std::unique_ptr missionSnapshotPtr = std::make_unique(); - int result = dmsProxy->GetRemoteMissionSnapshotInfo(deviceId, missionId, missionSnapshotPtr); - if (result != ERR_OK) { - HILOG_ERROR("GetRemoteMissionSnapshotInfo failed, result = %{public}d", result); - return result; - } - missionSnapshot = *missionSnapshotPtr; - return ERR_OK; -} - void AbilityManagerService::StartFreezingScreen() { HILOG_DEBUG("%{public}s", __func__); @@ -2937,49 +2942,5 @@ void AbilityManagerService::InitPendWantManager(int32_t userId, bool switchUser) } } } - -int AbilityManagerService::SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) -{ - HILOG_DEBUG("%{public}s, imAStabilityTest: %{public}d", __func__, imAStabilityTest); - std::lock_guard guard(globalLock_); - abilityController_ = abilityController; - controllerIsAStabilityTest_ = imAStabilityTest; - return ERR_OK; -} - -bool AbilityManagerService::IsUserAStabilityTest() -{ - std::lock_guard guard(globalLock_); - bool ret = abilityController_ != nullptr && controllerIsAStabilityTest_; - HILOG_DEBUG("%{public}s, isUserAStabilityTest: %{public}d", __func__, ret); - return ret; -} - -bool AbilityManagerService::IsAbilityControllerStarting(const Want &want, const std::string &bundleName) -{ - if (abilityController_ != nullptr) { - HILOG_DEBUG("%{public}s, controllerIsAStabilityTest_: %{public}d", __func__, controllerIsAStabilityTest_); - bool isStart = abilityController_->AbilityStarting(want, bundleName); - if (!isStart) { - HILOG_INFO("Not finishing start ability because controller starting: %{public}s", bundleName.c_str()); - return false; - } - } - return true; -} - -bool AbilityManagerService::IsAbilityControllerResuming(const std::string &bundleName) -{ - if (abilityController_ != nullptr) { - HILOG_DEBUG("%{public}s, controllerIsAStabilityTest_: %{public}d", __func__, controllerIsAStabilityTest_); - bool isResume = abilityController_->AbilityResuming(bundleName); - if (!isResume) { - HILOG_INFO("Not finishing terminate ability because controller resuming: %{public}s", bundleName.c_str()); - return false; - } - } - return true; -} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index b94cf6b91ae2e39a3bfdf0b6ab463621966317a3..e5fe7cf31e24704296653adcc39bc9a115ea3b84 100755 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -125,8 +125,9 @@ void AbilityManagerStub::SecondStepInit() requestFuncMap_[MOVE_MISSION_TO_FRONT] = &AbilityManagerStub::MoveMissionToFrontInner; requestFuncMap_[START_USER] = &AbilityManagerStub::StartUserInner; requestFuncMap_[STOP_USER] = &AbilityManagerStub::StopUserInner; - requestFuncMap_[SET_ABILITY_CONTROLLER] = &AbilityManagerStub::SetAbilityControllerInner; - requestFuncMap_[IS_USER_A_STABILITY_TEST] = &AbilityManagerStub::IsUserAStabilityTestInner; + requestFuncMap_[GET_ABILITY_RUNNING_INFO] = &AbilityManagerStub::GetAbilityRunningInfosInner; + requestFuncMap_[GET_EXTENSION_RUNNING_INFO] = &AbilityManagerStub::GetExtensionRunningInfosInner; + requestFuncMap_[GET_PROCESS_RUNNING_INFO] = &AbilityManagerStub::GetProcessRunningInfosInner; } int AbilityManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) @@ -1125,6 +1126,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(); @@ -1208,34 +1258,5 @@ int AbilityManagerStub::GetMissionSnapshotInfoInner(MessageParcel &data, Message reply.WriteParcelable(&missionSnapshot); return result; } - -int AbilityManagerStub::SetAbilityControllerInner(MessageParcel &data, MessageParcel &reply) -{ - sptr controller = - iface_cast(data.ReadRemoteObject()); - if (controller == nullptr) { - HILOG_ERROR("AbilityManagerStub: setAbilityControllerInner controller readParcelable failed!"); - return ERR_NULL_OBJECT; - } - bool imAStabilityTest = data.ReadBool(); - int32_t result = SetAbilityController(controller, imAStabilityTest); - HILOG_INFO("AbilityManagerStub: setAbilityControllerInner result = %{public}d", result); - if (!reply.WriteInt32(result)) { - HILOG_ERROR("setAbilityControllerInner failed."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilityManagerStub::IsUserAStabilityTestInner(MessageParcel &data, MessageParcel &reply) -{ - bool result = IsUserAStabilityTest(); - HILOG_INFO("AbilityManagerStub: isUserAStabilityTest result = %{public}d", result); - if (!reply.WriteBool(result)) { - HILOG_ERROR("isUserAStabilityTest failed."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} } // namespace AAFwk } // namespace OHOS 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..2870e0034587aacc9a4f33d66549235665a15dd9 100644 --- a/services/abilitymgr/src/ability_stack_manager.cpp +++ b/services/abilitymgr/src/ability_stack_manager.cpp @@ -646,8 +646,7 @@ int AbilityStackManager::TerminateAbilityLocked(std::list &t ability->SendResultToCallers(); MoveToBackgroundTask(ability); } - if (ability->IsAbilityState(AbilityState::BACKGROUND) || - ability->IsAbilityState(AbilityState::BACKGROUND_NEW)) { + if (ability->IsAbilityState(AbilityState::BACKGROUND)) { // ability on background, remove AbilityRecord out of stack and then schedule to terminate. RemoveTerminatingAbility(ability, lastActiveAbility); ability->SendResultToCallers(); @@ -2927,7 +2926,6 @@ void AbilityStackManager::OnTimeOut(uint32_t msgId, int64_t eventId) auto abilityRecord = GetAbilityRecordByEventId(eventId); if (abilityRecord == nullptr) { HILOG_ERROR("stack manager on time out event: ability record is nullptr."); - BackToLauncher(); return; } 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..7c16645db905127b2ae1041d9fe83e1606b25f4e 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(runningInfo.token, 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..5d8d8e51b0d0ec7c8bb0a8753c6db17f84416c24 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(runningInfo.token, 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_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index c934493732e873220a6fd281aee0fd0d352fba87..98b1a1676e7e98390c23bad20d6a4530acbeba0d 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -1494,5 +1494,49 @@ void MissionListManager::DumpMission(int missionId, std::vector &in } innerMissionInfo.Dump(info); } + +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(runningInfo.token, 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/start_options.cpp b/services/abilitymgr/src/start_options.cpp index 20eb4bfd33af410f4bf68d5d27c14aa979080452..737cc87316449b6e74fc0162555f25f0e8f0a4da 100644 --- a/services/abilitymgr/src/start_options.cpp +++ b/services/abilitymgr/src/start_options.cpp @@ -18,12 +18,11 @@ namespace OHOS { namespace AAFwk { -const std::string StartOptions::STRING_DISPLAY_ID = "ohos.aafwk.displayId"; +const std::string StartOptions::STRING_WINDOW_MODE = "ohos.aafwk.windowMode"; bool StartOptions::ReadFromParcel(Parcel &parcel) { SetWindowMode(parcel.ReadInt32()); - SetDisplayID(parcel.ReadInt32()); return true; } @@ -45,7 +44,6 @@ StartOptions *StartOptions::Unmarshalling(Parcel &parcel) bool StartOptions::Marshalling(Parcel &parcel) const { parcel.WriteInt32(GetWindowMode()); - parcel.WriteInt32(GetDisplayID()); return true; } @@ -58,15 +56,5 @@ int32_t StartOptions::GetWindowMode() const { return windowMode_; } - -void StartOptions::SetDisplayID(int32_t id) -{ - displayId_ = id; -} - -int32_t StartOptions::GetDisplayID() const -{ - return displayId_; -} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/test/BUILD.gn b/services/abilitymgr/test/BUILD.gn index a782a35ef33d98c8df815a6bfb5ca0d7550b0f1b..6bc34c56639eae2ff1551fde01f3ff77f7115508 100644 --- a/services/abilitymgr/test/BUILD.gn +++ b/services/abilitymgr/test/BUILD.gn @@ -198,5 +198,8 @@ group("unittest") { "unittest/phone/want_sender_stub_test:unittest", "unittest/phone/wants_info_test:unittest", "unittest/phone/window_info_test:unittest", + + #ability new + "unittest/ability_new/ability_manager_service_new_test:unittest", ] } 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..8a01e9423e5ae9b51e4b8d321b2311382ce8b28f 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 @@ -87,7 +87,8 @@ BundleMgrService::BundleMgrService() abilityInfoMap_.emplace(COM_IX_HIRADIO, HiRadioInfo); abilityInfoMap_.emplace(COM_IX_HISERVICE, HiServiceInfo); abilityInfoMap_.emplace(COM_IX_MUSICSERVICE, MusicServiceInfo); - abilityInfoMap_.emplace(COM_IX_HIDATA, HiDataInfo); + abilityInfoMap_.emplace(COM_IX_HIDATA, HiDataInfo); + abilityInfoMap_.emplace(COM_IX_HIEXTENSION, HiExtensionInfo); GTEST_LOG_(INFO) << "BundleMgrService()"; } diff --git a/services/abilitymgr/test/unittest/ability_new/ability_manager_service_new_test/BUILD.gn b/services/abilitymgr/test/unittest/ability_new/ability_manager_service_new_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e7ead235cfe502a0ca65f25d14306df1bc90df28 --- /dev/null +++ b/services/abilitymgr/test/unittest/ability_new/ability_manager_service_new_test/BUILD.gn @@ -0,0 +1,69 @@ +# 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/test.gni") +import("//foundation/aafwk/standard/aafwk.gni") + +module_output_path = "aafwk_standard/ability_new/" + +ohos_unittest("ability_manager_service_new_test") { + module_out_path = module_output_path + + include_dirs = [ + "${services_path}/abilitymgr/test/mock/libs/system_ability_mock", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", + "//foundation/distributedschedule/samgr/adapter/interfaces/innerkits/include/", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmgr", + "//foundation/aafwk/standard/frameworks/kits/ability/native/test/mock/include", + ] + + sources = [ + # add mock file + "//foundation/aafwk/standard/services/abilitymgr/test/mock/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", + "ability_manager_service_new_test.cpp", + ] + + configs = [ "${services_path}/abilitymgr:abilityms_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${innerkits_path}/want:want", + "${services_path}/abilitymgr/test:abilityms_test_source", + "${services_path}/abilitymgr/test/mock/libs/aakit:aakit_mock", + "${services_path}/abilitymgr/test/mock/libs/appexecfwk_core:appexecfwk_appmgr_mock", + "${services_path}/abilitymgr/test/mock/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", + "//foundation/aafwk/standard/frameworks/kits/ability/native:dummy_classes", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", + "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + "//utils/native/base:utils", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":ability_manager_service_new_test" ] +} diff --git a/services/abilitymgr/test/unittest/ability_new/ability_manager_service_new_test/ability_manager_service_new_test.cpp b/services/abilitymgr/test/unittest/ability_new/ability_manager_service_new_test/ability_manager_service_new_test.cpp new file mode 100755 index 0000000000000000000000000000000000000000..80bb3747f0d738328c62bb377466f42468a60951 --- /dev/null +++ b/services/abilitymgr/test/unittest/ability_new/ability_manager_service_new_test/ability_manager_service_new_test.cpp @@ -0,0 +1,353 @@ +/* + * 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 +#define private public +#define protected public +#include "ability_manager_service.h" +#include "ability_event_handler.h" +#undef private +#undef protected + +#include "app_process_data.h" +#include "system_ability_definition.h" +#include "ability_manager_errors.h" +#include "ability_scheduler.h" +#include "bundlemgr/mock_bundle_manager.h" +#include "sa_mgr_client.h" +#include "mock_ability_connect_callback.h" +#include "mock_ability_token.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace AAFwk { + +// static void WaitUntilTaskFinished() +// { +// const uint32_t maxRetryCount = 1000; +// const uint32_t sleepTime = 1000; +// uint32_t count = 0; +// auto handler = OHOS::DelayedSingleton::GetInstance()->GetEventHandler(); +// std::atomic taskCalled(false); +// auto f = [&taskCalled]() { taskCalled.store(true); }; +// if (handler->PostTask(f)) { +// while (!taskCalled.load()) { +// ++count; +// if (count >= maxRetryCount) { +// break; +// } +// usleep(sleepTime); +// } +// } +// } + +// static void WaitUntilTaskFinishedByTimer() +// { +// const uint32_t maxRetryCount = 1000; +// const uint32_t sleepTime = 1000; +// uint32_t count = 0; +// auto handler = OHOS::DelayedSingleton::GetInstance()->GetEventHandler(); +// std::atomic taskCalled(false); +// auto f = [&taskCalled]() { taskCalled.store(true); }; +// int sleepingTime = 5000; +// if (handler->PostTask(f, "AbilityManagerServiceTest", sleepingTime)) { +// while (!taskCalled.load()) { +// ++count; +// if (count >= maxRetryCount) { +// break; +// } +// usleep(sleepTime); +// } +// } +// } + +#define SLEEP(milli) std::this_thread::sleep_for(std::chrono::seconds(milli)) + +namespace { +// const std::string NAME_BUNDLE_MGR_SERVICE = "BundleMgrService"; +// static int32_t g_windowToken = 0; +} // namespace + +class AbilityManagerServiceTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + void OnStartAms(); + void OnStopAms(); + // static constexpr int TEST_WAIT_TIME = 100000; + +public: + std::shared_ptr abilityMs_ {nullptr}; +}; + +void AbilityManagerServiceTest::OnStartAms() +{ + if (abilityMs_) { + 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_); + + abilityMs_->handler_ = std::make_shared(abilityMs_->eventLoop_, abilityMs_); + EXPECT_TRUE(abilityMs_->handler_); + EXPECT_TRUE(abilityMs_->connectManager_); + + abilityMs_->connectManager_->SetEventHandler(abilityMs_->handler_); + + abilityMs_->dataAbilityManager_ = std::make_shared(); + EXPECT_TRUE(abilityMs_->dataAbilityManager_); + + abilityMs_->amsConfigResolver_ = std::make_shared(); + EXPECT_TRUE(abilityMs_->amsConfigResolver_); + abilityMs_->amsConfigResolver_->Parse(); + + abilityMs_->pendingWantManager_ = std::make_shared(); + EXPECT_TRUE(abilityMs_->pendingWantManager_); + + abilityMs_->configuration_ = std::make_shared(); + EXPECT_TRUE(abilityMs_->configuration_); + //abilityMs_->GetGlobalConfiguration(); + + int userId = abilityMs_->GetUserId(); + abilityMs_->SetStackManager(userId); + abilityMs_->systemAppManager_ = std::make_shared(userId); + EXPECT_TRUE(abilityMs_->systemAppManager_); + + abilityMs_->InitMissionListManager(userId); + + abilityMs_->kernalAbilityManager_ = std::make_shared(userId); + + abilityMs_->eventLoop_->Run(); + return; + } + + GTEST_LOG_(INFO) << "OnStart fail"; +} + +void AbilityManagerServiceTest::OnStopAms() +{ + abilityMs_->eventLoop_.reset(); + abilityMs_->handler_.reset(); + abilityMs_->state_ = ServiceRunningState::STATE_NOT_START; +} + +void AbilityManagerServiceTest::SetUpTestCase() +{ + OHOS::DelayedSingleton::GetInstance()->RegisterSystemAbility( + OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService()); +} + +void AbilityManagerServiceTest::TearDownTestCase() +{ + OHOS::DelayedSingleton::DestroyInstance(); +} + +void AbilityManagerServiceTest::SetUp() +{ + abilityMs_ = OHOS::DelayedSingleton::GetInstance(); + OnStartAms(); +} + +void AbilityManagerServiceTest::TearDown() +{ + OnStopAms(); + OHOS::DelayedSingleton::DestroyInstance(); +} + +/* + * Feature: AbilityManagerService + * Function: query info + * SubFunction: NA + * FunctionPoints:query start abilites infos + * EnvConditions: NA + * CaseDescription: start page ability + */ +HWTEST_F(AbilityManagerServiceTest, GetAbilityRunningInfos_001, TestSize.Level1) +{ + Want want; + ElementName element("device", "com.ix.hiMusic", "MusicAbility"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + auto topAbility = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); + EXPECT_TRUE(topAbility); + + std::vector infos; + abilityMs_->GetAbilityRunningInfos(infos); + + EXPECT_TRUE(infos.size() == 1); + EXPECT_TRUE(infos[0].ability.GetAbilityName() == element.GetAbilityName()); + EXPECT_TRUE(infos[0].abilityState == topAbility->GetAbilityState()); +} +#if 0 +/* + * Feature: AbilityManagerService + * Function: query info + * SubFunction: NA + * FunctionPoints:query start abilites infos + * EnvConditions: NA + * CaseDescription: start serviec ability + */ +HWTEST_F(AbilityManagerServiceTest, GetAbilityRunningInfos_002, TestSize.Level1) +{ + Want want; + ElementName element("device", "com.ix.hiService", "ServiceAbility"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + auto topAbility = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); + EXPECT_TRUE(topAbility); + + std::vector infos; + abilityMs_->GetAbilityRunningInfos(infos); + + EXPECT_TRUE(infos.size() == 1); + EXPECT_TRUE(infos[0].ElementName.GetAbilityName() == element.GetAbilityName()); + EXPECT_TRUE(infos[0].abilityState == topAbility.GetAbilityState()); +} + +/* + * Feature: AbilityManagerService + * Function: query info + * SubFunction: NA + * FunctionPoints:query start abilites infos + * EnvConditions: NA + * CaseDescription: start luncher ability + */ +HWTEST_F(AbilityManagerServiceTest, GetAbilityRunningInfos_003, TestSize.Level1) +{ + Want want; + ElementName element("device", "com.ix.hiworld", "Helloworld"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + auto topAbility = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); + EXPECT_TRUE(topAbility); + + std::vector infos; + abilityMs_->GetAbilityRunningInfos(infos); + + EXPECT_TRUE(infos.size() == 1); + EXPECT_TRUE(infos[0].ElementName.GetAbilityName() == topAbility.GetAbilityName()); + EXPECT_TRUE(infos[0].abilityState == topAbility.GetAbilityState()); +} + +/* + * Feature: AbilityManagerService + * Function: query info + * SubFunction: NA + * FunctionPoints:query start abilites infos + * EnvConditions: NA + * CaseDescription: start date ability + */ +HWTEST_F(AbilityManagerServiceTest, GetAbilityRunningInfos_004, TestSize.Level1) +{ + Want want; + ElementName element("device", "com.ix.hiData", "hiData"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + auto topAbility = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); + EXPECT_TRUE(topAbility); + + std::vector infos; + abilityMs_->GetAbilityRunningInfos(infos); + + EXPECT_TRUE(infos.size() == 1); + EXPECT_TRUE(infos[0].ElementName.GetAbilityName() == topAbility.GetAbilityName()); + EXPECT_TRUE(infos[0].abilityState == topAbility.GetAbilityState()); +} + +/* + * Feature: AbilityManagerService + * Function: query info + * SubFunction: NA + * FunctionPoints:query start abilites infos + * EnvConditions: NA + * CaseDescription: start EXTENSION ability + */ +HWTEST_F(AbilityManagerServiceTest, GetExtensionRunningInfos_001, TestSize.Level1) +{ + Want want; + ElementName element("device", "com.ix.hiExtension", "hiExtension"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + auto topAbility = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); + EXPECT_TRUE(topAbility); + + std::vector infos; + abilityMs_->GetAbilityRunningInfos(infos); + + EXPECT_TRUE(infos.size() == 1); + EXPECT_TRUE(infos[0].ElementName.GetAbilityName() == topAbility.GetAbilityName()); + EXPECT_TRUE(infos[0].abilityState == topAbility.GetAbilityState()); +} + + +/* + * Feature: AbilityManagerService + * Function: query info + * SubFunction: NA + * FunctionPoints:query start abilites infos + * EnvConditions: NA + * CaseDescription: start mulit EXTENSION ability + */ +HWTEST_F(AbilityManagerServiceTest, GetExtensionRunningInfos_002, TestSize.Level1) +{ + Want want; + ElementName element("device", "com.ix.hiExtension", "hiExtension"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + auto topAbility = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); + EXPECT_TRUE(topAbility); + topAbility->SetAbilityState(AbilityState::ACTIVE); + + ElementName element("device", "com.ix.hiExtension", "hiExtensionOther"); + want.SetElement(element); + auto result = abilityMs_->StartAbility(want); + EXPECT_EQ(OHOS::ERR_OK, result); + + std::vector infos; + abilityMs_->GetAbilityRunningInfos(infos); + + EXPECT_TRUE(infos.size() == 2); + EXPECT_TRUE(infos[0].ElementName.GetAbilityName() == topAbility.GetAbilityName()); + EXPECT_TRUE(infos[0].abilityState == topAbility.GetAbilityState()); + + EXPECT_TRUE(infos[1].ElementName.GetAbilityName() == topAbility.GetAbilityName()); + EXPECT_TRUE(infos[1].abilityState == topAbility.GetAbilityState()); +} +#endif +} // namespace AAFwk +} // namespace OHOS 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..c4b56b32be2737f4bf92c2a10d92d01fe0fdb7b6 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 @@ -334,18 +334,6 @@ public: { return 0; } - - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - MOCK_METHOD2(TerminateAbilityByCaller, int(const sptr &callerToken, int requestCode)); MOCK_METHOD3(StartAbility, int(const Want &want, const sptr &callerToken, int requestCode)); MOCK_METHOD2( @@ -379,6 +367,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_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..60a75a02bf3676cd36a8113fa5572bf3a59c5939 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 @@ -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; @@ -376,17 +380,6 @@ public: { return 0; } - - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } }; } // namespace AAFwk } // namespace OHOS 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..285bfc2861cfb3d1e4ed9d5b8118e1e818f92663 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; @@ -138,17 +143,6 @@ public: { return 0; } - - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } }; } // namespace AAFwk } // namespace OHOS diff --git a/services/test/mock/include/mock_ability_manager_proxy.h b/services/test/mock/include/mock_ability_manager_proxy.h index 44bef71f3080aa17cebad92e214f89df3d0d9c0b..9963caba0f4d62fe0eb6756064b8a3c602549437 100644 --- a/services/test/mock/include/mock_ability_manager_proxy.h +++ b/services/test/mock/include/mock_ability_manager_proxy.h @@ -90,17 +90,6 @@ public: MOCK_METHOD1(GetPendingWantUserId, int(const sptr &target)); MOCK_METHOD1(SetShowOnLockScreen, int(bool isAllow)); - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - public: int id_; }; diff --git a/services/test/mock/include/mock_ability_mgr_service.h b/services/test/mock/include/mock_ability_mgr_service.h index a95f9080f8163e01ddb6a3d5c06c176b90b8cb06..9c18a5a6cbfb7b432d461ef4464bbbb99eb5c976 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; @@ -145,17 +149,6 @@ public: return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - - virtual bool IsUserAStabilityTest() override - { - return true; - } - void Wait() { sem_.Wait(); diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 73fe0ad0e5b38a59abbda26b9bf1d1340ef3d177..8e9d8afe64e21f278ccbe85797ddd36c809a6ad2 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 { @@ -169,15 +173,6 @@ public: { return 0; } - virtual int SetAbilityController(const sptr &abilityController, - bool imAStabilityTest) override - { - return 0; - } - virtual bool IsUserAStabilityTest() override - { - return true; - } public: std::string powerState_; }; diff --git a/tools/test/systemtest/aa/BUILD.gn b/tools/test/systemtest/aa/BUILD.gn index 955b13924221522e03b37a9e43658741e27019d1..1da41815e85567095136959f8a16d4d2c961c71d 100644 --- a/tools/test/systemtest/aa/BUILD.gn +++ b/tools/test/systemtest/aa/BUILD.gn @@ -16,17 +16,6 @@ import("//foundation/aafwk/standard/aafwk.gni") module_output_path = "aafwk_standard/tools" -config("tools_aa_test_config") { - include_dirs = [ - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include", - "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr", - "${appexecfwk_path}/tools/bm/include", - "//utils/system/safwk/native/include", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include", - "//base/security/appverify/interfaces/innerkits/appverify/include", - ] -} - ohos_systemtest("aa_command_start_system_test") { module_out_path = module_output_path @@ -37,7 +26,7 @@ ohos_systemtest("aa_command_start_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ "${appexecfwk_path}/tools/bm:tools_bm_config" ] cflags = [] if (target_cpu == "arm") { @@ -65,7 +54,7 @@ ohos_systemtest("aa_command_stop_service_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ "${appexecfwk_path}/tools/bm:tools_bm_config" ] cflags = [] if (target_cpu == "arm") { @@ -95,7 +84,7 @@ ohos_systemtest("aa_command_dump_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ "${appexecfwk_path}/tools/bm:tools_bm_config" ] cflags = [] if (target_cpu == "arm") {