mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
refactor: rename bg abbreviation to background for clarity
Rename all 'bg' abbreviations to full 'background' word across BgUserExtensionMonitor feature code, including: - File names: bg_user_extension_monitor -> background_user_extension_monitor - Class/struct names: BgUserExtensionMonitor -> BackgroundUserExtensionMonitor - Method names: OnBgUserExtensionStarted -> OnBackgroundUserExtensionStarted - Constants: BG_START_EVENT_VALUE -> BACKGROUND_START_EVENT_VALUE - All log messages and test names Signed-off-by: zhang_hao_zheng <zhanghaozheng2@h-partners.com> Co-Authored-By: Agent Change-Id: Idcf82f70e7381334ab48e2b0a8cb71733fd48e47
This commit is contained in:
@@ -49,7 +49,7 @@ abilityms_files = [
|
||||
"src/extension_record/base_extension_record.cpp",
|
||||
"src/extension_record/extension_record_manager.cpp",
|
||||
"src/extension_running_timeout_monitor.cpp",
|
||||
"src/bg_user_extension_monitor.cpp",
|
||||
"src/background_user_extension_monitor.cpp",
|
||||
"src/extension_record/extension_record.cpp",
|
||||
"src/extension_record/extension_record_factory.cpp",
|
||||
"src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
|
||||
@@ -3513,7 +3513,7 @@ private:
|
||||
void ReportPreventStartAbilityResult(const AppExecFwk::AbilityInfo &callerAbilityInfo,
|
||||
const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
|
||||
void ReportBgUserExtensionEvent(const sptr<IRemoteObject> &callerToken,
|
||||
void ReportBackgroundUserExtensionEvent(const sptr<IRemoteObject> &callerToken,
|
||||
const AppExecFwk::AbilityInfo &calleeAbilityInfo, int32_t targetUserId);
|
||||
|
||||
void SetAbilityRequestSessionInfo(AbilityRequest &abilityRequest, AppExecFwk::ExtensionAbilityType extensionType);
|
||||
|
||||
+13
-13
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_BG_USER_EXTENSION_MONITOR_H
|
||||
#define OHOS_ABILITY_RUNTIME_BG_USER_EXTENSION_MONITOR_H
|
||||
#ifndef OHOS_ABILITY_RUNTIME_BACKGROUND_USER_EXTENSION_MONITOR_H
|
||||
#define OHOS_ABILITY_RUNTIME_BACKGROUND_USER_EXTENSION_MONITOR_H
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
@@ -25,14 +25,14 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
|
||||
struct BgUserExtensionCallerInfo {
|
||||
struct BackgroundUserExtensionCallerInfo {
|
||||
int32_t callerUid = 0;
|
||||
int32_t callerUserId = 0;
|
||||
std::string callerProcessName;
|
||||
std::string callerBundleName;
|
||||
};
|
||||
|
||||
struct BgUserExtensionEvent {
|
||||
struct BackgroundUserExtensionEvent {
|
||||
// Caller info
|
||||
int32_t callerUid = 0;
|
||||
std::string callerBundleName;
|
||||
@@ -45,13 +45,13 @@ struct BgUserExtensionEvent {
|
||||
int32_t cnt = 1;
|
||||
};
|
||||
|
||||
class BgUserExtensionMonitor : public DelayedSingleton<BgUserExtensionMonitor> {
|
||||
DECLARE_DELAYED_SINGLETON(BgUserExtensionMonitor)
|
||||
class BackgroundUserExtensionMonitor : public DelayedSingleton<BackgroundUserExtensionMonitor> {
|
||||
DECLARE_DELAYED_SINGLETON(BackgroundUserExtensionMonitor)
|
||||
public:
|
||||
void StartMonitor();
|
||||
void StopMonitor();
|
||||
|
||||
void OnBgUserExtensionStarted(const BgUserExtensionCallerInfo &callerInfo,
|
||||
void OnBackgroundUserExtensionStarted(const BackgroundUserExtensionCallerInfo &callerInfo,
|
||||
const std::string &calleeBundleName, const std::string &calleeProcessName,
|
||||
const std::string &extensionTypeName, const std::string &abilityName,
|
||||
int32_t calleeUid);
|
||||
@@ -59,20 +59,20 @@ public:
|
||||
void ReportCachedEvents();
|
||||
|
||||
private:
|
||||
void AddOrUpdateEvent(const BgUserExtensionEvent &event);
|
||||
bool IsDuplicateEvent(const BgUserExtensionEvent &event,
|
||||
std::list<BgUserExtensionEvent>::iterator &dupIter);
|
||||
void AddOrUpdateEvent(const BackgroundUserExtensionEvent &event);
|
||||
bool IsDuplicateEvent(const BackgroundUserExtensionEvent &event,
|
||||
std::list<BackgroundUserExtensionEvent>::iterator &dupIter);
|
||||
void SubmitPeriodicTask();
|
||||
|
||||
std::mutex cacheMutex_;
|
||||
std::list<BgUserExtensionEvent> cachedEvents_;
|
||||
std::list<BackgroundUserExtensionEvent> cachedEvents_;
|
||||
|
||||
static constexpr int32_t HISEVENT_PARAM_COUNT = 7;
|
||||
static constexpr int32_t MAX_CACHED_EVENTS = 5;
|
||||
static constexpr int64_t REPORT_INTERVAL_MS = 2 * 60 * 60 * 1000; // 2 hours
|
||||
static constexpr const char *PERIODIC_TASK_NAME = "BgUserExtensionPeriodicTask";
|
||||
static constexpr const char *PERIODIC_TASK_NAME = "BackgroundUserExtensionPeriodicTask";
|
||||
};
|
||||
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_BG_USER_EXTENSION_MONITOR_H
|
||||
#endif // OHOS_ABILITY_RUNTIME_BACKGROUND_USER_EXTENSION_MONITOR_H
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "hitrace_meter.h"
|
||||
#include "hisysevent_report.h"
|
||||
#include "extension_running_timeout_monitor.h"
|
||||
#include "bg_user_extension_monitor.h"
|
||||
#include "background_user_extension_monitor.h"
|
||||
#include "insight_intent_execute_manager.h"
|
||||
#include "insight_intent_db_cache.h"
|
||||
#include "insight_intent_utils.h"
|
||||
@@ -475,7 +475,7 @@ bool AbilityManagerService::Init()
|
||||
modularObjectExtensionEventMgr_->SubscribeSysEventReceiver();
|
||||
ReportDataPartitionUsageManager::SendReportDataPartitionUsageEvent();
|
||||
DelayedSingleton<AAFwk::ExtensionRunningTimeoutMonitor>::GetInstance()->StartMonitor();
|
||||
DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance()->StartMonitor();
|
||||
DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance()->StartMonitor();
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
ResourceSchedule::ResSchedClient::GetInstance().InitKillReasonListener();
|
||||
#endif
|
||||
@@ -606,7 +606,7 @@ void AbilityManagerService::InitStartupFlag()
|
||||
void AbilityManagerService::OnStop()
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "stop");
|
||||
DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance()->StopMonitor();
|
||||
DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance()->StopMonitor();
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
std::unique_lock<ffrt::mutex> lock(bgtaskObserverMutex_);
|
||||
if (bgtaskObserver_) {
|
||||
@@ -4461,7 +4461,7 @@ int32_t AbilityManagerService::StartExtensionAbilityInner(const Want &want, cons
|
||||
}
|
||||
}
|
||||
if (eventInfo.errCode == ERR_OK) {
|
||||
ReportBgUserExtensionEvent(callerToken, abilityInfo, validUserId);
|
||||
ReportBackgroundUserExtensionEvent(callerToken, abilityInfo, validUserId);
|
||||
}
|
||||
ReportAbilityAssociatedStartInfoToRSS(abilityRequest.abilityInfo, RES_TYPE_EXTENSION_START_ABILITY, callerToken);
|
||||
return eventInfo.errCode;
|
||||
@@ -6156,7 +6156,7 @@ int32_t AbilityManagerService::ConnectLocalAbility(const Want &want, const int32
|
||||
indirectCallerInfo);
|
||||
}
|
||||
if (ret == ERR_OK) {
|
||||
ReportBgUserExtensionEvent(callerToken, abilityInfo, userId);
|
||||
ReportBackgroundUserExtensionEvent(callerToken, abilityInfo, userId);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -15515,13 +15515,13 @@ void AbilityManagerService::ReportPreventStartAbilityResult(const AppExecFwk::Ab
|
||||
hisyseventReport->Report("AAFWK", "PREVENT_START_ABILITY", HISYSEVENT_BEHAVIOR);
|
||||
}
|
||||
|
||||
void AbilityManagerService::ReportBgUserExtensionEvent(const sptr<IRemoteObject> &callerToken,
|
||||
void AbilityManagerService::ReportBackgroundUserExtensionEvent(const sptr<IRemoteObject> &callerToken,
|
||||
const AppExecFwk::AbilityInfo &calleeAbilityInfo, int32_t targetUserId)
|
||||
{
|
||||
if (JudgeMultiUserConcurrency(targetUserId)) {
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "report bg user extension event, targetUserId:%{public}d", targetUserId);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "report background user extension event, targetUserId:%{public}d", targetUserId);
|
||||
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
int32_t callerUserId = callerUid / BASE_USER_RANGE;
|
||||
@@ -15551,14 +15551,14 @@ void AbilityManagerService::ReportBgUserExtensionEvent(const sptr<IRemoteObject>
|
||||
}
|
||||
}
|
||||
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
if (monitor != nullptr) {
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo;
|
||||
callerInfo.callerUid = callerUid;
|
||||
callerInfo.callerUserId = callerUserId;
|
||||
callerInfo.callerProcessName = callerProcessName;
|
||||
callerInfo.callerBundleName = callerBundleName;
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
calleeAbilityInfo.bundleName, calleeAbilityInfo.process,
|
||||
calleeAbilityInfo.extensionTypeName, calleeAbilityInfo.name,
|
||||
calleeAbilityInfo.applicationInfo.uid);
|
||||
|
||||
+29
-28
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bg_user_extension_monitor.h"
|
||||
#include "background_user_extension_monitor.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -33,7 +33,7 @@ constexpr const char *ABILITY_NAME_KEY = "ABILITY_NAME";
|
||||
constexpr const char *RUNNING_DURATION_KEY = "RUNNING_DURATION";
|
||||
constexpr const char *STILL_ALIVE_KEY = "STILL_ALIVE";
|
||||
constexpr const char *CNT_KEY = "CNT";
|
||||
constexpr const char *BG_START_EVENT_VALUE = "BG_USER_START_EVENT";
|
||||
constexpr const char *BACKGROUND_START_EVENT_VALUE = "BACKGROUND_USER_START_EVENT";
|
||||
|
||||
bool CopyStringParam(const std::string &str, std::vector<std::unique_ptr<char[]>> &buffers,
|
||||
std::vector<char*> &ptrs)
|
||||
@@ -48,7 +48,7 @@ bool CopyStringParam(const std::string &str, std::vector<std::unique_ptr<char[]>
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BuildJsonInfo(const BgUserExtensionEvent &event)
|
||||
std::string BuildJsonInfo(const BackgroundUserExtensionEvent &event)
|
||||
{
|
||||
return std::string("{\"callerUid\":") + std::to_string(event.callerUid) +
|
||||
",\"callerBundleName\":\"" + event.callerBundleName + "\"" +
|
||||
@@ -61,37 +61,38 @@ std::string BuildJsonInfo(const BgUserExtensionEvent &event)
|
||||
}
|
||||
}
|
||||
|
||||
BgUserExtensionMonitor::BgUserExtensionMonitor() {}
|
||||
BackgroundUserExtensionMonitor::BackgroundUserExtensionMonitor() {}
|
||||
|
||||
BgUserExtensionMonitor::~BgUserExtensionMonitor() {}
|
||||
BackgroundUserExtensionMonitor::~BackgroundUserExtensionMonitor() {}
|
||||
|
||||
void BgUserExtensionMonitor::StartMonitor()
|
||||
void BackgroundUserExtensionMonitor::StartMonitor()
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "start bg user extension monitor");
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "start background user extension monitor");
|
||||
SubmitPeriodicTask();
|
||||
}
|
||||
|
||||
void BgUserExtensionMonitor::StopMonitor()
|
||||
void BackgroundUserExtensionMonitor::StopMonitor()
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "stop bg user extension monitor");
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "stop background user extension monitor");
|
||||
auto taskHandler = TaskHandlerWrap::GetFfrtHandler();
|
||||
if (taskHandler != nullptr) {
|
||||
taskHandler->CancelTask(PERIODIC_TASK_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
void BgUserExtensionMonitor::OnBgUserExtensionStarted(const BgUserExtensionCallerInfo &callerInfo,
|
||||
void BackgroundUserExtensionMonitor::OnBackgroundUserExtensionStarted(
|
||||
const BackgroundUserExtensionCallerInfo &callerInfo,
|
||||
const std::string &calleeBundleName, const std::string &calleeProcessName,
|
||||
const std::string &extensionTypeName, const std::string &abilityName,
|
||||
int32_t calleeUid)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR,
|
||||
"bg user extension started, type:%{public}s, callerUid:%{public}d, callerBundle:%{public}s, "
|
||||
"background user extension started, type:%{public}s, callerUid:%{public}d, callerBundle:%{public}s, "
|
||||
"calleeBundle:%{public}s, ability:%{public}s, calleeUid:%{public}d",
|
||||
extensionTypeName.c_str(), callerInfo.callerUid, callerInfo.callerBundleName.c_str(),
|
||||
calleeBundleName.c_str(), abilityName.c_str(), calleeUid);
|
||||
|
||||
BgUserExtensionEvent event;
|
||||
BackgroundUserExtensionEvent event;
|
||||
event.callerUid = callerInfo.callerUid;
|
||||
event.callerBundleName = callerInfo.callerBundleName;
|
||||
event.calleeBundleName = calleeBundleName;
|
||||
@@ -104,7 +105,7 @@ void BgUserExtensionMonitor::OnBgUserExtensionStarted(const BgUserExtensionCalle
|
||||
AddOrUpdateEvent(event);
|
||||
}
|
||||
|
||||
void BgUserExtensionMonitor::SubmitPeriodicTask()
|
||||
void BackgroundUserExtensionMonitor::SubmitPeriodicTask()
|
||||
{
|
||||
auto taskHandler = TaskHandlerWrap::GetFfrtHandler();
|
||||
if (taskHandler == nullptr) {
|
||||
@@ -113,21 +114,21 @@ void BgUserExtensionMonitor::SubmitPeriodicTask()
|
||||
}
|
||||
|
||||
auto task = []() {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "bg user extension periodic task triggered");
|
||||
auto monitor = DelayedSingleton<BgUserExtensionMonitor>::GetInstance();
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "background user extension periodic task triggered");
|
||||
auto monitor = DelayedSingleton<BackgroundUserExtensionMonitor>::GetInstance();
|
||||
monitor->ReportCachedEvents();
|
||||
monitor->SubmitPeriodicTask();
|
||||
};
|
||||
taskHandler->SubmitTask(task, PERIODIC_TASK_NAME, REPORT_INTERVAL_MS);
|
||||
}
|
||||
|
||||
void BgUserExtensionMonitor::ReportCachedEvents()
|
||||
void BackgroundUserExtensionMonitor::ReportCachedEvents()
|
||||
{
|
||||
std::list<BgUserExtensionEvent> eventsToReport;
|
||||
std::list<BackgroundUserExtensionEvent> eventsToReport;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cacheMutex_);
|
||||
if (cachedEvents_.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "no bg user extension events to report");
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "no background user extension events to report");
|
||||
return;
|
||||
}
|
||||
eventsToReport = cachedEvents_;
|
||||
@@ -138,9 +139,9 @@ void BgUserExtensionMonitor::ReportCachedEvents()
|
||||
std::vector<char*> extensionTypePtrs;
|
||||
std::vector<char*> bundleNamePtrs;
|
||||
|
||||
// EXTENSION_TYPE is fixed to "BG_START_EVENT" with length 1
|
||||
if (!CopyStringParam(BG_START_EVENT_VALUE, stringBuffers, extensionTypePtrs)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "strcpy_s failed for BG_START_EVENT");
|
||||
// EXTENSION_TYPE is fixed to "BACKGROUND_START_EVENT" with length 1
|
||||
if (!CopyStringParam(BACKGROUND_START_EVENT_VALUE, stringBuffers, extensionTypePtrs)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "strcpy_s failed for BACKGROUND_START_EVENT");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,12 +170,12 @@ void BgUserExtensionMonitor::ReportCachedEvents()
|
||||
report.InsertParam(STILL_ALIVE_KEY, emptyBoolArray);
|
||||
report.InsertParam(CNT_KEY, emptyInt32Array);
|
||||
int32_t ret = report.Report(DOMAIN, EVENT_NAME, HISYSEVENT_STATISTIC);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "reported %{public}zu bg user extension events, ret: %{public}d",
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "reported %{public}zu background user extension events, ret: %{public}d",
|
||||
eventsToReport.size(), ret);
|
||||
}
|
||||
|
||||
bool BgUserExtensionMonitor::IsDuplicateEvent(const BgUserExtensionEvent &event,
|
||||
std::list<BgUserExtensionEvent>::iterator &dupIter)
|
||||
bool BackgroundUserExtensionMonitor::IsDuplicateEvent(const BackgroundUserExtensionEvent &event,
|
||||
std::list<BackgroundUserExtensionEvent>::iterator &dupIter)
|
||||
{
|
||||
for (auto it = cachedEvents_.begin(); it != cachedEvents_.end(); ++it) {
|
||||
if (it->calleeExtensionTypeName == event.calleeExtensionTypeName &&
|
||||
@@ -186,9 +187,9 @@ bool BgUserExtensionMonitor::IsDuplicateEvent(const BgUserExtensionEvent &event,
|
||||
return false;
|
||||
}
|
||||
|
||||
void BgUserExtensionMonitor::AddOrUpdateEvent(const BgUserExtensionEvent &event)
|
||||
void BackgroundUserExtensionMonitor::AddOrUpdateEvent(const BackgroundUserExtensionEvent &event)
|
||||
{
|
||||
std::list<BgUserExtensionEvent>::iterator dupIter;
|
||||
std::list<BackgroundUserExtensionEvent>::iterator dupIter;
|
||||
if (IsDuplicateEvent(event, dupIter)) {
|
||||
dupIter->cnt++;
|
||||
dupIter->callerUid = event.callerUid;
|
||||
@@ -196,7 +197,7 @@ void BgUserExtensionMonitor::AddOrUpdateEvent(const BgUserExtensionEvent &event)
|
||||
dupIter->calleeBundleName = event.calleeBundleName;
|
||||
dupIter->calleeUid = event.calleeUid;
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR,
|
||||
"updated existing bg user extension event for %{public}s, cnt: %{public}d",
|
||||
"updated existing background user extension event for %{public}s, cnt: %{public}d",
|
||||
event.calleeAbilityName.c_str(), dupIter->cnt);
|
||||
return;
|
||||
}
|
||||
@@ -210,7 +211,7 @@ void BgUserExtensionMonitor::AddOrUpdateEvent(const BgUserExtensionEvent &event)
|
||||
|
||||
cachedEvents_.push_back(event);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR,
|
||||
"added new bg user extension event for %{public}s, cache size: %{public}zu",
|
||||
"added new background user extension event for %{public}s, cache size: %{public}zu",
|
||||
event.calleeAbilityName.c_str(), cachedEvents_.size());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_moduletest("ability_timeout_module_test") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_bundle_event_callback.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_cache_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_manager_service.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/app_exit_reason_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/assert_fault_callback_death_mgr.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/assert_fault_proxy.cpp",
|
||||
|
||||
@@ -31,7 +31,7 @@ ohos_moduletest("running_infos_module_test") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_bundle_event_callback.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_cache_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_manager_service.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/app_exit_reason_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/assert_fault_callback_death_mgr.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/assert_fault_proxy.cpp",
|
||||
|
||||
@@ -44,7 +44,7 @@ abilityms_files = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/base_extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
|
||||
@@ -124,7 +124,7 @@ ohos_unittest("ability_manager_service_fourteenth_test") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/free_install_observer_manager.cpp",
|
||||
|
||||
@@ -126,7 +126,7 @@ ohos_unittest("ability_manager_service_second_test") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/free_install_observer_manager.cpp",
|
||||
|
||||
@@ -44,7 +44,7 @@ abilityms_files = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/base_extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
|
||||
@@ -44,7 +44,7 @@ abilityms_files = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/base_extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
|
||||
@@ -124,7 +124,7 @@ ohos_unittest("ability_manager_service_thirteenth_test") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/foreground_app_connection_manager/foreground_app_connection_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/free_install_observer_manager.cpp",
|
||||
|
||||
@@ -49,7 +49,7 @@ ohos_unittest("extension_record_manager_second_test") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_running_timeout_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/bg_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/background_user_extension_monitor.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_config.cpp",
|
||||
"${ability_runtime_services_path}/common/src/ffrt_task_handler_wrap.cpp",
|
||||
"${ability_runtime_services_path}/common/src/hisysevent_report.cpp",
|
||||
|
||||
+76
-76
@@ -26,7 +26,7 @@
|
||||
#include "extension_record.h"
|
||||
#include "extension_record_manager.h"
|
||||
#include "extension_running_timeout_monitor.h"
|
||||
#include "bg_user_extension_monitor.h"
|
||||
#include "background_user_extension_monitor.h"
|
||||
#include "extension_config.h"
|
||||
#define inline
|
||||
#undef protected
|
||||
@@ -1931,9 +1931,9 @@ HWTEST_F(ExtensionRunningTimeoutMonitorTest, OnExtensionStarted_0500, TestSize.L
|
||||
TAG_LOGI(AAFwkTag::TEST, "end.");
|
||||
}
|
||||
|
||||
// ========== BgUserExtensionMonitor TDD Tests ==========
|
||||
// ========== BackgroundUserExtensionMonitor TDD Tests ==========
|
||||
|
||||
class BgUserExtensionMonitorTest : public testing::Test {
|
||||
class BackgroundUserExtensionMonitorTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
@@ -1941,44 +1941,44 @@ public:
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void BgUserExtensionMonitorTest::SetUpTestCase()
|
||||
void BackgroundUserExtensionMonitorTest::SetUpTestCase()
|
||||
{}
|
||||
|
||||
void BgUserExtensionMonitorTest::TearDownTestCase()
|
||||
void BackgroundUserExtensionMonitorTest::TearDownTestCase()
|
||||
{}
|
||||
|
||||
void BgUserExtensionMonitorTest::SetUp()
|
||||
void BackgroundUserExtensionMonitorTest::SetUp()
|
||||
{
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
monitor->cachedEvents_.clear();
|
||||
}
|
||||
|
||||
void BgUserExtensionMonitorTest::TearDown()
|
||||
void BackgroundUserExtensionMonitorTest::TearDown()
|
||||
{
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
monitor->StopMonitor();
|
||||
monitor->cachedEvents_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_OnBgUserExtensionStarted_0100
|
||||
* @tc.desc: Test OnBgUserExtensionStarted stores event fields correctly.
|
||||
* @tc.name: BackgroundUserExtension_OnBackgroundUserExtensionStarted_0100
|
||||
* @tc.desc: Test OnBackgroundUserExtensionStarted stores event fields correctly.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_0100, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_OnBackgroundUserExtensionStarted_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo;
|
||||
callerInfo.callerUid = 200000100;
|
||||
callerInfo.callerUserId = 100;
|
||||
callerInfo.callerProcessName = "com.example.caller";
|
||||
callerInfo.callerBundleName = "com.example.caller";
|
||||
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.callee", "com.example.callee",
|
||||
"ServiceExtension", "ServiceExtAbility", 100200);
|
||||
|
||||
@@ -1996,26 +1996,26 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_01
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_OnBgUserExtensionStarted_0200
|
||||
* @tc.desc: Test OnBgUserExtensionStarted with multiple different events.
|
||||
* @tc.name: BackgroundUserExtension_OnBackgroundUserExtensionStarted_0200
|
||||
* @tc.desc: Test OnBackgroundUserExtensionStarted with multiple different events.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_0200, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_OnBackgroundUserExtensionStarted_0200, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo;
|
||||
callerInfo.callerUid = 200000100;
|
||||
callerInfo.callerBundleName = "com.example.caller";
|
||||
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.callee", "com.example.callee",
|
||||
"ServiceExtension", "ServiceExtAbility", 100200);
|
||||
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.callee", "com.example.callee",
|
||||
"ShareExtension", "ShareExtAbility", 100200);
|
||||
|
||||
@@ -2025,22 +2025,22 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_02
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_OnBgUserExtensionStarted_0300
|
||||
* @tc.desc: Test OnBgUserExtensionStarted dedupes by extensionTypeName + abilityName and increments cnt.
|
||||
* @tc.name: BackgroundUserExtension_OnBackgroundUserExtensionStarted_0300
|
||||
* @tc.desc: Test OnBackgroundUserExtensionStarted dedupes by extensionTypeName + abilityName and increments cnt.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_0300, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_OnBackgroundUserExtensionStarted_0300, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo1;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo1;
|
||||
callerInfo1.callerUid = 200000100;
|
||||
callerInfo1.callerBundleName = "com.example.caller1";
|
||||
|
||||
monitor->OnBgUserExtensionStarted(callerInfo1,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo1,
|
||||
"com.example.callee", "com.example.callee",
|
||||
"ServiceExtension", "ServiceExtAbility", 100200);
|
||||
|
||||
@@ -2048,11 +2048,11 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_03
|
||||
EXPECT_EQ(monitor->cachedEvents_.front().cnt, 1);
|
||||
|
||||
// Second call with same extension type + ability name → dedupe, cnt++
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo2;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo2;
|
||||
callerInfo2.callerUid = 200000200;
|
||||
callerInfo2.callerBundleName = "com.example.caller2";
|
||||
|
||||
monitor->OnBgUserExtensionStarted(callerInfo2,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo2,
|
||||
"com.example.callee2", "com.example.callee2",
|
||||
"ServiceExtension", "ServiceExtAbility", 100300);
|
||||
|
||||
@@ -2068,30 +2068,30 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_03
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_OnBgUserExtensionStarted_0400
|
||||
* @tc.desc: Test OnBgUserExtensionStarted discards event when cache is full (MAX_CACHED_EVENTS=5).
|
||||
* @tc.name: BackgroundUserExtension_OnBackgroundUserExtensionStarted_0400
|
||||
* @tc.desc: Test OnBackgroundUserExtensionStarted discards event when cache is full (MAX_CACHED_EVENTS=5).
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_0400, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_OnBackgroundUserExtensionStarted_0400, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo;
|
||||
callerInfo.callerUid = 200000100;
|
||||
callerInfo.callerBundleName = "com.example.caller";
|
||||
|
||||
for (int32_t i = 0; i < monitor->MAX_CACHED_EVENTS; i++) {
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.callee" + std::to_string(i), "com.example.callee" + std::to_string(i),
|
||||
"ServiceExtension", "Ability" + std::to_string(i), 100200 + i);
|
||||
}
|
||||
EXPECT_EQ(monitor->cachedEvents_.size(), static_cast<size_t>(monitor->MAX_CACHED_EVENTS));
|
||||
|
||||
// 6th event should be discarded
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.overflow", "com.example.overflow",
|
||||
"ServiceExtension", "OverflowAbility", 999999);
|
||||
EXPECT_EQ(monitor->cachedEvents_.size(), static_cast<size_t>(monitor->MAX_CACHED_EVENTS));
|
||||
@@ -2109,27 +2109,27 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_OnBgUserExtensionStarted_04
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_IsDuplicateEvent_0100
|
||||
* @tc.name: BackgroundUserExtension_IsDuplicateEvent_0100
|
||||
* @tc.desc: Test IsDuplicateEvent returns true for same extensionTypeName + abilityName.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_IsDuplicateEvent_0100, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_IsDuplicateEvent_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionEvent event;
|
||||
AAFwk::BackgroundUserExtensionEvent event;
|
||||
event.calleeExtensionTypeName = "ServiceExtension";
|
||||
event.calleeAbilityName = "TestAbility";
|
||||
monitor->cachedEvents_.push_back(event);
|
||||
|
||||
AAFwk::BgUserExtensionEvent candidate;
|
||||
AAFwk::BackgroundUserExtensionEvent candidate;
|
||||
candidate.calleeExtensionTypeName = "ServiceExtension";
|
||||
candidate.calleeAbilityName = "TestAbility";
|
||||
|
||||
std::list<AAFwk::BgUserExtensionEvent>::iterator dupIter;
|
||||
std::list<AAFwk::BackgroundUserExtensionEvent>::iterator dupIter;
|
||||
EXPECT_TRUE(monitor->IsDuplicateEvent(candidate, dupIter));
|
||||
EXPECT_EQ(dupIter->calleeAbilityName, "TestAbility");
|
||||
|
||||
@@ -2137,69 +2137,69 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_IsDuplicateEvent_0100, Test
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_IsDuplicateEvent_0200
|
||||
* @tc.name: BackgroundUserExtension_IsDuplicateEvent_0200
|
||||
* @tc.desc: Test IsDuplicateEvent returns false for different extensionTypeName.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_IsDuplicateEvent_0200, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_IsDuplicateEvent_0200, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionEvent event;
|
||||
AAFwk::BackgroundUserExtensionEvent event;
|
||||
event.calleeExtensionTypeName = "ServiceExtension";
|
||||
event.calleeAbilityName = "TestAbility";
|
||||
monitor->cachedEvents_.push_back(event);
|
||||
|
||||
AAFwk::BgUserExtensionEvent candidate;
|
||||
AAFwk::BackgroundUserExtensionEvent candidate;
|
||||
candidate.calleeExtensionTypeName = "ShareExtension";
|
||||
candidate.calleeAbilityName = "TestAbility";
|
||||
|
||||
std::list<AAFwk::BgUserExtensionEvent>::iterator dupIter;
|
||||
std::list<AAFwk::BackgroundUserExtensionEvent>::iterator dupIter;
|
||||
EXPECT_FALSE(monitor->IsDuplicateEvent(candidate, dupIter));
|
||||
|
||||
TAG_LOGI(AAFwkTag::TEST, "end.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_IsDuplicateEvent_0300
|
||||
* @tc.name: BackgroundUserExtension_IsDuplicateEvent_0300
|
||||
* @tc.desc: Test IsDuplicateEvent returns false for different abilityName.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_IsDuplicateEvent_0300, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_IsDuplicateEvent_0300, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionEvent event;
|
||||
AAFwk::BackgroundUserExtensionEvent event;
|
||||
event.calleeExtensionTypeName = "ServiceExtension";
|
||||
event.calleeAbilityName = "Ability1";
|
||||
monitor->cachedEvents_.push_back(event);
|
||||
|
||||
AAFwk::BgUserExtensionEvent candidate;
|
||||
AAFwk::BackgroundUserExtensionEvent candidate;
|
||||
candidate.calleeExtensionTypeName = "ServiceExtension";
|
||||
candidate.calleeAbilityName = "Ability2";
|
||||
|
||||
std::list<AAFwk::BgUserExtensionEvent>::iterator dupIter;
|
||||
std::list<AAFwk::BackgroundUserExtensionEvent>::iterator dupIter;
|
||||
EXPECT_FALSE(monitor->IsDuplicateEvent(candidate, dupIter));
|
||||
|
||||
TAG_LOGI(AAFwkTag::TEST, "end.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_ReportCachedEvents_0100
|
||||
* @tc.name: BackgroundUserExtension_ReportCachedEvents_0100
|
||||
* @tc.desc: Test ReportCachedEvents with empty cache does nothing.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_ReportCachedEvents_0100, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_ReportCachedEvents_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
EXPECT_EQ(monitor->cachedEvents_.size(), static_cast<size_t>(0));
|
||||
@@ -2210,18 +2210,18 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_ReportCachedEvents_0100, Te
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_ReportCachedEvents_0200
|
||||
* @tc.name: BackgroundUserExtension_ReportCachedEvents_0200
|
||||
* @tc.desc: Test ReportCachedEvents clears cache after reporting events.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_ReportCachedEvents_0200, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_ReportCachedEvents_0200, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionEvent event;
|
||||
AAFwk::BackgroundUserExtensionEvent event;
|
||||
event.callerUid = 200000100;
|
||||
event.callerBundleName = "com.example.caller";
|
||||
event.calleeBundleName = "com.example.callee";
|
||||
@@ -2239,15 +2239,15 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_ReportCachedEvents_0200, Te
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_StartStopMonitor_0100
|
||||
* @tc.name: BackgroundUserExtension_StartStopMonitor_0100
|
||||
* @tc.desc: Test StartMonitor and StopMonitor do not crash.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_StartStopMonitor_0100, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_StartStopMonitor_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
monitor->StartMonitor();
|
||||
@@ -2259,24 +2259,24 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_StartStopMonitor_0100, Test
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_BuildJsonInfo_0100
|
||||
* @tc.name: BackgroundUserExtension_BuildJsonInfo_0100
|
||||
* @tc.desc: Test JSON string built from event contains all 7 fields.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_BuildJsonInfo_0100, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_BuildJsonInfo_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo;
|
||||
callerInfo.callerUid = 200000100;
|
||||
callerInfo.callerUserId = 100;
|
||||
callerInfo.callerProcessName = "com.example.caller";
|
||||
callerInfo.callerBundleName = "com.example.caller";
|
||||
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.callee", "com.example.callee",
|
||||
"ServiceExtension", "ServiceExtAbility", 100200);
|
||||
|
||||
@@ -2301,15 +2301,15 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_BuildJsonInfo_0100, TestSiz
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BgUserExtension_ConcurrentAccess_0100
|
||||
* @tc.desc: Test concurrent OnBgUserExtensionStarted does not crash.
|
||||
* @tc.name: BackgroundUserExtension_ConcurrentAccess_0100
|
||||
* @tc.desc: Test concurrent OnBackgroundUserExtensionStarted does not crash.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_ConcurrentAccess_0100, TestSize.Level1)
|
||||
HWTEST_F(BackgroundUserExtensionMonitorTest, BackgroundUserExtension_ConcurrentAccess_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin.");
|
||||
auto monitor = DelayedSingleton<AAFwk::BgUserExtensionMonitor>::GetInstance();
|
||||
auto monitor = DelayedSingleton<AAFwk::BackgroundUserExtensionMonitor>::GetInstance();
|
||||
ASSERT_NE(monitor, nullptr);
|
||||
|
||||
const int32_t threadCount = 10;
|
||||
@@ -2317,10 +2317,10 @@ HWTEST_F(BgUserExtensionMonitorTest, BgUserExtension_ConcurrentAccess_0100, Test
|
||||
|
||||
for (int32_t i = 0; i < threadCount; i++) {
|
||||
threads.emplace_back([monitor, i]() {
|
||||
AAFwk::BgUserExtensionCallerInfo callerInfo;
|
||||
AAFwk::BackgroundUserExtensionCallerInfo callerInfo;
|
||||
callerInfo.callerUid = 200000100 + i;
|
||||
callerInfo.callerBundleName = "com.example.caller" + std::to_string(i);
|
||||
monitor->OnBgUserExtensionStarted(callerInfo,
|
||||
monitor->OnBackgroundUserExtensionStarted(callerInfo,
|
||||
"com.example.callee" + std::to_string(i),
|
||||
"com.example.callee" + std::to_string(i),
|
||||
"ServiceExtension",
|
||||
|
||||
Reference in New Issue
Block a user