diff --git a/frameworks/kits/ability/native/src/ability.cpp b/frameworks/kits/ability/native/src/ability.cpp index 70f132b10092890c5a54e8dd9b276c364668eadd..d5380085f163813555cb6e4c3e8d9ec687d286d6 100644 --- a/frameworks/kits/ability/native/src/ability.cpp +++ b/frameworks/kits/ability/native/src/ability.cpp @@ -208,6 +208,11 @@ void Ability::OnStart(const Want &want) if (abilityWindow_ != nullptr) { APP_LOGI("%{public}s begin abilityWindow_->OnPostAbilityStart.", __func__); abilityWindow_->OnPostAbilityStart(); + if (abilityWindow_->GetWindow()) { + auto windowId = abilityWindow_->GetWindow()->GetWindowId(); + APP_LOGI("Ability::OnStart: add window info = %{public}d", windowId); + OHOS::AAFwk::AbilityManagerClient::GetInstance()->AddWindowInfo(AbilityContext::GetToken(), windowId); + } APP_LOGI("%{public}s end abilityWindow_->OnPostAbilityStart.", __func__); } } diff --git a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client_interface1.cpp b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client_interface1.cpp index b3c30f697c7622bfa8cede4d7230bfe7334a55f6..9cd20832d354ec60e57e339b5e9a9e88a27b4d80 100644 --- a/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client_interface1.cpp +++ b/frameworks/kits/ability/native/test/mock/include/mock_ability_manager_client_interface1.cpp @@ -161,7 +161,7 @@ ErrCode AbilityManagerClient::GetRecentMissions( return ERR_OK; } -ErrCode AbilityManagerClient::GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) +ErrCode AbilityManagerClient::GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { return ERR_OK; } 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 b58ca0ffe5cf470a769c6961e1d9514a099cb522..58430d0f6e0c45571617401348394792e4c8574e 100644 --- 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 @@ -131,6 +131,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + int RemoveMission(int id) override; int RemoveStack(int id) override; @@ -152,7 +154,7 @@ public: return 0; } - int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) + int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { return 0; } 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 479f88f57e753c08b480ea2dffdfc74a2ec39fb2..ffe84090a3ac8739e5fa5f45d0171bdd6fa8a488 100644 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp @@ -35,6 +35,7 @@ #include "ohos/aafwk/base/zchar_wrapper.h" #include "parcel_macro.h" #include "string_ex.h" +#include "want_params_wrapper.h" using namespace OHOS::AppExecFwk; using OHOS::AppExecFwk::ElementName; @@ -1935,5 +1936,98 @@ void Want::DumpInfo(int level) const APP_LOGI("==================Want::DumpInfo level: %{public}d end=============", level); } +nlohmann::json Want::ToJson() const +{ + WantParamWrapper wrapper(parameters_); + std::string parametersString = wrapper.ToString(); + + nlohmann::json entitiesJson; + std::vector entities = GetEntities(); + for (auto entity : entities) { + entitiesJson.emplace_back(entity); + } + + nlohmann::json wantJson = nlohmann::json{ + {"deviceId", operation_.GetDeviceId()}, + {"bundleName", operation_.GetBundleName()}, + {"abilityName", operation_.GetAbilityName()}, + {"uri", GetUriString()}, + {"type", GetType()}, + {"flags", GetFlags()}, + {"action", GetAction()}, + {"parameters", parametersString}, + {"entities", entitiesJson}, + }; + + return wantJson; +} + +bool Want::ReadFromJson(nlohmann::json &wantJson) +{ + const auto &jsonObjectEnd = wantJson.end(); + if ((wantJson.find("deviceId") == jsonObjectEnd) + || (wantJson.find("bundleName") == jsonObjectEnd) + || (wantJson.find("abilityName") == jsonObjectEnd) + || (wantJson.find("uri") == jsonObjectEnd) + || (wantJson.find("type") == jsonObjectEnd) + || (wantJson.find("flags") == jsonObjectEnd) + || (wantJson.find("action") == jsonObjectEnd) + || (wantJson.find("parameters") == jsonObjectEnd) + || (wantJson.find("entities") == jsonObjectEnd)) { + APP_LOGE("Incomplete wantJson"); + return false; + } + + std::string deviceId = wantJson.at("deviceId").get(); + std::string bundleName = wantJson.at("bundleName").get(); + std::string abilityName = wantJson.at("abilityName").get(); + SetElementName(deviceId, bundleName, abilityName); + + std::string uri = wantJson.at("uri").get(); + SetUri(uri); + + std::string type = wantJson.at("type").get(); + SetType(type); + + unsigned int flags = wantJson.at("flags").get(); + SetFlags(flags); + + std::string action = wantJson.at("action").get(); + SetAction(action); + + std::string parametersString = wantJson.at("parameters").get(); + WantParams parameters = WantParamWrapper::ParseWantParams(parametersString); + SetParams(parameters); + + std::vector entities; + wantJson.at("entities").get_to>(entities); + for (size_t i = 0; i < entities.size(); i++) { + AddEntity(entities[i]); + } + + return true; +} + +std::string Want::ToString() const +{ + return ToJson().dump(); +} + +Want *Want::FromString(std::string &string) +{ + if (string.empty()) { + APP_LOGE("Invalid string."); + return nullptr; + } + + nlohmann::json wantJson = nlohmann::json::parse(string); + + Want *want = new (std::nothrow) Want(); + if (want != nullptr && !want->ReadFromJson(wantJson)) { + delete want; + want = nullptr; + } + return want; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.cpp b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.cpp index 4a38af85cc59500c01b6fb17ef79141f1aa2da3d..d6c88cf7ffd3dd67ea0b63b05a6a5d2e7d2fd06a 100644 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.cpp @@ -102,6 +102,7 @@ bool WantParamWrapper::ValidateStr(const std::string &str) } return true; } + sptr WantParamWrapper::Parse(const std::string &str) { WantParams wantPaqrams; @@ -152,5 +153,56 @@ sptr WantParamWrapper::Parse(const std::string &str) sptr iwantParams = new WantParamWrapper(wantPaqrams); return iwantParams; } + +WantParams WantParamWrapper::ParseWantParams(const std::string &str) +{ + WantParams wantPaqrams; + std::string key = ""; + int typeId = 0; + if (!ValidateStr(str)) { + return wantPaqrams; + } + for (unsigned int strnum = 0; strnum < str.size(); strnum++) { + if (str[strnum] == '{' && key != "" && typeId == WantParams::VALUE_TYPE_WANTPARAMS) { + unsigned int num; + int count = 0; + for (num = strnum; num < str.size(); num++) { + if (str[num] == '{') { + count++; + } else if (str[num] == '}') { + count--; + } + if (count == 0) { + break; + } + } + wantPaqrams.SetParam(key, WantParamWrapper::Parse(str.substr(strnum, num - strnum))); + key = ""; + typeId = 0; + strnum = num + 1; + } else if (str[strnum] == '"') { + if (key == "") { + strnum++; + key = str.substr(strnum, str.find('"', strnum) - strnum); + strnum = str.find('"', strnum); + } else if (typeId == 0) { + strnum++; + typeId = atoi(str.substr(strnum, str.find('"', strnum) - strnum).c_str()); + if (errno == ERANGE) { + return wantPaqrams; + } + strnum = str.find('"', strnum); + } else { + strnum++; + wantPaqrams.SetParam(key, + WantParams::GetInterfaceByType(typeId, str.substr(strnum, str.find('"', strnum) - strnum))); + strnum = str.find('"', strnum); + typeId = 0; + key = ""; + } + } + } + return wantPaqrams; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.h b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.h index baa1052fba86d0da58ae4ea74969a841dcd7b592..5a88e6558187e0cab04897216c7d7845b472bc7b 100644 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.h +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want_params_wrapper.h @@ -56,6 +56,8 @@ public: static sptr Parse(const std::string &str); + static WantParams ParseWantParams(const std::string &str); + static constexpr char SIGNATURE = 'W'; private: diff --git a/frameworks/kits/content/cpp/test/unittest/common/want_test.cpp b/frameworks/kits/content/cpp/test/unittest/common/want_test.cpp index 19d69f8efc96d63503f4cf5258a248a041620d8f..8c0da10bde2c517b01bd14f861036863db2b1385 100644 --- a/frameworks/kits/content/cpp/test/unittest/common/want_test.cpp +++ b/frameworks/kits/content/cpp/test/unittest/common/want_test.cpp @@ -567,6 +567,12 @@ HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0500, Function | MediumTest | Level void WantBaseTest::CompareWant(const std::shared_ptr &want1, const std::shared_ptr &want2) const { + Operation opt1 = want1->GetOperation(); + Operation opt2 = want2->GetOperation(); + EXPECT_EQ(opt1.GetDeviceId(), opt2.GetDeviceId()); + EXPECT_EQ(opt1.GetBundleName(), opt2.GetBundleName()); + EXPECT_EQ(opt1.GetAbilityName(), opt2.GetAbilityName()); + EXPECT_EQ(want1->GetAction(), want2->GetAction()); EXPECT_EQ(want1->GetFlags(), want2->GetFlags()); EXPECT_EQ(want1->GetType(), want2->GetType()); @@ -3819,5 +3825,56 @@ HWTEST_F(WantBaseTest, AaFwk_Want_HasParameter_0200, Function | MediumTest | Lev std::shared_ptr p2(newWant); CompareWant(p1, p2); } +/** + * @tc.number: AaFwk_Want_ToString_0100 + * @tc.name: ToString and FromString + * @tc.desc: Verify FromString() + */ +HWTEST_F(WantBaseTest, AaFwk_Want_ToString_0100, Function | MediumTest | Level1) +{ + std::string deviceId = "deviceId"; + std::string bundleName = "bundleName"; + std::string abilityName ="abilityName"; + std::string uri = "url"; + std::string type = "type"; + unsigned int flags = 1; + std::string action = "action"; + WantParams parameters; + std::vector entities = {"entity.system.entity1", "entity.system.entity2"}; + + std::string keyBool = "key_bool"; + bool valueBool = true; + parameters.SetParam(keyBool, Boolean::Box(valueBool)); + + std::string keyStr = "key_string"; + std::string valueString = "123"; + parameters.SetParam(keyStr, String::Box(valueString)); + + std::string keyInt = "key_int"; + int valueInt = 111; + parameters.SetParam(keyStr, Integer::Box(valueInt)); + + std::shared_ptr want1 = std::make_shared(); + if (want1 == nullptr) { + return; + } + want1->SetElementName(deviceId, bundleName, abilityName); + want1->SetUri(uri); + want1->SetType(type); + want1->SetFlags(flags); + want1->SetAction(action); + for (auto entity : entities) { + want1->AddEntity(entity); + } + + std::string jsonString = want1->ToString(); + Want *newWant = Want::FromString(jsonString); + if (newWant == nullptr) { + return; + } + std::shared_ptr want2(newWant); + + CompareWant(want1, want2); +} } // namespace AAFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/kits/test/BUILD.gn b/frameworks/kits/test/BUILD.gn index 288d34c106135b691271075bcb5f136d43120031..75c808c9e6b39f4501d1ddc47dd0eb3d94c14d17 100644 --- a/frameworks/kits/test/BUILD.gn +++ b/frameworks/kits/test/BUILD.gn @@ -70,9 +70,9 @@ ohos_moduletest("ability_moduletest") { "//foundation/aafwk/standard/services/abilitymgr/src/mission_option.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_record_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_stack_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/sender_info.cpp", + "//foundation/aafwk/standard/services/abilitymgr/src/shared_memory.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/stack_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/stack_setting.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/want_sender_info.cpp", @@ -195,8 +195,6 @@ ohos_moduletest("data_ability_operation_moduletest") { "//foundation/aafwk/standard/services/abilitymgr/src/ability_scheduler_proxy.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/ability_scheduler_stub.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/caller_info.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/image_info.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/launch_param.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/lifecycle_state_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_description_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_info.cpp", @@ -204,7 +202,6 @@ ohos_moduletest("data_ability_operation_moduletest") { "//foundation/aafwk/standard/services/abilitymgr/src/mission_listener_stub.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_record_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_stack_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/sender_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/stack_info.cpp", diff --git a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.cpp b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.cpp index b7a8322ca56bd4c0269ee41d1c2990b7a7d244b7..5efa32557d2b1f8d88fd94360e7b141cccf225e9 100644 --- a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.cpp +++ b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.cpp @@ -176,7 +176,7 @@ int MockAbilityManagerService::GetRecentMissions( return 0; } -int MockAbilityManagerService::GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) +int MockAbilityManagerService::GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { return 0; } 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 eb0962e01efaa9bdecff22c11ff5660fbce221ca..b4f6fd42fab018f1ad4784d7a02d524ec48958c6 100644 --- a/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h +++ b/frameworks/kits/test/mock/AMS/mock_ability_manager_service.h @@ -109,6 +109,8 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); + MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); int MoveMissionToEnd(const sptr &token, const bool nonFirst) override; bool IsFirstInMission(const sptr &token) override; @@ -117,7 +119,7 @@ public: int GetRecentMissions( const int32_t numMax, const int32_t flags, std::vector &recentList) override; - int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) override; + int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) override; int RemoveMission(int id) override; diff --git a/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h b/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h index daa3fe3b5fb1ebee83a504f9f9a10762a431d014..cddce9ac2d93aa24465e87a1e8c61b372bb778ce 100644 --- a/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h +++ b/frameworks/kits/test/mock/AMS/mock_serviceability_manager_service.h @@ -105,6 +105,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &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; @@ -154,7 +156,7 @@ public: return 0; } - int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) + int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { return 0; } diff --git a/interfaces/innerkits/ability_manager/BUILD.gn b/interfaces/innerkits/ability_manager/BUILD.gn index efa77a191fecb55cf6d1754d7ec4dfe4244e160c..babf5d4141b564100686327df86622bd710d8d66 100644 --- a/interfaces/innerkits/ability_manager/BUILD.gn +++ b/interfaces/innerkits/ability_manager/BUILD.gn @@ -28,6 +28,7 @@ config("ability_manager_public_config") { "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmgr", "//foundation/appexecfwk/standard/kits/appkit/native/app/include", + "//foundation/multimedia/image_standard/interfaces/innerkits/include", "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_rdb/include", "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_appdatafwk/include", "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_dataability/include", @@ -60,9 +61,10 @@ ohos_shared_library("ability_manager") { "${services_path}/abilitymgr/src/mission_listener_stub.cpp", "${services_path}/abilitymgr/src/mission_option.cpp", "${services_path}/abilitymgr/src/mission_record_info.cpp", - "${services_path}/abilitymgr/src/mission_snapshot_info.cpp", + "${services_path}/abilitymgr/src/mission_snapshot.cpp", "${services_path}/abilitymgr/src/mission_stack_info.cpp", "${services_path}/abilitymgr/src/sender_info.cpp", + "${services_path}/abilitymgr/src/shared_memory.cpp", "${services_path}/abilitymgr/src/stack_info.cpp", "${services_path}/abilitymgr/src/stack_setting.cpp", "${services_path}/abilitymgr/src/start_options.cpp", @@ -92,6 +94,7 @@ ohos_shared_library("ability_manager") { "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_rdb:native_rdb", "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", "//third_party/jsoncpp:jsoncpp", "//utils/native/base:utils", ] diff --git a/interfaces/innerkits/ability_manager/ability_manager_headers.gni b/interfaces/innerkits/ability_manager/ability_manager_headers.gni index 489c60760d4bde5ee6b8dbdbd751ab09b31e05aa..5913ebcafca8dcc11af8ee84109cdef13e7e2383 100644 --- a/interfaces/innerkits/ability_manager/ability_manager_headers.gni +++ b/interfaces/innerkits/ability_manager/ability_manager_headers.gni @@ -34,6 +34,9 @@ ability_manager_headers = { "mission_option.h", "stack_setting.h", "start_options.h", + "global_configuration.h", + "pixel_map.h", + "shared_memory.h", ] header_base = "interfaces/innerkits/ability_manager/include" } diff --git a/interfaces/innerkits/ability_manager/include/ability_manager_client.h b/interfaces/innerkits/ability_manager/include/ability_manager_client.h index 4f7a91c60fd8c047c69c391ce1081f5c6f0eea25..5d200e8191cc08cb20b238754a37ddbdd082f650 100644 --- a/interfaces/innerkits/ability_manager/include/ability_manager_client.h +++ b/interfaces/innerkits/ability_manager/include/ability_manager_client.h @@ -262,7 +262,7 @@ public: * @param missionId the id of the mission to retrieve the sAutoapshots * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot); + ErrCode GetMissionSnapshot(const int32_t missionId, MissionSnapshot &missionSnapshot); /** * Ask that the mission associated with a given mission ID be moved to the @@ -391,6 +391,8 @@ public: ErrCode GetPendingRequestWant(const sptr &target, std::shared_ptr &want); + ErrCode GetWantSenderInfo(const sptr &target, std::shared_ptr &info); + /** * Moving mission to the specified stack by mission option(Enter floating window mode). * @param missionOption, target mission option diff --git a/interfaces/innerkits/ability_manager/include/ability_manager_interface.h b/interfaces/innerkits/ability_manager/include/ability_manager_interface.h index 2309cc08fe307a4a56869ef3436d102a233ad111..a8f5da730a66cefa59e8f5ead23ee35ffe5fe089 100644 --- a/interfaces/innerkits/ability_manager/include/ability_manager_interface.h +++ b/interfaces/innerkits/ability_manager/include/ability_manager_interface.h @@ -25,7 +25,7 @@ #include "ability_scheduler_interface.h" #include "ability_start_setting.h" #include "foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmgr/configuration.h" -#include "mission_snapshot_info.h" +#include "mission_snapshot.h" #include "ability_mission_info.h" #include "mission_option.h" #include "stack_info.h" @@ -276,7 +276,7 @@ public: * @param missionId the id of the mission to retrieve the sAutoapshots * @return Returns ERR_OK on success, others on failure. */ - virtual int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) = 0; + virtual int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) = 0; /** * Ask that the mission associated with a given mission ID be moved to the @@ -488,6 +488,7 @@ public: virtual int GetPendingRequestWant(const sptr &target, std::shared_ptr &want) = 0; + virtual int GetWantSenderInfo(const sptr &target, std::shared_ptr &info) = 0; /** * set lock screen white list * @@ -710,11 +711,14 @@ public: GET_PENDING_REQUEST_WANT, + GET_PENDING_WANT_SENDER_INFO, SET_SHOW_ON_LOCK_SCREEN, // ipc id for starting ability by settings(1018) START_ABILITY_FOR_SETTINGS, + GET_ABILITY_MISSION_SNAPSHOT, + GET_SYSTEM_MEMORY_ATTR, CLEAR_UP_APPLICATION_DATA, diff --git a/interfaces/innerkits/ability_manager/include/global_configuration_key.h b/interfaces/innerkits/ability_manager/include/global_configuration_key.h index 2984ec34851cf99d4a2f20b64e83af0e0e046841..35ce3f1229efc73365d73f84025f9d36dffa2e4a 100644 --- a/interfaces/innerkits/ability_manager/include/global_configuration_key.h +++ b/interfaces/innerkits/ability_manager/include/global_configuration_key.h @@ -22,6 +22,9 @@ namespace OHOS { namespace AAFwk { namespace GlobalConfigurationKey { /* For the time being, there is no uniform standard */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@*/ + /* Must be synchronized with the keystore(SystemConfigurationKeyStore)in the configuration */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ static const std::string SYSTEM_LANGUAGE {"ohos.system.language"}; static const std::string SYSTEM_ORIENTATION {"ohos.system.orientation"}; } // namespace GlobalConfigurationKey diff --git a/interfaces/innerkits/ability_manager/include/image_info.h b/interfaces/innerkits/ability_manager/include/image_info.h index 50b84de30ebac6d8e636f1ef595145165682598b..f2c15479fbebde09fe008cb5ca58fb9a0acde82f 100644 --- a/interfaces/innerkits/ability_manager/include/image_info.h +++ b/interfaces/innerkits/ability_manager/include/image_info.h @@ -18,53 +18,20 @@ #include -#include "ability_record_info.h" -#include "mission_description_info.h" #include "parcel.h" -#include "want.h" namespace OHOS { namespace AAFwk { /** * @struct ImageInfo - * Defines image header information. - */ -struct ImageHeader : public Parcelable { - /** - * Color format, which is used to match image type. This variable is important. - */ - uint32_t colorMode = 8; - - uint32_t reserved = 24; - - uint16_t width; - - uint16_t height; - - bool ReadFromParcel(Parcel &parcel); - virtual bool Marshalling(Parcel &parcel) const override; - static ImageHeader *Unmarshalling(Parcel &parcel); -}; - -/** - * @struct ImageInfo - * Defines image information. + * ImageInfo is used to save informations about sanpshot. */ struct ImageInfo : public Parcelable { - ImageHeader header; - - /** - * Size of the image data (in bytes) - */ - uint32_t dataSize; - - uint8_t *data; - - uint32_t userDataSize; - /** - * User-defined data - */ - void *userData; + uint32_t width; + uint32_t height; + uint32_t format; + uint32_t size; + int32_t shmKey; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; diff --git a/interfaces/innerkits/ability_manager/include/mission_snapshot.h b/interfaces/innerkits/ability_manager/include/mission_snapshot.h index 1db1c7e82f922bbe17c1f604a1c97219588eb055..ed1b0dd209a0ac37b8f6cbad71d35774a5efd914 100644 --- a/interfaces/innerkits/ability_manager/include/mission_snapshot.h +++ b/interfaces/innerkits/ability_manager/include/mission_snapshot.h @@ -1,41 +1,47 @@ -/* - * 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_MISSION_SNAPSHOT_H -#define OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_H - -#include - -#include "element_name.h" -#include "parcel.h" -#include "pixel_map.h" - -namespace OHOS { -namespace AAFwk { -/** - * @struct MissionSnapshotInfo - * MissionSnapshotInfo is used to save informations about mission sanpshot. - */ -struct MissionSnapshot : public Parcelable { - AppExecFwk::ElementName ability; - Media::PixelMap snapshot; - - bool ReadFromParcel(Parcel &parcel); - virtual bool Marshalling(Parcel &parcel) const override; - static MissionSnapshot *Unmarshalling(Parcel &parcel); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_H \ No newline at end of file +/* + * 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_MISSION_SNAPSHOT_H +#define OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_H + +#include +#include "image_info.h" +#include "parcel.h" +#include "element_name.h" +#include "foundation/multimedia/image_standard/interfaces/innerkits/include/pixel_map.h" + +namespace OHOS { +namespace AAFwk { +/** + * @struct MissionPixelMap + * MissionPixelMap is used to save informations about mission sanpshot. + */ +struct MissionPixelMap : public Parcelable { + AppExecFwk::ElementName topAbility; + AAFwk::ImageInfo imageInfo; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static MissionPixelMap *Unmarshalling(Parcel &parcel); +}; + +struct MissionSnapshot { + AppExecFwk::ElementName topAbility; + std::shared_ptr snapshot; +}; + +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_H diff --git a/interfaces/innerkits/ability_manager/include/shared_memory.h b/interfaces/innerkits/ability_manager/include/shared_memory.h new file mode 100644 index 0000000000000000000000000000000000000000..7e5f982574bda4f81f6507ef6b5b66953d27d8f7 --- /dev/null +++ b/interfaces/innerkits/ability_manager/include/shared_memory.h @@ -0,0 +1,32 @@ +/* + * 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_SHARED_MEMORY_H +#define OHOS_AAFWK_INTERFACES_SHARED_MEMORY_H + +namespace OHOS { +namespace AAFwk { +class SharedMemory { +public: + SharedMemory() = default; + ~SharedMemory() = default; + + static void ReleaseShmId(const int shmId); + static void* PopSharedMemory(int shmKey, int size); + static int PushSharedMemory(const void *data, const int size); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_AAFWK_INTERFACES_SHARED_MEMORY_H \ No newline at end of file diff --git a/interfaces/innerkits/want/BUILD.gn b/interfaces/innerkits/want/BUILD.gn index c99db3c0bf6ea2e44ce35ff5faa075be67fecde1..2568619f53b9a4d968a21879146d6e8737057126 100644 --- a/interfaces/innerkits/want/BUILD.gn +++ b/interfaces/innerkits/want/BUILD.gn @@ -38,6 +38,7 @@ config("want_public_config") { "//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content", "//foundation/aafwk/standard/frameworks/kits/content/cpp/src", "//third_party/jsoncpp/include", + "//third_party/json/include", ] } diff --git a/interfaces/innerkits/want/include/ohos/aafwk/content/want.h b/interfaces/innerkits/want/include/ohos/aafwk/content/want.h index b943483d22b88828c6ee4afb057f6f8180422b6a..0127fedd27838ad0535f84011dfd7888aa17f401 100644 --- a/interfaces/innerkits/want/include/ohos/aafwk/content/want.h +++ b/interfaces/innerkits/want/include/ohos/aafwk/content/want.h @@ -25,6 +25,7 @@ #include "element_name.h" #include "operation.h" #include "parcel.h" +#include "nlohmann/json.hpp" using Operation = OHOS::AAFwk::Operation; @@ -757,6 +758,9 @@ public: void DumpInfo(int level) const; + std::string ToString() const; + + static Want *FromString(std::string &string); public: // action definition static const std::string ACTION_PLAY; @@ -808,6 +812,9 @@ private: static bool CheckAndSetParameters(Want &want, const std::string &key, std::string &prop, const std::string &value); Uri GetLowerCaseScheme(const Uri &uri); void ToUriStringInner(std::string &uriString) const; + nlohmann::json ToJson() const; + bool ReadFromJson(nlohmann::json &wantJson); + }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/kits/js/@ohos.ability.formmanager.d.ts b/interfaces/kits/js/@ohos.ability.formmanager.d.ts deleted file mode 100644 index 77a22265be05b79e0e390d75d723f734e88a7112..0000000000000000000000000000000000000000 --- a/interfaces/kits/js/@ohos.ability.formmanager.d.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* - * 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 { AsyncCallback } from './.basic'; -import { Want } from './ability/want'; -import { FormInfo } from './ability/forminfo'; - -/** - * Provides utilities for system application components to access ability form - * on the OHOS OS. - * @name formManager - * @since 7 - * @sysCap AAFwk - * @devices phone, tablet - * @permission N/A - */ -declare namespace formManager { - /** - * user need to force refresh form. - * - *

You can use this method to ask for newly form from service.

- * - * @param formId the specify form id. - * @since 7 - */ - function requestForm(formId: number, callback: AsyncCallback): void; - function requestForm(formId: number): Promise; - - /** - * delete forms. - * - *

You can use this method to delete ability form.

- * - * @param formId Indicates the form to be deleted. - * @since 7 - */ - function deleteForm(formId: number, callback: AsyncCallback): void; - function deleteForm(formId: number): Promise; - - /** - * release form. - * - *

You can use this method to release ability form, it does not delete form cache in - * form manager.

- * - * @param formId Indicates the form to be released. - * @param isReleaseCache Indicates whether to delete cache in service. - * @since 7 - */ - function releaseForm(formId: number, isReleaseCache: boolean, callback: AsyncCallback): void; - function releaseForm(formId: number, isReleaseCache: boolean): Promise; - - /** - * Sends a notification to the form framework to make the specified forms visible. - * - * @param formIds Indicates the IDs of the forms to be made visible. - * @since 7 - */ - function notifyVisibleForms(formIds: Array, callback: AsyncCallback): void; - function notifyVisibleForms(formIds: Array): Promise; - - /** - * Sends a notification to the form framework to make the specified forms invisible. - * - * @param formIds Indicates the IDs of the forms to be made invisible. - * @since 7 - */ - function notifyInvisibleForms(formIds: Array, callback: AsyncCallback): void; - function notifyInvisibleForms(formIds: Array): Promise; - - /** - * set form refresh state to true. - * - *

You can use this method to set form refresh state to true, the form can receive new - * update from service.

- * - * @param formIds the specify form id. - * @since 7 - */ - function enableFormsUpdate(formIds: Array, callback: AsyncCallback): void; - function enableFormsUpdate(formIds: Array): Promise; - - /** - * set form refresh state to false. - * - *

You can use this method to set form refresh state to false, the form do not receive - * new update from service.

- * - * @param formIds the specify form id. - * @since 7 - */ - function disableFormsUpdate(formIds: Array, callback: AsyncCallback): void; - function disableFormsUpdate(formIds: Array): Promise; - - /** - * Check form manager service ready. - * - *

You can use this method to check if form manager service is ready.

- * - * @return Returns {@code true} form manager service ready; returns {@code false} otherwise. - * @since 7 - */ - function checkFMSReady(callback: AsyncCallback): void; - function checkFMSReady(): Promise; - - /** - * Cast temp form to narmal form. - * - *

You can use this method to cast a temp form to normal form.

- * - * @param formId the specify form id to be casted. - * @since 7 - */ - function castTempForm(formId: number, callback: AsyncCallback): void; - function castTempForm(formId: number): Promise; - - /** - * Checks for and deletes invalid forms of the application in the Form Manager Service based on the list of valid - * form IDs passed. - * - *

If an empty list is passed to this method, the Form Manager Service will delete all forms of the - * application.

- * - * @param persistedIds Indicates the list of valid forms with persisted IDs. - * @since 7 - */ - function checkAndDeleteInvalidForms(persistedIds: Array, callback: AsyncCallback): void; - function checkAndDeleteInvalidForms(persistedIds: Array): Promise; - - /** - * Updates the content of a specified JS form. - * - *

This method is called by a form provider to update JS form data as needed. - * - * @param formId Indicates the ID of the JS form to update. - * @param formBindingData Indicates the object used to update the JS form displayed - * on the client. - * @return Returns {@code true} if the update is successful; returns {@code false} otherwise. - * @throws FormException Throws this exception if the form fails to be obtained due to any of the following reasons: - *

    - *
  • The passed {@code formID} or {@code component} is invalid. The value of {@code formID} must be larger than 0, - * and {@code component} must not be null.
  • - *
  • An error occurred when connecting to the Form Manager Service.
  • - *
  • The specified form ID does not exist.
  • - *
  • The form has been obtained by another application and cannot be updated by the current application.
  • - *
  • The form is being restored.
  • - *
- * @since 7 - */ - function updateForm(formid: number, data: FormBindingData, callback: AsyncCallback): void; - function updateForm(formid: number, data: FormBindingData): Promise; - - /** - * Set next refresh time since now. - * - *

This method is called by a form provider to set refresh time. - * - * @param formId Indicates the ID of the form to set refreshTime. - * @param bundleName Indicates the bundleName of current form. - * @param nextTime Indicates the next time gap now in seconds, can not be litter than 5 mins. - * @return Returns {@code true} if seting succeed; returns {@code false} otherwise. - * @throws FormException Throws this exception if the form fails to be obtained due to any of the following reasons: - *

    - *
  • The passed {@code formId} or {@code nextTime} is invalid. The value of {@code formId} must be larger - * than 0, and {@code nextTime} must at least be 120 (5min).
  • - *
  • An error occurred when connecting to the Form Manager Service.
  • - *
  • The specified form ID does not exist.
  • - *
  • The form has been obtained by another application and cannot be updated by the current application.
  • - *
  • The form is being restored.
  • - *
- * @since 7 - */ - function setFormNextRefreshTime(formid: number, nextTime: number, callback: AsyncCallback): boolean; - function setFormNextRefreshTime(formid: number, nextTime: number): Promise; - - /** - * get all forms info. - * - *

You can use this method to get all forms info.

- * - * @return Returns the forms' information of all forms provided - * @since 7 - */ - function getAllFormsInfo(callback: AsyncCallback>): void; - function getAllFormsInfo(): Promise>; - - /** - * get forms info by application name. - * - *

You can use this method to get all forms info of the specify application name.

- * - * @param bundleName application name. - * @return Returns the forms' information of the specify application name. - * @since 7 - */ - function getFormsInfoByApp(bundleName: string, callback: AsyncCallback): void; - function getFormsInfoByApp(bundleName: string): Promise; - - /** - * get forms info by application name and module name. - * - *

You can use this method to get all forms info of the specify application name and module name.

- * - * @param bundleName application name. - * @param moduleName module name of hap - * @return Returns the forms' information of the specify application name and module name - * @since 7 - */ - function getFormsInfoByModule(bundleName: string, moduleName: string, callback: AsyncCallback): void; - function getFormsInfoByModule(bundleName: string, moduleName: string): Promise; - - on(type: "formUninstalled", formID: number, callback: AsyncCallback): void; - off(type: "formUninstalled", formID: number, callback?: AsyncCallback): void; - - on(type: "getAnimation", callback: AsyncCallback): void; - off(type: "getAnimation", callback?: AsyncCallback): void; - - export enum FromParam { - /** - * Indicates the key specifying the ID of the form to be obtained, which is represented as - * {@code intent.setParam(PARAM_FORM_IDENTITY_KEY, 1L)}. - */ - IDENTITY_KEY = "ohos.extra.param.key.form_identity", - /** - * Indicates the form dimension, now value support 1,2,3,4. - */ - DIMENSION_KEY = "ohos.extra.param.key.form_dimension", - /** - * Indicates the form name. - */ - NAME_KEY = "ohos.extra.param.key.form_name", - /** - * Indicates the module name of the form. - */ - NAME_KEY = "ohos.extra.param.key.module_name", - /** - * Indicates the form view width. - */ - WIDTH_KEY = "ohos.extra.param.key.form_width", - /** - * Indicates the form view height. - */ - HEIGHT_KEY = "ohos.extra.param.key.form_height", - /** - * Indicates the temporary flag of form to be obtained - */ - TEMPORARY_KEY = "ohos.extra.param.key.form_temporary" - } - - export enum FormError { - ERR_CODE_COMMON = 1, - ERR_PERMISSION_DENY = 2, - ERR_GET_INFO_FAILED = 4, - ERR_GET_BUNDLE_FAILED = 5, - ERR_GET_LAYOUT_FAILED = 6, - ERR_ADD_INVALID_PARAM = 7, - ERR_CFG_NOT_MATCH_ID = 8, - ERR_NOT_EXIST_ID = 9, - ERR_BIND_PROVIDER_FAILED = 10, - ERR_MAX_SYSTEM_FORMS = 11, - ERR_MAX_INSTANCES_PER_FORM = 12, - ERR_OPERATION_FORM_NOT_SELF = 13, - ERR_PROVIDER_DEL_FAIL = 14, - ERR_MAX_FORMS_PER_CLIENT = 15, - ERR_MAX_SYSTEM_TEMP_FORMS = 16, - ERR_FORM_NO_SUCH_MODULE = 17, - ERR_FORM_NO_SUCH_ABILITY = 18, - ERR_FORM_NO_SUCH_DIMENSION = 19, - ERR_FORM_FA_NOT_INSTALLED = 20, - - // error code in sdk - ERR_GET_FMS_RPC = 30, - ERR_FORM_DUPLICATE_ADDED = 31, - ERR_SEND_FMS_MSG = 32, - ERR_GET_BMS_RPC = 33, - ERR_SEND_BMS_MSG = 34, - ERR_START_ABILITY = 35, - ERR_IN_RECOVER = 36 - } -} -export default formManager; \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/abilityManager/BUILD.gn b/interfaces/kits/napi/aafwk/abilityManager/BUILD.gn index e3ffbec7e5dc8539269c964886f5f8edaf1c220b..37e7973e84402a8286c460dc23115573ff4c2e19 100644 --- a/interfaces/kits/napi/aafwk/abilityManager/BUILD.gn +++ b/interfaces/kits/napi/aafwk/abilityManager/BUILD.gn @@ -18,6 +18,7 @@ ohos_shared_library("abilitymanager") { "//foundation/ace/napi/interfaces/kits", "//third_party/node/src", "//foundation/aafwk/standard/services/common/include", + "//foundation/multimedia/image_standard/interfaces/kits/js/common/include/", "//utils/system/safwk/native/include", "./", ] @@ -26,6 +27,7 @@ ohos_shared_library("abilitymanager") { "napi_ability_manager.cpp", "native_module.cpp", ] + ldflags = [ "-Wl,-rpath=/system/lib/module/multimedia/" ] deps = [ "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", diff --git a/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp b/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp index 8b47222bacd87136205252bed1624196fff99a2d..653888abc7482ff5b340f716a44c9347a4f81109 100644 --- a/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp +++ b/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.cpp @@ -293,6 +293,39 @@ int32_t RemoveMissionsForResult(const std::vector &missionIds) return error; } +void GetMissionSnapshotInfoForResult(napi_env env, MissionSnapshot &recentMissionInfos, napi_value result) +{ + HILOG_INFO("%{public}s,%{public}d", __PRETTY_FUNCTION__, __LINE__); + napi_value objTopAbilityInfo; + NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &objTopAbilityInfo)); + napi_value deviceId; + NAPI_CALL_RETURN_VOID(env, + napi_create_string_utf8(env, recentMissionInfos.topAbility.GetDeviceID().c_str(), NAPI_AUTO_LENGTH, &deviceId)); + HILOG_INFO("deviceId = [%{public}s]", recentMissionInfos.topAbility.GetDeviceID().c_str()); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objTopAbilityInfo, "deviceId", deviceId)); + napi_value bundleName; + NAPI_CALL_RETURN_VOID(env, + napi_create_string_utf8( + env, recentMissionInfos.topAbility.GetBundleName().c_str(), NAPI_AUTO_LENGTH, &bundleName)); + HILOG_INFO("bundleName = [%{public}s]", recentMissionInfos.topAbility.GetBundleName().c_str()); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objTopAbilityInfo, "bundleName", bundleName)); + napi_value abilityName; + NAPI_CALL_RETURN_VOID(env, + napi_create_string_utf8( + env, recentMissionInfos.topAbility.GetAbilityName().c_str(), NAPI_AUTO_LENGTH, &abilityName)); + HILOG_INFO("abilityName = [%{public}s]", recentMissionInfos.topAbility.GetAbilityName().c_str()); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objTopAbilityInfo, "abilityName", abilityName)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "topAbility", objTopAbilityInfo)); + + if (recentMissionInfos.snapshot) { + napi_value iconResult = nullptr; + iconResult = Media::PixelMapNapi::CreatePixelMap(env, recentMissionInfos.snapshot); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "snapshot", iconResult)); + }else{ + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "snapshot", NapiGetNull(env))); + } +} + auto NAPI_QueryRecentAbilityMissionInfosAsyncExecuteCallback = [](napi_env env, void *data) { HILOG_INFO("queryRecentAbilityMissionInfos called(CallBack Mode)..."); AsyncMissionInfosCallbackInfo *async_callback_info = (AsyncMissionInfosCallbackInfo *)data; @@ -1814,6 +1847,130 @@ napi_value NAPI_ClearUpApplicationData(napi_env env, napi_callback_info info) return ((callBackMode) ? (nullptr) : (ret)); } +auto NAPI_GetAbilityMissionSnapshotAsyncExecute = [](napi_env env, void *data) { + HILOG_INFO("GetAbilityMissionSnapshotWrap called..."); + AsyncGetMissionSnapshot *async_callback_info = (AsyncGetMissionSnapshot *)data; + AAFwk::AbilityManagerClient::GetInstance()->GetMissionSnapshot(async_callback_info->missionId, + async_callback_info->missionSnapshot); +}; + +auto NAPI_GetAbilityMissionSnapshotAsyncCompleteCallback = [](napi_env env, napi_status status, void *data) { + HILOG_INFO("GetAbilityMissionSnapshotWrap compeleted(CallBack Mode)..."); + AsyncGetMissionSnapshot *async_callback_info = (AsyncGetMissionSnapshot *)data; + napi_value result[2] = {0}; + napi_value callback; + napi_value undefined; + napi_value callResult = 0; + + result[0] = GetCallbackErrorValue(async_callback_info->env, NapiAbilityMgr::BUSINESS_ERROR_CODE_OK); + napi_create_object(async_callback_info->env, &result[1]); + GetMissionSnapshotInfoForResult( + async_callback_info->env, async_callback_info->missionSnapshot, result[1]); + napi_get_undefined(env, &undefined); + + napi_get_reference_value(env, async_callback_info->callback[0], &callback); + napi_call_function(env, undefined, callback, 2, &result[0], &callResult); + if (async_callback_info->callback[0] != nullptr) { + napi_delete_reference(env, async_callback_info->callback[0]); + } + napi_delete_async_work(env, async_callback_info->asyncWork); + delete async_callback_info; +}; + +auto NAPI_GetAbilityMissionSnapshotPromiseCompleteCallback = [](napi_env env, napi_status status, void *data) { + HILOG_INFO("GetAbilityMissionSnapshotWrap compeleted(Promise Mode)..."); + AsyncGetMissionSnapshot *async_callback_info = (AsyncGetMissionSnapshot *)data; + napi_value result; + napi_create_object(async_callback_info->env, &result); + GetMissionSnapshotInfoForResult(async_callback_info->env, async_callback_info->missionSnapshot, result); + napi_resolve_deferred(async_callback_info->env, async_callback_info->deferred, result); + napi_delete_async_work(env, async_callback_info->asyncWork); + delete async_callback_info; +}; + +napi_value NAPI_GetAbilityMissionSnapshotWrap( + napi_env env, napi_callback_info info, bool callBackMode, AsyncGetMissionSnapshot *async_callback_info) +{ + HILOG_INFO("NAPI_GetAbilityMissionSnapshotWrap called..."); + if (callBackMode) { + napi_value resourceName; + napi_create_string_latin1(env, "NAPI_GetAbilityMissionSnapshotWrap", NAPI_AUTO_LENGTH, &resourceName); + + napi_create_async_work(env, + nullptr, + resourceName, + NAPI_GetAbilityMissionSnapshotAsyncExecute, + NAPI_GetAbilityMissionSnapshotAsyncCompleteCallback, + (void *)async_callback_info, + &async_callback_info->asyncWork); + + NAPI_CALL(env, napi_queue_async_work(env, async_callback_info->asyncWork)); + // create reutrn + napi_value ret = 0; + NAPI_CALL(env, napi_create_int32(env, 0, &ret)); + return ret; + } else { + napi_value resourceName; + napi_create_string_latin1(env, "NAPI_GetAbilityMissionSnapshotWrap", NAPI_AUTO_LENGTH, &resourceName); + + napi_deferred deferred; + napi_value promise; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + async_callback_info->deferred = deferred; + + napi_create_async_work(env, + nullptr, + resourceName, + NAPI_GetAbilityMissionSnapshotAsyncExecute, + NAPI_GetAbilityMissionSnapshotPromiseCompleteCallback, + (void *)async_callback_info, + &async_callback_info->asyncWork); + napi_queue_async_work(env, async_callback_info->asyncWork); + return promise; + } +} + +napi_value NAPI_GetAbilityMissionSnapshot(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value argv[argc]; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); + HILOG_INFO("argc = [%{public}d]", argc); + + napi_valuetype valuetype0; + NAPI_CALL(env, napi_typeof(env, argv[0], &valuetype0)); + NAPI_ASSERT(env, valuetype0 == napi_number, "Wrong argument type. Numbers expected."); + int32_t missionId; + NAPI_CALL(env, napi_get_value_int32(env, argv[0], &missionId)); + + bool callBackMode = false; + if (argc >= 2) { + napi_valuetype valuetype; + NAPI_CALL(env, napi_typeof(env, argv[1], &valuetype)); + NAPI_ASSERT(env, valuetype == napi_function, "Wrong argument type. Function expected."); + callBackMode = true; + } + + AsyncGetMissionSnapshot *async_callback_info = + new (std::nothrow) AsyncGetMissionSnapshot{.env = env, .asyncWork = nullptr, .deferred = nullptr}; + if (async_callback_info == nullptr) { + return NapiGetNull(env); + } + + async_callback_info->missionId = missionId; + if (callBackMode) { + napi_create_reference(env, argv[1], 1, &async_callback_info->callback[0]); + } + + napi_value ret = NAPI_GetAbilityMissionSnapshotWrap(env, info, callBackMode, async_callback_info); + if (ret == nullptr) { + delete async_callback_info; + async_callback_info = nullptr; + } + + return ((callBackMode) ? (NapiGetNull(env)) : (ret)); +} + void CreateWeightReasonCodeObject(napi_env env, napi_value value) { napi_value nUnknow = nullptr; @@ -1868,6 +2025,13 @@ napi_value GetCallbackErrorValue(napi_env env, int errCode) return result; } +napi_value NapiGetNull(napi_env env) +{ + napi_value result = 0; + napi_get_null(env, &result); + return result; +} + static napi_value SystemMemoryAttrConvertJSObject(napi_env env, const SystemMemoryAttr &memoryInfo) { napi_value retJsObject = nullptr; diff --git a/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.h b/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.h index 12fd1aad0c67244b9f85a56d398a14e24603836d..c4c8b11ad11ba5538d2a10b36a1e42d8e06d73f1 100644 --- a/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.h +++ b/interfaces/kits/napi/aafwk/abilityManager/napi_ability_manager.h @@ -21,11 +21,16 @@ #include "ability_mission_info.h" #include "napi/native_common.h" #include "napi/native_node_api.h" +#include "pixel_map_napi.h" +#include "ability_manager_client.h" #include "running_process_info.h" #include "system_memory_attr.h" +#include "ability_mission_info.h" +#include "mission_snapshot.h" using RunningProcessInfo = OHOS::AppExecFwk::RunningProcessInfo; using AbilityMissionInfo = OHOS::AAFwk::AbilityMissionInfo; +using MissionSnapshot = OHOS::AAFwk::MissionSnapshot; namespace OHOS { namespace AppExecFwk { @@ -121,6 +126,15 @@ struct AsyncPreviousMissionInfosCallbackInfo { std::vector previousMissionInfo; }; +struct AsyncGetMissionSnapshot { + napi_env env; + napi_async_work asyncWork; + napi_deferred deferred; + napi_ref callback[2] = {0}; + int32_t missionId = -1; + MissionSnapshot missionSnapshot; +}; + struct SystemMemroyInfoCB { std::shared_ptr info = nullptr; napi_async_work asyncWork = nullptr; @@ -140,8 +154,10 @@ napi_value NAPI_ClearMissions(napi_env env, napi_callback_info info); napi_value NAPI_MoveMissionToTop(napi_env env, napi_callback_info info); napi_value NAPI_KillProcessesByBundleName(napi_env env, napi_callback_info info); napi_value NAPI_ClearUpApplicationData(napi_env env, napi_callback_info info); +napi_value NAPI_GetAbilityMissionSnapshot(napi_env env, napi_callback_info info); void CreateWeightReasonCodeObject(napi_env env, napi_value value); napi_value GetCallbackErrorValue(napi_env env, int errCode); +napi_value NapiGetNull(napi_env env); napi_value NAPI_GetSystemMemoryAttr(napi_env env, napi_callback_info); } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp b/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp index 7d1d07e5ff553b9bf84ea629dcdcbdfc8652dc79..0a458fc94ae189594fc93e0b686999235506afac 100644 --- a/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp +++ b/interfaces/kits/napi/aafwk/abilityManager/native_module.cpp @@ -52,6 +52,7 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("moveMissionToTop", NAPI_MoveMissionToTop), DECLARE_NAPI_FUNCTION("killProcessesByBundleName", NAPI_KillProcessesByBundleName), DECLARE_NAPI_FUNCTION("clearUpApplicationData", NAPI_ClearUpApplicationData), + DECLARE_NAPI_FUNCTION("getAbilityMissionSnapshot", NAPI_GetAbilityMissionSnapshot), DECLARE_NAPI_PROPERTY("WeightReasonCode", nWeightReasonCode), DECLARE_NAPI_FUNCTION("getSystemMemoryAttr", NAPI_GetSystemMemoryAttr), }; diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 64949d2585ceb1200b8a14372a95fcbf61ed0ca8..eefb631469e756e891a017353f1de6264c43f7e0 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -48,10 +48,13 @@ config("abilityms_config") { "//prebuilts/jdk/jdk8/linux-x86/include/linux", "//third_party/json/include", "//foundation/aafwk/standard/frameworks/kits/ability/native/include", + "//foundation/graphic/standard/interfaces/innerkits", + "//foundation/multimedia/image_standard/interfaces/innerkits/include", "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_rdb/include", "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_appdatafwk/include", "//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_dataability/include", "//foundation/aafwk/standard/interfaces/innerkits/dataobs_manager/include", + "//foundation/graphic/standard/interfaces/innerkits/wmservice", "//base/global/i18n_standard/frameworks/intl/include", "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", "//base/hiviewdfx/hiview/adapter/utility/include", @@ -67,7 +70,6 @@ ohos_shared_library("abilityms") { sources += [ "${services_path}/abilitymgr/src/sa_mgr_client.cpp" ] configs = [ ":abilityms_config" ] - deps = [ "${innerkits_path}/base:base", "${innerkits_path}/want:want", @@ -98,7 +100,10 @@ ohos_shared_library("abilityms") { "ipc:ipc_core", ] - public_deps = [ "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr:distributedschedsvr" ] + public_deps = [ + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr:distributedschedsvr", + "//foundation/graphic/standard:libwmservice", + ] subsystem_name = "aafwk" part_name = "aafwk_standard" diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index 8f2770062e2830ce911e2b1f4f232adbfb812b45..6bfd32c14d4fb3b0c0731837d63c7cbdc4310020 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -31,6 +31,7 @@ abilityms_files = [ "${services_path}/abilitymgr/src/data_ability_manager.cpp", "${services_path}/abilitymgr/src/data_ability_record.cpp", "${services_path}/abilitymgr/src/launch_param.cpp", + "${services_path}/abilitymgr/src/image_info.cpp", "${services_path}/abilitymgr/src/lifecycle_deal.cpp", "${services_path}/abilitymgr/src/mission_record.cpp", "${services_path}/abilitymgr/src/mission_stack.cpp", @@ -42,9 +43,7 @@ abilityms_files = [ "${services_path}/abilitymgr/src/ability_record_info.cpp", "${services_path}/abilitymgr/src/ability_mission_info.cpp", "${services_path}/abilitymgr/src/mission_description_info.cpp", - "${services_path}/abilitymgr/src/image_info.cpp", - "${services_path}/abilitymgr/src/mission_snapshot_info.cpp", - "${services_path}/abilitymgr/src/kernal_ability_manager.cpp", + "${services_path}/abilitymgr/src/mission_snapshot.cpp", "${services_path}/abilitymgr/src/kernal_system_app_manager.cpp", "${services_path}/abilitymgr/src/caller_info.cpp", "${services_path}/abilitymgr/src/sender_info.cpp", @@ -63,7 +62,10 @@ abilityms_files = [ "${services_path}/abilitymgr/src/ability_start_setting.cpp", "${services_path}/abilitymgr/src/mission_option.cpp", "${services_path}/abilitymgr/src/stack_setting.cpp", + "${services_path}/abilitymgr/src/shared_memory.cpp", "${services_path}/abilitymgr/src/resume_mission_container.cpp", + "${services_path}/abilitymgr/src/screenshot_handler.cpp", + "${services_path}/abilitymgr/src/screenshot_response.cpp", "${services_path}/abilitymgr/src/ams_configuration_parameter.cpp", "${services_path}/abilitymgr/src/mission_index_info.cpp", @@ -81,7 +83,7 @@ abilityms_files = [ "${services_path}/abilitymgr/src/mission_listener_stub.cpp", "${services_path}/abilitymgr/src/mission_list_manager.cpp", "${services_path}/abilitymgr/src/mission_list.cpp", - "${services_path}/abilitymgr/src/mission_snapshot.cpp", "${services_path}/abilitymgr/src/task_data_persistence_mgr.cpp", "${services_path}/abilitymgr/src/start_options.cpp", + "${services_path}/abilitymgr/src/kernal_ability_manager.cpp", ] diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 16d2cb480757a169c7c6f1e4428490bba86744c9..ee5d9280300ae581d8401b83135c61472d8401a1 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -257,7 +257,7 @@ public: * @param missionId the id of the mission to retrieve the sAutoapshots * @return Returns ERR_OK on success, others on failure. */ - virtual int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) override; + virtual int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) override; /** * Ask that the mission associated with a given mission ID be moved to the @@ -471,6 +471,7 @@ public: virtual int GetPendingRequestWant(const sptr &target, std::shared_ptr &want) override; + virtual int GetWantSenderInfo(const sptr &target, std::shared_ptr &info) override; /** * set lock screen white list * diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index e09f10193e76d2a3fdca38185e22c2700f466cc2..78dfd75dc9147f57ef3c95b09d5c01f942026f20 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -326,7 +326,7 @@ public: * @param missionId the id of the mission to retrieve the sAutoapshots * @return Returns ERR_OK on success, others on failure. */ - virtual int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) override; + virtual int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) override; /** * Ask that the mission associated with a given mission ID be moved to the @@ -553,6 +553,8 @@ public: virtual int GetPendingRequestWant(const sptr &target, std::shared_ptr &want) override; + virtual int GetWantSenderInfo(const sptr &target, std::shared_ptr &info) override; + /** * set lock screen white list * diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 758129a4b87fa3d7f471d1b228705a4673ed26c8..13ed51dd0ea3aa639e9e24da24ed48ee11ba7997 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -100,6 +100,7 @@ private: int UnregisterCancelListenerInner(MessageParcel &data, MessageParcel &reply); int GetPendingRequestWantInner(MessageParcel &data, MessageParcel &reply); + int GetWantSenderInfoInner(MessageParcel &data, MessageParcel &reply); int SetShowOnLockScreenInner(MessageParcel &data, MessageParcel &reply); int GetSystemMemoryAttrInner(MessageParcel &data, MessageParcel &reply); diff --git a/services/abilitymgr/include/ability_stack_manager.h b/services/abilitymgr/include/ability_stack_manager.h index ab379a2f85a6c92c363870037218dbafc8ea5d7f..3e4ef96cc0018a2d7e2a5ea4d192eb6029e69e9f 100644 --- a/services/abilitymgr/include/ability_stack_manager.h +++ b/services/abilitymgr/include/ability_stack_manager.h @@ -26,6 +26,7 @@ #include "ability_record.h" #include "application_info.h" #include "mission_record.h" +#include "mission_snapshot.h" #include "mission_stack.h" #include "mission_index_info.h" #include "mission_option.h" @@ -37,6 +38,7 @@ #include "stack_info.h" #include "power_storage.h" #include "want.h" +#include "screenshot_handler.h" namespace OHOS { namespace AAFwk { @@ -431,12 +433,8 @@ public: void RestartAbility(const std::shared_ptr abilityRecord); - /** - * set lock screen white list - * - * @param isAllow whether to allow startup on lock screen. - * @return Returns ERR_OK on success, others on failure. - */ + int GetMissionSnapshot(int32_t missionId, MissionPixelMap &missionPixelMap); + int SetShowOnLockScreen(const std::string &bundleName, bool isAllow); void UpdateLockScreenState(bool isLockScreen); private: @@ -791,6 +789,7 @@ private: std::map> focusAbilityRecordMap_; // abilities has been focused , // key : display id, value: focused ability std::shared_ptr resumeMissionContainer_; + std::shared_ptr screenshotHandler_; static int64_t splitScreenStackId; const static std::map windowModeToStrMap_; std::shared_ptr subscriber_ = nullptr; diff --git a/services/abilitymgr/include/pending_want_manager.h b/services/abilitymgr/include/pending_want_manager.h index 64ae7dd6a22628bef96f38d05a06a715f9caaadb..8a21726b4b2ac3d2cdd8a2bf6702e6c54b7fb62d 100644 --- a/services/abilitymgr/include/pending_want_manager.h +++ b/services/abilitymgr/include/pending_want_manager.h @@ -146,6 +146,7 @@ public: void RegisterCancelListener(const sptr &sender, const sptr &recevier); void UnregisterCancelListener(const sptr &sender, const sptr &recevier); int32_t GetPendingRequestWant(const sptr &target, std::shared_ptr &want); + int32_t GetWantSenderInfo(const sptr &target, std::shared_ptr &info); void CancelWantSenderLocked(PendingWantRecord &record, bool cleanAbility); int32_t PendingWantStartAbility( diff --git a/services/abilitymgr/include/screenshot_handler.h b/services/abilitymgr/include/screenshot_handler.h new file mode 100644 index 0000000000000000000000000000000000000000..5f40b5cb351232605b1dcd032f390f9a068d7af2 --- /dev/null +++ b/services/abilitymgr/include/screenshot_handler.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_SCREEN_SHOT_HANDLER_H +#define OHOS_AAFWK_SCREEN_SHOT_HANDLER_H + +#include +#include +#include +#include +#include "nocopyable.h" +#include "screenshot_response.h" +#include "window_manager_service_client.h" + +namespace OHOS { +namespace AAFwk { +class ScreenshotHandler { +public: + ScreenshotHandler(); + virtual ~ScreenshotHandler() = default; + + void StartScreenshot(int32_t missionId, int32_t winId); + WMImageInfo GetImageInfo(int32_t missionId); + void RemoveImageInfo(int32_t missionId); + +private: + std::map screenShot_; + sptr windowMS_; +}; +} // namespace AAFwk +} // namespace OHOS + +#endif // OHOS_AAFWK_SCREEN_SHOT_HANDLER_H diff --git a/interfaces/innerkits/ability_manager/include/mission_snapshot_info.h b/services/abilitymgr/include/screenshot_response.h similarity index 53% rename from interfaces/innerkits/ability_manager/include/mission_snapshot_info.h rename to services/abilitymgr/include/screenshot_response.h index e9c310c50bd2b57089d6c62694bb435990dc6f1b..10a58b95d56f05e9cbb50bc0defb96b07ac19de8 100644 --- a/interfaces/innerkits/ability_manager/include/mission_snapshot_info.h +++ b/services/abilitymgr/include/screenshot_response.h @@ -13,27 +13,34 @@ * limitations under the License. */ -#ifndef OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_INFO_H -#define OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_INFO_H +#ifndef OHOS_AAFWK_SCREEN_SHOT_RESPONSE_H +#define OHOS_AAFWK_SCREEN_SHOT_RESPONSE_H +#include +#include +#include #include - -#include "image_info.h" -#include "parcel.h" +#include "nocopyable.h" +#include +#include "wm_common.h" namespace OHOS { namespace AAFwk { -/** - * @struct MissionSnapshotInfo - * MissionSnapshotInfo is used to save informations about mission sanpshot. - */ -struct MissionSnapshotInfo : public Parcelable { - ImageInfo snapshot; +class ScreenShotResponse { +public: + ScreenShotResponse() = default; + virtual ~ScreenShotResponse() = default; - bool ReadFromParcel(Parcel &parcel); - virtual bool Marshalling(Parcel &parcel) const override; - static MissionSnapshotInfo *Unmarshalling(Parcel &parcel); + void OnWindowShot(const struct WMImageInfo &info); + WMImageInfo GetImageInfo(); + +private: + static constexpr int TIME_OUT = 200 * 1000; + std::mutex mutex_; + std::condition_variable condition_; + std::shared_ptr info_; }; } // namespace AAFwk } // namespace OHOS -#endif // OHOS_AAFWK_INTERFACES_INNERKITS_MISSION_SNAPSHOT_INFO_H \ No newline at end of file + +#endif // OHOS_AAFWK_SCREEN_SHOT_RESPONSE_H diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index c0fa2eddd7e49d88982b1c151b7b240f7d3f8b79..a31d208cab1e1476dbf8324ca907d1a7b47b741f 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -15,6 +15,7 @@ #include "ability_manager_client.h" +#include "string_ex.h" #include "ability_manager_interface.h" #include "hilog_wrapper.h" #include "if_system_ability_manager.h" @@ -22,6 +23,7 @@ #include "iservice_registry.h" #include "string_ex.h" #include "system_ability_definition.h" +#include "shared_memory.h" namespace OHOS { namespace AAFwk { @@ -244,11 +246,41 @@ ErrCode AbilityManagerClient::GetRecentMissions( return abms->GetRecentMissions(numMax, flags, recentList); } -ErrCode AbilityManagerClient::GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) +ErrCode AbilityManagerClient::GetMissionSnapshot(const int32_t missionId, MissionSnapshot &missionSnapshot) { CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); sptr abms = iface_cast(remoteObject_); - return abms->GetMissionSnapshot(missionId, snapshot); + MissionPixelMap missionPixelMap; + int ret = abms->GetMissionSnapshot(missionId, missionPixelMap); + if (ret == ERR_OK) { + HILOG_INFO("missionPixelMap.imageInfo.shmKey: %{public}d", missionPixelMap.imageInfo.shmKey); + if (0 == missionPixelMap.imageInfo.size) { + HILOG_INFO("size is 0."); + return -1; + } + void *data = SharedMemory::PopSharedMemory(missionPixelMap.imageInfo.shmKey, missionPixelMap.imageInfo.size); + if (!data) { + HILOG_INFO("SharedMemory::PopSharedMemory return value is nullptr."); + return -1; + } + Media::InitializationOptions mediaOption; + mediaOption.size.width = missionPixelMap.imageInfo.width; + mediaOption.size.height = missionPixelMap.imageInfo.height; + mediaOption.pixelFormat = Media::PixelFormat::BGRA_8888; + mediaOption.editable = true; + auto pixel = + Media::PixelMap::Create((const uint32_t *)data, missionPixelMap.imageInfo.size / sizeof(uint32_t), mediaOption); + if (!pixel) { + HILOG_INFO(" Media::PixelMap::Create return value is nullptr."); + return -1; + } + HILOG_INFO("width = [%{public}d]", pixel->GetWidth()); + HILOG_INFO("height = [%{public}d]", pixel->GetHeight()); + HILOG_INFO("size = [%{public}d]", missionPixelMap.imageInfo.size); + missionSnapshot.topAbility = missionPixelMap.topAbility; + missionSnapshot.snapshot = std::move(pixel); + } + return ret; } ErrCode AbilityManagerClient::MoveMissionToTop(int32_t missionId) @@ -562,6 +594,21 @@ ErrCode AbilityManagerClient::GetPendingRequestWant(const sptr &tar return abms->GetPendingRequestWant(target, want); } +ErrCode AbilityManagerClient::GetWantSenderInfo(const sptr &target, std::shared_ptr &info) +{ + CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); + if (target == nullptr) { + HILOG_ERROR("target is nullptr."); + return ABILITY_SERVICE_NOT_CONNECTED; + } + if (info == nullptr) { + HILOG_ERROR("info is nullptr."); + return ABILITY_SERVICE_NOT_CONNECTED; + } + sptr abms = iface_cast(remoteObject_); + return abms->GetWantSenderInfo(target, info); +} + ErrCode AbilityManagerClient::SetShowOnLockScreen(bool isAllow) { CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED); diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 4e6e67b4ede4c3d08dd6faf20aa484ccdb529cef..60313aafca66e910049b2e9b4624917721416f77 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -15,6 +15,10 @@ #include "ability_manager_proxy.h" +#include +#include +#include + #include "errors.h" #include "string_ex.h" @@ -634,7 +638,7 @@ int AbilityManagerProxy::GetRecentMissions( return reply.ReadInt32(); } -int AbilityManagerProxy::GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) +int AbilityManagerProxy::GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { int error; MessageParcel data; @@ -653,12 +657,12 @@ int AbilityManagerProxy::GetMissionSnapshot(const int32_t missionId, MissionSnap HILOG_ERROR("Send request error: %{public}d", error); return error; } - std::unique_ptr info(reply.ReadParcelable()); + std::unique_ptr info(reply.ReadParcelable()); if (!info) { HILOG_ERROR("readParcelableInfo failed."); return ERR_UNKNOWN_OBJECT; } - snapshot = *info; + missionPixelMap = *info; return reply.ReadInt32(); } @@ -1416,6 +1420,37 @@ int AbilityManagerProxy::GetPendingRequestWant(const sptr &target, return NO_ERROR; } +int AbilityManagerProxy::GetWantSenderInfo(const sptr &target, std::shared_ptr &info) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + return INNER_ERR; + } + if (target == nullptr || !data.WriteParcelable(target->AsObject())) { + HILOG_ERROR("target write failed."); + return INNER_ERR; + } + if (info == nullptr || !data.WriteParcelable(info.get())) { + HILOG_ERROR("info write failed."); + return INNER_ERR; + } + auto error = Remote()->SendRequest(IAbilityManager::GET_PENDING_WANT_SENDER_INFO, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("Send request error: %{public}d", error); + return error; + } + std::unique_ptr wantSenderInfo(reply.ReadParcelable()); + if (!wantSenderInfo) { + HILOG_ERROR("readParcelable Info failed"); + return INNER_ERR; + } + info = std::move(wantSenderInfo); + + return NO_ERROR; +} + int AbilityManagerProxy::SetShowOnLockScreen(bool isAllow) { int error; @@ -1742,4 +1777,4 @@ int AbilityManagerProxy::MoveMissionToFront(int32_t missionId) return reply.ReadInt32(); } } // 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 333eabba0daf54e87e7c4899be0875a19a4b2ece..18f532650967faedc456ed53ee97eb37f7253e8a 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -598,9 +598,13 @@ int AbilityManagerService::GetRecentMissions( return currentStackManager_->GetRecentMissions(numMax, flags, recentList); } -int AbilityManagerService::GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) +int AbilityManagerService::GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { - return 0; + if (missionId < 0) { + HILOG_ERROR("GetMissionSnapshot failed."); + return ERR_INVALID_VALUE; + } + return currentStackManager_->GetMissionSnapshot(missionId, missionPixelMap); } int AbilityManagerService::SetMissionDescriptionInfo( @@ -2353,6 +2357,15 @@ bool AbilityManagerService::CheckCallerIsSystemAppByIpc() return bms->CheckIsSystemAppByUid(callerUid); } +int AbilityManagerService::GetWantSenderInfo(const sptr &target, std::shared_ptr &info) +{ + HILOG_INFO("Get pending request info."); + CHECK_POINTER_AND_RETURN(pendingWantManager_, ERR_INVALID_VALUE); + CHECK_POINTER_AND_RETURN(target, ERR_INVALID_VALUE); + CHECK_POINTER_AND_RETURN(info, ERR_INVALID_VALUE); + return pendingWantManager_->GetWantSenderInfo(target, info); +} + void AbilityManagerService::UpdateLockScreenState(bool isLockScreen) { HILOG_DEBUG("%{public}s begin", __func__); diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 155e1d0a26bafca82a15b91357d054b2e6234c6c..6b5b6ea239b511858972246e9237c0a317f6c26b 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -100,6 +100,7 @@ void AbilityManagerStub::SecondStepInit() requestFuncMap_[REGISTER_CANCEL_LISTENER] = &AbilityManagerStub::RegisterCancelListenerInner; requestFuncMap_[UNREGISTER_CANCEL_LISTENER] = &AbilityManagerStub::UnregisterCancelListenerInner; requestFuncMap_[GET_PENDING_REQUEST_WANT] = &AbilityManagerStub::GetPendingRequestWantInner; + requestFuncMap_[GET_PENDING_WANT_SENDER_INFO] = &AbilityManagerStub::GetPendingRequestWantInner; requestFuncMap_[SET_MISSION_INFO] = &AbilityManagerStub::SetMissionDescriptionInfoInner; requestFuncMap_[GET_MISSION_LOCK_MODE_STATE] = &AbilityManagerStub::GetMissionLockModeStateInner; requestFuncMap_[UPDATE_CONFIGURATION] = &AbilityManagerStub::UpdateConfigurationInner; @@ -290,10 +291,10 @@ int AbilityManagerStub::ScheduleCommandAbilityDoneInner(MessageParcel &data, Mes int AbilityManagerStub::GetMissionSnapshotInner(MessageParcel &data, MessageParcel &reply) { - MissionSnapshotInfo snapshot; + MissionPixelMap missionPixelMap; int32_t missionId = data.ReadInt32(); - int32_t result = GetMissionSnapshot(missionId, snapshot); - if (!reply.WriteParcelable(&snapshot)) { + int32_t result = GetMissionSnapshot(missionId, missionPixelMap); + if (!reply.WriteParcelable(&missionPixelMap)) { HILOG_ERROR("GetMissionSnapshot error"); return ERR_INVALID_VALUE; } @@ -864,6 +865,24 @@ int AbilityManagerStub::GetPendingRequestWantInner(MessageParcel &data, MessageP return NO_ERROR; } +int AbilityManagerStub::GetWantSenderInfoInner(MessageParcel &data, MessageParcel &reply) +{ + sptr wantSender = iface_cast(data.ReadParcelable()); + if (wantSender == nullptr) { + HILOG_ERROR("wantSender is nullptr"); + return ERR_INVALID_VALUE; + } + + std::shared_ptr info(data.ReadParcelable()); + int32_t result = GetWantSenderInfo(wantSender, info); + if (result != NO_ERROR) { + HILOG_ERROR("GetWantSenderInfo is failed"); + return ERR_INVALID_VALUE; + } + reply.WriteParcelable(info.get()); + return NO_ERROR; +} + int AbilityManagerStub::SetShowOnLockScreenInner(MessageParcel &data, MessageParcel &reply) { auto isAllow = data.ReadBool(); diff --git a/services/abilitymgr/src/ability_stack_manager.cpp b/services/abilitymgr/src/ability_stack_manager.cpp index 1b685326be9bde15db08c812edd2cf9b850bb825..c849d7f7139ad5252dc9fe471ea80f91f688bcf8 100644 --- a/services/abilitymgr/src/ability_stack_manager.cpp +++ b/services/abilitymgr/src/ability_stack_manager.cpp @@ -16,7 +16,10 @@ #include "ability_stack_manager.h" #include -#include +#include +#include +#include +#include #include "ability_manager_errors.h" #include "ability_manager_service.h" @@ -25,7 +28,7 @@ #include "bytrace.h" #include "common_event.h" #include "common_event_manager.h" -#include "hilog_wrapper.h" +#include "shared_memory.h" namespace OHOS { namespace AAFwk { @@ -49,6 +52,7 @@ void AbilityStackManager::Init() resumeMissionContainer_ = std::make_shared( DelayedSingleton::GetInstance()->GetEventHandler()); + screenshotHandler_ = std::make_shared(); powerStorage_ = std::make_shared(); if (!SubscribeEvent()) { HILOG_ERROR("SubscribeEvent Error."); @@ -4402,6 +4406,42 @@ void AbilityStackManager::CheckMissionRecordIsResume(const std::shared_ptr guard(stackLock_); + + auto missionRecord = GetMissionRecordFromAllStacks(missionId); + CHECK_POINTER_AND_RETURN_LOG(missionRecord, REMOVE_MISSION_ID_NOT_EXIST, "mission is invalid."); + auto topAbilityRecord = missionRecord->GetTopAbilityRecord(); + CHECK_POINTER_AND_RETURN_LOG(topAbilityRecord, REMOVE_MISSION_ID_NOT_EXIST, "top ability is invalid."); + auto windowInfo = topAbilityRecord->GetWindowInfo(); + int windowID = 0; + if(windowInfo){ + windowID = windowInfo->windowToken_; + HILOG_INFO("windowID is %{public}d", windowID); + } + screenshotHandler_->StartScreenshot(missionId, windowID); + auto topAbility = missionRecord->GetTopAbilityRecord(); + if (topAbility) { + OHOS::AppExecFwk::ElementName topElement(topAbility->GetAbilityInfo().deviceId, + topAbility->GetAbilityInfo().bundleName, + topAbility->GetAbilityInfo().name); + missionPixelMap.topAbility = topElement; + } + + auto imageInfo = screenshotHandler_->GetImageInfo(missionId); + screenshotHandler_->RemoveImageInfo(missionId); + HILOG_INFO("width : %{public}d, height: %{public}d", imageInfo.width, imageInfo.height); + missionPixelMap.imageInfo.width = imageInfo.width; + missionPixelMap.imageInfo.height = imageInfo.height; + missionPixelMap.imageInfo.format = imageInfo.format; + missionPixelMap.imageInfo.size = imageInfo.size; + missionPixelMap.imageInfo.shmKey = SharedMemory::PushSharedMemory(imageInfo.data, imageInfo.size); + return ERR_OK; +} + bool AbilityStackManager::IsLockScreenState() { HILOG_INFO("Is Lock Screen State."); diff --git a/services/abilitymgr/src/image_info.cpp b/services/abilitymgr/src/image_info.cpp index 7d6eb3b0a7eedecc744fc7ea440e3a34f413b3d2..350f00110829847178da24fbf064baafce0bcc64 100644 --- a/services/abilitymgr/src/image_info.cpp +++ b/services/abilitymgr/src/image_info.cpp @@ -21,41 +21,14 @@ namespace OHOS { namespace AAFwk { -bool ImageHeader::ReadFromParcel(Parcel &parcel) -{ - colorMode = parcel.ReadUint32(); - reserved = parcel.ReadUint32(); - width = parcel.ReadUint16(); - height = parcel.ReadUint16(); - return true; -} - -ImageHeader *ImageHeader::Unmarshalling(Parcel &parcel) -{ - ImageHeader *info = new (std::nothrow) ImageHeader(); - if (info == nullptr) { - return nullptr; - } - - if (!info->ReadFromParcel(parcel)) { - delete info; - info = nullptr; - } - return info; -} - -bool ImageHeader::Marshalling(Parcel &parcel) const -{ - parcel.WriteUint32(colorMode); - parcel.WriteUint32(reserved); - parcel.WriteUint16(width); - parcel.WriteUint16(height); - return true; -} - bool ImageInfo::ReadFromParcel(Parcel &parcel) { - return false; + parcel.ReadUint32(width); + parcel.ReadUint32(height); + parcel.ReadUint32(format); + parcel.ReadUint32(size); + parcel.ReadInt32(shmKey); + return true; } ImageInfo *ImageInfo::Unmarshalling(Parcel &parcel) @@ -74,7 +47,12 @@ ImageInfo *ImageInfo::Unmarshalling(Parcel &parcel) bool ImageInfo::Marshalling(Parcel &parcel) const { - return false; + parcel.WriteUint32(width); + parcel.WriteUint32(height); + parcel.WriteUint32(format); + parcel.WriteUint32(size); + parcel.WriteInt32(shmKey); + return true; } } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/mission_snapshot.cpp b/services/abilitymgr/src/mission_snapshot.cpp index 734b191d15e865fe122e21e4656839ddb67da4b6..1cb4cc918853ecf2dd85dfd87832c577220c1424 100644 --- a/services/abilitymgr/src/mission_snapshot.cpp +++ b/services/abilitymgr/src/mission_snapshot.cpp @@ -1,60 +1,64 @@ -/* - * 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 "mission_snapshot.h" - -#include "hilog_wrapper.h" -#include "nlohmann/json.hpp" -#include "string_ex.h" - -namespace OHOS { -namespace AAFwk { -bool MissionSnapshot::ReadFromParcel(Parcel &parcel) -{ - auto elementName = parcel.ReadParcelable(); - if (elementName == nullptr) { - return false; - } - ability = *elementName; - auto pixelMap = parcel.ReadParcelable(); - if (pixelMap == nullptr) { - return false; - } - snapshot = *pixelMap; - return true; -} - -MissionSnapshot *MissionSnapshot::Unmarshalling(Parcel &parcel) -{ - MissionSnapshot *info = new (std::nothrow) MissionSnapshot(); - if (info == nullptr) { - return nullptr; - } - - if (!info->ReadFromParcel(parcel)) { - delete info; - info = nullptr; - } - return info; -} - -bool MissionSnapshot::Marshalling(Parcel &parcel) const -{ - parcel.WriteParcelable(&ability); - parcel.WriteParcelable(&snapshot); - return true; -} -} // namespace AAFwk +/* + * 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 "mission_snapshot.h" + +#include "hilog_wrapper.h" +#include "nlohmann/json.hpp" +#include "string_ex.h" + +namespace OHOS { +namespace AAFwk { +bool MissionPixelMap::ReadFromParcel(Parcel &parcel) +{ + std::unique_ptr ability(parcel.ReadParcelable()); + if (ability == nullptr) { + return false; + } + topAbility = *ability; + std::unique_ptr image(parcel.ReadParcelable()); + if (ability == nullptr) { + return false; + } + imageInfo = *image; + return true; +} + +MissionPixelMap *MissionPixelMap::Unmarshalling(Parcel &parcel) +{ + MissionPixelMap *info = new (std::nothrow) MissionPixelMap(); + if (info == nullptr) { + return nullptr; + } + + if (!info->ReadFromParcel(parcel)) { + delete info; + info = nullptr; + } + return info; +} + +bool MissionPixelMap::Marshalling(Parcel &parcel) const +{ + if (!parcel.WriteParcelable(&topAbility)) { + return false; + } + if (!parcel.WriteParcelable(&imageInfo)) { + return false; + } + return true; +} +} // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/pending_want_manager.cpp b/services/abilitymgr/src/pending_want_manager.cpp index 85d2835d43358f1daddfb0e154ca1ff61dd0a7d0..256e8684f09d8b01c8adedb9fb2a211533481084 100644 --- a/services/abilitymgr/src/pending_want_manager.cpp +++ b/services/abilitymgr/src/pending_want_manager.cpp @@ -424,6 +424,33 @@ int32_t PendingWantManager::GetPendingRequestWant(const sptr &targe return NO_ERROR; } +int32_t PendingWantManager::GetWantSenderInfo(const sptr &target, std::shared_ptr &info) +{ + HILOG_INFO("%{public}s:begin.", __func__); + if (target == nullptr) { + HILOG_ERROR("%{public}s:target is nullptr.", __func__); + return ERR_INVALID_VALUE; + } + if (info == nullptr) { + HILOG_ERROR("%{public}s:info is nullptr.", __func__); + return ERR_INVALID_VALUE; + } + sptr targetRecord = iface_cast(target->AsObject()); + auto record = GetPendingWantRecordByCode(targetRecord->GetKey()->GetCode()); + if (record == nullptr) { + HILOG_ERROR("%{public}s:record is nullptr.", __func__); + return ERR_INVALID_VALUE; + } + WantSenderInfo wantSenderInfo; + wantSenderInfo.requestCode = record->GetKey()->GetRequestCode(); + wantSenderInfo.type = record->GetKey()->GetType(); + wantSenderInfo.flags = record->GetKey()->GetFlags(); + wantSenderInfo.allWants = record->GetKey()->GetAllWantsInfos(); + info.reset(new (std::nothrow) WantSenderInfo(wantSenderInfo)); + HILOG_ERROR("%{public}s:want is ok.", __func__); + return NO_ERROR; +} + void PendingWantManager::ClearPendingWantRecord(const std::string &bundleName) { HILOG_INFO("ClearPendingWantRecord, bundleName: %{public}s", bundleName.c_str()); diff --git a/services/abilitymgr/src/screenshot_handler.cpp b/services/abilitymgr/src/screenshot_handler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..350f342602ef747f2d75016a26e78777942ee6ac --- /dev/null +++ b/services/abilitymgr/src/screenshot_handler.cpp @@ -0,0 +1,98 @@ +/* + * 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 "screenshot_handler.h" +#include +#include +#include +#include "hilog_wrapper.h" + +namespace OHOS { +namespace AAFwk { + +ScreenshotHandler::ScreenshotHandler() +{ + auto wmsClient = WindowManagerServiceClient::GetInstance(); + if (wmsClient) { + HILOG_INFO("init window manager service."); + wmsClient->Init(); + windowMS_ = wmsClient->GetService(); + } +} + +void ScreenshotHandler::StartScreenshot(int32_t missionId, int32_t winId) +{ + HILOG_INFO("StartScreenshot"); + if (!windowMS_) { + HILOG_INFO("wms is nullptr."); + return; + } + auto response = std::make_shared(); + + auto promise = windowMS_->ShotWindow(winId); + if (!promise) { + HILOG_INFO("promise is nullptr."); + return; + } + + auto then = [response](const auto &wmsinfo) { + WMImageInfo wminfo = { + .wret = wmsinfo.wret, + .width = wmsinfo.width, + .height = wmsinfo.height, + .format = wmsinfo.format, + .size = wmsinfo.stride * wmsinfo.height, + .data = nullptr, + }; + + auto data = mmap(nullptr, wminfo.size, PROT_READ, MAP_SHARED, wmsinfo.fd, 0); + wminfo.data = data; + + response->OnWindowShot(wminfo); + + // 0xffffffff + uint8_t *errPtr = nullptr; + errPtr--; + if (data != errPtr) { + munmap(data, wminfo.size); + } + }; + promise->Then(then); + + auto imageInfo = response->GetImageInfo(); + screenShot_.emplace(missionId, imageInfo); +} + +WMImageInfo ScreenshotHandler::GetImageInfo(int32_t missionId) +{ + HILOG_DEBUG("%{public}s begin", __func__); + WMImageInfo imageInfo; + auto iter = screenShot_.find(missionId); + if (iter != screenShot_.end()) { + imageInfo = iter->second; + } + + return imageInfo; +} + +void ScreenshotHandler::RemoveImageInfo(int32_t missionId) +{ + HILOG_DEBUG("%{public}s begin", __func__); + screenShot_.erase(missionId); + HILOG_DEBUG("%{public}zu screenShot_ size", screenShot_.size()); +} + +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/mission_snapshot_info.cpp b/services/abilitymgr/src/screenshot_response.cpp similarity index 46% rename from services/abilitymgr/src/mission_snapshot_info.cpp rename to services/abilitymgr/src/screenshot_response.cpp index 676cb08b54423b4a9eecf0cee0922afb50ea7977..b1449277f3d28e0bd116b6869438e4b0854fcd63 100644 --- a/services/abilitymgr/src/mission_snapshot_info.cpp +++ b/services/abilitymgr/src/screenshot_response.cpp @@ -13,42 +13,44 @@ * limitations under the License. */ -#include "mission_snapshot_info.h" - +#include +#include +#include +#include #include "hilog_wrapper.h" -#include "nlohmann/json.hpp" -#include "string_ex.h" +#include "screenshot_response.h" namespace OHOS { namespace AAFwk { -bool MissionSnapshotInfo::ReadFromParcel(Parcel &parcel) + +void ScreenShotResponse::OnWindowShot(const struct WMImageInfo &info) { - std::unique_ptr image(parcel.ReadParcelable()); - if (image == nullptr) { - return false; + HILOG_INFO("On screen shot call back."); + std::unique_lock lock(mutex_); + info_ = std::make_shared(); + if (!info_) { + return; } - snapshot = *image; - return true; + info_->width = info.width; + info_->size = info.size; + info_->height = info.height; + info_->format = info.format; + info_->data = info.data; + condition_.notify_all(); } -MissionSnapshotInfo *MissionSnapshotInfo::Unmarshalling(Parcel &parcel) +WMImageInfo ScreenShotResponse::GetImageInfo() { - MissionSnapshotInfo *info = new (std::nothrow) MissionSnapshotInfo(); - if (info == nullptr) { - return nullptr; + std::unique_lock lock(mutex_); + if (info_ == nullptr) { + if (condition_.wait_for(lock, std::chrono::milliseconds(TIME_OUT)) == std::cv_status::timeout) { + return WMImageInfo(); + } } - if (!info->ReadFromParcel(parcel)) { - delete info; - info = nullptr; - } + WMImageInfo info = *info_; + info_.reset(); return info; } - -bool MissionSnapshotInfo::Marshalling(Parcel &parcel) const -{ - parcel.WriteParcelable(&snapshot); - return true; -} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/shared_memory.cpp b/services/abilitymgr/src/shared_memory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a40c04c192eb4b45f9cc1da87a3e6e150e0f194 --- /dev/null +++ b/services/abilitymgr/src/shared_memory.cpp @@ -0,0 +1,128 @@ +/* + * 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 "shared_memory.h" +#include +#include +#include +#include +#include "hilog_wrapper.h" +#include "securec.h" + +namespace OHOS { +namespace AAFwk { +namespace { +constexpr int SHM_KEY_START = 400000; // chosen randomly +constexpr int SHM_KEY_END = 500000; // chosen randomly +constexpr unsigned int SHM_READ_WRITE_PERMISSIONS = 0666U; + +#ifndef EOK +#define EOK (0) +#endif +} + +void SharedMemory::ReleaseShmId(const int shmId) +{ + if (shmId == -1) { + return; + } + if (shmctl(shmId, IPC_RMID, nullptr) == -1) { + HILOG_ERROR("shmctl IPC_RMID failed: %{public}d.", errno); + return; + } +} + +int SharedMemory::PushSharedMemory(const void *data, const int size) +{ + // internal call, no need to check null. + static int shmKey = SHM_KEY_START; + int shmId; + while ((shmId = shmget(shmKey, size, SHM_READ_WRITE_PERMISSIONS | IPC_CREAT | IPC_EXCL)) < 0) { + if (errno == EEXIST) { + ++shmKey; + if (shmKey >= SHM_KEY_END) { + shmKey = SHM_KEY_START; + } + continue; + } + HILOG_ERROR("shmget failed: %{public}d.", errno); + return -1; + } + HILOG_INFO("shmget succeed, shmKey = %{public}d, shmId = %{public}d.", shmKey, shmId); + + void *shared = shmat(shmId, nullptr, 0); + if (shared == reinterpret_cast(-1)) { + ReleaseShmId(shmId); + HILOG_ERROR("shmat failed: %{public}d.", errno); + return -1; + } + + int retCode; + if ((retCode = memcpy_s(shared, size, data, size)) != EOK) { + shmdt(shared); + ReleaseShmId(shmId); + HILOG_ERROR("memcpy_s failed: %{public}d.", retCode); + return -1; + } + + // memcpy(shared, data, size); + + if (shmdt(shared) == -1) { + ReleaseShmId(shmId); + HILOG_ERROR("shmdt failed: %{public}d.", errno); + return -1; + } + + return shmKey; +} + +void* SharedMemory::PopSharedMemory(int shmKey, int size) +{ + void *data = reinterpret_cast(malloc(size)); + int shmId = shmget(shmKey, 0, 0 | SHM_READ_WRITE_PERMISSIONS); + if (shmId == -1) { + HILOG_ERROR("shmId is invalid: %{public}d, %{public}d.", shmId, errno); + return nullptr; + } + + void *shared = shmat(shmId, nullptr, 0); + if (shared == reinterpret_cast(-1)) { + HILOG_ERROR("shmat failed %{public}d.", errno); + ReleaseShmId(shmId); + return nullptr; + } + + int retCode = memcpy_s(data, size, shared, size); + if (retCode != EOK) { + shmdt(shared); + ReleaseShmId(shmId); + HILOG_ERROR("Failed to memory copy, retCode[%{public}d].", retCode); + return nullptr; + } + // memcpy(data, shared, size); + + if (shmdt(shared) == -1) { + ReleaseShmId(shmId); + HILOG_ERROR("shmdt failed: %{public}d.", errno); + return nullptr; + } + + ReleaseShmId(shmId); + + return data; +} + +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/test/BUILD.gn b/services/abilitymgr/test/BUILD.gn index 1d7ce53a0a0d9335e40ca57424090e3954c6d018..4a4f35d50845785c11a8f71c1c1deb57731c8111 100644 --- a/services/abilitymgr/test/BUILD.gn +++ b/services/abilitymgr/test/BUILD.gn @@ -65,7 +65,6 @@ ohos_source_set("abilityms_test_source") { "${services_path}/abilitymgr/src/mission_record.cpp", "${services_path}/abilitymgr/src/mission_record_info.cpp", "${services_path}/abilitymgr/src/mission_snapshot.cpp", - "${services_path}/abilitymgr/src/mission_snapshot_info.cpp", "${services_path}/abilitymgr/src/mission_stack.cpp", "${services_path}/abilitymgr/src/mission_stack_info.cpp", "${services_path}/abilitymgr/src/pending_want_common_event.cpp", @@ -74,7 +73,10 @@ ohos_source_set("abilityms_test_source") { "${services_path}/abilitymgr/src/pending_want_record.cpp", "${services_path}/abilitymgr/src/power_storage.cpp", "${services_path}/abilitymgr/src/resume_mission_container.cpp", + "${services_path}/abilitymgr/src/screenshot_handler.cpp", + "${services_path}/abilitymgr/src/screenshot_response.cpp", "${services_path}/abilitymgr/src/sender_info.cpp", + "${services_path}/abilitymgr/src/shared_memory.cpp", "${services_path}/abilitymgr/src/stack_info.cpp", "${services_path}/abilitymgr/src/stack_setting.cpp", "${services_path}/abilitymgr/src/task_data_persistence_mgr.cpp", @@ -123,6 +125,7 @@ ohos_source_set("abilityms_test_source") { "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core", "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", + "//foundation/graphic/standard:libwmservice", "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", "//utils/native/base:utils", ] @@ -144,46 +147,47 @@ group("unittest") { testonly = true deps = [ - #"unittest/phone/ability_connect_callback_proxy_test:unittest", - #"unittest/phone/ability_connect_callback_stub_test:unittest", - #"unittest/phone/ability_connect_manage_test:unittest", - #"unittest/phone/ability_dump_test:unittest", - #"unittest/phone/ability_manager_proxy_test:unittest", - #"unittest/phone/ability_manager_service_test:unittest", - #"unittest/phone/ability_manager_stub_test:unittest", - #"unittest/phone/ability_record_test:unittest", - #"unittest/phone/ability_scheduler_proxy_test:unittest", - #"unittest/phone/ability_scheduler_stub_test:unittest", - #"unittest/phone/ability_service_start_test:unittest", - #"unittest/phone/ability_stack_manager_test:unittest", - #"unittest/phone/ability_token_proxy_test:unittest", - #"unittest/phone/ability_token_stub_test:unittest", - #"unittest/phone/ability_with_applications_test:unittest", - #"unittest/phone/abilityms_appms_test:unittest", - #"unittest/phone/app_scheduler_test:unittest", - #"unittest/phone/configuration_test:unittest", - #"unittest/phone/connection_record_test:unittest", - #"unittest/phone/data_ability_manager_test:unittest", - #"unittest/phone/data_ability_record_test:unittest", - #"unittest/phone/info_test:unittest", - #"unittest/phone/kernal_system_app_manager_test:unittest", - #"unittest/phone/lifecycle_deal_test:unittest", - #"unittest/phone/lifecycle_test:unittest", - #"unittest/phone/lock_screen_white_list_test:unittest", - #"unittest/phone/mission_record_test:unittest", - #"unittest/phone/mission_stack_test:unittest", - #"unittest/phone/pending_want_key_test:unittest", - #"unittest/phone/pending_want_manager_test:unittest", - #"unittest/phone/pending_want_record_test:unittest", - #"unittest/phone/resume_mission_container_test:unittest", - #"unittest/phone/sender_info_test:unittest", - #"unittest/phone/terminate_ability_test:unittest", - #"unittest/phone/want_receiver_proxy_test:unittest", - #"unittest/phone/want_receiver_stub_test:unittest", - #"unittest/phone/want_sender_info_test:unittest", - #"unittest/phone/want_sender_proxy_test:unittest", - #"unittest/phone/want_sender_stub_test:unittest", - #"unittest/phone/wants_info_test:unittest", - #"unittest/phone/window_info_test:unittest", + # "unittest/phone/ability_connect_callback_proxy_test:unittest", + # "unittest/phone/ability_connect_callback_stub_test:unittest", + # "unittest/phone/ability_connect_manage_test:unittest", + # "unittest/phone/ability_dump_test:unittest", + # "unittest/phone/ability_manager_proxy_test:unittest", + # "unittest/phone/ability_manager_service_test:unittest", + # "unittest/phone/ability_manager_stub_test:unittest", + # "unittest/phone/ability_record_test:unittest", + # "unittest/phone/ability_scheduler_proxy_test:unittest", + # "unittest/phone/ability_scheduler_stub_test:unittest", + # "unittest/phone/ability_service_start_test:unittest", + # "unittest/phone/ability_stack_manager_test:unittest", + # "unittest/phone/ability_token_proxy_test:unittest", + # "unittest/phone/ability_token_stub_test:unittest", + # "unittest/phone/ability_with_applications_test:unittest", + # "unittest/phone/abilityms_appms_test:unittest", + # "unittest/phone/app_scheduler_test:unittest", + # "unittest/phone/configuration_test:unittest", + # "unittest/phone/connection_record_test:unittest", + # "unittest/phone/data_ability_manager_test:unittest", + # "unittest/phone/data_ability_record_test:unittest", + # "unittest/phone/info_test:unittest", + # "unittest/phone/kernal_system_app_manager_test:unittest", + # "unittest/phone/lifecycle_deal_test:unittest", + # "unittest/phone/lifecycle_test:unittest", + # "unittest/phone/lock_screen_white_list_test:unittest", + # "unittest/phone/mission_record_test:unittest", + # "unittest/phone/mission_stack_test:unittest", + # "unittest/phone/pending_want_key_test:unittest", + # "unittest/phone/pending_want_manager_test:unittest", + # "unittest/phone/pending_want_record_test:unittest", + # "unittest/phone/resume_mission_container_test:unittest", + # "unittest/phone/screenshot_handler_test:unittest", + # "unittest/phone/sender_info_test:unittest", + # "unittest/phone/terminate_ability_test:unittest", + # "unittest/phone/want_receiver_proxy_test:unittest", + # "unittest/phone/want_receiver_stub_test:unittest", + # "unittest/phone/want_sender_info_test:unittest", + # "unittest/phone/want_sender_proxy_test:unittest", + # "unittest/phone/want_sender_stub_test:unittest", + # "unittest/phone/wants_info_test:unittest", + # "unittest/phone/window_info_test:unittest", ] } diff --git a/services/abilitymgr/test/mock/appmgr_test_service/BUILD.gn b/services/abilitymgr/test/mock/appmgr_test_service/BUILD.gn index 21a755b934c98a9b0bf0cd4a81f04813b62435dc..41fdf972e0b2230af415ef2f0d879bf11ba6a257 100644 --- a/services/abilitymgr/test/mock/appmgr_test_service/BUILD.gn +++ b/services/abilitymgr/test/mock/appmgr_test_service/BUILD.gn @@ -52,6 +52,8 @@ ohos_source_set("appmgr_test_service") { "//utils/native/base:utils", ] + public_deps = [ "//foundation/graphic/standard:libwmservice" ] + external_deps = [ "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/ability_connect_callback_stub_test.cpp b/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/ability_connect_callback_stub_test.cpp index 97ef69ca9006a7c3150d30591153a95c593df5aa..f7110e25c917e863f896bfc7eade1b9c4abd5d98 100644 --- a/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/ability_connect_callback_stub_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_connect_callback_stub_test/ability_connect_callback_stub_test.cpp @@ -55,7 +55,7 @@ void AbilityConnectCallBackStubTest::WriteInterfaceToken(MessageParcel &data) * EnvConditions: ElementName is nullptr * CaseDescription: Verify that on remote request is normal and abnormal */ -HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_001, TestSize.Level0) +HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_001, TestSize.Level1) { sptr mockAbilityConnectStub(new MockAbilityConnectCallback()); @@ -83,7 +83,7 @@ HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_001, Test * EnvConditions: ElementName is not nullptr * CaseDescription: Verify that on remote request is normal and abnormal */ -HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_002, TestSize.Level0) +HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_002, TestSize.Level1) { sptr mockAbilityConnectStub(new MockAbilityConnectCallback()); @@ -112,7 +112,7 @@ HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_002, Test * EnvConditions: ElementName is nullptr * CaseDescription: Verify that on remote request is normal and abnormal */ -HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_003, TestSize.Level0) +HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_003, TestSize.Level1) { sptr mockAbilityConnectStub(new MockAbilityConnectCallback()); @@ -140,7 +140,7 @@ HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_003, Test * EnvConditions: ElementName is not nullptr * CaseDescription: Verify that on remote request is normal and abnormal */ -HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_004, TestSize.Level0) +HWTEST_F(AbilityConnectCallBackStubTest, AbilityConnectionCallBack_IPC_004, TestSize.Level1) { sptr mockAbilityConnectStub(new MockAbilityConnectCallback()); diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_proxy_test.cpp b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_proxy_test.cpp index 6f11efc2ff2ba7b12ccca6e412467fd324fbb71c..aeb06172e5d700f69328c99cb690119f2503b5c5 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_proxy_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_manager_proxy_test/ability_manager_proxy_test.cpp @@ -59,7 +59,7 @@ void AbilityManagerProxyTest::SetUp() * EnvConditions: NA * CaseDescription: Verify the normal process of startability */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_001, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_001, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -79,7 +79,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_001, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the return value of startability is abnormal */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_002, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_002, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -99,7 +99,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_002, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal process of TerminateAbility */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_003, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_003, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -120,7 +120,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_003, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the return value of TerminateAbility is abnormal */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_004, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_004, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -141,7 +141,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_004, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of connectability */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_005, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_005, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -166,7 +166,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_005, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of connectability */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_006, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_006, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -188,7 +188,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_006, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of disconnectAbility */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_007, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_007, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -208,7 +208,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_007, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of disconnectAbility */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_008, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_008, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -228,7 +228,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_008, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of attachAbilityThread */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_009, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_009, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -249,7 +249,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_009, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of attachAbilityThread */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_010, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_010, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -274,7 +274,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_010, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of abilityTransitionDone */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0011, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0011, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -295,7 +295,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0011, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of abilityTransitionDone */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_012, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_012, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -316,7 +316,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_012, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of scheduleConnectAbilityDone */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0013, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0013, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -337,7 +337,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0013, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of scheduleConnectAbilityDone */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_014, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_014, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -358,7 +358,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_014, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of scheduleDisconnectAbilityDone */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0015, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0015, TestSize.Level1) { sptr token = nullptr; auto res = proxy_->ScheduleDisconnectAbilityDone(token); @@ -373,7 +373,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0015, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of addWindowInfo */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0016, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0016, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -392,7 +392,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0016, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of dumpState */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0017, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0017, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -412,7 +412,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0017, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of terminateAbilityResult */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0018, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0018, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -432,7 +432,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0018, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of terminateAbilityResult */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_019, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_019, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -452,7 +452,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_019, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of getAllStackInfo */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0020, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0020, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -471,7 +471,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0020, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of getRecentMissions */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0021, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0021, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -493,7 +493,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0021, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of RemoveMission */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0023, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0023, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -511,7 +511,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0023, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of RemoveStack */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0024, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0024, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -529,7 +529,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0024, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal conditions of MoveMissionToTop */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0025, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0025, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -547,7 +547,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0025, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the abnormal conditions of ScheduleCommandAbilityDone */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_026, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_026, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -567,7 +567,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_026, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the normal process of StopServiceAbility */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_027, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_027, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -661,7 +661,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_031, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the function AcquireDataAbility normal flow. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_001, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_001, TestSize.Level1) { OHOS::Uri dataAbilityUri("dataability:///data.bundle.DataAbility"); AbilityRequest abilityRequest; @@ -682,7 +682,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_001, Te * EnvConditions: NA * CaseDescription: Verify the function AcquireDataAbility callerToken is nullptr. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_002, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_002, TestSize.Level1) { OHOS::Uri dataAbilityUri("dataability:///data.bundle.DataAbility"); @@ -698,7 +698,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_002, Te * EnvConditions: NA * CaseDescription: Verify the function AcquireDataAbility SendRequest return error. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_003, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_003, TestSize.Level1) { OHOS::Uri dataAbilityUri("dataability:///data.bundle.DataAbility"); AbilityRequest abilityRequest; @@ -719,7 +719,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AcquireDataAbility_003, Te * EnvConditions: NA * CaseDescription: Verify the function ReleaseDataAbility normal flow. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_001, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_001, TestSize.Level1) { OHOS::sptr scheduler = new AbilityScheduler(); AbilityRequest abilityRequest; @@ -740,7 +740,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_001, Te * EnvConditions: NA * CaseDescription: Verify the function ReleaseDataAbility dataAbilityScheduler is nullptr. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_002, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_002, TestSize.Level1) { AbilityRequest abilityRequest; abilityRequest.appInfo.bundleName = "data.client.bundle"; @@ -760,7 +760,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_002, Te * EnvConditions: NA * CaseDescription: Verify the function ReleaseDataAbility callerToken is nullptr. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_003, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_003, TestSize.Level1) { OHOS::sptr scheduler = new AbilityScheduler(); @@ -776,7 +776,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_003, Te * EnvConditions: NA * CaseDescription: Verify the function ReleaseDataAbility SendRequest error. */ -HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_004, TestSize.Level0) +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ReleaseDataAbility_004, TestSize.Level1) { OHOS::sptr scheduler = new AbilityScheduler(); AbilityRequest abilityRequest; 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 5a97de3a7662534574296102910a877f833d87b3..8ee8b2b9aac7d2e33f525382837ed0fc8cb28eb7 100644 --- 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 @@ -168,7 +168,7 @@ public: return 0; } - int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) + int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { return 0; } @@ -327,6 +327,7 @@ public: MOCK_METHOD1(CleanMission, int(int32_t missionId)); MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &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 04daeb465f34aecd5ae27285cac57eae9817ea0e..09c085e94986997e5fe64f4a14d2260d84cd5fc8 100644 --- 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 @@ -45,20 +45,8 @@ public: MOCK_METHOD2(UnregisterCancelListener, void(const sptr &sender, const sptr &receiver)); MOCK_METHOD2(GetPendingRequestWant, int(const sptr &target, std::shared_ptr &want)); MOCK_METHOD1(GetSystemMemoryAttr, void(AppExecFwk::SystemMemoryAttr &memoryInfo)); - MOCK_METHOD2(StartContinuation, int(const Want &want, const sptr &abilityToken)); - MOCK_METHOD2(NotifyContinuationResult, int(const sptr &abilityToken, const int32_t result)); - - MOCK_METHOD1(LockMissionForCleanup, int(int32_t missionId)); - MOCK_METHOD1(UnlockMissionForCleanup, int(int32_t missionId)); - MOCK_METHOD1(RegisterMissionListener, int(const sptr &listener)); - MOCK_METHOD1(UnRegisterMissionListener, int(const sptr &listener)); - MOCK_METHOD3( - GetMissionInfos, int(const std::string& deviceId, int32_t numMax, std::vector &missionInfos)); - MOCK_METHOD3(GetMissionInfo, int(const std::string& deviceId, int32_t missionId, MissionInfo &missionInfo)); - MOCK_METHOD1(CleanMission, int(int32_t missionId)); - MOCK_METHOD0(CleanAllMissions, int()); - MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); - + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + int InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { code_ = code; @@ -181,7 +169,7 @@ public: return 0; } - int GetMissionSnapshot(const int32_t missionId, MissionSnapshotInfo &snapshot) + int GetMissionSnapshot(const int32_t missionId, MissionPixelMap &missionPixelMap) { return 0; } diff --git a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_test.cpp b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_test.cpp index 1803c15027fdf4d58c5bfbd15a944db54836d039..1180def500a3bed47edb4b8f008b65beab554d17 100644 --- a/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_manager_stub_test/ability_manager_stub_test.cpp @@ -60,7 +60,7 @@ void AbilityManagerStubTest::WriteInterfaceToken(MessageParcel &data) * EnvConditions: code is START_ABILITY * CaseDescription: Verify that on remote request is normal and abnormal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_001, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -89,7 +89,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_001, TestSize.Level0) * EnvConditions: code is TERMINATE_ABILITY * CaseDescription: Verify that on remote request is normal and abnormal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_002, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_002, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -114,7 +114,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_002, TestSize.Level0) * EnvConditions: code is CONNECT_ABILITY * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_004, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_004, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -141,7 +141,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_004, TestSize.Level0) * EnvConditions: NA * CaseDescription: OnRemoteRequest IAbilityManager::CONNECT_ABILITY */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_005, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_005, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -168,7 +168,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_005, TestSize.Level0) * EnvConditions: NA * CaseDescription: OnRemoteRequest IAbilityManager::CONNECT_ABILITY */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_006, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_006, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -193,7 +193,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_006, TestSize.Level0) * EnvConditions: code is DISCONNECT_ABILITY * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_007, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_007, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -215,7 +215,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_007, TestSize.Level0) * EnvConditions: code is ATTACH_ABILITY_THREAD * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_008, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_008, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -239,7 +239,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_008, TestSize.Level0) * EnvConditions: code is ABILITY_TRANSITION_DONE * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_009, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_009, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -265,7 +265,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_009, TestSize.Level0) * EnvConditions: code is CONNECT_ABILITY_DONE * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_010, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_010, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -289,7 +289,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_010, TestSize.Level0) * EnvConditions: code is DISCONNECT_ABILITY_DONE * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_011, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_011, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -311,7 +311,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_011, TestSize.Level0) * EnvConditions: code is ADD_WINDOW_INFO * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_012, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_012, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -334,7 +334,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_012, TestSize.Level0) * EnvConditions: code is DUMP_STATE * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_013, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_013, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -357,7 +357,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_013, TestSize.Level0) * EnvConditions: code is LIST_STACK_INFO * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_014, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_014, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -376,7 +376,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_014, TestSize.Level0) * EnvConditions: code is TERMINATE_ABILITY_RESULT * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_015, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_015, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -395,7 +395,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_015, TestSize.Level0) * EnvConditions: code is default * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_016, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_016, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -414,7 +414,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_016, TestSize.Level0) * EnvConditions: code is GET_RECENT_MISSION * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_017, TestSize.Level0) +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_017, TestSize.Level1) { MessageParcel data; MessageParcel reply; 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 1ad7a88f1fc0ef2d4ec030e9ea68f65ffa38e7dd..e91f26b8ec83562ec5f0db7af14b8e3a3bdce777 100644 --- 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 @@ -97,19 +97,7 @@ public: MOCK_METHOD1(ChangeFocusTest, void(const std::vector missionId)); MOCK_METHOD1(TerminateAbilityTest, void(int id)); MOCK_METHOD1(MoveMissionToEnd, int(int id)); - MOCK_METHOD2(StartContinuation, int(const Want &want, const sptr &abilityToken)); - MOCK_METHOD2(NotifyContinuationResult, int(const sptr &abilityToken, const int32_t result)); - - MOCK_METHOD1(LockMissionForCleanup, int(int32_t missionId)); - MOCK_METHOD1(UnlockMissionForCleanup, int(int32_t missionId)); - MOCK_METHOD1(RegisterMissionListener, int(const sptr &listener)); - MOCK_METHOD1(UnRegisterMissionListener, int(const sptr &listener)); - MOCK_METHOD3( - GetMissionInfos, int(const std::string& deviceId, int32_t numMax, std::vector &missionInfos)); - MOCK_METHOD3(GetMissionInfo, int(const std::string& deviceId, int32_t missionId, MissionInfo &missionInfo)); - MOCK_METHOD1(CleanMission, int(int32_t missionId)); - MOCK_METHOD0(CleanAllMissions, int()); - MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/test/unittest/phone/ability_record_test/ability_record_test.cpp b/services/abilitymgr/test/unittest/phone/ability_record_test/ability_record_test.cpp index 456701a29256602f4e60055c38fe5c6c41736455..71202da4478be0de3b0a80295a10f2934a1942c1 100644 --- a/services/abilitymgr/test/unittest/phone/ability_record_test/ability_record_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_record_test/ability_record_test.cpp @@ -287,7 +287,7 @@ HWTEST_F(AbilityRecordTest, AaFwk_AbilityMS_IsLauncherAbility, TestSize.Level1) * EnvConditions: NA * CaseDescription: AddConnectRecordToList UT. */ -HWTEST_F(AbilityRecordTest, AaFwk_AbilityMS_AddConnectRecordToList, TestSize.Level0) +HWTEST_F(AbilityRecordTest, AaFwk_AbilityMS_AddConnectRecordToList, TestSize.Level1) { // test1 for input param is null abilityRecord_->AddConnectRecordToList(nullptr); diff --git a/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/ability_scheduler_proxy_test.cpp b/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/ability_scheduler_proxy_test.cpp index 0aa5caa58d476ba0cd456b4b8a53d66e51b42c29..574bf41a41752ca787f6ac6dc8b7af0865647cbf 100644 --- a/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/ability_scheduler_proxy_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_scheduler_proxy_test/ability_scheduler_proxy_test.cpp @@ -58,7 +58,7 @@ void AbilitySchedulerProxyTest::SetUp(void) * EnvConditions:NA * CaseDescription: verify AbilitySchedulerProxy is create success */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_001, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_001, TestSize.Level1) { EXPECT_NE(abilitySchedulerProxy_, nullptr); } @@ -71,7 +71,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_001, TestS * EnvConditions:NA * CaseDescription: verify AbilitySchedulerRecipient is create success */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_002, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_002, TestSize.Level1) { EXPECT_NE(abilitySchedulerRecipient_, nullptr); } @@ -84,7 +84,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_002, TestS * EnvConditions: NA * CaseDescription: verify ScheduleAbilityTransaction Normal case */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_003, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_003, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -105,7 +105,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_003, TestS * EnvConditions: NA * CaseDescription: verify ScheduleAbilityTransaction Return value exception */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_004, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_004, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -126,7 +126,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_004, TestS * EnvConditions: NA * CaseDescription: verify SendResult Normal case */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_005, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_005, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -146,7 +146,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_005, TestS * EnvConditions: NA * CaseDescription: verify SendResult Return value exception */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_006, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_006, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -166,7 +166,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_006, TestS * EnvConditions: NA * CaseDescription: verify ScheduleConnectAbility Normal case */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_007, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_007, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -186,7 +186,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_007, TestS * EnvConditions: NA * CaseDescription: verify ScheduleConnectAbility Return value exception */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_008, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_008, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -206,7 +206,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_008, TestS * EnvConditions: NA * CaseDescription: verify ScheduleDisconnectAbility Normal case */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_009, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_009, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -226,7 +226,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_009, TestS * EnvConditions: NA * CaseDescription: verify ScheduleDisconnectAbility Return value exception */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_010, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_010, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -246,7 +246,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_010, TestS * EnvConditions: NA * CaseDescription: verify ScheduleCommandAbility Normal case */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_011, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_011, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -266,7 +266,7 @@ HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_011, TestS * EnvConditions: NA * CaseDescription: verify ScheduleCommandAbility Return value exception */ -HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_012, TestSize.Level0) +HWTEST_F(AbilitySchedulerProxyTest, ability_scheduler_proxy_operating_012, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) diff --git a/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_scheduler_stub_test.cpp b/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_scheduler_stub_test.cpp index 6cb7aeab3ff84343b0d96004fcbe493df2c80d38..2481809453e0bb0c0cbeacfb01734b8773395b9c 100644 --- a/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_scheduler_stub_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_scheduler_stub_test/ability_scheduler_stub_test.cpp @@ -54,7 +54,7 @@ void AbilitySchedulerStubTest::WriteInterfaceToken(MessageParcel &data) * EnvConditions: code is SCHEDULE_ABILITY_TRANSACTION * CaseDescription: Verify the normal process of onremoterequest */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_001, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -77,7 +77,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_001, TestSize.Level0) * EnvConditions: code is SCHEDULE_ABILITY_TRANSACTION * CaseDescription: Verifying stateinfo is nullptr causes onremoterequest to fail */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_002, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_002, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -99,7 +99,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_002, TestSize.Level0) * EnvConditions: code is SEND_RESULT * CaseDescription: Verify the normal process of onremoterequest */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_003, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_003, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -123,7 +123,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_003, TestSize.Level0) * EnvConditions: code is SEND_RESULT * CaseDescription: Verifying want is nullptr causes onremoterequest to fail */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_004, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_004, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -144,7 +144,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_004, TestSize.Level0) * EnvConditions: code is SCHEDULE_ABILITY_CONNECT * CaseDescription: Verify the normal and failed conditions of onremoterequest */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_005, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_005, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -171,7 +171,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_005, TestSize.Level0) * EnvConditions: code is SCHEDULE_ABILITY_DISCONNECT * CaseDescription: Verify the normal conditions of onremoterequest */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_006, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_006, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -189,7 +189,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_006, TestSize.Level0) * EnvConditions: code is SCHEDULE_SAVE_ABILITY_STATE * CaseDescription: Verify the failed conditions of onremoterequest */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_007, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_007, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -207,7 +207,7 @@ HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_007, TestSize.Level0) * EnvConditions: code is default * CaseDescription: Verify the normal conditions of onremoterequest */ -HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_008, TestSize.Level0) +HWTEST_F(AbilitySchedulerStubTest, AbilitySchedulerStub_008, TestSize.Level1) { MessageParcel data; MessageParcel reply; diff --git a/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp b/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp index 1d616408f758eae8ea36ca17350dff93dc3faa41..7c8547bc4e84f88ade17e8d142cf640581a1c308 100644 --- a/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_stack_manager_test/ability_stack_manager_test.cpp @@ -3180,6 +3180,45 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_084, TestSize. EXPECT_EQ(AbilityState::TERMINATING, ability->GetAbilityState()); } +/* + * Feature: AbilityStackManager + * Function : GetMissionSnapshot + * SubFunction : NA + * FunctionPoints : Get Mission Snapshot + * EnvConditions: NA + * CaseDescription : Get Mission Snapshot + */ +HWTEST_F(AbilityStackManagerTest, ability_stack_manager_getMissionSnapshot_001, TestSize.Level1) +{ + stackManager_->Init(); + EXPECT_TRUE(stackManager_); + int32_t missionId = -1; + MissionPixelMap missionPixelMap; + auto ret = stackManager_->GetMissionSnapshot(missionId, missionPixelMap); + + EXPECT_TRUE(REMOVE_MISSION_ID_NOT_EXIST == ret); +} + +/* + * Feature: AbilityStackManager + * Function : GetMissionSnapshot + * SubFunction : NA + * FunctionPoints : Get Mission Snapshot + * EnvConditions: NA + * CaseDescription : Get Mission Snapshot + */ +HWTEST_F(AbilityStackManagerTest, ability_stack_manager_getMissionSnapshot_002, TestSize.Level1) +{ + stackManager_->Init(); + EXPECT_TRUE(stackManager_); + int32_t missionId = 0; + MissionPixelMap missionPixelMap; + stackManager_->missionStackList_.clear(); + auto ret = stackManager_->GetMissionSnapshot(missionId, missionPixelMap); + + EXPECT_TRUE(REMOVE_MISSION_ID_NOT_EXIST == ret); +} + /* * Feature: AbilityStackManager * Function: GenerateMissinOptionsOfSplitScreen @@ -3201,7 +3240,7 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_087, TestSize. auto ref = stackManager_->GenerateMissinOptionsOfSplitScreen(primary, secondary, options); EXPECT_EQ(ERR_INVALID_DATA, ref); } - + /* * Feature: AbilityStackManager * Function: GenerateMissinOptionsOfSplitScreen diff --git a/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/ability_token_proxy_test.cpp b/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/ability_token_proxy_test.cpp index e39762d4eeb10ae9de636bbd517df76b50ac7cd8..b47a3a6e3d8fdd36714681b494077c01f12b6b90 100644 --- a/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/ability_token_proxy_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_token_proxy_test/ability_token_proxy_test.cpp @@ -50,7 +50,7 @@ void AbilityTokenProxyTest::SetUp(void) * EnvConditions:NA * CaseDescription: verify AbilityTokenProxy is create success */ -HWTEST_F(AbilityTokenProxyTest, ability_token_proxy_operating_001, TestSize.Level0) +HWTEST_F(AbilityTokenProxyTest, ability_token_proxy_operating_001, TestSize.Level1) { EXPECT_NE(abilityTokenProxy_, nullptr); } diff --git a/services/abilitymgr/test/unittest/phone/ability_token_stub_test/ability_token_stub_test.cpp b/services/abilitymgr/test/unittest/phone/ability_token_stub_test/ability_token_stub_test.cpp index 452fb2fd52060770637f86ebf7f11384969d7cd9..68666e878af02351cce246cef32be3fd834520ae 100644 --- a/services/abilitymgr/test/unittest/phone/ability_token_stub_test/ability_token_stub_test.cpp +++ b/services/abilitymgr/test/unittest/phone/ability_token_stub_test/ability_token_stub_test.cpp @@ -51,7 +51,7 @@ void AbilityTokenStubTest::SetUp(void) * EnvConditions:NA * CaseDescription: verify AbilityTokenStub is create success */ -HWTEST_F(AbilityTokenStubTest, ability_token_stub_operating_001, TestSize.Level0) +HWTEST_F(AbilityTokenStubTest, ability_token_stub_operating_001, TestSize.Level1) { EXPECT_NE(abilityTokenStub_, nullptr); } @@ -64,7 +64,7 @@ HWTEST_F(AbilityTokenStubTest, ability_token_stub_operating_001, TestSize.Level0 * EnvConditions:NA * CaseDescription: verify AbilityTokenRecipient is create success */ -HWTEST_F(AbilityTokenStubTest, ability_token_stub_operating_002, TestSize.Level0) +HWTEST_F(AbilityTokenStubTest, ability_token_stub_operating_002, TestSize.Level1) { EXPECT_NE(abilityTokenRecipient_, nullptr); } diff --git a/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp b/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp index c0542777d5957b085fa9ef28f41be495284b2e70..01ce62816282bbc9869c892f8315e66fb4ae8def 100644 --- a/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp +++ b/services/abilitymgr/test/unittest/phone/app_scheduler_test/app_scheduler_test.cpp @@ -81,7 +81,7 @@ AbilityRequest AppSchedulerTest::GenerateAbilityRequest(const std::string &devic * EnvConditions:NA * CaseDescription: Appstatecallback is nullptr causes init to fail */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_001, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_001, TestSize.Level1) { std::shared_ptr appStateMock; EXPECT_EQ(false, DelayedSingleton::GetInstance()->Init(appStateMock)); @@ -95,7 +95,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_001, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify init success */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_002, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_002, TestSize.Level1) { EXPECT_EQ(true, DelayedSingleton::GetInstance()->Init(appStateMock_)); } @@ -108,7 +108,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_002, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify the normal process of loadability */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_003, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_003, TestSize.Level1) { std::string deviceName = "device"; std::string abilityName = "FirstAbility"; @@ -139,7 +139,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_003, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify the fail process of loadability */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_004, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_004, TestSize.Level1) { std::string deviceName = "device"; std::string abilityName = "FirstAbility"; @@ -170,7 +170,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_004, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is nullptr causes init to fail */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_005, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_005, TestSize.Level1) { EXPECT_EQ(false, DelayedSingleton::GetInstance()->Init(appStateMock_)); } @@ -183,7 +183,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_005, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is nullptr causes TerminateAbility to fail */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_006, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_006, TestSize.Level1) { std::string deviceName = "device"; std::string abilityName = "FirstAbility"; @@ -204,7 +204,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_006, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is not nullptr causes TerminateAbility to success */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_007, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_007, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); @@ -227,7 +227,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_007, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is null causes movetoforground to be invalid */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_008, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_008, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = nullptr; @@ -250,7 +250,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_008, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify the normal process of movetoforground */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_009, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_009, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); @@ -273,7 +273,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_009, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is null causes OnAbilityRequestDone to be invalid */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_010, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_010, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = nullptr; @@ -296,7 +296,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_010, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is not nullptr causes onabilityrequestdone invoke */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_011, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_011, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); std::string deviceName = "device"; @@ -320,7 +320,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_011, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify ConvertToAppAbilityState result */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_012, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_012, TestSize.Level1) { EXPECT_EQ(AppAbilityState::ABILITY_STATE_FOREGROUND, DelayedSingleton::GetInstance()->ConvertToAppAbilityState( @@ -343,7 +343,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_012, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify ConvertToAppAbilityState result */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_013, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_013, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = nullptr; EXPECT_EQ(false, DelayedSingleton::GetInstance()->Init(appStateMock_)); @@ -357,7 +357,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_013, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is not nullptr causes AbilityBehaviorAnalysis to success */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_014, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_014, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); @@ -400,7 +400,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_014, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is nullptr causes AbilityBehaviorAnalysis to fail */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_015, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_015, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = nullptr; @@ -427,7 +427,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_015, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is not nullptr causes KillProcessByAbilityToken to success */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_016, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_016, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); @@ -450,7 +450,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_016, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify appmgrclient_ Is nullptr causes KillProcessByAbilityToken to fail */ -HWTEST_F(AppSchedulerTest, AppScheduler_oprator_017, TestSize.Level0) +HWTEST_F(AppSchedulerTest, AppScheduler_oprator_017, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = nullptr; diff --git a/services/abilitymgr/test/unittest/phone/configuration_test/configuration_test.cpp b/services/abilitymgr/test/unittest/phone/configuration_test/configuration_test.cpp index cf830b3dcfb6c590686f2b4aadcdbbd437e5f347..e7bfc803fa03cd09d492de1ada02b3f2c6632f03 100644 --- a/services/abilitymgr/test/unittest/phone/configuration_test/configuration_test.cpp +++ b/services/abilitymgr/test/unittest/phone/configuration_test/configuration_test.cpp @@ -66,6 +66,45 @@ HWTEST_F(ConfigurationTest, AddItem_001, TestSize.Level1) EXPECT_EQ(1, config.GetItemSize()); } +/* + * Feature: Configuration + * Function: AddItem + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Update Configuration + */ +HWTEST_F(ConfigurationTest, AddItem_002, TestSize.Level1) +{ + AppExecFwk::Configuration config; + std::string val {"中文"}; + EXPECT_EQ(0, config.GetItemSize()); + config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, val); + EXPECT_EQ(1, config.GetItemSize()); + + // replace + config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, val); + EXPECT_EQ(1, config.GetItemSize()); +} + +/* + * Feature: Configuration + * Function: AddItem + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Update Configuration + */ +HWTEST_F(ConfigurationTest, AddItem_003, TestSize.Level1) +{ + AppExecFwk::Configuration config; + std::string val {"中文"}; + std::string key {"test_key"}; + EXPECT_EQ(0, config.GetItemSize()); + auto ref = config.AddItem(key, val); + EXPECT_FALSE(ref); +} + /* * Feature: Configuration * Function: GetItem @@ -96,6 +135,50 @@ HWTEST_F(ConfigurationTest, GetItem_001, TestSize.Level1) EXPECT_EQ(item, non); } +/* + * Feature: Configuration + * Function: GetItem + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Process Configuration Change + */ +HWTEST_F(ConfigurationTest, GetItem_002, TestSize.Level1) +{ + AppExecFwk::Configuration config; + std::string val {"中文"}; + config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, val); + + auto item = config.GetItem(GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_EQ(item, val); + + // replace + std::string english {"英文"}; + config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, english); + item = config.GetItem(GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_EQ(item, english); + + int displayId2 = 1002; + std::string non {""}; + item = config.GetItem(displayId2, GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_EQ(item, non); +} + +/* + * Feature: Configuration + * Function: GetItem + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Process Configuration Change + */ +HWTEST_F(ConfigurationTest, GetItem_003, TestSize.Level1) +{ + AppExecFwk::Configuration config; + std::string non {""}; + auto item = config.GetItem("test_kay"); + EXPECT_EQ(item, non); +} /* * Feature: Configuration * Function: RemoveItem @@ -130,6 +213,38 @@ HWTEST_F(ConfigurationTest, RemoveItem_001, TestSize.Level1) EXPECT_FALSE(canRemove); } +/* + * Feature: Configuration + * Function: RemoveItem + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Process Configuration Change + */ +HWTEST_F(ConfigurationTest, RemoveItem_002, TestSize.Level1) +{ + AppExecFwk::Configuration config; + std::string val {"中文"}; + config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, val); + + auto item = config.GetItem(GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_EQ(item, val); + + // remove it + bool canRemove = config.RemoveItem(GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_TRUE(canRemove); + + std::string non {""}; + item = config.GetItem(GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_EQ(item, non); + + canRemove = config.RemoveItem(non); + EXPECT_FALSE(canRemove); + + canRemove = config.RemoveItem(GlobalConfigurationKey::SYSTEM_LANGUAGE); + EXPECT_FALSE(canRemove); +} + /* * Feature: Configuration * Function: GetItemSize diff --git a/services/abilitymgr/test/unittest/phone/info_test/info_test.cpp b/services/abilitymgr/test/unittest/phone/info_test/info_test.cpp index 7863be66d3e80fefbc701bf28f52df1b92f05800..6e23be07c69c0969014e3981c1b3fed610ff29bc 100644 --- a/services/abilitymgr/test/unittest/phone/info_test/info_test.cpp +++ b/services/abilitymgr/test/unittest/phone/info_test/info_test.cpp @@ -17,7 +17,7 @@ #include "stack_info.h" #include "lifecycle_state_info.h" #include "image_info.h" -#include "mission_snapshot_info.h" +#include "mission_snapshot.h" #include "mission_description_info.h" #include "ability_mission_info.h" @@ -38,8 +38,6 @@ public: AbilityRecordInfo abilityRecordInfo_ {}; LifeCycleStateInfo lifeCycleStateInfo_ {}; ImageInfo imageInfo_ {}; - ImageHeader imageHeader_ {}; - MissionSnapshotInfo missionSnapshotInfo_ {}; MissionDescriptionInfo missionDescriptionInfo_ {}; AbilityMissionInfo recentMissionInfo_ {}; }; @@ -61,7 +59,7 @@ void InfoTest::TearDown() * EnvConditions:NA * CaseDescription: The process of verifying stackenfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_001, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_001, TestSize.Level1) { MissionStackInfo missionInfo; missionInfo.id = 10; @@ -88,7 +86,7 @@ HWTEST_F(InfoTest, stack_info_oprator_001, TestSize.Level0) * EnvConditions:NA * CaseDescription: The process of verifying MissionStackInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_002, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_002, TestSize.Level1) { MissionRecordInfo info; info.id = 1; @@ -113,7 +111,7 @@ HWTEST_F(InfoTest, stack_info_oprator_002, TestSize.Level0) * EnvConditions:NA * CaseDescription: The process of verifying MissionRecordInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_003, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_003, TestSize.Level1) { AbilityRecordInfo info; info.id = 10; @@ -164,7 +162,7 @@ HWTEST_F(InfoTest, stack_info_oprator_003, TestSize.Level0) * EnvConditions:NA * CaseDescription: The process of verifying AbilityRecordInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_004, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_004, TestSize.Level1) { abilityRecordInfo_.id = 10; abilityRecordInfo_.elementName = "test"; @@ -212,7 +210,7 @@ HWTEST_F(InfoTest, stack_info_oprator_004, TestSize.Level0) * EnvConditions:NA * CaseDescription: The process of verifying LifeCycleStateInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_005, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_005, TestSize.Level1) { lifeCycleStateInfo_.isNewWant = 10; lifeCycleStateInfo_.state = AbilityLifeCycleState::ABILITY_STATE_BACKGROUND; @@ -229,30 +227,32 @@ HWTEST_F(InfoTest, stack_info_oprator_005, TestSize.Level0) } /* - * Feature: ImageHeader + * Feature: ImageInfo * Function: ReadFromParcel and Marshalling and Unmarshalling * SubFunction: NA - * FunctionPoints: ImageHeader ReadFromParcel and Marshalling and Unmarshalling + * FunctionPoints: ImageInfo ReadFromParcel and Marshalling and Unmarshalling * EnvConditions:NA - * CaseDescription: The process of verifying ImageHeader parcel + * CaseDescription: The process of verifying ImageInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_007, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_007, TestSize.Level1) { - imageHeader_.colorMode = 8; - imageHeader_.reserved = 24; - imageHeader_.width = 10; - imageHeader_.height = 10; + imageInfo_.width = 8; + imageInfo_.height = 24; + imageInfo_.format = 10; + imageInfo_.size = 10; + imageInfo_.shmKey = 30; Parcel parcel; - imageHeader_.Marshalling(parcel); - ImageHeader *obj = imageHeader_.Unmarshalling(parcel); + imageInfo_.Marshalling(parcel); + ImageInfo *obj = imageInfo_.Unmarshalling(parcel); if (!obj) { return; } EXPECT_TRUE(obj); - EXPECT_EQ(obj->colorMode, imageHeader_.colorMode); - EXPECT_EQ(obj->reserved, imageHeader_.reserved); - EXPECT_EQ(obj->width, imageHeader_.width); - EXPECT_EQ(obj->height, imageHeader_.height); + EXPECT_EQ(obj->width, imageInfo_.width); + EXPECT_EQ(obj->height, imageInfo_.height); + EXPECT_EQ(obj->format, imageInfo_.format); + EXPECT_EQ(obj->size, imageInfo_.size); + EXPECT_EQ(obj->shmKey, imageInfo_.shmKey); } /* @@ -263,7 +263,7 @@ HWTEST_F(InfoTest, stack_info_oprator_007, TestSize.Level0) * EnvConditions:NA * CaseDescription: The process of verifying MissionDescriptionInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_008, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_008, TestSize.Level1) { missionDescriptionInfo_.label = "label"; missionDescriptionInfo_.iconPath = "iconpath"; @@ -286,7 +286,7 @@ HWTEST_F(InfoTest, stack_info_oprator_008, TestSize.Level0) * EnvConditions:NA * CaseDescription: The process of verifying AbilityMissionInfo parcel */ -HWTEST_F(InfoTest, stack_info_oprator_009, TestSize.Level0) +HWTEST_F(InfoTest, stack_info_oprator_009, TestSize.Level1) { recentMissionInfo_.id = 10; recentMissionInfo_.runingState = -1; diff --git a/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/lifecycle_deal_test.cpp b/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/lifecycle_deal_test.cpp index 27e1215856de418c3a2e272fa70ac9a4e3960408..89e74ada5b257a5b9909df1096b1c4bf63c42723 100644 --- a/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/lifecycle_deal_test.cpp +++ b/services/abilitymgr/test/unittest/phone/lifecycle_deal_test/lifecycle_deal_test.cpp @@ -54,7 +54,7 @@ void LifecycleDealTest::SetUp() * EnvConditions:NA * CaseDescription: Verify activate operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_001, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_001, TestSize.Level1) { LifeCycleStateInfo val; EXPECT_CALL(*abilityScheduler_, ScheduleAbilityTransaction(::testing::_, ::testing::_)) @@ -86,7 +86,7 @@ HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_001, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify Inactivate operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_002, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_002, TestSize.Level1) { LifeCycleStateInfo val; EXPECT_CALL(*abilityScheduler_, ScheduleAbilityTransaction(::testing::_, ::testing::_)) @@ -118,7 +118,7 @@ HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_002, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify MoveToBackground operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_003, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_003, TestSize.Level1) { LifeCycleStateInfo val; EXPECT_CALL(*abilityScheduler_, ScheduleAbilityTransaction(::testing::_, ::testing::_)) @@ -150,7 +150,7 @@ HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_003, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify ConnectAbility operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_004, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_004, TestSize.Level1) { EXPECT_CALL(*abilityScheduler_, ScheduleConnectAbility(::testing::_)).Times(1); const Want want; @@ -167,7 +167,7 @@ HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_004, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify DisconnectAbility operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_005, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_005, TestSize.Level1) { EXPECT_CALL(*abilityScheduler_, ScheduleDisconnectAbility(::testing::_)).Times(1); @@ -185,7 +185,7 @@ HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_005, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify Terminate operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_006, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_006, TestSize.Level1) { EXPECT_CALL(*abilityScheduler_, ScheduleAbilityTransaction(::testing::_, ::testing::_)).Times(1); @@ -210,7 +210,7 @@ HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_006, TestSize.Level0) * EnvConditions:NA * CaseDescription: Verify CommandAbility operation and call mock once */ -HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_007, TestSize.Level0) +HWTEST_F(LifecycleDealTest, LifecycleDeal_oprator_007, TestSize.Level1) { EXPECT_CALL(*abilityScheduler_, ScheduleCommandAbility(::testing::_, ::testing::_, ::testing::_)).Times(1); const Want want; diff --git a/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp b/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp index 311cf1270cbb2c606fa6a52ac7f421426316975f..b9885ce96be3f50b546d62ee2767fe9508ae23e6 100644 --- a/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp +++ b/services/abilitymgr/test/unittest/phone/mission_stack_test/mission_stack_test.cpp @@ -109,7 +109,7 @@ std::shared_ptr getSecondMissionRecord() * EnvConditions: NA * CaseDescription: Results after verifying removeAll */ -HWTEST_F(MissionStackTest, MS_oprator_01, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_01, TestSize.Level1) { missionStack_->AddMissionRecordToTop(getFirstMissionRecord()); missionStack_->RemoveAll(); @@ -124,7 +124,7 @@ HWTEST_F(MissionStackTest, MS_oprator_01, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the top ability record is the same as the added record */ -HWTEST_F(MissionStackTest, MS_oprator_002, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_002, TestSize.Level1) { std::shared_ptr nullMissionRecord = nullptr; missionStack_->AddMissionRecordToTop(nullMissionRecord); @@ -153,7 +153,7 @@ HWTEST_F(MissionStackTest, MS_oprator_002, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the top mission record is not empty */ -HWTEST_F(MissionStackTest, MS_oprator_003, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_003, TestSize.Level1) { missionStack_->AddMissionRecordToTop(getFirstMissionRecord()); missionStack_->AddMissionRecordToTop(getSecondMissionRecord()); @@ -169,7 +169,7 @@ HWTEST_F(MissionStackTest, MS_oprator_003, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the top mission record is the same as the added record */ -HWTEST_F(MissionStackTest, MS_oprator_004, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_004, TestSize.Level1) { EXPECT_EQ(missionStack_->GetTopMissionRecord(), nullptr); @@ -194,7 +194,7 @@ HWTEST_F(MissionStackTest, MS_oprator_004, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the mission stack id is not 0 */ -HWTEST_F(MissionStackTest, MS_oprator_005, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_005, TestSize.Level1) { missionStack_->AddMissionRecordToTop(getFirstMissionRecord()); EXPECT_NE(missionStack_->GetMissionStackId(), 0); @@ -208,7 +208,7 @@ HWTEST_F(MissionStackTest, MS_oprator_005, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the get target mission record is equal to the one added */ -HWTEST_F(MissionStackTest, MS_oprator_006, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_006, TestSize.Level1) { EXPECT_EQ(nullptr, missionStack_->GetTargetMissionRecord("FirstApp")); @@ -234,7 +234,7 @@ HWTEST_F(MissionStackTest, MS_oprator_006, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the value of get mission stack ID and get mission stack user ID */ -HWTEST_F(MissionStackTest, MS_oprator_007, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_007, TestSize.Level1) { EXPECT_EQ(missionStack_->GetMissionStackId(), 1); EXPECT_EQ(missionStack_->GetMissionStackUserId(), 2); @@ -248,7 +248,7 @@ HWTEST_F(MissionStackTest, MS_oprator_007, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the value of get mission record count */ -HWTEST_F(MissionStackTest, MS_oprator_008, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_008, TestSize.Level1) { EXPECT_EQ(missionStack_->GetMissionRecordCount(), 0); missionStack_->AddMissionRecordToTop(getSecondMissionRecord()); @@ -263,7 +263,7 @@ HWTEST_F(MissionStackTest, MS_oprator_008, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the get top mission record is equal to the one added */ -HWTEST_F(MissionStackTest, MS_oprator_009, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_009, TestSize.Level1) { std::string deviceName = "device"; std::string abilityName = "FirstAbility"; @@ -291,7 +291,7 @@ HWTEST_F(MissionStackTest, MS_oprator_009, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify Dump and DumpStackList results */ -HWTEST_F(MissionStackTest, MS_oprator_010, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_010, TestSize.Level1) { std::vector info; std::vector listInfo; @@ -329,7 +329,7 @@ HWTEST_F(MissionStackTest, MS_oprator_010, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the get mission record by ID value is empty */ -HWTEST_F(MissionStackTest, MS_oprator_011, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_011, TestSize.Level1) { EXPECT_EQ(missionStack_->GetMissionRecordById(0), nullptr); @@ -355,7 +355,7 @@ HWTEST_F(MissionStackTest, MS_oprator_011, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify the get mission record by ID value */ -HWTEST_F(MissionStackTest, MS_oprator_012, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_012, TestSize.Level1) { EXPECT_EQ(missionStack_->GetMissionRecordById(0), nullptr); @@ -381,7 +381,7 @@ HWTEST_F(MissionStackTest, MS_oprator_012, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the values of get ability record by token are equal */ -HWTEST_F(MissionStackTest, MS_oprator_013, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_013, TestSize.Level1) { OHOS::sptr token = nullptr; EXPECT_EQ(missionStack_->GetAbilityRecordByToken(token), nullptr); @@ -409,7 +409,7 @@ HWTEST_F(MissionStackTest, MS_oprator_013, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that remove ability record by token is successful */ -HWTEST_F(MissionStackTest, MS_oprator_014, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_014, TestSize.Level1) { std::string deviceName = "device"; std::string abilityName = "FirstAbility"; @@ -436,7 +436,7 @@ HWTEST_F(MissionStackTest, MS_oprator_014, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that remove mission record is successful */ -HWTEST_F(MissionStackTest, MS_oprator_015, TestSize.Level0) +HWTEST_F(MissionStackTest, MS_oprator_015, TestSize.Level1) { EXPECT_EQ(missionStack_->RemoveMissionRecord(100), false); diff --git a/services/abilitymgr/test/unittest/phone/screenshot_handler_test/BUILD.gn b/services/abilitymgr/test/unittest/phone/screenshot_handler_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0f1087409a88b199e36d324b5d87963897e0435c --- /dev/null +++ b/services/abilitymgr/test/unittest/phone/screenshot_handler_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/abilitymgr" + +ohos_unittest("ability_screenshot_handler_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/aafwk/standard/services/abilitymgr/test/mock/libs/ability_scheduler_mock", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmgr/", + ] + + sources = [ + "//foundation/aafwk/standard/services/abilitymgr/test/mock/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", + "screenshot_handler_test.cpp", + ] + + configs = [ + "${services_path}/abilitymgr:abilityms_config", + "${services_path}/abilitymgr/test/mock:aafwk_mock_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/interfaces/innerkits/base:base", + "//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 = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":ability_screenshot_handler_test" ] +} diff --git a/services/abilitymgr/test/unittest/phone/screenshot_handler_test/screenshot_handler_test.cpp b/services/abilitymgr/test/unittest/phone/screenshot_handler_test/screenshot_handler_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c60cbc9640e1d52d26ae4637526a975759cd6f0d --- /dev/null +++ b/services/abilitymgr/test/unittest/phone/screenshot_handler_test/screenshot_handler_test.cpp @@ -0,0 +1,145 @@ +/* + * 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_stack_manager.h" +#include "screenshot_handler.h" +#include "screenshot_response.h" +#undef private +#undef protected + +#include "app_process_data.h" +#include "mock_bundle_manager.h" +#include "sa_mgr_client.h" +#include "system_ability_definition.h" +#include "ability_manager_errors.h" +#include "ability_scheduler.h" +#include "mock_ability_connect_callback.h" +#include "ability_scheduler_mock.h" + +using namespace testing::ext; +using namespace OHOS::AppExecFwk; +namespace OHOS { +namespace AAFwk { + +class ScreenShotHandlerTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr screenShotHandler_; + std::shared_ptr screenShotResponse_; +}; + +void ScreenShotHandlerTest::SetUpTestCase(void) +{} + +void ScreenShotHandlerTest::TearDownTestCase(void) +{} + +void ScreenShotHandlerTest::SetUp() +{ + screenShotHandler_ = std::make_shared(); + screenShotResponse_ = std::make_shared(); +} + +void ScreenShotHandlerTest::TearDown() +{ + screenShotHandler_.reset(); + screenShotResponse_.reset(); +} + +/* + * Feature: ScreenShotHandlerTest + * Function: OnWindowShot + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions: NA + * CaseDescription: get Screen Shot + */ +HWTEST_F(ScreenShotHandlerTest, ability_screenshot_response_001, TestSize.Level1) +{ + WMImageInfo info; + info.width = 1; + info.size = 5; + info.height = 2; + info.format = 3; + info.data = nullptr; + screenShotResponse_->OnWindowShot(info); + WMImageInfo infos = screenShotResponse_->GetImageInfo(); + EXPECT_EQ(infos.width, static_cast(1)); + EXPECT_EQ(infos.size, static_cast(5)); + EXPECT_EQ(infos.height, static_cast(2)); + EXPECT_EQ(infos.format, static_cast(3)); + EXPECT_EQ(infos.data, nullptr); +} + +/* + * Feature: ScreenShotHandlerTest + * Function: ScreenshotHandler::GetImageInfo + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions: NA + * CaseDescription: get Image Info + */ +HWTEST_F(ScreenShotHandlerTest, ability_screenshot_handler_001, TestSize.Level1) +{ + int missionId = 0; + WMImageInfo info; + info.width = 1; + info.size = 5; + info.height = 2; + info.format = 3; + info.data = nullptr; + screenShotHandler_->screenShot_.emplace(missionId, info); + EXPECT_EQ(static_cast(screenShotHandler_->screenShot_.size()), static_cast(1)); + auto imageInfo = screenShotHandler_->GetImageInfo(missionId); + EXPECT_EQ(static_cast(screenShotHandler_->screenShot_.size()), static_cast(1)); + EXPECT_EQ(imageInfo.width, static_cast(1)); + EXPECT_EQ(imageInfo.size, static_cast(5)); + EXPECT_EQ(imageInfo.height, static_cast(2)); + EXPECT_EQ(imageInfo.format, static_cast(3)); + EXPECT_EQ(imageInfo.data, nullptr); +} + +/* + * Feature: ScreenShotHandlerTest + * Function: ScreenshotHandler::RemoveImageInfo + * SubFunction: NA + * FunctionPoints: NA + * EnvConditions: NA + * CaseDescription: remove Image Info + */ +HWTEST_F(ScreenShotHandlerTest, ability_screenshot_handler_002, TestSize.Level1) +{ + int missionId = 0; + WMImageInfo info; + info.width = 1; + info.size = 5; + info.height = 2; + info.format = 3; + info.data = nullptr; + screenShotHandler_->screenShot_.emplace(missionId, info); + EXPECT_EQ(static_cast(screenShotHandler_->screenShot_.size()), static_cast(1)); + screenShotHandler_->RemoveImageInfo(missionId); + EXPECT_EQ(static_cast(screenShotHandler_->screenShot_.size()), static_cast(0)); +} +} // namespace AAFwk +} // namespace OHOS diff --git a/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/want_receiver_proxy_test.cpp b/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/want_receiver_proxy_test.cpp index ac041dbe3bd6af534f3d0385cce3d015aea4a09c..a90287be686c14884d0f4b0b79d2b234fa3860d5 100644 --- a/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/want_receiver_proxy_test.cpp +++ b/services/abilitymgr/test/unittest/phone/want_receiver_proxy_test/want_receiver_proxy_test.cpp @@ -56,7 +56,7 @@ void WantReceiverProxyTest::SetUp() * EnvConditions: NA * CaseDescription: Verify that the return value of Send is normal */ -HWTEST_F(WantReceiverProxyTest, WantReceiverProxyTest_001, TestSize.Level0) +HWTEST_F(WantReceiverProxyTest, WantReceiverProxyTest_001, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) @@ -75,7 +75,7 @@ HWTEST_F(WantReceiverProxyTest, WantReceiverProxyTest_001, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify that the return value of PerformReceive is normal */ -HWTEST_F(WantReceiverProxyTest, WantReceiverProxyTest_002, TestSize.Level0) +HWTEST_F(WantReceiverProxyTest, WantReceiverProxyTest_002, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) diff --git a/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/want_receiver_stub_test.cpp b/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/want_receiver_stub_test.cpp index c3a1a7a47ddc5db54ab9ba852ee1111c7eb1efbd..b7c9fd7c7ff3fef9db305ab6742a86ae7a6798fb 100644 --- a/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/want_receiver_stub_test.cpp +++ b/services/abilitymgr/test/unittest/phone/want_receiver_stub_test/want_receiver_stub_test.cpp @@ -57,7 +57,7 @@ void WantReceiverStubTest::WriteInterfaceToken(MessageParcel &data) * EnvConditions: The code which not exist * CaseDescription: Verify that on remote request is abnormal */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_001, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -77,7 +77,7 @@ HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_001, TestSiz * EnvConditions: Description abnormal * CaseDescription: Verify that on remote request is abnormal */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_002, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_002, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -96,7 +96,7 @@ HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_002, TestSiz * EnvConditions: Code is WANT_SENDER_SEND * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_003, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_003, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -119,7 +119,7 @@ HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_OnRemoteRequest_003, TestSiz * EnvConditions: Valid parameter * CaseDescription: Verify the function SendInner request is normal. */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_SendInner_001, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_SendInner_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -140,7 +140,7 @@ HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_SendInner_001, TestSize.Leve * EnvConditions: Invalid parameter * CaseDescription: Verify the function PerformReceiveInner request is abnormal. */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_001, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -158,7 +158,7 @@ HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_001, Tes * EnvConditions: Invalid parameter * CaseDescription: Verify the function PerformReceiveInner request is abnormal. */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_002, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_002, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -179,7 +179,7 @@ HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_002, Tes * EnvConditions: Valid parameter * CaseDescription: Verify the function PerformReceiveInner request is normal. */ -HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_003, TestSize.Level0) +HWTEST_F(WantReceiverStubTest, WantReceiverStubTest_PerformReceiveInner_003, TestSize.Level1) { MessageParcel data; MessageParcel reply; diff --git a/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/want_sender_proxy_test.cpp b/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/want_sender_proxy_test.cpp index a2c4113cdc37475e6dcadecf18496966a8bca331..d44fe90e3bfe80585dd6afc5145894c465cfac84 100644 --- a/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/want_sender_proxy_test.cpp +++ b/services/abilitymgr/test/unittest/phone/want_sender_proxy_test/want_sender_proxy_test.cpp @@ -57,7 +57,7 @@ void WantSenderProxyTest::SetUp() * EnvConditions: NA * CaseDescription: Verify that the return value of Send is normal */ -HWTEST_F(WantSenderProxyTest, WantSenderProxyTest_001, TestSize.Level0) +HWTEST_F(WantSenderProxyTest, WantSenderProxyTest_001, TestSize.Level1) { EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) diff --git a/services/abilitymgr/test/unittest/phone/want_sender_stub_test/want_sender_stub_test.cpp b/services/abilitymgr/test/unittest/phone/want_sender_stub_test/want_sender_stub_test.cpp index 0f2d7c450edf82c42f77b0be1f9b030e27b835fa..82ab3c60f3e398f4cec2b7bd9583a6ecec6e1c83 100644 --- a/services/abilitymgr/test/unittest/phone/want_sender_stub_test/want_sender_stub_test.cpp +++ b/services/abilitymgr/test/unittest/phone/want_sender_stub_test/want_sender_stub_test.cpp @@ -57,7 +57,7 @@ void WantSenderStubTest::WriteInterfaceToken(MessageParcel &data) * EnvConditions: The code which not exist * CaseDescription: Verify that on remote request is abnormal */ -HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_001, TestSize.Level0) +HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -77,7 +77,7 @@ HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_001, TestSize.Le * EnvConditions: Description abnormal * CaseDescription: Verify that on remote request is abnormal */ -HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_002, TestSize.Level0) +HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_002, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -96,7 +96,7 @@ HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_002, TestSize.Le * EnvConditions: Code is WANT_SENDER_SEND * CaseDescription: Verify that on remote request is normal */ -HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_003, TestSize.Level0) +HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_003, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -119,7 +119,7 @@ HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_003, TestSize.Le * EnvConditions: Invalid parameter * CaseDescription: Verify the function SendInner request is abnormal. */ -HWTEST_F(WantSenderStubTest, WantSenderStubTest_SendInner_001, TestSize.Level0) +HWTEST_F(WantSenderStubTest, WantSenderStubTest_SendInner_001, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -137,7 +137,7 @@ HWTEST_F(WantSenderStubTest, WantSenderStubTest_SendInner_001, TestSize.Level0) * EnvConditions: Valid parameter * CaseDescription: Verify the function SendInner request is normal. */ -HWTEST_F(WantSenderStubTest, WantSenderStubTest_SendInner_002, TestSize.Level0) +HWTEST_F(WantSenderStubTest, WantSenderStubTest_SendInner_002, TestSize.Level1) { MessageParcel data; MessageParcel reply; diff --git a/services/abilitymgr/test/unittest/phone/window_info_test/window_info_test.cpp b/services/abilitymgr/test/unittest/phone/window_info_test/window_info_test.cpp index 2c4808d102f21d9f01250f73323bfc67a627c62e..1e7c1d40a72486a8f6b015388a99d21bc5987b94 100644 --- a/services/abilitymgr/test/unittest/phone/window_info_test/window_info_test.cpp +++ b/services/abilitymgr/test/unittest/phone/window_info_test/window_info_test.cpp @@ -57,7 +57,7 @@ std::shared_ptr WindowInfoTest::get() const * EnvConditions:NA * CaseDescription: Verify member variable values */ -HWTEST_F(WindowInfoTest, AAFWK_Window_Info, TestSize.Level0) +HWTEST_F(WindowInfoTest, AAFWK_Window_Info, TestSize.Level1) { EXPECT_EQ((int)get()->windowToken_, 1); EXPECT_FALSE(get()->isVisible_); diff --git a/services/test/mock/include/mock_ability_manager_proxy.h b/services/test/mock/include/mock_ability_manager_proxy.h index f884df11531d92f171bae5281653376a2a9d39c6..9963caba0f4d62fe0eb6756064b8a3c602549437 100644 --- a/services/test/mock/include/mock_ability_manager_proxy.h +++ b/services/test/mock/include/mock_ability_manager_proxy.h @@ -50,8 +50,8 @@ public: MOCK_METHOD2(TerminateAbilityResult, int(const sptr &, int startId)); MOCK_METHOD1(StopServiceAbility, int(const Want &)); MOCK_METHOD1(GetAllStackInfo, int(StackInfo &stackInfo)); - MOCK_METHOD3(GetRecentMissions, int(const int32_t, const int32_t, std::vector &)); - MOCK_METHOD2(GetMissionSnapshot, int(const int32_t, MissionSnapshotInfo &)); + MOCK_METHOD3(GetRecentMissions, int(const int32_t, const int32_t, std::vector &)); + MOCK_METHOD2(GetMissionSnapshot, int(const int32_t, MissionPixelMap &)); MOCK_METHOD1(RemoveMission, int(int)); MOCK_METHOD1(RemoveStack, int(int)); MOCK_METHOD1(MoveMissionToTop, int(int32_t)); diff --git a/services/test/mock/include/mock_ability_mgr_service.h b/services/test/mock/include/mock_ability_mgr_service.h index 5274f1e6964ca3344d3cd183ed9d8589fa45c1c8..d9f1de9f09fa7a1859fd67ec18c1cfa28a9266fd 100644 --- a/services/test/mock/include/mock_ability_mgr_service.h +++ b/services/test/mock/include/mock_ability_mgr_service.h @@ -46,7 +46,7 @@ public: MOCK_METHOD1(StopServiceAbility, int(const Want &)); MOCK_METHOD1(GetAllStackInfo, int(StackInfo &stackInfo)); MOCK_METHOD3(GetRecentMissions, int(const int32_t, const int32_t, std::vector &)); - MOCK_METHOD2(GetMissionSnapshot, int(const int32_t, MissionSnapshotInfo &)); + MOCK_METHOD2(GetMissionSnapshot, int(const int32_t, MissionPixelMap &)); MOCK_METHOD1(RemoveMission, int(int)); MOCK_METHOD1(RemoveStack, int(int)); MOCK_METHOD1(MoveMissionToTop, int(int32_t)); @@ -103,6 +103,8 @@ public: MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string &)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); + void Wait() { sem_.Wait(); diff --git a/services/test/mock/include/mock_window_manager.h b/services/test/mock/include/mock_window_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..43b13451571c0f006a0c0de4850b2f5bf5c95134 --- /dev/null +++ b/services/test/mock/include/mock_window_manager.h @@ -0,0 +1,56 @@ +/* + * 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 FRAMEWORKS_WM_INCLUDE_MOCK_WINDOW_MANAGER_H +#define FRAMEWORKS_WM_INCLUDE_MOCK_WINDOW_MANAGER_H + +#include +#include + +#include "iwindow_manager_service.h" + +namespace OHOS { +class WindowManagerServiceMock : public IWindowManagerService { +public: + virtual ~WindowManagerServiceMock() = default; + + MOCK_METHOD1(GetDisplays, WMError(std::vector &displays)); + MOCK_METHOD1(GetDisplayPower, sptr(int32_t did)); + MOCK_METHOD2(SetDisplayPower, sptr(int32_t did, DispPowerStatus status)); + MOCK_METHOD1(GetDisplayBacklight, sptr(int32_t did)); + MOCK_METHOD2(SetDisplayBacklight, sptr(int32_t did, uint32_t level)); + MOCK_METHOD1(GetDisplayModes, WMError(uint32_t &displayModes)); + MOCK_METHOD1(SetDisplayMode, sptr(WMSDisplayMode modes)); + MOCK_METHOD1(AddDisplayChangeListener, WMError(IWindowManagerDisplayListenerClazz *listener)); + MOCK_METHOD1(OnWindowListChange, sptr(IWindowChangeListenerClazz *listener)); + MOCK_METHOD1(SetDisplayDirection, WMError(WMSDisplayDirection direction)); + MOCK_METHOD1(OnDisplayDirectionChange, WMError(DisplayDirectionChangeFunc func)); + MOCK_METHOD1(SetStatusBarVisibility, sptr(bool visibility)); + MOCK_METHOD1(SetNavigationBarVisibility, sptr(bool visibility)); + MOCK_METHOD1(ShotScreen, sptr(int32_t did)); + MOCK_METHOD1(ShotWindow, sptr(int32_t wid)); + MOCK_METHOD1(DestroyWindow, sptr(int32_t wid)); + MOCK_METHOD1(SwitchTop, sptr(int32_t wid)); + MOCK_METHOD1(Show, sptr(int32_t wid)); + MOCK_METHOD1(Hide, sptr(int32_t wid)); + MOCK_METHOD3(Move, sptr(int32_t wid, int32_t x, int32_t y)); + MOCK_METHOD3(Resize, sptr(int32_t wid, uint32_t width, uint32_t height)); + MOCK_METHOD3(ScaleTo, sptr(int32_t wid, uint32_t width, uint32_t height)); + MOCK_METHOD2(SetWindowType, sptr(int32_t wid, WindowType type)); + MOCK_METHOD2(SetWindowMode, sptr(int32_t wid, WindowMode mode)); +}; +} // namespace OHOS + +#endif // FRAMEWORKS_WM_INCLUDE_MOCK_WINDOW_MANAGER_H diff --git a/services/test/moduletest/ability_mgr_service_test/BUILD.gn b/services/test/moduletest/ability_mgr_service_test/BUILD.gn index cb267a323795a51cb58186cf92fc7396898eda4a..d32ca7212ff79ece1b6bc11816a1ce0258f684e3 100644 --- a/services/test/moduletest/ability_mgr_service_test/BUILD.gn +++ b/services/test/moduletest/ability_mgr_service_test/BUILD.gn @@ -45,7 +45,6 @@ ohos_moduletest("ability_mgr_module_test") { "//foundation/aafwk/standard/services/abilitymgr/src/connection_record.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/data_ability_manager.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/data_ability_record.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/image_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/kernal_system_app_manager.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/launch_param.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/lifecycle_deal.cpp", @@ -54,7 +53,7 @@ ohos_moduletest("ability_mgr_module_test") { "//foundation/aafwk/standard/services/abilitymgr/src/mission_option.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_record.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_record_info.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot_info.cpp", + "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_stack.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_stack_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/pending_want_key.cpp", diff --git a/services/test/moduletest/ability_record_test/BUILD.gn b/services/test/moduletest/ability_record_test/BUILD.gn index 26d34aeeebfae175cde84b43356f6691442552da..1c379461458acbdf006e88b64337b7680a745cb1 100644 --- a/services/test/moduletest/ability_record_test/BUILD.gn +++ b/services/test/moduletest/ability_record_test/BUILD.gn @@ -46,7 +46,6 @@ ohos_moduletest("AbilityRecordModuleTest") { "${services_path}/abilitymgr/src/connection_record.cpp", "${services_path}/abilitymgr/src/data_ability_manager.cpp", "${services_path}/abilitymgr/src/data_ability_record.cpp", - "${services_path}/abilitymgr/src/image_info.cpp", "${services_path}/abilitymgr/src/kernal_system_app_manager.cpp", "${services_path}/abilitymgr/src/launch_param.cpp", "${services_path}/abilitymgr/src/lifecycle_deal.cpp", @@ -54,7 +53,7 @@ ohos_moduletest("AbilityRecordModuleTest") { "${services_path}/abilitymgr/src/mission_description_info.cpp", "${services_path}/abilitymgr/src/mission_record.cpp", "${services_path}/abilitymgr/src/mission_record_info.cpp", - "${services_path}/abilitymgr/src/mission_snapshot_info.cpp", + "${services_path}/abilitymgr/src/mission_snapshot.cpp", "${services_path}/abilitymgr/src/mission_stack.cpp", "${services_path}/abilitymgr/src/mission_stack_info.cpp", "${services_path}/abilitymgr/src/pending_want_key.cpp", diff --git a/services/test/moduletest/ability_stack_test/BUILD.gn b/services/test/moduletest/ability_stack_test/BUILD.gn index 947e6336da718e543ba5ffbc3cd98b5c05539338..c20b22affb03ce3514736e3ef6965a705d875d88 100644 --- a/services/test/moduletest/ability_stack_test/BUILD.gn +++ b/services/test/moduletest/ability_stack_test/BUILD.gn @@ -44,7 +44,6 @@ ohos_moduletest("ability_stack_module_test") { "//foundation/aafwk/standard/services/abilitymgr/src/connection_record.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/data_ability_manager.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/data_ability_record.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/image_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/kernal_system_app_manager.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/launch_param.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/lifecycle_deal.cpp", @@ -52,7 +51,7 @@ ohos_moduletest("ability_stack_module_test") { "//foundation/aafwk/standard/services/abilitymgr/src/mission_description_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_record.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_record_info.cpp", - "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot_info.cpp", + "//foundation/aafwk/standard/services/abilitymgr/src/mission_snapshot.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_stack.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/mission_stack_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/pending_want_key.cpp", @@ -60,6 +59,7 @@ ohos_moduletest("ability_stack_module_test") { "//foundation/aafwk/standard/services/abilitymgr/src/pending_want_record.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/power_storage.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/sender_info.cpp", + "//foundation/aafwk/standard/services/abilitymgr/src/shared_memory.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/stack_info.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/want_receiver_stub.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/want_sender_info.cpp", diff --git a/services/test/moduletest/ability_stack_test/ability_stack_module_test.cpp b/services/test/moduletest/ability_stack_test/ability_stack_module_test.cpp index c3fbe93e2202e310f924de0addb28d3c59d0b0cc..85fff73c8f39ca352d8ab330ba74e336cc2f957d 100644 --- a/services/test/moduletest/ability_stack_test/ability_stack_module_test.cpp +++ b/services/test/moduletest/ability_stack_test/ability_stack_module_test.cpp @@ -24,6 +24,8 @@ #include "mock_app_mgr_client.h" #include "mock_app_scheduler.h" #include "ability_manager_service.h" +#include "mock_window_manager.h" +#include "screenshot_handler.h" #undef private #undef protected #include @@ -262,6 +264,55 @@ ApplicationInfo AbilityStackModuleTest::CreateAppInfo(const std::string &appName return appInfo; } +/* + * Feature: AaFwk + * Function:GetMissionSnapshot + * SubFunction: Get Mission Snapshot + * FunctionPoints: + * EnvConditions: NA + * CaseDescription: Get Mission Snapshot + */ +HWTEST_F(AbilityStackModuleTest, ability_stack_test_getMissionSnapshot_001, TestSize.Level1) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + stackManager_->Init(); + + WindowManagerServiceMock *mockWindowManager = new WindowManagerServiceMock(); + // set mock + stackManager_->screenshotHandler_->windowMS_ = mockWindowManager; + sptr promise = new PromiseWMSImageInfo(); + auto infos = [promise](int32_t id) -> sptr { + return promise; + }; + EXPECT_CALL(*mockWindowManager, ShotWindow) + .Times(AtLeast(1)) + .WillOnce(Invoke(infos)); + + auto launcherAbilityRequest_ = GenerateAbilityRequest("device", "LauncherAbility", "launcher", "com.ix.hiworld"); + auto ref = stackManager_->StartAbility(launcherAbilityRequest_); + EXPECT_EQ(ERR_OK, ref); + EXPECT_TRUE(stackManager_->missionStackList_.size() != 0); + + int32_t missionId = 0; + MissionPixelMap missionPixelMap; + std::thread([promise]() { + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + WMSImageInfo imageInfo; + imageInfo.width = 2; + imageInfo.height = 3; + imageInfo.format = 10; + promise->Resolve(imageInfo); + }).detach(); + auto ret = stackManager_->GetMissionSnapshot(missionId,missionPixelMap); + + EXPECT_TRUE(missionPixelMap.topAbility.abilityName_ == "LauncherAbility"); + EXPECT_TRUE(missionPixelMap.topAbility.bundleName_ == "com.ix.hiworld"); + EXPECT_TRUE(missionPixelMap.imageInfo.width == 2); + EXPECT_TRUE(missionPixelMap.imageInfo.height== 3); + EXPECT_TRUE(missionPixelMap.imageInfo.format == 10); + EXPECT_TRUE(ERR_OK == ret); +} + /* * Feature: AaFwk * Function: ability stack management diff --git a/services/test/moduletest/ipc_ability_mgr_test/ipc_ability_mgr_module_test.cpp b/services/test/moduletest/ipc_ability_mgr_test/ipc_ability_mgr_module_test.cpp index 02446671f38cc1015b961e564da2ec84c59554dd..69b19815e655d0dd547fffbe1847da2130b71755 100644 --- a/services/test/moduletest/ipc_ability_mgr_test/ipc_ability_mgr_module_test.cpp +++ b/services/test/moduletest/ipc_ability_mgr_test/ipc_ability_mgr_module_test.cpp @@ -480,11 +480,11 @@ HWTEST_F(IpcAbilityMgrModuleTest, AbilityMgrService_IPC_015, TestSize.Level1) sptr mockAbilityMgr(new MockAbilityMgrService()); sptr abilityMgrClient = iface_cast(mockAbilityMgr); - MissionSnapshotInfo snapshot; + MissionPixelMap missionPixelMap; EXPECT_CALL(*mockAbilityMgr, GetMissionSnapshot(_, _)) .Times(1) .WillOnce(InvokeWithoutArgs(mockAbilityMgr.GetRefPtr(), &MockAbilityMgrService::Post)); - abilityMgrClient->GetMissionSnapshot(1, snapshot); + abilityMgrClient->GetMissionSnapshot(1, missionPixelMap); mockAbilityMgr->Wait(); } diff --git a/services/test/moduletest/panding_want_manager_test/BUILD.gn b/services/test/moduletest/panding_want_manager_test/BUILD.gn index f817abb176f5ef22819ec7f6c68377e80b955a05..0344df5ceba7bf45f711573e6ca733e2b64a59ee 100644 --- a/services/test/moduletest/panding_want_manager_test/BUILD.gn +++ b/services/test/moduletest/panding_want_manager_test/BUILD.gn @@ -22,24 +22,15 @@ ohos_moduletest("PandingWantMgrTest") { include_dirs = [ "//foundation/aafwk/standard/services/test/mock/include", - "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", - "//foundation/distributedschedule/samgr/adapter/interfaces/innerkits/include/", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmg", "//foundation/appexecfwk/standard/kits/appkit/native/app/include", - "//base/notification/ns_standard/interfaces/innerkits/wantagent/include", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", + "//foundation/distributedschedule/samgr/adapter/interfaces/innerkits/include/", "//third_party/jsoncpp/include", - "//base/notification/ans_standard/interfaces/innerkits/wantagent/include", ] sources = abilityms_files sources += [ - "//base/notification/ans_standard/frameworks/wantagent/src/completed_dispatcher.cpp", - "//base/notification/ans_standard/frameworks/wantagent/src/pending_want.cpp", - "//base/notification/ans_standard/frameworks/wantagent/src/trigger_info.cpp", - "//base/notification/ans_standard/frameworks/wantagent/src/want_agent.cpp", - "//base/notification/ans_standard/frameworks/wantagent/src/want_agent_helper.cpp", - "//base/notification/ans_standard/frameworks/wantagent/src/want_agent_info.cpp", - "//base/notification/ans_standard/frameworks/wantagent/src/want_agent_log_wrapper.cpp", "//foundation/aafwk/standard/services/abilitymgr/src/ability_manager_client.cpp", "//foundation/aafwk/standard/services/abilitymgr/test/mock/libs/sa_mgr/src/sa_mgr_client_mock.cpp", "//foundation/aafwk/standard/services/test/mock/src/mock_app_mgr_client.cpp", @@ -59,6 +50,7 @@ ohos_moduletest("PandingWantMgrTest") { "${innerkits_path}/want:want", "//base/global/i18n_standard/frameworks/intl:intl_util", "//base/hiviewdfx/hiview/adapter/utility:hiview_adapter_utility", + "//base/notification/ans_standard/frameworks/wantagent:wantagent_innerkits", "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", "//foundation/aafwk/standard/frameworks/kits/ability/native:dummy_classes", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", @@ -67,6 +59,7 @@ ohos_moduletest("PandingWantMgrTest") { "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//foundation/graphic/standard:libwmservice", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", diff --git a/tools/aa/src/ability_command.cpp b/tools/aa/src/ability_command.cpp index f4947457cdb191a074dfb29ad03ea0df42eabcae..61b2afeb96df824d433714877c9460dee2ebaf4a 100644 --- a/tools/aa/src/ability_command.cpp +++ b/tools/aa/src/ability_command.cpp @@ -17,6 +17,7 @@ #include #include "ability_manager_client.h" +#include "mission_snapshot.h" #include "hilog_wrapper.h" #include "ohos/aafwk/base/bool_wrapper.h" @@ -933,5 +934,6 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want &want, std::string &win return result; } + } // namespace AAFwk } // namespace OHOS diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 9ec12f2b8829ad6b8f7a615d1823297d32bbe920..1ee0bd746d0c06cfe8357b26f1e3021d6477280e 100644 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -71,7 +71,7 @@ public: MOCK_METHOD1(GetAllStackInfo, int(StackInfo &stackInfo)); MOCK_METHOD3( GetRecentMissions, int(const int32_t numMax, const int32_t flags, std::vector &recentList)); - MOCK_METHOD2(GetMissionSnapshot, int(const int32_t missionId, MissionSnapshotInfo &snapshot)); + MOCK_METHOD2(GetMissionSnapshot, int(const int32_t missionId, MissionPixelMap &missionPixelMap)); MOCK_METHOD1(MoveMissionToTop, int(int32_t missionId)); MOCK_METHOD1(RemoveMission, int(int id)); MOCK_METHOD1(RemoveStack, int(int id)); @@ -129,6 +129,7 @@ public: MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string &)); + MOCK_METHOD2(GetWantSenderInfo, int(const sptr &target, std::shared_ptr &info)); public: std::string powerState_; };