mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-30 02:41:30 +00:00
!163 Fix wantAgent service bugs
Merge pull request !163 from blackleon/master_1129
This commit is contained in:
commit
eb7e5cb356
@ -29,6 +29,7 @@ ohos_shared_library("appexecfwk_base") {
|
||||
"src/ability_info.cpp",
|
||||
"src/application_info.cpp",
|
||||
"src/bundle_info.cpp",
|
||||
"src/common_event_info.cpp",
|
||||
"src/compatible_ability_info.cpp",
|
||||
"src/compatible_application_info.cpp",
|
||||
"src/element_name.cpp",
|
||||
|
@ -97,7 +97,6 @@ struct ApplicationInfo : public Parcelable {
|
||||
std::string cpuAbi;
|
||||
bool isCompressNativeLibs = true;
|
||||
bool debug = false;
|
||||
bool unremovable = false;
|
||||
bool singleUser = false;
|
||||
bool systemApp = false;
|
||||
|
||||
|
@ -58,7 +58,6 @@ struct BundleInfo : public Parcelable {
|
||||
bool isKeepAlive = false;
|
||||
bool isNativeApp = false;
|
||||
bool isDifferentName = false;
|
||||
bool unremovable = false;
|
||||
bool singleUser = false;
|
||||
int64_t installTime = 0; // the installation time is the number of seconds elapsed since January 1,
|
||||
// 1970 00:00:00 UTC. The time will be recalculated if the application is reinstalled
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_COMMON_EVENT_H
|
||||
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_COMMON_EVENT_H
|
||||
|
||||
#include <string>
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct CommonEventInfo : public Parcelable {
|
||||
std::string name;
|
||||
std::string bundleName;
|
||||
int uid = -1;
|
||||
std::string permission;
|
||||
std::vector<std::string> data;
|
||||
std::vector<std::string> type;
|
||||
std::vector<std::string> events;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static CommonEventInfo *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_COMMON_EVENT_H
|
@ -20,6 +20,7 @@
|
||||
#include "bundle_info.h"
|
||||
#include "form_info.h"
|
||||
#include "shortcut_info.h"
|
||||
#include "common_event_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -48,7 +49,8 @@ void to_json(nlohmann::json &jsonObject, const FormInfo &formInfo);
|
||||
void from_json(const nlohmann::json &jsonObject, FormInfo &formInfo);
|
||||
void to_json(nlohmann::json &jsonObject, const ShortcutInfo &shortcutInfo);
|
||||
void from_json(const nlohmann::json &jsonObject, ShortcutInfo &shortcutInfo);
|
||||
|
||||
void to_json(nlohmann::json &jsonObject, const CommonEventInfo &commonEvent);
|
||||
void from_json(const nlohmann::json &jsonObject, CommonEventInfo &commonEvent);
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_JSON_SERIALIZER_H
|
||||
|
@ -49,7 +49,6 @@ bool ApplicationInfo::ReadFromParcel(Parcel &parcel)
|
||||
isLauncherApp = parcel.ReadBool();
|
||||
enabled = parcel.ReadBool();
|
||||
debug = parcel.ReadBool();
|
||||
unremovable = parcel.ReadBool();
|
||||
singleUser = parcel.ReadBool();
|
||||
supportedModes = parcel.ReadInt32();
|
||||
labelId = parcel.ReadInt32();
|
||||
@ -111,7 +110,6 @@ bool ApplicationInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isLauncherApp);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enabled);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, debug);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, unremovable);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, singleUser);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportedModes);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labelId);
|
||||
@ -191,7 +189,6 @@ void to_json(nlohmann::json &jsonObject, const ApplicationInfo &applicationInfo)
|
||||
{"dataBaseDir", applicationInfo.dataBaseDir},
|
||||
{"cacheDir", applicationInfo.cacheDir},
|
||||
{"flags", applicationInfo.flags},
|
||||
{"unremovable", applicationInfo.unremovable},
|
||||
{"singleUser", applicationInfo.singleUser}
|
||||
};
|
||||
}
|
||||
@ -210,7 +207,6 @@ void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInf
|
||||
applicationInfo.signatureKey = jsonObject.at("signatureKey").get<std::string>();
|
||||
applicationInfo.isSystemApp = jsonObject.at("isSystemApp").get<bool>();
|
||||
applicationInfo.isLauncherApp = jsonObject.at("isLauncherApp").get<bool>();
|
||||
applicationInfo.unremovable = jsonObject.at("unremovable").get<bool>();
|
||||
applicationInfo.singleUser = jsonObject.at("singleUser").get<bool>();
|
||||
applicationInfo.enabled = jsonObject.at("enabled").get<bool>();
|
||||
applicationInfo.debug = jsonObject.at("debug").get<bool>();
|
||||
|
@ -48,7 +48,6 @@ bool BundleInfo::ReadFromParcel(Parcel &parcel)
|
||||
isKeepAlive = parcel.ReadBool();
|
||||
isNativeApp = parcel.ReadBool();
|
||||
isDifferentName = parcel.ReadBool();
|
||||
unremovable = parcel.ReadBool();
|
||||
singleUser = parcel.ReadBool();
|
||||
installTime = parcel.ReadInt64();
|
||||
updateTime = parcel.ReadInt64();
|
||||
@ -148,7 +147,6 @@ bool BundleInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isKeepAlive);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isNativeApp);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDifferentName);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, unremovable);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, singleUser);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, installTime);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int64, parcel, updateTime);
|
||||
@ -249,7 +247,6 @@ void to_json(nlohmann::json &jsonObject, const BundleInfo &bundleInfo)
|
||||
{"modulePublicDirs", bundleInfo.modulePublicDirs},
|
||||
{"moduleDirs", bundleInfo.moduleDirs},
|
||||
{"moduleResPaths", bundleInfo.moduleResPaths},
|
||||
{"unremovable", bundleInfo.unremovable},
|
||||
{"singleUser", bundleInfo.singleUser}
|
||||
};
|
||||
}
|
||||
@ -289,7 +286,6 @@ void from_json(const nlohmann::json &jsonObject, BundleInfo &bundleInfo)
|
||||
bundleInfo.modulePublicDirs = jsonObject.at("modulePublicDirs").get<std::vector<std::string>>();
|
||||
bundleInfo.moduleDirs = jsonObject.at("moduleDirs").get<std::vector<std::string>>();
|
||||
bundleInfo.moduleResPaths = jsonObject.at("moduleResPaths").get<std::vector<std::string>>();
|
||||
bundleInfo.unremovable = jsonObject.at("unremovable").get<bool>();
|
||||
bundleInfo.singleUser = jsonObject.at("singleUser").get<bool>();
|
||||
}
|
||||
|
||||
|
123
interfaces/innerkits/appexecfwk_base/src/common_event_info.cpp
Normal file
123
interfaces/innerkits/appexecfwk_base/src/common_event_info.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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 "common_event_info.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include "json_serializer.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "string_ex.h"
|
||||
#include "parcel_macro.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "bundle_constants.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string JSON_KEY_NAME = "name";
|
||||
const std::string JSON_KEY_BUNDLE_NAME = "bundleName";
|
||||
const std::string JSON_KEY_UID = "uid";
|
||||
const std::string JSON_KEY_PERMISSION = "permission";
|
||||
const std::string JSON_KEY_DATA = "data";
|
||||
const std::string JSON_KEY_TYPE = "type";
|
||||
const std::string JSON_KEY_EVENTS = "events";
|
||||
} // namespace
|
||||
|
||||
bool CommonEventInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
name = Str16ToStr8(parcel.ReadString16());
|
||||
bundleName = Str16ToStr8(parcel.ReadString16());
|
||||
uid = parcel.ReadInt32();
|
||||
permission = Str16ToStr8(parcel.ReadString16());
|
||||
|
||||
int32_t typeSize;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, typeSize);
|
||||
for (int32_t i = 0; i < typeSize; i++) {
|
||||
data.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||
}
|
||||
int32_t dataSize;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, dataSize);
|
||||
for (int32_t i = 0; i < dataSize; i++) {
|
||||
type.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||
}
|
||||
int32_t eventsSize;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, eventsSize);
|
||||
for (int32_t i = 0; i < eventsSize; i++) {
|
||||
events.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CommonEventInfo *CommonEventInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
std::unique_ptr<CommonEventInfo> info = std::make_unique<CommonEventInfo>();
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
APP_LOGW("read from parcel failed");
|
||||
info = nullptr;
|
||||
}
|
||||
return info.release();
|
||||
}
|
||||
|
||||
bool CommonEventInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uid);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(permission));
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, data.size());
|
||||
for (auto &dataSingle : data) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataSingle));
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, type.size());
|
||||
for (auto &typeSingle : type) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(typeSingle));
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, events.size());
|
||||
for (auto &event : events) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(event));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &jsonObject, const CommonEventInfo &commonEvent)
|
||||
{
|
||||
jsonObject = nlohmann::json {
|
||||
{JSON_KEY_NAME, commonEvent.name},
|
||||
{JSON_KEY_BUNDLE_NAME, commonEvent.bundleName},
|
||||
{JSON_KEY_UID, commonEvent.uid},
|
||||
{JSON_KEY_PERMISSION, commonEvent.permission},
|
||||
{JSON_KEY_DATA, commonEvent.data},
|
||||
{JSON_KEY_TYPE, commonEvent.type},
|
||||
{JSON_KEY_EVENTS, commonEvent.events}
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &jsonObject, CommonEventInfo &commonEvent)
|
||||
{
|
||||
commonEvent.name = jsonObject.at(JSON_KEY_NAME).get<std::string>();
|
||||
commonEvent.bundleName = jsonObject.at(JSON_KEY_BUNDLE_NAME).get<std::string>();
|
||||
commonEvent.uid = jsonObject.at(JSON_KEY_UID).get<int>();
|
||||
commonEvent.permission = jsonObject.at(JSON_KEY_PERMISSION).get<std::string>();
|
||||
commonEvent.data = jsonObject.at(JSON_KEY_DATA).get<std::vector<std::string>>();
|
||||
commonEvent.type = jsonObject.at(JSON_KEY_TYPE).get<std::vector<std::string>>();
|
||||
commonEvent.events = jsonObject.at(JSON_KEY_EVENTS).get<std::vector<std::string>>();
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -384,6 +384,13 @@ private:
|
||||
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||
*/
|
||||
ErrCode HandleGetShortcutInfos(Parcel &data, Parcel &reply);
|
||||
/**
|
||||
* @brief Handles the HandleGetAllCommonEventInfo function called from a IBundleMgr proxy object.
|
||||
* @param data Indicates the data to be read.
|
||||
* @param reply Indicates the reply to be sent;
|
||||
* @return Returns ERR_OK if called successfully; returns error code otherwise.
|
||||
*/
|
||||
ErrCode HandleGetAllCommonEventInfo(Parcel &data, Parcel &reply);
|
||||
/**
|
||||
* @brief Handles the HandleGetModuleUsageRecords function called from a IBundleMgr proxy object.
|
||||
* @param data Indicates the data to be read.
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ability_info.h"
|
||||
#include "form_info.h"
|
||||
#include "shortcut_info.h"
|
||||
#include "common_event_info.h"
|
||||
#include "module_usage_record.h"
|
||||
#include "application_info.h"
|
||||
#include "bundle_info.h"
|
||||
@ -406,7 +407,14 @@ public:
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) = 0;
|
||||
/**
|
||||
/**
|
||||
* @brief Obtains the CommonEventInfo objects provided by a event key on the device.
|
||||
* @param eventKey Indicates the event of the subscribe.
|
||||
* @param commonEventInfos List of CommonEventInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) = 0;
|
||||
/**
|
||||
* @brief Get module usage record list in descending order of lastLaunchTime.
|
||||
* @param maxNum the return size of the records, must be in range of 1 to 1000.
|
||||
* @param moduleUsageRecords List of ModuleUsageRecord objects if obtained.
|
||||
@ -480,6 +488,7 @@ public:
|
||||
GET_FORMS_INFO_BY_MODULE,
|
||||
GET_MODULE_USAGE_RECORD,
|
||||
GET_SHORTCUT_INFO,
|
||||
GET_ALL_COMMON_EVENT_INFO,
|
||||
GET_BUNDLE_INSTALLER,
|
||||
NOTIFY_ACTIVITY_LIFE_STATUS,
|
||||
};
|
||||
|
@ -401,7 +401,15 @@ public:
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
|
||||
/**
|
||||
/**
|
||||
* @brief Obtains the CommonEventInfo objects provided by a event key on the device.
|
||||
* @param eventKey Indicates the event of the subscribe.
|
||||
* @param commonEventInfos List of CommonEventInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos) override;
|
||||
/**
|
||||
* @brief Get module usage record list in descending order of lastLaunchTime.
|
||||
* @param maxNum the return size of the records, must be in range of 1 to 1000.
|
||||
* @param moduleUsageRecords List of ModuleUsageRecord objects if obtained.
|
||||
|
@ -200,6 +200,9 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa
|
||||
case static_cast<uint32_t>(IBundleMgr::Message::GET_SHORTCUT_INFO):
|
||||
errCode = HandleGetShortcutInfos(data, reply);
|
||||
break;
|
||||
case static_cast<uint32_t>(IBundleMgr::Message::GET_ALL_COMMON_EVENT_INFO):
|
||||
errCode = HandleGetAllCommonEventInfo(data, reply);
|
||||
break;
|
||||
case static_cast<uint32_t>(IBundleMgr::Message::GET_MODULE_USAGE_RECORD):
|
||||
errCode = HandleGetModuleUsageRecords(data, reply);
|
||||
break;
|
||||
@ -1080,6 +1083,25 @@ ErrCode BundleMgrHost::HandleGetShortcutInfos(Parcel &data, Parcel &reply)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHost::HandleGetAllCommonEventInfo(Parcel &data, Parcel &reply)
|
||||
{
|
||||
std::string eventKey = data.ReadString();
|
||||
std::vector<CommonEventInfo> infos;
|
||||
bool ret = GetAllCommonEventInfo(eventKey, infos);
|
||||
if (!reply.WriteBool(ret)) {
|
||||
APP_LOGE("write failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
if (!WriteParcelableVector(infos, reply)) {
|
||||
APP_LOGE("write failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHost::HandleGetModuleUsageRecords(Parcel &data, Parcel &reply)
|
||||
{
|
||||
int32_t number = data.ReadInt32();
|
||||
|
@ -1326,6 +1326,31 @@ bool BundleMgrProxy::GetShortcutInfos(const std::string &bundleName, std::vector
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrProxy::GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos)
|
||||
{
|
||||
if (eventKey.empty()) {
|
||||
APP_LOGE("fail to GetAllCommonEventInfo due to eventKey empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
APP_LOGE("fail to GetAllCommonEventInfo due to write MessageParcel fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteString(eventKey)) {
|
||||
APP_LOGE("fail to GetAllCommonEventInfo due to write eventKey fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetParcelableInfos<CommonEventInfo>(IBundleMgr::Message::GET_ALL_COMMON_EVENT_INFO, data, commonEventInfos)) {
|
||||
APP_LOGE("fail to GetAllCommonEventInfo from server");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrProxy::GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -151,10 +151,6 @@ static void ConvertApplicationInfo(napi_env env, napi_value objAppInfo, const Ap
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, appInfo.process.c_str(), NAPI_AUTO_LENGTH, &nProcess));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objAppInfo, "process", nProcess));
|
||||
|
||||
napi_value nUnremovable;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, appInfo.unremovable, &nUnremovable));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objAppInfo, "unremovable", nUnremovable));
|
||||
|
||||
napi_value nSingleUser;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, appInfo.singleUser, &nSingleUser));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objAppInfo, "singleUser", nSingleUser));
|
||||
@ -601,11 +597,6 @@ static void ConvertBundleInfo(napi_env env, napi_value objBundleInfo, const Bund
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, bundleInfo.name.c_str(), NAPI_AUTO_LENGTH, &nName));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objBundleInfo, "name", nName));
|
||||
|
||||
napi_value nUnremovable;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, bundleInfo.unremovable, &nUnremovable));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objBundleInfo, "unremovable", nUnremovable));
|
||||
HILOG_INFO("ConvertApplicationInfo unremovable=%{public}d.", bundleInfo.unremovable);
|
||||
|
||||
napi_value nSingleUser;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, bundleInfo.singleUser, &nSingleUser));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objBundleInfo, "singleUser", nSingleUser));
|
||||
|
@ -357,6 +357,11 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool GetModuleUsageRecords(
|
||||
const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) override
|
||||
{
|
||||
|
@ -399,6 +399,13 @@ public:
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) const;
|
||||
/**
|
||||
* @brief Obtains the CommonEventInfo objects provided by a event key on the device.
|
||||
* @param eventKey Indicates the event of the subscribe.
|
||||
* @param commonEventInfos List of CommonEventInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) const;
|
||||
/**
|
||||
* @brief Notify a specified ability for activity.
|
||||
* @param bundleName Indicates the bundle name of the ability to activity.
|
||||
|
@ -371,7 +371,15 @@ public:
|
||||
* @return Returns true if GetShortcutInfos successfully; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
|
||||
/**
|
||||
/**
|
||||
* @brief Obtains the CommonEventInfo objects provided by a event key on the device.
|
||||
* @param eventKey Indicates the event of the subscribe.
|
||||
* @param commonEventInfos List of CommonEventInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos) override;
|
||||
/**
|
||||
* @brief Get module usage record list in descending order of lastLaunchTime.
|
||||
* @param maxNum the return size of the records, must be in range of 1 to 1000.
|
||||
* @param moduleUsageRecords List of ModuleUsageRecord objects if obtained.
|
||||
|
@ -45,7 +45,6 @@ const std::string BUNDLE_APP_PROFILE_KEY_VENDOR = "vendor";
|
||||
const std::string BUNDLE_APP_PROFILE_KEY_VERSION = "version";
|
||||
const std::string BUNDLE_APP_PROFILE_KEY_API_VERSION = "apiVersion";
|
||||
const std::string BUNDLE_APP_PROFILE_KEY_DEBUG = "debug";
|
||||
const std::string BUNDLE_APP_PROFILE_KEY_UNREMOVABLE = "unremovable";
|
||||
const std::string BUNDLE_APP_PROFILE_KEY_SINGLE_USER = "singleUser";
|
||||
// sub BUNDLE_APP_PROFILE_KEY_VERSION
|
||||
const std::string BUNDLE_APP_PROFILE_KEY_CODE = "code";
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "ability_info.h"
|
||||
#include "form_info.h"
|
||||
#include "common_event_info.h"
|
||||
#include "bundle_info.h"
|
||||
#include "hap_module_info.h"
|
||||
#include "bundle_constants.h"
|
||||
@ -348,6 +349,17 @@ public:
|
||||
formInfos_.try_emplace(forms.first, forms.second);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Add common events to old InnerBundleInfo object.
|
||||
* @param commonEvents Indicates the Common Event object to be add.
|
||||
* @return
|
||||
*/
|
||||
void AddModuleCommonEvent(const std::map<std::string, CommonEventInfo> &commonEvents)
|
||||
{
|
||||
for (const auto &commonEvent : commonEvents) {
|
||||
commonEvents_.try_emplace(commonEvent.first, commonEvent.second);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Add shortcut infos to old InnerBundleInfo object.
|
||||
* @param shortcutInfos Indicates the Shortcut object to be add.
|
||||
@ -958,6 +970,15 @@ public:
|
||||
{
|
||||
formInfos_.emplace(keyName, formInfos);
|
||||
}
|
||||
/**
|
||||
* @brief Insert commonEvent.
|
||||
* @param keyName Indicates object as key.
|
||||
* @param commonEvents Indicates the common event object as value.
|
||||
*/
|
||||
void InsertCommonEvents(const std::string &keyName, const CommonEventInfo &commonEvents)
|
||||
{
|
||||
commonEvents_.emplace(keyName, commonEvents);
|
||||
}
|
||||
/**
|
||||
* @brief Insert shortcutInfos.
|
||||
* @param keyName Indicates object as key.
|
||||
@ -1017,6 +1038,12 @@ public:
|
||||
* @param shortcutInfos List of ShortcutInfo objects if obtained.
|
||||
*/
|
||||
void GetShortcutInfos(std::vector<ShortcutInfo> &shortcutInfos) const;
|
||||
/**
|
||||
* @brief Obtains the common event objects provided by a specified application on the device.
|
||||
* @param commonEvents List of common event objects if obtained.
|
||||
*/
|
||||
void GetCommonEvents(const std::string &eventKey, std::vector<CommonEventInfo> &commonEvents) const;
|
||||
|
||||
|
||||
std::optional<InnerModuleInfo> GetInnerModuleInfoByModuleName(const std::string &moduleName) const;
|
||||
|
||||
@ -1043,6 +1070,7 @@ private:
|
||||
std::string mainAbilityName_;
|
||||
|
||||
std::map<std::string, std::vector<FormInfo>> formInfos_;
|
||||
std::map<std::string, CommonEventInfo> commonEvents_;
|
||||
std::map<std::string, AbilityInfo> baseAbilityInfos_;
|
||||
std::map<std::string, InnerModuleInfo> innerModuleInfos_;
|
||||
std::map<std::string, std::vector<Skill>> skillInfos_;
|
||||
|
@ -1599,6 +1599,37 @@ bool BundleDataMgr::GetShortcutInfos(const std::string &bundleName, std::vector<
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleDataMgr::GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos) const
|
||||
{
|
||||
if (eventKey.empty()) {
|
||||
APP_LOGW("event key is empty");
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(bundleInfoMutex_);
|
||||
if (bundleInfos_.empty()) {
|
||||
APP_LOGI("bundleInfos_ data is empty");
|
||||
return false;
|
||||
}
|
||||
for (auto infoItem : bundleInfos_) {
|
||||
auto innerBundleInfo = infoItem.second.find(Constants::CURRENT_DEVICE_ID);
|
||||
if (innerBundleInfo == infoItem.second.end()) {
|
||||
continue;
|
||||
}
|
||||
if (innerBundleInfo->second.IsDisabled()) {
|
||||
APP_LOGI("app %{public}s is disabled", innerBundleInfo->second.GetBundleName().c_str());
|
||||
continue;
|
||||
}
|
||||
innerBundleInfo->second.GetCommonEvents(eventKey, commonEventInfos);
|
||||
}
|
||||
if (commonEventInfos.size() == 0) {
|
||||
APP_LOGE("commonEventInfos is empty");
|
||||
return false;
|
||||
}
|
||||
APP_LOGE("commonEventInfos find success");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleDataMgr::RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
if (!callback) {
|
||||
|
@ -580,6 +580,17 @@ bool BundleMgrHostImpl::GetShortcutInfos(const std::string &bundleName, std::vec
|
||||
return dataMgr->GetShortcutInfos(bundleName, shortcutInfos);
|
||||
}
|
||||
|
||||
bool BundleMgrHostImpl::GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos)
|
||||
{
|
||||
auto dataMgr = GetDataMgrFromService();
|
||||
if (dataMgr == nullptr) {
|
||||
APP_LOGE("DataMgr is nullptr");
|
||||
return false;
|
||||
}
|
||||
return dataMgr->GetAllCommonEventInfo(eventKey, commonEventInfos);
|
||||
}
|
||||
|
||||
bool BundleMgrHostImpl::GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords)
|
||||
{
|
||||
auto dataMgr = GetDataMgrFromService();
|
||||
|
@ -95,7 +95,6 @@ struct App {
|
||||
Version version;
|
||||
ApiVersion apiVersion;
|
||||
bool debug = false;
|
||||
bool unremovable = false;
|
||||
bool singleUser = false;
|
||||
};
|
||||
|
||||
@ -410,11 +409,6 @@ void from_json(const nlohmann::json &jsonObject, App &app)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<bool>(jsonObject, jsonObjectEnd, BUNDLE_APP_PROFILE_KEY_UNREMOVABLE, app.unremovable,
|
||||
JsonType::BOOLEAN,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<bool>(jsonObject, jsonObjectEnd, BUNDLE_APP_PROFILE_KEY_SINGLE_USER, app.singleUser,
|
||||
JsonType::BOOLEAN,
|
||||
false,
|
||||
@ -1877,7 +1871,6 @@ bool TransformToInfo(const ProfileReader::ConfigJson &configJson, ApplicationInf
|
||||
applicationInfo.process = configJson.deveicConfig.defaultDevice.process;
|
||||
applicationInfo.debug = configJson.app.debug;
|
||||
applicationInfo.singleUser = configJson.app.singleUser;
|
||||
applicationInfo.unremovable = configJson.app.unremovable;
|
||||
applicationInfo.enabled = true;
|
||||
return true;
|
||||
}
|
||||
@ -1899,7 +1892,6 @@ bool TransformToInfo(const ProfileReader::ConfigJson &configJson, BundleInfo &bu
|
||||
bundleInfo.targetVersion = configJson.app.apiVersion.target;
|
||||
bundleInfo.releaseType = configJson.app.apiVersion.releaseType;
|
||||
bundleInfo.isKeepAlive = configJson.deveicConfig.defaultDevice.keepAlive;
|
||||
bundleInfo.unremovable = configJson.app.unremovable;
|
||||
bundleInfo.singleUser = configJson.app.singleUser;
|
||||
if (configJson.module.abilities.size() > 0) {
|
||||
bundleInfo.label = configJson.module.abilities[0].label;
|
||||
@ -2083,6 +2075,17 @@ bool TransformToInfo(ProfileReader::ConfigJson &configJson, InnerBundleInfo &inn
|
||||
std::string shortcutkey = configJson.app.bundleName + configJson.module.package + info.shortcutId;
|
||||
innerBundleInfo.InsertShortcutInfos(shortcutkey, shortcutInfo);
|
||||
}
|
||||
for (const auto &info : configJson.module.commonEvents) {
|
||||
CommonEventInfo commonEvent;
|
||||
commonEvent.name = info.name;
|
||||
commonEvent.bundleName = configJson.app.bundleName;
|
||||
commonEvent.permission = info.permission;
|
||||
commonEvent.data = info.data;
|
||||
commonEvent.type = info.type;
|
||||
commonEvent.events = info.events;
|
||||
std::string commonEventKey = configJson.app.bundleName + configJson.module.package + info.name;
|
||||
innerBundleInfo.InsertCommonEvents(commonEventKey, commonEvent);
|
||||
}
|
||||
bool find = false;
|
||||
for (const auto &ability : configJson.module.abilities) {
|
||||
AbilityInfo abilityInfo;
|
||||
|
@ -59,6 +59,7 @@ const std::string MODULE_ABILITY_KEYS = "abilityKeys";
|
||||
const std::string MODULE_SKILL_KEYS = "skillKeys";
|
||||
const std::string MODULE_FORMS = "formInfos";
|
||||
const std::string MODULE_SHORTCUT = "shortcutInfos";
|
||||
const std::string MODULE_COMMON_EVENT = "commonEvents";
|
||||
const std::string MODULE_MAIN_ABILITY = "mainAbility";
|
||||
|
||||
} // namespace
|
||||
@ -179,6 +180,7 @@ void InnerBundleInfo::ToJson(nlohmann::json &jsonObject) const
|
||||
jsonObject[HAS_ENTRY] = hasEntry_;
|
||||
jsonObject[MODULE_FORMS] = formInfos_;
|
||||
jsonObject[MODULE_SHORTCUT] = shortcutInfos_;
|
||||
jsonObject[MODULE_COMMON_EVENT] = commonEvents_;
|
||||
jsonObject[CAN_UNINSTALL] = canUninstall_;
|
||||
}
|
||||
|
||||
@ -713,6 +715,14 @@ int32_t InnerBundleInfo::FromJson(const nlohmann::json &jsonObject)
|
||||
true,
|
||||
ProfileReader::parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::map<std::string, CommonEventInfo>>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
MODULE_COMMON_EVENT,
|
||||
commonEvents_,
|
||||
JsonType::OBJECT,
|
||||
true,
|
||||
ProfileReader::parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<bool>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
HAS_ENTRY,
|
||||
@ -854,6 +864,7 @@ bool InnerBundleInfo::AddModuleInfo(const InnerBundleInfo &newInfo)
|
||||
AddModuleSkillInfo(newInfo.skillInfos_);
|
||||
AddModuleFormInfo(newInfo.formInfos_);
|
||||
AddModuleShortcutInfo(newInfo.shortcutInfos_);
|
||||
AddModuleCommonEvent(newInfo.commonEvents_);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -896,6 +907,13 @@ void InnerBundleInfo::UpdateModuleInfo(const InnerBundleInfo &newInfo)
|
||||
++it;
|
||||
}
|
||||
}
|
||||
for (auto it = commonEvents_.begin(); it != commonEvents_.end();) {
|
||||
if (it->first.find(newInfo.currentPackage_) != std::string::npos) {
|
||||
commonEvents_.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
if (!hasEntry_ && newInfo.HasEntry()) {
|
||||
hasEntry_ = true;
|
||||
}
|
||||
@ -907,6 +925,7 @@ void InnerBundleInfo::UpdateModuleInfo(const InnerBundleInfo &newInfo)
|
||||
AddModuleSkillInfo(newInfo.skillInfos_);
|
||||
AddModuleFormInfo(newInfo.formInfos_);
|
||||
AddModuleShortcutInfo(newInfo.shortcutInfos_);
|
||||
AddModuleCommonEvent(newInfo.commonEvents_);
|
||||
}
|
||||
|
||||
void InnerBundleInfo::RemoveModuleInfo(const std::string &modulePackage)
|
||||
@ -953,6 +972,13 @@ void InnerBundleInfo::RemoveModuleInfo(const std::string &modulePackage)
|
||||
++it;
|
||||
}
|
||||
}
|
||||
for (auto it = commonEvents_.begin(); it != commonEvents_.end();) {
|
||||
if (it->first.find(modulePackage) != std::string::npos) {
|
||||
commonEvents_.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string InnerBundleInfo::ToString() const
|
||||
@ -976,6 +1002,7 @@ std::string InnerBundleInfo::ToString() const
|
||||
j[HAS_ENTRY] = hasEntry_;
|
||||
j[MODULE_FORMS] = formInfos_;
|
||||
j[MODULE_SHORTCUT] = shortcutInfos_;
|
||||
j[MODULE_COMMON_EVENT] = commonEvents_;
|
||||
j[CAN_UNINSTALL] = canUninstall_;
|
||||
return j.dump();
|
||||
}
|
||||
@ -1080,6 +1107,21 @@ void InnerBundleInfo::GetShortcutInfos(std::vector<ShortcutInfo> &shortcutInfos)
|
||||
}
|
||||
}
|
||||
|
||||
void InnerBundleInfo::GetCommonEvents(const std::string &eventKey, std::vector<CommonEventInfo> &commonEvents) const
|
||||
{
|
||||
CommonEventInfo item;
|
||||
for (const auto &commonEvent : commonEvents_) {
|
||||
for (const auto event : commonEvent.second.events) {
|
||||
if (event == eventKey) {
|
||||
item=commonEvent.second;
|
||||
item.uid=GetUid();
|
||||
commonEvents.emplace_back(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<InnerModuleInfo> InnerBundleInfo::GetInnerModuleInfoByModuleName(const std::string &moduleName) const
|
||||
{
|
||||
for (const auto &innerModuleInfo : innerModuleInfos_) {
|
||||
|
@ -149,7 +149,6 @@ protected:
|
||||
"signatureKey": "",
|
||||
"supportedModes": 0,
|
||||
"debug": false,
|
||||
"unremovable": true,
|
||||
"singleUser": true
|
||||
},
|
||||
"baseBundleInfo": {
|
||||
@ -181,7 +180,6 @@ protected:
|
||||
"signatureKey": "",
|
||||
"supportedModes": 0,
|
||||
"debug": false,
|
||||
"unremovable": true,
|
||||
"singleUser": true
|
||||
},
|
||||
"compatibleVersion": 3,
|
||||
@ -214,7 +212,6 @@ protected:
|
||||
"vendor": "ohos",
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"unremovable": true,
|
||||
"singleUser": true
|
||||
},
|
||||
"baseDataDir": "/data/accounts/account_0/appdata/com.ohos.launcher",
|
||||
|
@ -135,6 +135,13 @@ const std::string SHORTCUT_LABEL = "shortcutLabel";
|
||||
const std::string SHORTCUT_DISABLE_MESSAGE = "shortcutDisableMessage";
|
||||
const std::string SHORTCUT_INTENTS_TARGET_BUNDLE = "targetBundle";
|
||||
const std::string SHORTCUT_INTENTS_TARGET_CLASS = "targetClass";
|
||||
const std::string COMMON_EVENT_NAME = ".MainAbililty";
|
||||
const std::string COMMON_EVENT_PERMISSION = "permission";
|
||||
const std::string COMMON_EVENT_DATA = "data";
|
||||
const std::string COMMON_EVENT_TYPE = "type";
|
||||
const std::string COMMON_EVENT_EVENT = "usual.event.PACKAGE_ADDED";
|
||||
const std::string COMMON_EVENT_EVENT_ERROR_KEY = "usual.event.PACKAGE_ADDED_D";
|
||||
const std::string COMMON_EVENT_EVENT_NOT_EXISTS_KEY = "usual.event.PACKAGE_REMOVED";
|
||||
const int FORMINFO_DESCRIPTIONID = 123;
|
||||
|
||||
} // namespace
|
||||
@ -157,6 +164,7 @@ public:
|
||||
FormInfo MockFormInfo(
|
||||
const std::string &bundleName, const std::string &module, const std::string &abilityName) const;
|
||||
ShortcutInfo MockShortcutInfo(const std::string &bundleName, const std::string &shortcutId) const;
|
||||
CommonEventInfo MockCommonEventInfo(const std::string &bundleName, const int uid) const;
|
||||
void CheckBundleInfo(const std::string &bundleName, const std::string &moduleName, const uint32_t abilitySize,
|
||||
const BundleInfo &bundleInfo) const;
|
||||
void CheckBundleArchiveInfo(const std::string &bundleName, const std::string &moduleName,
|
||||
@ -184,6 +192,7 @@ public:
|
||||
void CheckFormInfoTest(const std::vector<FormInfo> &forms) const;
|
||||
void CheckFormInfoDemo(const std::vector<FormInfo> &forms) const;
|
||||
void CheckShortcutInfoTest(std::vector<ShortcutInfo> &shortcutInfos) const;
|
||||
void CheckCommonEventInfoTest(std::vector<CommonEventInfo> &commonEventInfos) const;
|
||||
void CheckShortcutInfoDemo(std::vector<ShortcutInfo> &shortcutInfos) const;
|
||||
|
||||
public:
|
||||
@ -227,7 +236,6 @@ void BmsBundleKitServiceTest::MockInstallBundle(
|
||||
appInfo.cacheDir = CACHE_DIR;
|
||||
appInfo.flags = APPLICATION_INFO_FLAGS;
|
||||
appInfo.enabled = true;
|
||||
appInfo.unremovable = false;
|
||||
appInfo.singleUser = true;
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
@ -243,7 +251,6 @@ void BmsBundleKitServiceTest::MockInstallBundle(
|
||||
bundleInfo.isKeepAlive = true;
|
||||
bundleInfo.isDifferentName = true;
|
||||
bundleInfo.jointUserId = BUNDLE_JOINT_USERID;
|
||||
bundleInfo.unremovable = false;
|
||||
bundleInfo.singleUser = true;
|
||||
|
||||
InnerModuleInfo moduleInfo;
|
||||
@ -313,6 +320,9 @@ void BmsBundleKitServiceTest::MockInstallBundle(
|
||||
innerBundleInfo.InsertShortcutInfos(shortcutKey, shortcut);
|
||||
}
|
||||
innerBundleInfo.InsertFormInfos(keyName, formInfos);
|
||||
std::string commonEventKey = bundleName + moduleName + abilityName;
|
||||
CommonEventInfo eventInfo = MockCommonEventInfo(bundleName, innerBundleInfo.GetUid());
|
||||
innerBundleInfo.InsertCommonEvents(commonEventKey, eventInfo);
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
bool startRet = dataMgr->UpdateBundleInstallState(bundleName, InstallState::INSTALL_START);
|
||||
@ -379,6 +389,20 @@ ShortcutInfo BmsBundleKitServiceTest::MockShortcutInfo(
|
||||
return shortcutInfos;
|
||||
}
|
||||
|
||||
CommonEventInfo BmsBundleKitServiceTest::MockCommonEventInfo(
|
||||
const std::string &bundleName, const int uid) const
|
||||
{
|
||||
CommonEventInfo CommonEventInfo;
|
||||
CommonEventInfo.name = COMMON_EVENT_NAME;
|
||||
CommonEventInfo.bundleName = bundleName;
|
||||
CommonEventInfo.uid = uid;
|
||||
CommonEventInfo.permission = COMMON_EVENT_PERMISSION;
|
||||
CommonEventInfo.data.emplace_back(COMMON_EVENT_DATA);
|
||||
CommonEventInfo.type.emplace_back(COMMON_EVENT_TYPE);
|
||||
CommonEventInfo.events.emplace_back(COMMON_EVENT_EVENT);
|
||||
return CommonEventInfo;
|
||||
}
|
||||
|
||||
void BmsBundleKitServiceTest::MockUninstallBundle(const std::string &bundleName) const
|
||||
{
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
@ -480,7 +504,6 @@ void BmsBundleKitServiceTest::CheckBundleInfo(const std::string &bundleName, con
|
||||
EXPECT_EQ(abilitySize, static_cast<uint32_t>(bundleInfo.abilityInfos.size()));
|
||||
EXPECT_EQ(true, bundleInfo.isDifferentName);
|
||||
EXPECT_EQ(BUNDLE_JOINT_USERID, bundleInfo.jointUserId);
|
||||
EXPECT_FALSE(bundleInfo.unremovable);
|
||||
EXPECT_TRUE(bundleInfo.isKeepAlive);
|
||||
EXPECT_TRUE(bundleInfo.singleUser);
|
||||
}
|
||||
@ -521,7 +544,6 @@ void BmsBundleKitServiceTest::CheckApplicationInfo(
|
||||
EXPECT_EQ(permissionSize, static_cast<uint32_t>(appInfo.permissions.size()));
|
||||
EXPECT_EQ(APPLICATION_INFO_FLAGS, appInfo.flags);
|
||||
EXPECT_TRUE(appInfo.singleUser);
|
||||
EXPECT_FALSE(appInfo.unremovable);
|
||||
}
|
||||
|
||||
void BmsBundleKitServiceTest::CheckAbilityInfo(
|
||||
@ -835,6 +857,26 @@ void BmsBundleKitServiceTest::CheckShortcutInfoTest(std::vector<ShortcutInfo> &s
|
||||
}
|
||||
}
|
||||
|
||||
void BmsBundleKitServiceTest::CheckCommonEventInfoTest(std::vector<CommonEventInfo> &commonEventInfos) const
|
||||
{
|
||||
for (const auto &commonEventInfo : commonEventInfos) {
|
||||
|
||||
EXPECT_EQ(commonEventInfo.name, COMMON_EVENT_NAME);
|
||||
EXPECT_EQ(commonEventInfo.bundleName, BUNDLE_NAME_TEST);
|
||||
EXPECT_EQ(commonEventInfo.uid, TEST_UID);
|
||||
EXPECT_EQ(commonEventInfo.permission, COMMON_EVENT_PERMISSION);
|
||||
for (auto item : commonEventInfo.data) {
|
||||
EXPECT_EQ(item, COMMON_EVENT_DATA);
|
||||
}
|
||||
for (auto item : commonEventInfo.type) {
|
||||
EXPECT_EQ(item, COMMON_EVENT_TYPE);
|
||||
}
|
||||
for (auto item : commonEventInfo.events) {
|
||||
EXPECT_EQ(item, COMMON_EVENT_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BmsBundleKitServiceTest::CheckShortcutInfoDemo(std::vector<ShortcutInfo> &shortcutInfos) const
|
||||
{
|
||||
for (const auto &shortcutInfo : shortcutInfos) {
|
||||
@ -3212,4 +3254,74 @@ HWTEST_F(BmsBundleKitServiceTest, Application_0200, Function | SmallTest | Level
|
||||
CheckCompatibleApplicationInfo(BUNDLE_NAME_DEMO, PERMISSION_SIZE_ZERO, appInfo2);
|
||||
MockUninstallBundle(BUNDLE_NAME_TEST);
|
||||
MockUninstallBundle(BUNDLE_NAME_DEMO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllCommonEventInfo_0100
|
||||
* @tc.name: test can get CommonEventInfo by event key
|
||||
* @tc.desc: 1.can get CommonEventInfo
|
||||
*/
|
||||
HWTEST_F(BmsBundleKitServiceTest, GetAllCommonEventInfo_0100, Function | SmallTest | Level1)
|
||||
{
|
||||
MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST);
|
||||
std::vector<CommonEventInfo> commonEventInfos;
|
||||
auto result = GetBundleDataMgr()->GetAllCommonEventInfo(COMMON_EVENT_EVENT, commonEventInfos);
|
||||
EXPECT_TRUE(result);
|
||||
CheckCommonEventInfoTest(commonEventInfos);
|
||||
MockUninstallBundle(BUNDLE_NAME_TEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllCommonEventInfo_0200
|
||||
* @tc.name: test can't get the commonEventInfo have no bundle
|
||||
* @tc.desc: 1.have not get commonEventInfo by event key
|
||||
* 2.can't get commonEventInfo
|
||||
*/
|
||||
HWTEST_F(BmsBundleKitServiceTest, GetAllCommonEventInfo_0200, Function | SmallTest | Level1)
|
||||
{
|
||||
std::vector<CommonEventInfo> commonEventInfos;
|
||||
GetBundleDataMgr()->GetAllCommonEventInfo(COMMON_EVENT_EVENT, commonEventInfos);
|
||||
EXPECT_TRUE(commonEventInfos.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllCommonEventInfo_0300
|
||||
* @tc.name: test can't get the commonEventInfo in app by empty event key
|
||||
* @tc.desc: 1.have not get commonEventInfo by appName
|
||||
*/
|
||||
HWTEST_F(BmsBundleKitServiceTest, GetAllCommonEventInfo_0300, Function | SmallTest | Level1)
|
||||
{
|
||||
MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST);
|
||||
std::vector<CommonEventInfo> commonEventInfos;
|
||||
GetBundleDataMgr()->GetAllCommonEventInfo(EMPTY_STRING, commonEventInfos);
|
||||
EXPECT_TRUE(commonEventInfos.empty());
|
||||
MockUninstallBundle(BUNDLE_NAME_TEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllCommonEventInfo_0400
|
||||
* @tc.name: test can't get the commonEventInfo in app by error event key
|
||||
* @tc.desc: 1.have not get commonEventInfo by appName
|
||||
*/
|
||||
HWTEST_F(BmsBundleKitServiceTest, GetAllCommonEventInfo_0400, Function | SmallTest | Level1)
|
||||
{
|
||||
MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST);
|
||||
std::vector<CommonEventInfo> commonEventInfos;
|
||||
GetBundleDataMgr()->GetAllCommonEventInfo(COMMON_EVENT_EVENT_ERROR_KEY, commonEventInfos);
|
||||
EXPECT_TRUE(commonEventInfos.empty());
|
||||
MockUninstallBundle(BUNDLE_NAME_TEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllCommonEventInfo_0500
|
||||
* @tc.name: test can't get the commonEventInfo in app by not exists event key
|
||||
* @tc.desc: 1.have not get commonEventInfo by appName
|
||||
*/
|
||||
HWTEST_F(BmsBundleKitServiceTest, GetAllCommonEventInfo_0500, Function | SmallTest | Level1)
|
||||
{
|
||||
MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST);
|
||||
std::vector<CommonEventInfo> commonEventInfos;
|
||||
GetBundleDataMgr()->GetAllCommonEventInfo(COMMON_EVENT_EVENT_NOT_EXISTS_KEY, commonEventInfos);
|
||||
EXPECT_TRUE(commonEventInfos.empty());
|
||||
MockUninstallBundle(BUNDLE_NAME_TEST);
|
||||
}
|
@ -46,7 +46,6 @@ const nlohmann::json CONFIG_JSON = R"(
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.example.hiworld.himusic",
|
||||
"unremovable": true,
|
||||
"singleUser": true,
|
||||
"vendor": "example",
|
||||
"version": {
|
||||
|
@ -192,7 +192,20 @@ public:
|
||||
* @param form Indicates the callback a list to shortcutinfo.
|
||||
* @return Returns true if shortcutinfo get success
|
||||
*/
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName,std::vector<ShortcutInfo> &shortcut) override{
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcut) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the CommonEventInfo objects provided by a event key on the device.
|
||||
* @param eventKey Indicates the event of the subscribe.
|
||||
* @param commonEventInfos List of CommonEventInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -388,7 +401,20 @@ public:
|
||||
* @param form Indicates the callback a list to shortcutinfo.
|
||||
* @return Returns true if shortcutinfo get success
|
||||
*/
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName,std::vector<ShortcutInfo> &shortcut) override{
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcut) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the CommonEventInfo objects provided by a event key on the device.
|
||||
* @param eventKey Indicates the event of the subscribe.
|
||||
* @param commonEventInfos List of CommonEventInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey,
|
||||
std::vector<CommonEventInfo> &commonEventInfos) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,6 @@ protected:
|
||||
"signatureKey": "",
|
||||
"supportedModes": 0,
|
||||
"debug": false,
|
||||
"unremovable": true,
|
||||
"singleUser": true
|
||||
},
|
||||
"baseBundleInfo": {
|
||||
@ -241,7 +240,6 @@ protected:
|
||||
"signatureKey": "",
|
||||
"supportedModes": 0,
|
||||
"debug": false,
|
||||
"unremovable": true,
|
||||
"singleUser": true
|
||||
},
|
||||
"compatibleVersion": 6,
|
||||
@ -274,7 +272,6 @@ protected:
|
||||
"vendor": "ohos",
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"unremovable": true,
|
||||
"singleUser": true
|
||||
},
|
||||
"baseDataDir": "/data/accounts/account_0/appdata/com.ohos.launcher",
|
||||
|
Binary file not shown.
@ -41,13 +41,8 @@ config("amsConfigurationUpdatedTestConfig") {
|
||||
}
|
||||
ohos_shared_library("amsConfigurationUpdatedTest") {
|
||||
sources = [
|
||||
"${SUBDEMOSYSTEM_DIR}/src/fifth_ability.cpp",
|
||||
"${SUBDEMOSYSTEM_DIR}/src/fourth_ability.cpp",
|
||||
"${SUBDEMOSYSTEM_DIR}/src/main_ability.cpp",
|
||||
"${SUBDEMOSYSTEM_DIR}/src/second_ability.cpp",
|
||||
"${SUBDEMOSYSTEM_DIR}/src/sixth_ability.cpp",
|
||||
"${SUBDEMOSYSTEM_DIR}/src/test_utils.cpp",
|
||||
"${SUBDEMOSYSTEM_DIR}/src/third_ability.cpp",
|
||||
]
|
||||
configs = [ ":amsConfigurationUpdatedTestConfig" ]
|
||||
deps = [
|
||||
|
@ -39,60 +39,6 @@
|
||||
"visible": true,
|
||||
"skills": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SecondAbility",
|
||||
"icon": "$media:snowball",
|
||||
"srcLanguage": "c++",
|
||||
"label": "SecondAbility label",
|
||||
"launchType": "standard",
|
||||
"configChanges": ["orientation","locale"],
|
||||
"orientation": "unspecified",
|
||||
"type": "page",
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"name": "ThirdAbility",
|
||||
"icon": "$media:snowball",
|
||||
"srcLanguage": "c++",
|
||||
"label": "ThirdAbility label",
|
||||
"launchType": "standard",
|
||||
"configChanges": ["orientation","locale","layout"],
|
||||
"orientation": "unspecified",
|
||||
"type": "page",
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"name": "FourthAbility",
|
||||
"icon": "$media:snowball",
|
||||
"srcLanguage": "c++",
|
||||
"label": "FourthAbility label",
|
||||
"launchType": "standard",
|
||||
"configChanges": ["orientation","locale","layout","fontSize"],
|
||||
"orientation": "unspecified",
|
||||
"type": "page",
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"name": "FifthAbility",
|
||||
"icon": "$media:snowball",
|
||||
"srcLanguage": "c++",
|
||||
"label": "FifthAbility label",
|
||||
"launchType": "standard",
|
||||
"configChanges": ["orientation","locale","layout","fontSize","density"],
|
||||
"orientation": "unspecified",
|
||||
"type": "page",
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"name": "SixthAbility",
|
||||
"icon": "$media:snowball",
|
||||
"srcLanguage": "c++",
|
||||
"label": "SixthAbility label",
|
||||
"launchType": "standard",
|
||||
"orientation": "unspecified",
|
||||
"type": "page",
|
||||
"visible": true
|
||||
}]
|
||||
}
|
||||
}
|
@ -1,78 +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.
|
||||
*/
|
||||
|
||||
#ifndef AMS_CONFIGURATION_UPDATED_TEST_FIFTH_ABILITY_H
|
||||
#define AMS_CONFIGURATION_UPDATED_TEST_FIFTH_ABILITY_H
|
||||
#include "ability.h"
|
||||
#include "ability_loader.h"
|
||||
#include "common_event.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "ability_append_test_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
class FifthAbilityEventSubscriber;
|
||||
class FifthAbility : public Ability {
|
||||
public:
|
||||
void SubscribeEvent();
|
||||
void TestAbility(int apiIndex, int caseIndex, int code);
|
||||
|
||||
FifthAbility()
|
||||
{
|
||||
mapCase_ = {};
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::vector<std::function<void(int)>>> mapCase_;
|
||||
~FifthAbility();
|
||||
|
||||
protected:
|
||||
void Init(const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> &application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token) override;
|
||||
virtual void OnStart(const Want &want) override;
|
||||
virtual void OnStop() override;
|
||||
virtual void OnActive() override;
|
||||
virtual void OnInactive() override;
|
||||
virtual void OnBackground() override;
|
||||
virtual void OnForeground(const Want &want) override;
|
||||
virtual void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
|
||||
std::shared_ptr<FifthAbilityEventSubscriber> subscriber_;
|
||||
|
||||
std::string callbackSeq;
|
||||
std::string callbackUpdated;
|
||||
};
|
||||
class FifthAbilityEventSubscriber : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
explicit FifthAbilityEventSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp)
|
||||
{
|
||||
mapTestFunc_ = {};
|
||||
fifthAbility = nullptr;
|
||||
}
|
||||
|
||||
void TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
fifthAbility->TestAbility(apiIndex, caseIndex, code);
|
||||
}
|
||||
|
||||
virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
|
||||
|
||||
FifthAbility *fifthAbility;
|
||||
std::unordered_map<std::string, std::function<void(int, int, int)>> mapTestFunc_;
|
||||
~FifthAbilityEventSubscriber() = default;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // AMS_CONFIGURATION_UPDATED_TEST_FIFTH_ABILITY_H
|
@ -1,78 +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.
|
||||
*/
|
||||
|
||||
#ifndef AMS_CONFIGURATION_UPDATED_TEST_FOURTH_ABILITY_H
|
||||
#define AMS_CONFIGURATION_UPDATED_TEST_FOURTH_ABILITY_H
|
||||
#include "ability.h"
|
||||
#include "ability_loader.h"
|
||||
#include "common_event.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "ability_append_test_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
class FourthAbilityEventSubscriber;
|
||||
class FourthAbility : public Ability {
|
||||
public:
|
||||
void SubscribeEvent();
|
||||
void TestAbility(int apiIndex, int caseIndex, int code);
|
||||
|
||||
FourthAbility()
|
||||
{
|
||||
mapCase_ = {};
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::vector<std::function<void(int)>>> mapCase_;
|
||||
~FourthAbility();
|
||||
|
||||
protected:
|
||||
void Init(const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> &application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token) override;
|
||||
virtual void OnStart(const Want &want) override;
|
||||
virtual void OnStop() override;
|
||||
virtual void OnActive() override;
|
||||
virtual void OnInactive() override;
|
||||
virtual void OnBackground() override;
|
||||
virtual void OnForeground(const Want &want) override;
|
||||
virtual void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
|
||||
std::shared_ptr<FourthAbilityEventSubscriber> subscriber_;
|
||||
|
||||
std::string callbackSeq;
|
||||
std::string callbackUpdated;
|
||||
};
|
||||
class FourthAbilityEventSubscriber : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
explicit FourthAbilityEventSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp)
|
||||
{
|
||||
mapTestFunc_ = {};
|
||||
fourthAbility = nullptr;
|
||||
}
|
||||
|
||||
void TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
fourthAbility->TestAbility(apiIndex, caseIndex, code);
|
||||
}
|
||||
|
||||
virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
|
||||
|
||||
FourthAbility *fourthAbility;
|
||||
std::unordered_map<std::string, std::function<void(int, int, int)>> mapTestFunc_;
|
||||
~FourthAbilityEventSubscriber() = default;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // AMS_CONFIGURATION_UPDATED_TEST_FOURTH_ABILITY_H
|
@ -1,81 +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.
|
||||
*/
|
||||
|
||||
#ifndef AMS_CONFIGURATION_UPDATED_TEST_SECOND_ABILITY_H
|
||||
#define AMS_CONFIGURATION_UPDATED_TEST_SECOND_ABILITY_H
|
||||
#include "ability.h"
|
||||
#include "ability_loader.h"
|
||||
#include "common_event.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "ability_append_test_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
class SecondAbilityEventSubscriber;
|
||||
class SecondAbility : public Ability {
|
||||
public:
|
||||
void SubscribeEvent();
|
||||
void TestAbility(int apiIndex, int caseIndex, int code);
|
||||
|
||||
void MissionStackcase1(int code);
|
||||
void MissionStackcase2(int code);
|
||||
|
||||
SecondAbility()
|
||||
{
|
||||
mapCase_ = {};
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::vector<std::function<void(int)>>> mapCase_;
|
||||
~SecondAbility();
|
||||
|
||||
protected:
|
||||
void Init(const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> &application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token) override;
|
||||
virtual void OnStart(const Want &want) override;
|
||||
virtual void OnStop() override;
|
||||
virtual void OnActive() override;
|
||||
virtual void OnInactive() override;
|
||||
virtual void OnBackground() override;
|
||||
virtual void OnForeground(const Want &want) override;
|
||||
virtual void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
|
||||
std::shared_ptr<SecondAbilityEventSubscriber> subscriber_;
|
||||
|
||||
std::string callbackSeq;
|
||||
std::string callbackUpdated;
|
||||
};
|
||||
class SecondAbilityEventSubscriber : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
explicit SecondAbilityEventSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp)
|
||||
{
|
||||
mapTestFunc_ = {};
|
||||
secondAbility = nullptr;
|
||||
}
|
||||
|
||||
void TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
secondAbility->TestAbility(apiIndex, caseIndex, code);
|
||||
}
|
||||
|
||||
virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
|
||||
|
||||
SecondAbility *secondAbility;
|
||||
std::unordered_map<std::string, std::function<void(int, int, int)>> mapTestFunc_;
|
||||
~SecondAbilityEventSubscriber() = default;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // AMS_CONFIGURATION_UPDATED_TEST_SECOND_ABILITY_H
|
@ -1,78 +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.
|
||||
*/
|
||||
|
||||
#ifndef AMS_CONFIGURATION_UPDATED_TEST_SIXTH_ABILITY_H
|
||||
#define AMS_CONFIGURATION_UPDATED_TEST_SIXTH_ABILITY_H
|
||||
#include "ability.h"
|
||||
#include "ability_loader.h"
|
||||
#include "common_event.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "ability_append_test_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
class SixthAbilityEventSubscriber;
|
||||
class SixthAbility : public Ability {
|
||||
public:
|
||||
void SubscribeEvent();
|
||||
void TestAbility(int apiIndex, int caseIndex, int code);
|
||||
|
||||
SixthAbility()
|
||||
{
|
||||
mapCase_ = {};
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::vector<std::function<void(int)>>> mapCase_;
|
||||
~SixthAbility();
|
||||
|
||||
protected:
|
||||
void Init(const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> &application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token) override;
|
||||
virtual void OnStart(const Want &want) override;
|
||||
virtual void OnStop() override;
|
||||
virtual void OnActive() override;
|
||||
virtual void OnInactive() override;
|
||||
virtual void OnBackground() override;
|
||||
virtual void OnForeground(const Want &want) override;
|
||||
virtual void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
|
||||
std::shared_ptr<SixthAbilityEventSubscriber> subscriber_;
|
||||
|
||||
std::string callbackSeq;
|
||||
std::string callbackUpdated;
|
||||
};
|
||||
class SixthAbilityEventSubscriber : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
explicit SixthAbilityEventSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp)
|
||||
{
|
||||
mapTestFunc_ = {};
|
||||
sixthAbility = nullptr;
|
||||
}
|
||||
|
||||
void TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
sixthAbility->TestAbility(apiIndex, caseIndex, code);
|
||||
}
|
||||
|
||||
virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
|
||||
|
||||
SixthAbility *sixthAbility;
|
||||
std::unordered_map<std::string, std::function<void(int, int, int)>> mapTestFunc_;
|
||||
~SixthAbilityEventSubscriber() = default;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // AMS_CONFIGURATION_UPDATED_TEST_SIXTH_ABILITY_H
|
@ -1,78 +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.
|
||||
*/
|
||||
|
||||
#ifndef AMS_CONFIGURATION_UPDATED_TEST_THIRD_ABILITY_H
|
||||
#define AMS_CONFIGURATION_UPDATED_TEST_THIRD_ABILITY_H
|
||||
#include "ability.h"
|
||||
#include "ability_loader.h"
|
||||
#include "common_event.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "ability_append_test_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
class ThirdAbilityEventSubscriber;
|
||||
class ThirdAbility : public Ability {
|
||||
public:
|
||||
void SubscribeEvent();
|
||||
void TestAbility(int apiIndex, int caseIndex, int code);
|
||||
|
||||
ThirdAbility()
|
||||
{
|
||||
mapCase_ = {};
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::vector<std::function<void(int)>>> mapCase_;
|
||||
~ThirdAbility();
|
||||
|
||||
protected:
|
||||
void Init(const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> &application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token) override;
|
||||
virtual void OnStart(const Want &want) override;
|
||||
virtual void OnStop() override;
|
||||
virtual void OnActive() override;
|
||||
virtual void OnInactive() override;
|
||||
virtual void OnBackground() override;
|
||||
virtual void OnForeground(const Want &want) override;
|
||||
virtual void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
|
||||
std::shared_ptr<ThirdAbilityEventSubscriber> subscriber_;
|
||||
|
||||
std::string callbackSeq;
|
||||
std::string callbackUpdated;
|
||||
};
|
||||
class ThirdAbilityEventSubscriber : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
explicit ThirdAbilityEventSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp)
|
||||
{
|
||||
mapTestFunc_ = {};
|
||||
thirdAbility = nullptr;
|
||||
}
|
||||
|
||||
void TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
thirdAbility->TestAbility(apiIndex, caseIndex, code);
|
||||
}
|
||||
|
||||
virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
|
||||
|
||||
ThirdAbility *thirdAbility;
|
||||
std::unordered_map<std::string, std::function<void(int, int, int)>> mapTestFunc_;
|
||||
~ThirdAbilityEventSubscriber() = default;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // AMS_CONFIGURATION_UPDATED_TEST_THIRD_ABILITY_H
|
@ -1,134 +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.
|
||||
*/
|
||||
|
||||
#include "fifth_ability.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
void FifthAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("FifthAbility::Init");
|
||||
Ability::Init(abilityInfo, application, handler, token);
|
||||
}
|
||||
|
||||
FifthAbility::~FifthAbility()
|
||||
{
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void FifthAbility::OnStart(const Want &want)
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnStart");
|
||||
SubscribeEvent();
|
||||
Ability::OnStart(want);
|
||||
callbackSeq += "OnStart";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, "OnStart");
|
||||
}
|
||||
|
||||
void FifthAbility::OnStop()
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnStop");
|
||||
Ability::OnStop();
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
callbackSeq += "OnStop"; // OnInactiveOnBackgroundOnStop
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void FifthAbility::OnActive()
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnActive====<");
|
||||
Ability::OnActive();
|
||||
callbackSeq += "OnActive"; // OnStartOnActive
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void FifthAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnConfigurationUpdated====<");
|
||||
Ability::OnConfigurationUpdated(configuration);
|
||||
callbackUpdated += "Updated"; // UpdatedUpdated
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, callbackUpdated);
|
||||
}
|
||||
|
||||
void FifthAbility::OnInactive()
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnInactive");
|
||||
Ability::OnInactive();
|
||||
callbackSeq += "OnInactive";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, "OnInactive");
|
||||
}
|
||||
|
||||
void FifthAbility::OnBackground()
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnBackground");
|
||||
Ability::OnBackground();
|
||||
callbackSeq += "OnBackground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, "OnBackground");
|
||||
}
|
||||
|
||||
void FifthAbility::OnForeground(const Want &want)
|
||||
{
|
||||
APP_LOGI("FifthAbility::OnForeground");
|
||||
Ability::OnForeground(want);
|
||||
callbackSeq += "OnForeground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FIFTH_LIFECYCLE, FIFTH_ABILITY_CODE, "OnForeground");
|
||||
}
|
||||
|
||||
void FifthAbility::SubscribeEvent()
|
||||
{
|
||||
std::vector<std::string> eventList = {
|
||||
// g_EVENT_REQU_FIFTH,
|
||||
};
|
||||
MatchingSkills matchingSkills;
|
||||
for (const auto &e : eventList) {
|
||||
matchingSkills.AddEvent(e);
|
||||
}
|
||||
CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetPriority(1);
|
||||
subscriber_ = std::make_shared<FifthAbilityEventSubscriber>(subscribeInfo);
|
||||
subscriber_->fifthAbility = this;
|
||||
CommonEventManager::SubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void FifthAbilityEventSubscriber::OnReceiveEvent(const CommonEventData &data)
|
||||
{
|
||||
APP_LOGI("FifthAbilityEventSubscriber::OnReceiveEvent:event=%{public}s", data.GetWant().GetAction().c_str());
|
||||
APP_LOGI("FifthAbilityEventSubscriber::OnReceiveEvent:data=%{public}s", data.GetData().c_str());
|
||||
APP_LOGI("FifthAbilityEventSubscriber::OnReceiveEvent:code=%{public}d", data.GetCode());
|
||||
auto eventName = data.GetWant().GetAction();
|
||||
}
|
||||
|
||||
void FifthAbility::TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
APP_LOGI("FifthAbility::TestAbility");
|
||||
if (mapCase_.find(apiIndex) != mapCase_.end()) {
|
||||
if (caseIndex < (int)mapCase_[apiIndex].size()) {
|
||||
mapCase_[apiIndex][caseIndex](code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_AA(FifthAbility)
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -1,134 +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.
|
||||
*/
|
||||
|
||||
#include "fourth_ability.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
void FourthAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("FourthAbility::Init");
|
||||
Ability::Init(abilityInfo, application, handler, token);
|
||||
}
|
||||
|
||||
FourthAbility::~FourthAbility()
|
||||
{
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void FourthAbility::OnStart(const Want &want)
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnStart");
|
||||
SubscribeEvent();
|
||||
Ability::OnStart(want);
|
||||
callbackSeq += "OnStart";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, "OnStart");
|
||||
}
|
||||
|
||||
void FourthAbility::OnStop()
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnStop");
|
||||
Ability::OnStop();
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
callbackSeq += "OnStop"; // OnInactiveOnBackgroundOnStop
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void FourthAbility::OnActive()
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnActive====<");
|
||||
Ability::OnActive();
|
||||
callbackSeq += "OnActive"; // OnStartOnActive
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void FourthAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnConfigurationUpdated====<");
|
||||
Ability::OnConfigurationUpdated(configuration);
|
||||
callbackUpdated += "Updated"; // UpdatedUpdated
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, callbackUpdated);
|
||||
}
|
||||
|
||||
void FourthAbility::OnInactive()
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnInactive");
|
||||
Ability::OnInactive();
|
||||
callbackSeq += "OnInactive";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, "OnInactive");
|
||||
}
|
||||
|
||||
void FourthAbility::OnBackground()
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnBackground");
|
||||
Ability::OnBackground();
|
||||
callbackSeq += "OnBackground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, "OnBackground");
|
||||
}
|
||||
|
||||
void FourthAbility::OnForeground(const Want &want)
|
||||
{
|
||||
APP_LOGI("FourthAbility::OnForeground");
|
||||
Ability::OnForeground(want);
|
||||
callbackSeq += "OnForeground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_FOURTH_LIFECYCLE, FOURTH_ABILITY_CODE, "OnForeground");
|
||||
}
|
||||
|
||||
void FourthAbility::SubscribeEvent()
|
||||
{
|
||||
std::vector<std::string> eventList = {
|
||||
// g_EVENT_REQU_FOURTH,
|
||||
};
|
||||
MatchingSkills matchingSkills;
|
||||
for (const auto &e : eventList) {
|
||||
matchingSkills.AddEvent(e);
|
||||
}
|
||||
CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetPriority(1);
|
||||
subscriber_ = std::make_shared<FourthAbilityEventSubscriber>(subscribeInfo);
|
||||
subscriber_->fourthAbility = this;
|
||||
CommonEventManager::SubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void FourthAbilityEventSubscriber::OnReceiveEvent(const CommonEventData &data)
|
||||
{
|
||||
APP_LOGI("FourthAbilityEventSubscriber::OnReceiveEvent:event=%{public}s", data.GetWant().GetAction().c_str());
|
||||
APP_LOGI("FourthAbilityEventSubscriber::OnReceiveEvent:data=%{public}s", data.GetData().c_str());
|
||||
APP_LOGI("FourthAbilityEventSubscriber::OnReceiveEvent:code=%{public}d", data.GetCode());
|
||||
auto eventName = data.GetWant().GetAction();
|
||||
}
|
||||
|
||||
void FourthAbility::TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
APP_LOGI("FourthAbility::TestAbility");
|
||||
if (mapCase_.find(apiIndex) != mapCase_.end()) {
|
||||
if (caseIndex < (int)mapCase_[apiIndex].size()) {
|
||||
mapCase_[apiIndex][caseIndex](code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_AA(FourthAbility)
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -1,134 +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.
|
||||
*/
|
||||
|
||||
#include "second_ability.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
void SecondAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("SecondAbility::Init");
|
||||
Ability::Init(abilityInfo, application, handler, token);
|
||||
}
|
||||
|
||||
SecondAbility::~SecondAbility()
|
||||
{
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void SecondAbility::OnStart(const Want &want)
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnStart");
|
||||
SubscribeEvent();
|
||||
Ability::OnStart(want);
|
||||
callbackSeq += "OnStart";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, "OnStart");
|
||||
}
|
||||
|
||||
void SecondAbility::OnStop()
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnStop");
|
||||
Ability::OnStop();
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
callbackSeq += "OnStop"; // OnInactiveOnBackgroundOnStop
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void SecondAbility::OnActive()
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnActive====<");
|
||||
Ability::OnActive();
|
||||
callbackSeq += "OnActive"; // OnStartOnActive
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void SecondAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnConfigurationUpdated====<");
|
||||
Ability::OnConfigurationUpdated(configuration);
|
||||
callbackUpdated += "Updated"; // UpdatedUpdated
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, callbackUpdated);
|
||||
}
|
||||
|
||||
void SecondAbility::OnInactive()
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnInactive");
|
||||
Ability::OnInactive();
|
||||
callbackSeq += "OnInactive";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, "OnInactive");
|
||||
}
|
||||
|
||||
void SecondAbility::OnBackground()
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnBackground");
|
||||
Ability::OnBackground();
|
||||
callbackSeq += "OnBackground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, "OnBackground");
|
||||
}
|
||||
|
||||
void SecondAbility::OnForeground(const Want &want)
|
||||
{
|
||||
APP_LOGI("SecondAbility::OnForeground");
|
||||
Ability::OnForeground(want);
|
||||
callbackSeq += "OnForeground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SECOND_LIFECYCLE, SECOND_ABILITY_CODE, "OnForeground");
|
||||
}
|
||||
|
||||
void SecondAbility::SubscribeEvent()
|
||||
{
|
||||
std::vector<std::string> eventList = {
|
||||
// g_EVENT_REQU_SECOND,
|
||||
};
|
||||
MatchingSkills matchingSkills;
|
||||
for (const auto &e : eventList) {
|
||||
matchingSkills.AddEvent(e);
|
||||
}
|
||||
CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetPriority(1);
|
||||
subscriber_ = std::make_shared<SecondAbilityEventSubscriber>(subscribeInfo);
|
||||
subscriber_->secondAbility = this;
|
||||
CommonEventManager::SubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void SecondAbilityEventSubscriber::OnReceiveEvent(const CommonEventData &data)
|
||||
{
|
||||
APP_LOGI("SecondAbilityEventSubscriber::OnReceiveEvent:event=%{public}s", data.GetWant().GetAction().c_str());
|
||||
APP_LOGI("SecondAbilityEventSubscriber::OnReceiveEvent:data=%{public}s", data.GetData().c_str());
|
||||
APP_LOGI("SecondAbilityEventSubscriber::OnReceiveEvent:code=%{public}d", data.GetCode());
|
||||
auto eventName = data.GetWant().GetAction();
|
||||
}
|
||||
|
||||
void SecondAbility::TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
APP_LOGI("SecondAbility::TestAbility");
|
||||
if (mapCase_.find(apiIndex) != mapCase_.end()) {
|
||||
if (caseIndex < (int)mapCase_[apiIndex].size()) {
|
||||
mapCase_[apiIndex][caseIndex](code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_AA(SecondAbility)
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -1,133 +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.
|
||||
*/
|
||||
|
||||
#include "sixth_ability.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
void SixthAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("SixthAbility::Init");
|
||||
Ability::Init(abilityInfo, application, handler, token);
|
||||
}
|
||||
|
||||
SixthAbility::~SixthAbility()
|
||||
{
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void SixthAbility::OnStart(const Want &want)
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnStart");
|
||||
SubscribeEvent();
|
||||
Ability::OnStart(want);
|
||||
callbackSeq += "OnStart";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, "OnStart");
|
||||
}
|
||||
|
||||
void SixthAbility::OnStop()
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnStop");
|
||||
Ability::OnStop();
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
callbackSeq += "OnStop"; // OnInactiveOnBackgroundOnStop
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void SixthAbility::OnActive()
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnActive====<");
|
||||
Ability::OnActive();
|
||||
callbackSeq += "OnActive"; // OnStartOnActive
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void SixthAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnConfigurationUpdated====<");
|
||||
Ability::OnConfigurationUpdated(configuration);
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, "OnConfigurationUpdated");
|
||||
}
|
||||
|
||||
void SixthAbility::OnInactive()
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnInactive");
|
||||
Ability::OnInactive();
|
||||
callbackSeq += "OnInactive";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, "OnInactive");
|
||||
}
|
||||
|
||||
void SixthAbility::OnBackground()
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnBackground");
|
||||
Ability::OnBackground();
|
||||
callbackSeq += "OnBackground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, "OnBackground");
|
||||
}
|
||||
|
||||
void SixthAbility::OnForeground(const Want &want)
|
||||
{
|
||||
APP_LOGI("SixthAbility::OnForeground");
|
||||
Ability::OnForeground(want);
|
||||
callbackSeq += "OnForeground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_SIXTH_LIFECYCLE, SIXTH_ABILITY_CODE, "OnForeground");
|
||||
}
|
||||
|
||||
void SixthAbility::SubscribeEvent()
|
||||
{
|
||||
std::vector<std::string> eventList = {
|
||||
// g_EVENT_REQU_SIXTH,
|
||||
};
|
||||
MatchingSkills matchingSkills;
|
||||
for (const auto &e : eventList) {
|
||||
matchingSkills.AddEvent(e);
|
||||
}
|
||||
CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetPriority(1);
|
||||
subscriber_ = std::make_shared<SixthAbilityEventSubscriber>(subscribeInfo);
|
||||
subscriber_->sixthAbility = this;
|
||||
CommonEventManager::SubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void SixthAbilityEventSubscriber::OnReceiveEvent(const CommonEventData &data)
|
||||
{
|
||||
APP_LOGI("SixthAbilityEventSubscriber::OnReceiveEvent:event=%{public}s", data.GetWant().GetAction().c_str());
|
||||
APP_LOGI("SixthAbilityEventSubscriber::OnReceiveEvent:data=%{public}s", data.GetData().c_str());
|
||||
APP_LOGI("SixthAbilityEventSubscriber::OnReceiveEvent:code=%{public}d", data.GetCode());
|
||||
auto eventName = data.GetWant().GetAction();
|
||||
}
|
||||
|
||||
void SixthAbility::TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
APP_LOGI("SixthAbility::TestAbility");
|
||||
if (mapCase_.find(apiIndex) != mapCase_.end()) {
|
||||
if (caseIndex < (int)mapCase_[apiIndex].size()) {
|
||||
mapCase_[apiIndex][caseIndex](code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_AA(SixthAbility)
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -1,134 +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.
|
||||
*/
|
||||
|
||||
#include "third_ability.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::EventFwk;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
void ThirdAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("ThirdAbility::Init");
|
||||
Ability::Init(abilityInfo, application, handler, token);
|
||||
}
|
||||
|
||||
ThirdAbility::~ThirdAbility()
|
||||
{
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void ThirdAbility::OnStart(const Want &want)
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnStart");
|
||||
SubscribeEvent();
|
||||
Ability::OnStart(want);
|
||||
callbackSeq += "OnStart";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, "OnStart");
|
||||
}
|
||||
|
||||
void ThirdAbility::OnStop()
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnStop");
|
||||
Ability::OnStop();
|
||||
callbackSeq += "OnStop"; // OnInactiveOnBackgroundOnStop
|
||||
CommonEventManager::UnSubscribeCommonEvent(subscriber_);
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void ThirdAbility::OnActive()
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnActive====<");
|
||||
Ability::OnActive();
|
||||
callbackSeq += "OnActive"; // OnStartOnActive
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, callbackSeq);
|
||||
callbackSeq = "";
|
||||
}
|
||||
|
||||
void ThirdAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnConfigurationUpdated====<");
|
||||
Ability::OnConfigurationUpdated(configuration);
|
||||
callbackUpdated += "Updated"; // UpdatedUpdated
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, callbackUpdated);
|
||||
}
|
||||
|
||||
void ThirdAbility::OnInactive()
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnInactive");
|
||||
Ability::OnInactive();
|
||||
callbackSeq += "OnInactive";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, "OnInactive");
|
||||
}
|
||||
|
||||
void ThirdAbility::OnBackground()
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnBackground");
|
||||
Ability::OnBackground();
|
||||
callbackSeq += "OnBackground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, "OnBackground");
|
||||
}
|
||||
|
||||
void ThirdAbility::OnForeground(const Want &want)
|
||||
{
|
||||
APP_LOGI("ThirdAbility::OnForeground");
|
||||
Ability::OnForeground(want);
|
||||
callbackSeq += "OnForeground";
|
||||
TestUtils::PublishEvent(g_EVENT_RESP_THIRD_LIFECYCLE, THIRD_ABILITY_CODE, "OnForeground");
|
||||
}
|
||||
|
||||
void ThirdAbility::SubscribeEvent()
|
||||
{
|
||||
std::vector<std::string> eventList = {
|
||||
// g_EVENT_REQU_THIRD,
|
||||
};
|
||||
MatchingSkills matchingSkills;
|
||||
for (const auto &e : eventList) {
|
||||
matchingSkills.AddEvent(e);
|
||||
}
|
||||
CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetPriority(1);
|
||||
subscriber_ = std::make_shared<ThirdAbilityEventSubscriber>(subscribeInfo);
|
||||
subscriber_->thirdAbility = this;
|
||||
CommonEventManager::SubscribeCommonEvent(subscriber_);
|
||||
}
|
||||
|
||||
void ThirdAbilityEventSubscriber::OnReceiveEvent(const CommonEventData &data)
|
||||
{
|
||||
APP_LOGI("ThirdAbilityEventSubscriber::OnReceiveEvent:event=%{public}s", data.GetWant().GetAction().c_str());
|
||||
APP_LOGI("ThirdAbilityEventSubscriber::OnReceiveEvent:data=%{public}s", data.GetData().c_str());
|
||||
APP_LOGI("ThirdAbilityEventSubscriber::OnReceiveEvent:code=%{public}d", data.GetCode());
|
||||
auto eventName = data.GetWant().GetAction();
|
||||
}
|
||||
|
||||
void ThirdAbility::TestAbility(int apiIndex, int caseIndex, int code)
|
||||
{
|
||||
APP_LOGI("ThirdAbility::TestAbility");
|
||||
if (mapCase_.find(apiIndex) != mapCase_.end()) {
|
||||
if (caseIndex < (int)mapCase_[apiIndex].size()) {
|
||||
mapCase_[apiIndex][caseIndex](code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_AA(ThirdAbility)
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -36,8 +36,7 @@ group("systemtest") {
|
||||
"ams_ability_state_test:systemtest",
|
||||
"ams_ability_visible_test:systemtest",
|
||||
"ams_app_process_manage_test:systemtest",
|
||||
|
||||
#"ams_configuration_updated_test:systemtest",
|
||||
"ams_configuration_updated_test:systemtest",
|
||||
"ams_data_ability_test:systemtest",
|
||||
"ams_dfx_test:systemtest",
|
||||
"ams_kit_test:systemtest",
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ability_append_test_info.h"
|
||||
#include "common_event.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "configuration.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "stoperator.h"
|
||||
#include "st_ability_util.h"
|
||||
@ -36,11 +37,6 @@ namespace {
|
||||
static const string KIT_BUNDLE_NAME = "com.ohos.amsst.ConfigurationUpdated";
|
||||
static const string KIT_HAP_NAME = "amsConfigurationUpdatedTest";
|
||||
static const string MAIN_ABILITY = "MainAbility";
|
||||
static const string SECOND_ABILITY = "SecondAbility";
|
||||
static const string THIRD_ABILITY = "ThirdAbility";
|
||||
static const string FOURTH_ABILITY = "FourthAbility";
|
||||
static const string FIFTH_ABILITY = "FifthAbility";
|
||||
static const string SIXTH_ABILITY = "SixthAbility";
|
||||
static constexpr int WAIT_TIME = 1;
|
||||
static constexpr int WAIT_LAUNCHER_TIME = 5;
|
||||
static constexpr int WAIT_SETUP_TIME = 1;
|
||||
@ -52,11 +48,6 @@ static string g_tempDataStr = "";
|
||||
|
||||
std::vector<std::string> eventList = {
|
||||
g_EVENT_RESP_MAIN_LIFECYCLE,
|
||||
g_EVENT_RESP_SECOND_LIFECYCLE,
|
||||
g_EVENT_RESP_THIRD_LIFECYCLE,
|
||||
g_EVENT_RESP_FOURTH_LIFECYCLE,
|
||||
g_EVENT_RESP_FIFTH_LIFECYCLE,
|
||||
g_EVENT_RESP_SIXTH_LIFECYCLE,
|
||||
};
|
||||
|
||||
class AmsConfigurationUpdatedTest : public testing::Test {
|
||||
@ -158,7 +149,6 @@ HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0100, Function | M
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0100 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
@ -166,12 +156,18 @@ HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0100, Function | M
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "UpdatedUpdated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
AppExecFwk::Configuration configuration;
|
||||
configuration.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, "ZH-HANS");
|
||||
abilityMgrService->UpdateConfiguration(configuration);
|
||||
(void)TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME);
|
||||
STAbilityUtil::CleanMsg(event);
|
||||
|
||||
AppExecFwk::Configuration configuration2;
|
||||
configuration2.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, "fr_FR");
|
||||
abilityMgrService->UpdateConfiguration(configuration2);
|
||||
g_tempDataStr = "Updated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0100 end=========<";
|
||||
}
|
||||
@ -187,21 +183,27 @@ HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0200, Function | M
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0200 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SECOND_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SECOND_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("locale");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "UpdatedUpdated", SECOND_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
AppExecFwk::Configuration configuration;
|
||||
configuration.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, "ZH-HANS");
|
||||
abilityMgrService->UpdateConfiguration(configuration);
|
||||
(void)TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME);
|
||||
STAbilityUtil::CleanMsg(event);
|
||||
|
||||
AppExecFwk::Configuration configuration2;
|
||||
configuration2.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, "ZH-HANS");
|
||||
abilityMgrService->UpdateConfiguration(configuration2);
|
||||
|
||||
g_tempDataStr = "Updated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0200 end=========<";
|
||||
}
|
||||
@ -217,22 +219,26 @@ HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0300, Function | M
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0300 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", THIRD_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
abilityMgrService = nullptr;
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", THIRD_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("layout");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "UpdatedUpdated", THIRD_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
AppExecFwk::Configuration configuration;
|
||||
configuration.AddItem(GlobalConfigurationKey::SYSTEM_ORIENTATION, "vertical");
|
||||
abilityMgrService->UpdateConfiguration(configuration);
|
||||
(void)TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME);
|
||||
STAbilityUtil::CleanMsg(event);
|
||||
|
||||
AppExecFwk::Configuration configuration2;
|
||||
configuration2.AddItem(GlobalConfigurationKey::SYSTEM_ORIENTATION, "horizontal");
|
||||
abilityMgrService->UpdateConfiguration(configuration2);
|
||||
|
||||
g_tempDataStr = "Updated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0300 end=========<";
|
||||
}
|
||||
@ -248,367 +254,27 @@ HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0400, Function | M
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0400 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", FOURTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", FOURTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("density#fontSize#");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "UpdatedUpdated", FOURTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
AppExecFwk::Configuration configuration;
|
||||
configuration.AddItem(GlobalConfigurationKey::SYSTEM_ORIENTATION, "vertical");
|
||||
abilityMgrService->UpdateConfiguration(configuration);
|
||||
(void)TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME);
|
||||
STAbilityUtil::CleanMsg(event);
|
||||
|
||||
AppExecFwk::Configuration configuration2;
|
||||
configuration2.AddItem(GlobalConfigurationKey::SYSTEM_ORIENTATION, "vertical");
|
||||
abilityMgrService->UpdateConfiguration(configuration2);
|
||||
|
||||
g_tempDataStr = "Updated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0400 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 0500
|
||||
* @tc.name : AMS_UpdateConfiguration_0500
|
||||
* @tc.desc : Verify whether the results of the orientation, locale, layout,fontSize,density function of the system
|
||||
* configuration concerned by capability are correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0500, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0500 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", FIFTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", FIFTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("fontSize#density");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "UpdatedUpdated", FIFTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0500 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 0600
|
||||
* @tc.name : AMS_UpdateConfiguration_0600
|
||||
* @tc.desc : Verify whether the results of the orientation function of the system configuration concerned by
|
||||
* capability are correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0600, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0600 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("locale#layout#fontSize#density");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "UpdatedUpdated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0600 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 0700
|
||||
* @tc.name : AMS_UpdateConfiguration_0700
|
||||
* @tc.desc : Verify whether the results of the orientation, locale function of the system configuration concerned
|
||||
* by capability are correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0700, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0700 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SECOND_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SECOND_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("layout#fontSize#density");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", SECOND_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SECOND_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "UpdatedUpdated", SECOND_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0700 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 0800
|
||||
* @tc.name : AMS_UpdateConfiguration_0800
|
||||
* @tc.desc : Verify whether the results of the function of the system configuration concerned by capability are
|
||||
* correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0800, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0800 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SIXTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "OnConfigurationUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "OnConfigurationUpdated", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0800 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 0900
|
||||
* @tc.name : AMS_UpdateConfiguration_0900
|
||||
* @tc.desc : Verify whether the results of the function of the system configuration concerned by capability are
|
||||
* correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_0900, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0900 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SIXTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation#locale");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "OnConfigurationUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "OnConfigurationUpdated", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_0900 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 1000
|
||||
* @tc.name : AMS_UpdateConfiguration_1000
|
||||
* @tc.desc : Verify whether the results of the function of the system configuration concerned by capability are
|
||||
* correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_1000, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1000 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SIXTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation#locale#layout");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "OnConfigurationUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "OnConfigurationUpdated", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1000 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 1100
|
||||
* @tc.name : AMS_UpdateConfiguration_1100
|
||||
* @tc.desc : Verify whether the results of the function of the system configuration concerned by capability are
|
||||
* correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_1100, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1100 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SIXTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation#locale#layout#fontSize");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "OnConfigurationUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "OnConfigurationUpdated", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1100 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 1200
|
||||
* @tc.name : AMS_UpdateConfiguration_1200
|
||||
* @tc.desc : Verify whether the results of the function of the system configuration concerned by capability are
|
||||
* correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_1200, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1200 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", SIXTH_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation#locale#layout#fontSize#density");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnStop";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnStop", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
g_tempDataStr = "OnConfigurationUpdated";
|
||||
EXPECT_NE(TestWaitCompleted(event, "OnConfigurationUpdated", SIXTH_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1200 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 1300
|
||||
* @tc.name : AMS_UpdateConfiguration_1300
|
||||
* @tc.desc : Verify whether the results of the orientation function of the system configuration concerned by
|
||||
* capability are correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_1300, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1300 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
Want wantEntity;
|
||||
const std::string LAUNCHER_ABILITY_NAME = "com.ohos.launcher.MainAbility";
|
||||
const std::string LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
|
||||
wantEntity.SetElementName(LAUNCHER_BUNDLE_NAME, LAUNCHER_ABILITY_NAME);
|
||||
STAbilityUtil::StartAbility(wantEntity, abilityMgrService);
|
||||
GTEST_LOG_(INFO) << "====>Want::FLAG_HOME_INTENT_FROM_SYSTEM";
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility S ====>> " << eCode;
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
g_tempDataStr = "OnInactiveOnBackgroundOnForegroundOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnInactiveOnBackgroundOnForegroundOnActive", MAIN_ABILITY_CODE), 0);
|
||||
|
||||
g_tempDataStr = "Updated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "Updated", MAIN_ABILITY_CODE), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1300 end=========<";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : 1400
|
||||
* @tc.name : AMS_UpdateConfiguration_1400
|
||||
* @tc.desc : Verify whether the results of the orientation function of the system configuration concerned by
|
||||
* capability are correct.
|
||||
*/
|
||||
|
||||
HWTEST_F(AmsConfigurationUpdatedTest, AMS_UpdateConfiguration_1400, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "==========>\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1400 start";
|
||||
MAP_STR_STR params;
|
||||
Want want = STAbilityUtil::MakeWant("device", MAIN_ABILITY, KIT_BUNDLE_NAME, params);
|
||||
// start first ability
|
||||
ErrCode eCode = STAbilityUtil::StartAbility(want, abilityMgrService, WAIT_TIME);
|
||||
GTEST_LOG_(INFO) << "\nStartAbility ====>> " << eCode;
|
||||
|
||||
g_tempDataStr = "OnStartOnActive";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "OnStartOnActive", MAIN_ABILITY_CODE), 0);
|
||||
|
||||
sleep(WAIT_ONACTIVE_TIME);
|
||||
Configuration mDummyConfiguration("orientation#locale");
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
abilityMgrService->UpdateConfiguration(mDummyConfiguration);
|
||||
|
||||
g_tempDataStr = "UpdatedUpdated";
|
||||
EXPECT_EQ(TestWaitCompleted(event, "UpdatedUpdated", MAIN_ABILITY_CODE, WAIT_LAUNCHER_TIME), 0);
|
||||
|
||||
GTEST_LOG_(INFO) << "\nAmsConfigurationUpdatedTest AMS_UpdateConfiguration_1400 end=========<";
|
||||
}
|
||||
} // namespace
|
@ -87,6 +87,8 @@ public:
|
||||
MOCK_METHOD3(GetFormsInfoByModule,
|
||||
bool(const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos));
|
||||
MOCK_METHOD2(GetShortcutInfos, bool(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos));
|
||||
MOCK_METHOD2(GetAllCommonEventInfo,
|
||||
bool(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos));
|
||||
MOCK_METHOD2(GetModuleUsageRecords, bool(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords));
|
||||
MOCK_METHOD3(NotifyActivityLifeStatus,
|
||||
bool(const std::string &bundleName, const std::string &abilityName, const int64_t launchTime));
|
||||
|
Loading…
Reference in New Issue
Block a user