From b20235e517717fd079437b9f50e4cec8e1ef57cb Mon Sep 17 00:00:00 2001 From: liqiang Date: Thu, 20 Apr 2023 15:28:58 +0800 Subject: [PATCH 01/16] IssueNo:https://gitee.com/openharmony/ability_ability_runtime/issues/I6XCV6 Description:context deal no longer inherited from context Sig: SIG_ApplicationFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: liqiang Change-Id: I1471e7675f1096cae5a860cf61893640c582856e --- .../native/appkit/app/context_container.cpp | 379 +--------- frameworks/native/appkit/app/context_deal.cpp | 666 ++---------------- interfaces/kits/native/appkit/app/context.h | 41 +- .../native/appkit/app/context_container.h | 92 +-- .../kits/native/appkit/app/context_deal.h | 281 ++------ .../abilitycontext_fuzzer.cpp | 2 +- .../context_container_test.cpp | 23 - .../context_deal_test.cpp | 121 ---- 8 files changed, 121 insertions(+), 1484 deletions(-) diff --git a/frameworks/native/appkit/app/context_container.cpp b/frameworks/native/appkit/app/context_container.cpp index deaa88b88c..8b149c52ec 100644 --- a/frameworks/native/appkit/app/context_container.cpp +++ b/frameworks/native/appkit/app/context_container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -28,13 +28,8 @@ namespace OHOS { namespace AppExecFwk { // for api7 demo special constexpr int CURRENT_ACCOUNT_ID = 100; -/** - * Attaches a Context object to the current ability. - * Generally, this method is called after Ability is loaded to provide the application context for the current ability. - * - * @param base Indicates a Context object. - */ -void ContextContainer::AttachBaseContext(const std::shared_ptr &base) + +void ContextContainer::AttachBaseContext(const std::shared_ptr &base) { if (base == nullptr) { HILOG_ERROR("ContextDeal::AttachBaseContext failed, base is nullptr"); @@ -51,11 +46,6 @@ void ContextContainer::DetachBaseContext() baseContext_ = nullptr; } -/** - * Called when getting the ProcessInfo - * - * @return ProcessInfo - */ std::shared_ptr ContextContainer::GetProcessInfo() const { if (baseContext_ != nullptr) { @@ -64,12 +54,6 @@ std::shared_ptr ContextContainer::GetProcessInfo() const return nullptr; } -/** - * @brief Obtains information about the current application. The returned application information includes basic - * information such as the application name and application permissions. - * - * @return Returns the ApplicationInfo for the current application. - */ std::shared_ptr ContextContainer::GetApplicationInfo() const { if (baseContext_ != nullptr) { @@ -80,11 +64,6 @@ std::shared_ptr ContextContainer::GetApplicationInfo() const } } -/** - * @brief Obtains the Context object of the application. - * - * @return Returns the Context object of the application. - */ std::shared_ptr ContextContainer::GetApplicationContext() const { if (baseContext_ != nullptr) { @@ -95,12 +74,6 @@ std::shared_ptr ContextContainer::GetApplicationContext() const } } -/** - * @brief Obtains the path of the package containing the current ability. The returned path contains the resources, - * source code, and configuration files of a module. - * - * @return Returns the path of the package file. - */ std::string ContextContainer::GetBundleCodePath() { if (baseContext_ != nullptr) { @@ -111,12 +84,6 @@ std::string ContextContainer::GetBundleCodePath() } } -/** - * @brief Obtains information about the current ability. - * The returned information includes the class name, bundle name, and other information about the current ability. - * - * @return Returns the AbilityInfo object for the current ability. - */ const std::shared_ptr ContextContainer::GetAbilityInfo() { if (baseContext_ != nullptr) { @@ -127,11 +94,6 @@ const std::shared_ptr ContextContainer::GetAbilityInfo() } } -/** - * @brief Obtains the Context object of the application. - * - * @return Returns the Context object of the application. - */ std::shared_ptr ContextContainer::GetContext() { if (baseContext_ != nullptr) { @@ -142,12 +104,6 @@ std::shared_ptr ContextContainer::GetContext() } } -/** - * @brief Obtains an IBundleMgr instance. - * You can use this instance to obtain information about the application bundle. - * - * @return Returns an IBundleMgr instance. - */ sptr ContextContainer::GetBundleManager() const { if (baseContext_ != nullptr) { @@ -158,11 +114,6 @@ sptr ContextContainer::GetBundleManager() const } } -/** - * @brief Obtains a resource manager. - * - * @return Returns a ResourceManager object. - */ std::shared_ptr ContextContainer::GetResourceManager() const { if (baseContext_ != nullptr) { @@ -173,13 +124,6 @@ std::shared_ptr ContextContainer::GetResource } } -/** - * @brief Deletes the specified private file associated with the application. - * - * @param fileName Indicates the name of the file to delete. The file name cannot contain path separators. - * - * @return Returns true if the file is deleted successfully; returns false otherwise. - */ bool ContextContainer::DeleteFile(const std::string &fileName) { if (baseContext_ != nullptr) { @@ -190,13 +134,6 @@ bool ContextContainer::DeleteFile(const std::string &fileName) } } -/** - * @brief Obtains the application-specific cache directory on the device's internal storage. The system - * automatically deletes files from the cache directory if disk space is required elsewhere on the device. - * Older files are always deleted first. - * - * @return Returns the application-specific cache directory. - */ std::string ContextContainer::GetCacheDir() { if (baseContext_ != nullptr) { @@ -207,13 +144,6 @@ std::string ContextContainer::GetCacheDir() } } -/** - * @brief Obtains the application-specific code-cache directory on the device's internal storage. - * The system will delete any files stored in this location both when your specific application is upgraded, - * and when the entire platform is upgraded. - * - * @return Returns the application-specific code-cache directory. - */ std::string ContextContainer::GetCodeCacheDir() { if (baseContext_ != nullptr) { @@ -224,12 +154,6 @@ std::string ContextContainer::GetCodeCacheDir() } } -/** - * @brief Obtains the local database path. - * If the local database path does not exist, the system creates one and returns the created path. - * - * @return Returns the local database file. - */ std::string ContextContainer::GetDatabaseDir() { if (baseContext_ != nullptr) { @@ -240,11 +164,6 @@ std::string ContextContainer::GetDatabaseDir() } } -/** - * @brief Obtains the absolute path where all private data files of this application are stored. - * - * @return Returns the absolute path storing all private data files of this application. - */ std::string ContextContainer::GetDataDir() { if (baseContext_ != nullptr) { @@ -255,17 +174,6 @@ std::string ContextContainer::GetDataDir() } } -/** - * @brief Obtains the directory for storing custom data files of the application. - * You can use the returned File object to create and access files in this directory. The files - * can be accessible only by the current application. - * - * @param name Indicates the name of the directory to retrieve. This directory is created as part - * of your application data. - * @param mode Indicates the file operating mode. The value can be 0 or a combination of MODE_PRIVATE. - * - * @return Returns a File object for the requested directory. - */ std::string ContextContainer::GetDir(const std::string &name, int mode) { if (baseContext_ != nullptr) { @@ -276,47 +184,6 @@ std::string ContextContainer::GetDir(const std::string &name, int mode) } } -/** - * @brief Obtains the absolute path to the application-specific cache directory - * on the primary external or shared storage device. - * - * @return Returns the absolute path to the application-specific cache directory on the external or - * shared storage device; returns null if the external or shared storage device is temporarily unavailable. - */ -std::string ContextContainer::GetExternalCacheDir() -{ - if (baseContext_ != nullptr) { - return baseContext_->GetExternalCacheDir(); - } else { - HILOG_ERROR("ContextContainer::GetExternalCacheDir baseContext_ is nullptr"); - return ""; - } -} - -/** - * @brief Obtains the absolute path to the directory for storing files for the application on the - * primary external or shared storage device. - * - * @param type Indicates the type of the file directory to return - * - * @return Returns the absolute path to the application file directory on the external or shared storage - * device; returns null if the external or shared storage device is temporarily unavailable. - */ -std::string ContextContainer::GetExternalFilesDir(std::string &type) -{ - if (baseContext_ != nullptr) { - return baseContext_->GetExternalFilesDir(type); - } else { - HILOG_ERROR("ContextContainer::GetExternalFilesDir baseContext_ is nullptr"); - return ""; - } -} - -/** - * @brief Obtains the directory for storing files for the application on the device's internal storage. - * - * @return Returns the application file directory. - */ std::string ContextContainer::GetFilesDir() { if (baseContext_ != nullptr) { @@ -327,13 +194,6 @@ std::string ContextContainer::GetFilesDir() } } -/** - * @brief Obtains the absolute path which app created and will be excluded from automatic backup to remote storage. - * The returned path maybe changed if the application is moved to an adopted storage device. - * - * @return The path of the directory holding application files that will not be automatically backed up to remote - * storage. - */ std::string ContextContainer::GetNoBackupFilesDir() { if (baseContext_ != nullptr) { @@ -344,31 +204,6 @@ std::string ContextContainer::GetNoBackupFilesDir() } } -/** - * @brief Checks whether the current process has the given permission. - * You need to call requestPermissionsFromUser(std::vector,std::vector, int) to request a permission - * only if the current process does not have the specific permission. - * - * @param permission Indicates the permission to check. This parameter cannot be null. - * - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ -int ContextContainer::VerifySelfPermission(const std::string &permission) -{ - if (baseContext_ != nullptr) { - return baseContext_->VerifySelfPermission(permission); - } else { - HILOG_ERROR("ContextContainer::VerifySelfPermission baseContext_ is nullptr"); - return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; - } -} - -/** - * @brief Obtains the bundle name of the current ability. - * - * @return Returns the bundle name of the current ability. - */ std::string ContextContainer::GetBundleName() const { if (baseContext_ != nullptr) { @@ -379,11 +214,6 @@ std::string ContextContainer::GetBundleName() const } } -/** - * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. - * - * @return Returns the path of the HAP containing this ability. - */ std::string ContextContainer::GetBundleResourcePath() { if (baseContext_ != nullptr) { @@ -394,29 +224,6 @@ std::string ContextContainer::GetBundleResourcePath() } } -/** - * @brief Remove permissions for all users who have access to specific permissions - * - * @param permission Indicates the permission to unauth. This parameter cannot be null. - * @param uri Indicates the URI to unauth. This parameter cannot be null. - * @param uid Indicates the UID of the unauth to check. - * - */ -void ContextContainer::UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) -{ - if (baseContext_ != nullptr) { - baseContext_->UnauthUriPermission(permission, uri, uid); - } else { - HILOG_ERROR("ContextContainer::UnauthUriPermission baseContext_ is nullptr"); - } -} - -/** - * @brief Obtains an ability manager. - * The ability manager provides information about running processes and memory usage of an application. - * - * @return Returns an IAbilityManager instance. - */ sptr ContextContainer::GetAbilityManager() { if (baseContext_ != nullptr) { @@ -427,14 +234,6 @@ sptr ContextContainer::GetAbilityManager() } } -/** - * @brief Obtains the type of this application. - * - * @return Returns system if this application is a system application; - * returns normal if it is released in OHOS AppGallery; - * returns other if it is released by a third-party vendor; - * returns an empty string if the query fails. - */ std::string ContextContainer::GetAppType() { if (baseContext_ != nullptr) { @@ -445,32 +244,6 @@ std::string ContextContainer::GetAppType() } } -/** - * @brief Query whether the application of the specified PID and UID has been granted a certain permission - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param pid Process id - * @param uid - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ -int ContextContainer::VerifyPermission(const std::string &permission, int pid, int uid) -{ - if (baseContext_ != nullptr) { - return baseContext_->VerifyPermission(permission, pid, uid); - } else { - HILOG_ERROR("ContextContainer::VerifyPermission baseContext_ is nullptr"); - return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; - } -} - -/** - * @brief Obtains the distributed file path. - * If the distributed file path does not exist, the system creates one and returns the created path. This method is - * applicable only to the context of an ability rather than that of an application. - * - * @return Returns the distributed file. - */ std::string ContextContainer::GetDistributedDir() { if (baseContext_ != nullptr) { @@ -480,11 +253,7 @@ std::string ContextContainer::GetDistributedDir() return ""; } } -/** - * @brief Sets the pattern of this Context based on the specified pattern ID. - * - * @param patternId Indicates the resource ID of the pattern to set. - */ + void ContextContainer::SetPattern(int patternId) { if (baseContext_ != nullptr) { @@ -494,26 +263,6 @@ void ContextContainer::SetPattern(int patternId) } } -/** - * @brief Obtains the Context object of this ability. - * - * @return Returns the Context object of this ability. - */ -std::shared_ptr ContextContainer::GetAbilityPackageContext() -{ - if (baseContext_ != nullptr) { - return baseContext_->GetAbilityPackageContext(); - } else { - HILOG_ERROR("ContextContainer::GetAbilityPackageContext baseContext_ is nullptr"); - return nullptr; - } -} - -/** - * @brief Obtains the HapModuleInfo object of the application. - * - * @return Returns the HapModuleInfo object of the application. - */ std::shared_ptr ContextContainer::GetHapModuleInfo() { if (baseContext_ != nullptr) { @@ -524,11 +273,6 @@ std::shared_ptr ContextContainer::GetHapModuleInfo() } } -/** - * @brief Obtains the name of the current process. - * - * @return Returns the current process name. - */ std::string ContextContainer::GetProcessName() { if (baseContext_ != nullptr) { @@ -539,25 +283,6 @@ std::string ContextContainer::GetProcessName() } } -/** - * @brief Requests certain permissions from the system. - * This method is called for permission request. This is an asynchronous method. When it is executed, - * the task will be called back. - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null. - * @param task The callback or promise fo js interface. - */ -void ContextContainer::RequestPermissionsFromUser(std::vector &permissions, - std::vector &permissionsState, PermissionRequestTask &&task) -{ - if (baseContext_ != nullptr) { - baseContext_->RequestPermissionsFromUser(permissions, permissionsState, std::move(task)); - } else { - HILOG_ERROR("ContextContainer::RequestPermissionsFromUser baseContext_ is nullptr"); - } -} - std::shared_ptr ContextContainer::CreateBundleContext(std::string bundleName, int flag, int accountId) { if (bundleName.empty()) { @@ -646,11 +371,7 @@ void ContextContainer::InitResourceManager(BundleInfo &bundleInfo, std::shared_p resourceManager->UpdateResConfig(*resConfig); deal->initResourceManager(resourceManager); } -/** - * @brief Obtains information about the caller of this ability. - * - * @return Returns the caller information. - */ + Uri ContextContainer::GetCaller() { if (baseContext_ != nullptr) { @@ -662,13 +383,6 @@ Uri ContextContainer::GetCaller() } } -/** - * @brief Get the string of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string to get. - * - * @return Returns the string of this Context. - */ std::string ContextContainer::GetString(int resId) { if (baseContext_ != nullptr) { @@ -680,13 +394,6 @@ std::string ContextContainer::GetString(int resId) } } -/** - * @brief Get the string array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string array to get. - * - * @return Returns the string array of this Context. - */ std::vector ContextContainer::GetStringArray(int resId) { if (baseContext_ != nullptr) { @@ -697,13 +404,6 @@ std::vector ContextContainer::GetStringArray(int resId) } } -/** - * @brief Get the integer array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the integer array to get. - * - * @return Returns the integer array of this Context. - */ std::vector ContextContainer::GetIntArray(int resId) { if (baseContext_ != nullptr) { @@ -714,11 +414,6 @@ std::vector ContextContainer::GetIntArray(int resId) } } -/** - * @brief Obtains the theme of this Context. - * - * @return theme Returns the theme of this Context. - */ std::map ContextContainer::GetTheme() { if (baseContext_ != nullptr) { @@ -729,11 +424,6 @@ std::map ContextContainer::GetTheme() } } -/** - * @brief Sets the theme of this Context based on the specified theme ID. - * - * @param themeId Indicates the resource ID of the theme to set. - */ void ContextContainer::SetTheme(int themeId) { if (baseContext_ != nullptr) { @@ -743,11 +433,6 @@ void ContextContainer::SetTheme(int themeId) } } -/** - * @brief Obtains the pattern of this Context. - * - * @return getPattern in interface Context - */ std::map ContextContainer::GetPattern() { if (baseContext_ != nullptr) { @@ -758,13 +443,6 @@ std::map ContextContainer::GetPattern() } } -/** - * @brief Get the color of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the color to get. - * - * @return Returns the color value of this Context. - */ int ContextContainer::GetColor(int resId) { if (baseContext_ != nullptr) { @@ -775,11 +453,6 @@ int ContextContainer::GetColor(int resId) } } -/** - * @brief Obtains the theme id of this Context. - * - * @return int Returns the theme id of this Context. - */ int ContextContainer::GetThemeId() { if (baseContext_ != nullptr) { @@ -790,11 +463,6 @@ int ContextContainer::GetThemeId() } } -/** - * @brief Obtains the current display orientation of this ability. - * - * @return Returns the current display orientation. - */ int ContextContainer::GetDisplayOrientation() { if (baseContext_ != nullptr) { @@ -805,12 +473,6 @@ int ContextContainer::GetDisplayOrientation() } } -/** - * @brief Obtains the path storing the preference file of the application. - * If the preference file path does not exist, the system creates one and returns the created path. - * - * @return Returns the preference file path . - */ std::string ContextContainer::GetPreferencesDir() { if (baseContext_ != nullptr) { @@ -821,11 +483,6 @@ std::string ContextContainer::GetPreferencesDir() } } -/** - * @brief Set color mode - * - * @param the value of color mode. - */ void ContextContainer::SetColorMode(int mode) { if (baseContext_ == nullptr) { @@ -836,11 +493,6 @@ void ContextContainer::SetColorMode(int mode) baseContext_->SetColorMode(mode); } -/** - * @brief Obtains color mode. - * - * @return Returns the color mode value. - */ int ContextContainer::GetColorMode() { if (baseContext_ == nullptr) { @@ -851,11 +503,6 @@ int ContextContainer::GetColorMode() return baseContext_->GetColorMode(); } -/** - * @brief Obtains the unique ID of the mission containing this ability. - * - * @return Returns the unique mission ID. - */ int ContextContainer::GetMissionId() { if (baseContext_ != nullptr) { @@ -865,21 +512,5 @@ int ContextContainer::GetMissionId() return -1; } } - -bool ContextContainer::IsUpdatingConfigurations() -{ - if (baseContext_ != nullptr) { - return baseContext_->IsUpdatingConfigurations(); - } - return false; -} - -bool ContextContainer::PrintDrawnCompleted() -{ - if (baseContext_ != nullptr) { - return baseContext_->PrintDrawnCompleted(); - } - return false; -} } // namespace AppExecFwk } // namespace OHOS diff --git a/frameworks/native/appkit/app/context_deal.cpp b/frameworks/native/appkit/app/context_deal.cpp index 1c2df4853b..2bbe06503d 100644 --- a/frameworks/native/appkit/app/context_deal.cpp +++ b/frameworks/native/appkit/app/context_deal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -56,88 +56,48 @@ const std::string ContextDeal::CONTEXT_DEAL_DATA("data"); ContextDeal::ContextDeal(bool isCreateBySystemApp) : isCreateBySystemApp_(isCreateBySystemApp) {} -/** - * Called when getting the ProcessInfo - * - * @return ProcessInfo - */ std::shared_ptr ContextDeal::GetProcessInfo() const { return processInfo_; } -/** - * Called when setting the ProcessInfo - * - * @param info ProcessInfo instance - */ void ContextDeal::SetProcessInfo(const std::shared_ptr &info) { - HILOG_DEBUG("ContextDeal::SetProcessInfo"); if (info == nullptr) { - HILOG_ERROR("ContextDeal::SetProcessInfo failed, info is empty"); + HILOG_ERROR("SetProcessInfo failed, info is empty"); return; } processInfo_ = info; } -/** - * @brief Obtains information about the current application. The returned application information includes basic - * information such as the application name and application permissions. - * - * @return Returns the ApplicationInfo for the current application. - */ std::shared_ptr ContextDeal::GetApplicationInfo() const { return applicationInfo_; } -/** - * @brief Set ApplicationInfo - * - * @param info ApplicationInfo instance. - */ void ContextDeal::SetApplicationInfo(const std::shared_ptr &info) { - HILOG_DEBUG("ContextDeal::SetApplicationInfo"); if (info == nullptr) { - HILOG_ERROR("ContextDeal::SetApplicationInfo failed, info is empty"); + HILOG_ERROR("SetApplicationInfo failed, info is empty"); return; } applicationInfo_ = info; } -/** - * @brief Obtains the Context object of the application. - * - * @return Returns the Context object of the application. - */ std::shared_ptr ContextDeal::GetApplicationContext() const { return appContext_; } -/** - * @brief Set ApplicationContext - * - * @param context ApplicationContext instance. - */ void ContextDeal::SetApplicationContext(const std::shared_ptr &context) { - HILOG_DEBUG("ContextDeal::SetApplicationContext"); if (context == nullptr) { - HILOG_ERROR("ContextDeal::SetApplicationContext failed, context is empty"); + HILOG_ERROR("SetApplicationContext failed, context is empty"); return; } appContext_ = context; } -/** - * @brief Obtains the path of the package containing the current ability. The returned path contains the resources, - * source code, and configuration files of a module. - * - * @return Returns the path of the package file. - */ std::string ContextDeal::GetBundleCodePath() { if (applicationInfo_ == nullptr) { @@ -154,76 +114,41 @@ std::string ContextDeal::GetBundleCodePath() return dir; } -/** - * @brief SetBundleCodePath - * - * @param Returns string path - */ void ContextDeal::SetBundleCodePath(std::string &path) { path_ = path; } -/** - * @brief Obtains information about the current ability. - * The returned information includes the class name, bundle name, and other information about the current ability. - * - * @return Returns the AbilityInfo object for the current ability. - */ const std::shared_ptr ContextDeal::GetAbilityInfo() { return abilityInfo_; } -/** - * @brief Set AbilityInfo - * - * @param info AbilityInfo instance. - */ void ContextDeal::SetAbilityInfo(const std::shared_ptr &info) { - HILOG_DEBUG("ContextDeal::SetAbilityInfo"); if (info == nullptr) { - HILOG_ERROR("ContextDeal::SetAbilityInfo failed, info is empty"); + HILOG_ERROR("SetAbilityInfo failed, info is empty"); return; } abilityInfo_ = info; } -/** - * @brief Obtains the Context object of the ability. - * - * @return Returns the Context object of the ability. - */ std::shared_ptr ContextDeal::GetContext() { return abilityContext_; } -/** - * @brief Set Ability context - * - * @param context Ability object - */ void ContextDeal::SetContext(const std::shared_ptr &context) { - HILOG_DEBUG("ContextDeal::SetContext"); if (context == nullptr) { - HILOG_ERROR("ContextDeal::SetContext failed, context is empty"); + HILOG_ERROR("SetContext failed, context is empty"); return; } abilityContext_ = context; } -/** - * @brief Obtains an IBundleMgr instance. - * You can use this instance to obtain information about the application bundle. - * - * @return Returns an IBundleMgr instance. - */ sptr ContextDeal::GetBundleManager() const { - HILOG_DEBUG("ContextDeal::GetBundleManager"); auto bundleObj = OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); if (bundleObj == nullptr) { @@ -234,118 +159,48 @@ sptr ContextDeal::GetBundleManager() const return bms; } -/** - * @brief Obtains a resource manager. - * - * @return Returns a ResourceManager object. - */ std::shared_ptr ContextDeal::GetResourceManager() const { return resourceManager_; } -/** - * @brief Set Profile instance. - * - * @param Profile instance. - */ void ContextDeal::SetProfile(const std::shared_ptr &profile) { - HILOG_DEBUG("ContextDeal::SetProfile"); if (profile == nullptr) { - HILOG_ERROR("ContextDeal::SetProfile failed, profile is nullptr"); + HILOG_ERROR("SetProfile failed, profile is nullptr"); return; } profile_ = profile; } -/** - * @brief Obtains an Profile instance. - * - * @return Returns an Profile instance. - */ std::shared_ptr ContextDeal::GetProfile() const { return profile_; } -/** - * @brief Deletes the specified private file associated with the application. - * - * @param fileName Indicates the name of the file to delete. The file name cannot contain path separators. - * - * @return Returns true if the file is deleted successfully; returns false otherwise. - */ bool ContextDeal::DeleteFile(const std::string &fileName) { - HILOG_DEBUG("ContextDeal::DeleteFile begin"); std::string path = GetDataDir() + CONTEXT_DEAL_FILE_SEPARATOR + fileName; bool ret = OHOS::RemoveFile(path); - HILOG_DEBUG("ContextDeal::DeleteFile end"); return ret; } -/** - * @brief Destroys another ability that uses the AbilityInfo.AbilityType.SERVICE template. - * The current ability using either the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE - * template can call this method to destroy another ability that uses the AbilityInfo.AbilityType.SERVICE - * template. The current ability itself can be destroyed by calling the terminateAbility() method. - * - * @param want Indicates the Want containing information about the ability to destroy. - * - * @return Returns true if the ability is destroyed successfully; returns false otherwise. - */ -bool ContextDeal::StopAbility(const AAFwk::Want &want) -{ - return false; -} - -/** - * @brief Obtains the application-specific cache directory on the device's internal storage. The system - * automatically deletes files from the cache directory if disk space is required elsewhere on the device. - * Older files are always deleted first. - * - * @return Returns the application-specific cache directory. - */ std::string ContextDeal::GetCacheDir() { std::string dir = GetBaseDir() + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_CACHE; CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetCacheDir:%{public}s", dir.c_str()); + HILOG_DEBUG("GetCacheDir:%{public}s", dir.c_str()); return dir; } -bool ContextDeal::IsUpdatingConfigurations() -{ - return false; -} - -bool ContextDeal::PrintDrawnCompleted() -{ - return false; -} - -/** - * @brief Obtains the application-specific code-cache directory on the device's internal storage. - * The system will delete any files stored in this location both when your specific application is upgraded, - * and when the entire platform is upgraded. - * - * @return Returns the application-specific code-cache directory. - */ std::string ContextDeal::GetCodeCacheDir() { std::string dir = GetDataDir() + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_CODE_CACHE; CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetCodeCacheDir:%{public}s", dir.c_str()); + HILOG_DEBUG("GetCodeCacheDir:%{public}s", dir.c_str()); return dir; } -/** - * @brief Obtains the local database path. - * If the local database path does not exist, the system creates one and returns the created path. - * - * @return Returns the local database file. - */ std::string ContextDeal::GetDatabaseDir() { std::string dir; @@ -356,140 +211,58 @@ std::string ContextDeal::GetDatabaseDir() dir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_DATABASE; } CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetDatabaseDir:%{public}s", dir.c_str()); + HILOG_DEBUG("GetDatabaseDir:%{public}s", dir.c_str()); return dir; } -/** - * @brief Obtains the absolute path where all private data files of this application are stored. - * - * @return Returns the absolute path storing all private data files of this application. - */ std::string ContextDeal::GetDataDir() { std::string dir = GetBaseDir() + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_DATA; CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetDataDir dir = %{public}s", dir.c_str()); + HILOG_DEBUG("GetDataDir dir = %{public}s", dir.c_str()); return dir; } -/** - * @brief Obtains the directory for storing custom data files of the application. - * You can use the returned File object to create and access files in this directory. The files - * can be accessible only by the current application. - * - * @param name Indicates the name of the directory to retrieve. This directory is created as part - * of your application data. - * @param mode Indicates the file operating mode. The value can be 0 or a combination of MODE_PRIVATE. - * - * @return Returns a File object for the requested directory. - */ std::string ContextDeal::GetDir(const std::string &name, int mode) { - HILOG_DEBUG("ContextDeal::GetDir begin"); if (applicationInfo_ == nullptr) { - HILOG_ERROR("ContextDeal::GetDir failed, applicationInfo_ == nullptr"); + HILOG_ERROR("GetDir failed, applicationInfo_ == nullptr"); return ""; } std::string dir = applicationInfo_->dataDir + CONTEXT_DEAL_FILE_SEPARATOR + name; if (!OHOS::FileExists(dir)) { - HILOG_INFO("ContextDeal::GetDir File is not exits"); + HILOG_INFO("GetDir File is not exits"); OHOS::ForceCreateDirectory(dir); OHOS::ChangeModeDirectory(dir, mode); } - HILOG_DEBUG("ContextDeal::GetDir end"); return dir; } -/** - * @brief Obtains the absolute path to the application-specific cache directory - * on the primary external or shared storage device. - * - * @return Returns the absolute path to the application-specific cache directory on the external or - * shared storage device; returns null if the external or shared storage device is temporarily unavailable. - */ -std::string ContextDeal::GetExternalCacheDir() -{ - return ""; -} - -/** - * @brief Obtains the absolute path to the directory for storing files for the application on the - * primary external or shared storage device. - * - * @param type Indicates the type of the file directory to return - * - * @return Returns the absolute path to the application file directory on the external or shared storage - * device; returns null if the external or shared storage device is temporarily unavailable. - */ -std::string ContextDeal::GetExternalFilesDir(std::string &type) -{ - return ""; -} - -/** - * @brief Obtains the directory for storing files for the application on the device's internal storage. - * - * @return Returns the application file directory. - */ std::string ContextDeal::GetFilesDir() { std::string dir = GetBaseDir() + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_Files; CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetFilesDir dir = %{public}s", dir.c_str()); + HILOG_DEBUG("GetFilesDir dir = %{public}s", dir.c_str()); return dir; } -/** - * @brief Obtains the absolute path which app created and will be excluded from automatic backup to remote storage. - * The returned path maybe changed if the application is moved to an adopted storage device. - * - * @return The path of the directory holding application files that will not be automatically backed up to remote - * storage. - */ std::string ContextDeal::GetNoBackupFilesDir() { - HILOG_DEBUG("ContextDeal::GetNoBackupFilesDir begin"); std::string dir = GetDataDir() + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_NO_BACKUP_Files; if (!OHOS::FileExists(dir)) { - HILOG_INFO("ContextDeal::GetDir GetNoBackupFilesDir is not exits"); + HILOG_INFO("GetDir GetNoBackupFilesDir is not exits"); OHOS::ForceCreateDirectory(dir); OHOS::ChangeModeDirectory(dir, MODE); } - HILOG_DEBUG("ContextDeal::GetCodeCacheDir:%{public}s", dir.c_str()); + HILOG_DEBUG("GetCodeCacheDir:%{public}s", dir.c_str()); return dir; } -/** - * @brief Checks whether the current process has the given permission. - * You need to call requestPermissionsFromUser(std::vector,std::vector, int) to request a permission - * only if the current process does not have the specific permission. - * - * @param permission Indicates the permission to check. This parameter cannot be null. - * - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ -int ContextDeal::VerifySelfPermission(const std::string &permission) -{ - return 0; -} - -/** - * @brief Obtains the bundle name of the current ability. - * - * @return Returns the bundle name of the current ability. - */ std::string ContextDeal::GetBundleName() const { return (applicationInfo_ != nullptr) ? applicationInfo_->bundleName : ""; } -/** - * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. - * - * @return Returns the path of the HAP containing this ability. - */ std::string ContextDeal::GetBundleResourcePath() { if (abilityInfo_ == nullptr) { @@ -506,105 +279,28 @@ std::string ContextDeal::GetBundleResourcePath() return dir; } -/** - * @brief Starts a new ability. - * An ability using the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE template uses this method - * to start a specific ability. The system locates the target ability from installed abilities based on the value - * of the want parameter and then starts it. You can specify the ability to start using the want parameter. - * - * @param want Indicates the Want containing information about the target ability to start. - * - * @param requestCode Indicates the request code returned after the ability using the AbilityInfo.AbilityType.PAGE - * template is started. You can define the request code to identify the results returned by abilities. The value - * ranges from 0 to 65535. This parameter takes effect only on abilities using the AbilityInfo.AbilityType.PAGE - * template. - * - * @return errCode ERR_OK on success, others on failure. - */ -ErrCode ContextDeal::StartAbility(const AAFwk::Want &want, int requestCode) -{ - HILOG_DEBUG("ContextDeal::StartAbility is called"); - return ERR_INVALID_VALUE; -} - -/** - * @brief Remove permissions for all users who have access to specific permissions - * - * @param permission Indicates the permission to unauth. This parameter cannot be null. - * @param uri Indicates the URI to unauth. This parameter cannot be null. - * @param uid Indicates the UID of the unauth to check. - * - */ -void ContextDeal::UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) -{} - -/** - * @brief Obtains an ability manager. - * The ability manager provides information about running processes and memory usage of an application. - * - * @return Returns an IAbilityManager instance. - */ sptr ContextDeal::GetAbilityManager() { - HILOG_DEBUG("ContextDeal::GetAbilityManager begin"); auto remoteObject = OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(ABILITY_MGR_SERVICE_ID); if (remoteObject == nullptr) { HILOG_ERROR("failed to get ability manager service"); return nullptr; } sptr ams = iface_cast(remoteObject); - HILOG_DEBUG("ContextDeal::GetAbilityManager end"); return ams; } -/** - * @brief Obtains the type of this application. - * - * @return Returns system if this application is a system application; - * returns normal if it is released in OHOS AppGallery; - * returns other if it is released by a third-party vendor; - * returns an empty string if the query fails. - */ std::string ContextDeal::GetAppType() { - HILOG_DEBUG("ContextDeal::GetAppType begin"); sptr ptr = GetBundleManager(); if (ptr == nullptr) { HILOG_ERROR("GetAppType failed to get bundle manager service"); return ""; } std::string retString = ptr->GetAppType(applicationInfo_->bundleName); - HILOG_DEBUG("ContextDeal::GetAppType end"); return retString; } -/** - * @brief Destroys another ability you had previously started by calling Ability.startAbilityForResult - * (ohos.aafwk.content.Want, int, ohos.aafwk.ability.startsetting.AbilityStartSetting) with the same requestCode passed. - * - * @param requestCode Indicates the request code passed for starting the ability. - * - * @return errCode ERR_OK on success, others on failure. - */ -ErrCode ContextDeal::TerminateAbility(int requestCode) -{ - return ERR_INVALID_VALUE; -} - -/** - * @brief Query whether the application of the specified PID and UID has been granted a certain permission - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param pid Process id - * @param uid - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ -int ContextDeal::VerifyPermission(const std::string &permission, int pid, int uid) -{ - return 0; -} - bool ContextDeal::IsCreateBySystemApp() const { return (static_cast(flags_) & static_cast(CONTEXT_CREATE_BY_SYSTEM_APP)) == 1; @@ -619,9 +315,8 @@ int ContextDeal::GetCurrentAccountId() const void ContextDeal::CreateDirIfNotExist(const std::string &dirPath) const { - HILOG_DEBUG("CreateDirIfNotExist: create directory if not exists."); if (!OHOS::FileExists(dirPath)) { - HILOG_DEBUG("ContextDeal::CreateDirIfNotExist File is not exits"); + HILOG_DEBUG("CreateDirIfNotExist File is not exits"); bool createDir = OHOS::ForceCreateDirectory(dirPath); if (!createDir) { HILOG_INFO("CreateDirIfNotExist: create dir %{public}s failed.", dirPath.c_str()); @@ -630,16 +325,8 @@ void ContextDeal::CreateDirIfNotExist(const std::string &dirPath) const } } -/** - * @brief Obtains the distributed file path. - * If the distributed file path does not exist, the system creates one and returns the created path. This method is - * applicable only to the context of an ability rather than that of an application. - * - * @return Returns the distributed file. - */ std::string ContextDeal::GetDistributedDir() { - HILOG_DEBUG("ContextDeal::GetDistributedDir"); std::string dir; if (IsCreateBySystemApp()) { dir = CONTEXT_DISTRIBUTED_BASE_BEFORE + std::to_string(GetCurrentAccountId()) + @@ -648,46 +335,25 @@ std::string ContextDeal::GetDistributedDir() dir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_DISTRIBUTEDFILES; } CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetDistributedDir:%{public}s", dir.c_str()); + HILOG_DEBUG("GetDistributedDir:%{public}s", dir.c_str()); return dir; } -/** - * @brief Sets the pattern of this Context based on the specified pattern ID. - * - * @param patternId Indicates the resource ID of the pattern to set. - */ + void ContextDeal::SetPattern(int patternId) { - HILOG_DEBUG("ContextDeal::SetPattern begin"); if (resourceManager_ != nullptr) { if (!pattern_.empty()) { pattern_.clear(); } OHOS::Global::Resource::RState errval = resourceManager_->GetPatternById(patternId, pattern_); if (errval != OHOS::Global::Resource::RState::SUCCESS) { - HILOG_ERROR("ContextDeal::SetPattern GetPatternById(patternId:%d) retval is %u", patternId, errval); + HILOG_ERROR("SetPattern GetPatternById(patternId:%d) retval is %u", patternId, errval); } } else { - HILOG_ERROR("ContextDeal::SetPattern resourceManager_ is nullptr"); + HILOG_ERROR("SetPattern resourceManager_ is nullptr"); } - HILOG_DEBUG("ContextDeal::SetPattern end"); } -/** - * @brief Obtains the Context object of this ability. - * - * @return Returns the Context object of this ability. - */ -std::shared_ptr ContextDeal::GetAbilityPackageContext() -{ - return nullptr; -} - -/** - * @brief Obtains the HapModuleInfo object of the application. - * - * @return Returns the HapModuleInfo object of the application. - */ std::shared_ptr ContextDeal::GetHapModuleInfo() { // fix set HapModuleInfoLocal data failed, request only once @@ -698,146 +364,34 @@ std::shared_ptr ContextDeal::GetHapModuleInfo() return nullptr; } } - HILOG_DEBUG("ContextDeal::GetHapModuleInfo end"); return hapModuleInfoLocal_; } -/** - * @brief Obtains the name of the current process. - * - * @return Returns the current process name. - */ std::string ContextDeal::GetProcessName() { return (processInfo_ != nullptr) ? processInfo_->GetProcessName() : ""; } -/** - * @brief Obtains the bundle name of the ability that called the current ability. - * You can use the obtained bundle name to check whether the calling ability is allowed to receive the data you will - * send. If you did not use Ability.startAbilityForResult(ohos.aafwk.content.Want, int, - * ohos.aafwk.ability.startsetting.AbilityStartSetting) to start the calling ability, null is returned. - * - * @return Returns the bundle name of the calling ability; returns null if no calling ability is available. - */ -std::string ContextDeal::GetCallingBundle() -{ - return ""; -} - -/** - * @brief Requests certain permissions from the system. - * This method is called for permission request. This is an asynchronous method. When it is executed, - * the task will be called back. - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null. - * @param task The callback or promise fo js interface. - */ -void ContextDeal::RequestPermissionsFromUser(std::vector &permissions, std::vector &permissionsState, - PermissionRequestTask &&task) {} - -/** - * @brief Starts a new ability with special ability start setting. - * - * @param want Indicates the Want containing information about the target ability to start. - * @param requestCode Indicates the request code returned after the ability is started. You can define the request code - * to identify the results returned by abilities. The value ranges from 0 to 65535. - * @param abilityStartSetting Indicates the special start setting used in starting ability. - * - * @return errCode ERR_OK on success, others on failure. - */ -ErrCode ContextDeal::StartAbility(const Want &want, int requestCode, const AbilityStartSetting &abilityStartSetting) -{ - return ERR_INVALID_VALUE; -} - -/** - * @brief Destroys the current ability. - * - * @return errCode ERR_OK on success, others on failure. - */ -ErrCode ContextDeal::TerminateAbility() -{ - return ERR_INVALID_VALUE; -} - -/** - * @brief Connects the current ability to an ability - * - * @param want Indicates the want containing information about the ability to connect - * - * @param conn Indicates the callback object when the target ability is connected. - * - * @return True means success and false means failure - */ -bool ContextDeal::ConnectAbility(const Want &want, const sptr &conn) -{ - return false; -} - -/** - * @brief Disconnects the current ability from an ability - * - * @param conn Indicates the IAbilityConnection callback object passed by connectAbility after the connection - * is set up. The IAbilityConnection object uniquely identifies a connection between two abilities. - * - * @return errCode ERR_OK on success, others on failure. - */ -ErrCode ContextDeal::DisconnectAbility(const sptr &conn) -{ - return ERR_INVALID_VALUE; -} - -sptr ContextDeal::GetToken() -{ - return nullptr; -} - -/** - * @brief init the ResourceManager for ContextDeal. - * - * @param the ResourceManager has been inited. - * - */ void ContextDeal::initResourceManager(const std::shared_ptr &resourceManager) { - HILOG_DEBUG("ContextDeal::initResourceManager. Start."); resourceManager_ = resourceManager; - HILOG_DEBUG("ContextDeal::initResourceManager. End."); } -/** - * @brief Obtains information about the caller of this ability. - * - * @return Returns the caller information. - */ Uri ContextDeal::GetCaller() { Uri uri(uriString_); return uri; } -/** - * @brief SerUriString - */ void ContextDeal::SerUriString(const std::string &uri) { uriString_ = uri; } -/** - * @brief Get the string of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string to get. - * - * @return Returns the string of this Context. - */ std::string ContextDeal::GetString(int resId) { - HILOG_DEBUG("ContextDeal::GetString begin"); if (resourceManager_ == nullptr) { - HILOG_ERROR("ContextDeal::GetString resourceManager_ is nullptr"); + HILOG_ERROR("GetString resourceManager_ is nullptr"); return ""; } @@ -846,24 +400,15 @@ std::string ContextDeal::GetString(int resId) if (errval == OHOS::Global::Resource::RState::SUCCESS) { return ret; } else { - HILOG_ERROR("ContextDeal::GetString GetStringById(resId:%d) retval is %u", resId, errval); + HILOG_ERROR("GetString GetStringById(resId:%d) retval is %u", resId, errval); return ""; } - HILOG_DEBUG("ContextDeal::GetString end"); } -/** - * @brief Get the string array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string array to get. - * - * @return Returns the string array of this Context. - */ std::vector ContextDeal::GetStringArray(int resId) { - HILOG_DEBUG("ContextDeal::GetStringArray begin"); if (resourceManager_ == nullptr) { - HILOG_ERROR("ContextDeal::GetStringArray resourceManager_ is nullptr"); + HILOG_ERROR("GetStringArray resourceManager_ is nullptr"); return std::vector(); } @@ -872,24 +417,15 @@ std::vector ContextDeal::GetStringArray(int resId) if (errval == OHOS::Global::Resource::RState::SUCCESS) { return retv; } else { - HILOG_ERROR("ContextDeal::GetStringArray GetStringArrayById(resId:%d) retval is %u", resId, errval); + HILOG_ERROR("GetStringArray GetStringArrayById(resId:%d) retval is %u", resId, errval); return std::vector(); } - HILOG_DEBUG("ContextDeal::GetStringArray end"); } -/** - * @brief Get the integer array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the integer array to get. - * - * @return Returns the integer array of this Context. - */ std::vector ContextDeal::GetIntArray(int resId) { - HILOG_DEBUG("ContextDeal::GetIntArray begin"); if (resourceManager_ == nullptr) { - HILOG_ERROR("ContextDeal::GetIntArray resourceManager_ is nullptr"); + HILOG_ERROR("GetIntArray resourceManager_ is nullptr"); return std::vector(); } @@ -898,43 +434,29 @@ std::vector ContextDeal::GetIntArray(int resId) if (errval == OHOS::Global::Resource::RState::SUCCESS) { return retv; } else { - HILOG_ERROR("ContextDeal::GetIntArray GetIntArrayById(resId:%d) retval is %u", resId, errval); + HILOG_ERROR("GetIntArray GetIntArrayById(resId:%d) retval is %u", resId, errval); return std::vector(); } - HILOG_DEBUG("ContextDeal::GetIntArray end"); } -/** - * @brief Obtains the theme of this Context. - * - * @return theme Returns the theme of this Context. - */ std::map ContextDeal::GetTheme() { - HILOG_DEBUG("ContextDeal::GetTheme begin"); if (theme_.empty()) { SetTheme(GetThemeId()); } - HILOG_DEBUG("ContextDeal::GetTheme end"); return theme_; } -/** - * @brief Sets the theme of this Context based on the specified theme ID. - * - * @param themeId Indicates the resource ID of the theme to set. - */ void ContextDeal::SetTheme(int themeId) { - HILOG_DEBUG("ContextDeal::SetTheme begin"); if (resourceManager_ == nullptr) { - HILOG_ERROR("ContextDeal::SetTheme resourceManager_ is nullptr"); + HILOG_ERROR("SetTheme resourceManager_ is nullptr"); return; } auto hapModInfo = GetHapModuleInfo(); if (hapModInfo == nullptr) { - HILOG_ERROR("ContextDeal::SetTheme hapModInfo is nullptr"); + HILOG_ERROR("SetTheme hapModInfo is nullptr"); return; } @@ -943,43 +465,24 @@ void ContextDeal::SetTheme(int themeId) } OHOS::Global::Resource::RState errval = resourceManager_->GetThemeById(themeId, theme_); if (errval != OHOS::Global::Resource::RState::SUCCESS) { - HILOG_ERROR("ContextDeal::SetTheme GetThemeById(themeId:%d) retval is %u", themeId, errval); - return; + HILOG_ERROR("SetTheme GetThemeById(themeId:%d) retval is %u", themeId, errval); } - - HILOG_DEBUG("ContextDeal::SetTheme end"); - return; } -/** - * @brief Obtains the pattern of this Context. - * - * @return getPattern in interface Context - */ std::map ContextDeal::GetPattern() { - HILOG_DEBUG("ContextDeal::GetPattern begin"); if (!pattern_.empty()) { - HILOG_DEBUG("ContextDeal::GetPattern end"); return pattern_; } else { - HILOG_ERROR("ContextDeal::GetPattern pattern_ is empty"); + HILOG_ERROR("GetPattern pattern_ is empty"); return std::map(); } } -/** - * @brief Get the color of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the color to get. - * - * @return Returns the color value of this Context. - */ int ContextDeal::GetColor(int resId) { - HILOG_DEBUG("ContextDeal::GetColor begin"); if (resourceManager_ == nullptr) { - HILOG_ERROR("ContextDeal::GetColor resourceManager_ is nullptr"); + HILOG_ERROR("GetColor resourceManager_ is nullptr"); return INVALID_RESOURCE_VALUE; } @@ -988,91 +491,46 @@ int ContextDeal::GetColor(int resId) if (errval == OHOS::Global::Resource::RState::SUCCESS) { return ret; } else { - HILOG_ERROR("ContextDeal::GetColor GetColorById(resId:%d) retval is %u", resId, errval); + HILOG_ERROR("GetColor GetColorById(resId:%d) retval is %u", resId, errval); return INVALID_RESOURCE_VALUE; } - HILOG_DEBUG("ContextDeal::GetColor end"); } -/** - * @brief Obtains the theme id of this Context. - * - * @return int Returns the theme id of this Context. - */ int ContextDeal::GetThemeId() { auto hapModInfo = GetHapModuleInfo(); if (hapModInfo != nullptr) { return -1; } else { - HILOG_ERROR("ContextDeal::GetThemeId hapModInfo is nullptr"); + HILOG_ERROR("GetThemeId hapModInfo is nullptr"); return -1; } } -/** - * @brief - * Destroys this Service ability if the number of times it has been started equals the number represented by the - * given {@code startId}. This method is the same as calling {@link #terminateAbility} to destroy this Service - * ability, except that this method helps you avoid destroying it if a client has requested a Service - * ability startup in {@link ohos.aafwk.ability.Ability#onCommand} but you are unaware of it. - * - * @param startId Indicates the number of startup times of this Service ability passed to - * {@link ohos.aafwk.ability.Ability#onCommand}. The {@code startId} is - * incremented by 1 every time this ability is started. For example, - * if this ability has been started for six times, the value of {@code startId} is {@code 6}. - * - * @return Returns {@code true} if the {@code startId} matches the number of startup times - * and this Service ability will be destroyed; returns {@code false} otherwise. - */ -bool ContextDeal::TerminateAbilityResult(int startId) -{ - return false; -} - -/** - * @brief Obtains the current display orientation of this ability. - * - * @return Returns the current display orientation. - */ int ContextDeal::GetDisplayOrientation() { - HILOG_DEBUG("ContextDeal::GetDisplayOrientation begin"); if (abilityInfo_ != nullptr) { - HILOG_DEBUG("ContextDeal::GetDisplayOrientation end"); + HILOG_DEBUG("GetDisplayOrientation end"); return static_cast(abilityInfo_->orientation); } else { - HILOG_ERROR("ContextDeal::GetDisplayOrientation abilityInfo_ is nullptr"); + HILOG_ERROR("GetDisplayOrientation abilityInfo_ is nullptr"); return static_cast(DisplayOrientation::UNSPECIFIED); } } -/** - * @brief Obtains the path storing the preference file of the application. - * If the preference file path does not exist, the system creates one and returns the created path. - * - * @return Returns the preference file path . - */ std::string ContextDeal::GetPreferencesDir() { - HILOG_DEBUG("ContextDeal::GetPreferencesDir begin"); std::string dir = GetBaseDir() + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_PREFERENCES; CreateDirIfNotExist(dir); - HILOG_DEBUG("ContextDeal::GetPreferencesDir:%{public}s", dir.c_str()); + HILOG_DEBUG("GetPreferencesDir:%{public}s", dir.c_str()); return dir; } -/** - * @brief Set color mode - * - * @param the value of color mode. - */ void ContextDeal::SetColorMode(int mode) { - HILOG_DEBUG("ContextDeal::SetColorMode begin"); auto hapModInfo = GetHapModuleInfo(); if (hapModInfo == nullptr) { - HILOG_ERROR("ContextDeal::SetColorMode hapModInfo is nullptr"); + HILOG_ERROR("SetColorMode hapModInfo is nullptr"); return; } @@ -1083,83 +541,40 @@ void ContextDeal::SetColorMode(int mode) } else { // default use AUTO hapModInfo->colorMode = ModuleColorMode::AUTO; } - HILOG_DEBUG("ContextDeal::SetColorMode end"); } -/** - * @brief Obtains color mode. - * - * @return Returns the color mode value. - */ int ContextDeal::GetColorMode() { - HILOG_DEBUG("ContextDeal::GetColorMode begin"); auto hapModInfo = GetHapModuleInfo(); if (hapModInfo == nullptr) { - HILOG_ERROR("ContextDeal::GetColorMode hapModInfo is nullptr"); + HILOG_ERROR("GetColorMode hapModInfo is nullptr"); return -1; } - HILOG_DEBUG("ContextDeal::GetColorMode end"); return static_cast(hapModInfo->colorMode); } -/** - * @brief Set the LifeCycleStateInfo to the deal. - * - * @param info the info to set. - */ void ContextDeal::SetLifeCycleStateInfo(const AAFwk::LifeCycleStateInfo &info) { lifeCycleStateInfo_ = info; } -/** - * @brief Obtains the unique ID of the mission containing this ability. - * - * @return Returns the unique mission ID. - */ int ContextDeal::GetMissionId() { return lifeCycleStateInfo_.missionId; } -/** - * @brief Obtains the lifecycle state info. - * - * @return Returns the lifecycle state info. - */ AAFwk::LifeCycleStateInfo ContextDeal::GetLifeCycleStateInfo() const { return lifeCycleStateInfo_; } -/** - * @brief Starts multiple abilities. - * - * @param wants Indicates the Want containing information array about the target ability to start. - */ -void ContextDeal::StartAbilities(const std::vector &wants) -{} - -/** - * @brief Set EventRunner for main thread. - * - * @param runner The EventRunner. - */ void ContextDeal::SetRunner(const std::shared_ptr &runner) { mainEventRunner_ = runner; } -/** - * @brief init HapModuleInfo data - * - * @return Returns true on success, others on failure. - */ bool ContextDeal::HapModuleInfoRequestInit() { - HILOG_DEBUG("ContextDeal::HapModuleInfoRequestInit begin"); - sptr ptr = GetBundleManager(); if (ptr == nullptr) { HILOG_ERROR("GetHapModuleInfo failed to get bundle manager service"); @@ -1176,7 +591,6 @@ bool ContextDeal::HapModuleInfoRequestInit() HILOG_ERROR("IBundleMgr::GetHapModuleInfo failed, will retval false value"); return false; } - HILOG_DEBUG("ContextDeal::HapModuleInfoRequestInit end"); return true; } @@ -1191,7 +605,7 @@ std::string ContextDeal::GetBaseDir() const baseDir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_BASE; } - HILOG_DEBUG("ContextDeal::GetBaseDir:%{public}s", baseDir.c_str()); + HILOG_DEBUG("GetBaseDir:%{public}s", baseDir.c_str()); return baseDir; } } // namespace AppExecFwk diff --git a/interfaces/kits/native/appkit/app/context.h b/interfaces/kits/native/appkit/app/context.h index 249e751519..2d09de1acf 100644 --- a/interfaces/kits/native/appkit/app/context.h +++ b/interfaces/kits/native/appkit/app/context.h @@ -197,7 +197,10 @@ public: * @return Returns the absolute path to the application-specific cache directory on the external or * shared storage device; returns null if the external or shared storage device is temporarily unavailable. */ - virtual std::string GetExternalCacheDir() = 0; + virtual std::string GetExternalCacheDir() + { + return ""; + } /** * @brief Obtains the absolute path to the directory for storing files for the application on the @@ -208,7 +211,10 @@ public: * @return Returns the absolute path to the application file directory on the external or shared storage * device; returns null if the external or shared storage device is temporarily unavailable. */ - virtual std::string GetExternalFilesDir(std::string &type) = 0; + virtual std::string GetExternalFilesDir(std::string &type) + { + return ""; + } /** * @brief Obtains the directory for storing files for the application on the device's internal storage. @@ -236,7 +242,10 @@ public: * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. */ - virtual int VerifySelfPermission(const std::string &permission) = 0; + virtual int VerifySelfPermission(const std::string &permission) + { + return 0; + } /** * @brief Obtains the bundle name of the current ability. @@ -277,7 +286,8 @@ public: * @param uid Indicates the UID of the unauth to check. * */ - virtual void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) = 0; + virtual void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) + {} /** * @brief Obtains an ability manager. @@ -324,7 +334,10 @@ public: * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. */ - virtual int VerifyPermission(const std::string &permission, int pid, int uid) = 0; + virtual int VerifyPermission(const std::string &permission, int pid, int uid) + { + return 0; + } /** * @brief Obtains the distributed file path. @@ -347,7 +360,10 @@ public: * * @return Returns the Context object of this ability. */ - virtual std::shared_ptr GetAbilityPackageContext() = 0; + virtual std::shared_ptr GetAbilityPackageContext() + { + return nullptr; + } /** * @brief Obtains the HapModuleInfo object of the application. @@ -383,7 +399,8 @@ public: * @param task The callback or promise fo js interface. */ virtual void RequestPermissionsFromUser(std::vector &permissions, std::vector &permissionsState, - PermissionRequestTask &&task) = 0; + PermissionRequestTask &&task) + {} /** * @brief Starts a new ability with special ability start setting. @@ -554,14 +571,20 @@ public: * * @return Returns true if the configuration of this ability is changing and false otherwise. */ - virtual bool IsUpdatingConfigurations() = 0; + virtual bool IsUpdatingConfigurations() + { + return false; + } /** * @brief Informs the system of the time required for drawing this Page ability. * * @return Returns the notification is successful or fail */ - virtual bool PrintDrawnCompleted() = 0; + virtual bool PrintDrawnCompleted() + { + return false; + } friend DataAbilityHelperImpl; friend OHOS::DataShare::DataShareHelper; diff --git a/interfaces/kits/native/appkit/app/context_container.h b/interfaces/kits/native/appkit/app/context_container.h index 40aa3aeb66..a56126abff 100644 --- a/interfaces/kits/native/appkit/app/context_container.h +++ b/interfaces/kits/native/appkit/app/context_container.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -32,7 +32,7 @@ public: * * @param base Indicates a Context object. */ - void AttachBaseContext(const std::shared_ptr &base); + void AttachBaseContext(const std::shared_ptr &base); /** * @brief Detach a attatched context. @@ -78,20 +78,6 @@ public: */ virtual const std::shared_ptr GetAbilityInfo() override; - /** - * @brief Checks whether the configuration of this ability is changing. - * - * @return Returns true if the configuration of this ability is changing and false otherwise. - */ - virtual bool IsUpdatingConfigurations() override; - - /** - * @brief Informs the system of the time required for drawing this Page ability. - * - * @return Returns the notification is successful or fail - */ - virtual bool PrintDrawnCompleted() override; - /** * @brief Obtains the Context object of the application. * @@ -169,26 +155,6 @@ public: */ std::string GetDir(const std::string &name, int mode) override; - /** - * @brief Obtains the absolute path to the application-specific cache directory - * on the primary external or shared storage device. - * - * @return Returns the absolute path to the application-specific cache directory on the external or - * shared storage device; returns null if the external or shared storage device is temporarily unavailable. - */ - std::string GetExternalCacheDir() override; - - /** - * @brief Obtains the absolute path to the directory for storing files for the application on the - * primary external or shared storage device. - * - * @param type Indicates the type of the file directory to return - * - * @return Returns the absolute path to the application file directory on the external or shared storage - * device; returns null if the external or shared storage device is temporarily unavailable. - */ - std::string GetExternalFilesDir(std::string &type) override; - /** * @brief Obtains the directory for storing files for the application on the device's internal storage. * @@ -205,18 +171,6 @@ public: */ std::string GetNoBackupFilesDir() override; - /** - * @brief Checks whether the current process has the given permission. - * You need to call requestPermissionsFromUser(java.lang.std::string[],int) to request a permission only - * if the current process does not have the specific permission. - * - * @param permission Indicates the permission to check. This parameter cannot be null. - * - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ - int VerifySelfPermission(const std::string &permission) override; - /** * @brief Obtains the bundle name of the current ability. * @@ -231,16 +185,6 @@ public: */ std::string GetBundleResourcePath() override; - /** - * @brief Remove permissions for all users who have access to specific permissions - * - * @param permission Indicates the permission to unauth. This parameter cannot be null. - * @param uri Indicates the URI to unauth. This parameter cannot be null. - * @param uid Indicates the UID of the unauth to check. - * - */ - void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) override; - /** * @brief Obtains an ability manager. * The ability manager provides information about running processes and memory usage of an application. @@ -259,17 +203,6 @@ public: */ std::string GetAppType() override; - /** - * @brief Query whether the application of the specified PID and UID has been granted a certain permission - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param pid Process id - * @param uid - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ - int VerifyPermission(const std::string &permission, int pid, int uid) override; - /** * @brief Obtains the distributed file path. * If the distributed file path does not exist, the system creates one and returns the created path. This method is @@ -286,13 +219,6 @@ public: */ void SetPattern(int patternId) override; - /** - * @brief Obtains the Context object of this ability. - * - * @return Returns the Context object of this ability. - */ - std::shared_ptr GetAbilityPackageContext() override; - /** * @brief Obtains the HapModuleInfo object of the application. * @@ -307,18 +233,6 @@ public: */ std::string GetProcessName() override; - /** - * @brief Requests certain permissions from the system. - * This method is called for permission request. This is an asynchronous method. When it is executed, - * the task will be called back. - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null. - * @param task The callback or promise fo js interface. - */ - void RequestPermissionsFromUser(std::vector &permissions, std::vector &permissionsState, - PermissionRequestTask &&task) override; - /** * @brief Creates a Context object for an application with the given bundle name. * @@ -448,7 +362,7 @@ public: int GetMissionId() override; private: - std::shared_ptr baseContext_; + std::shared_ptr baseContext_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/kits/native/appkit/app/context_deal.h b/interfaces/kits/native/appkit/app/context_deal.h index e832dc1755..4f03316f63 100644 --- a/interfaces/kits/native/appkit/app/context_deal.h +++ b/interfaces/kits/native/appkit/app/context_deal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -23,7 +23,7 @@ namespace OHOS { namespace AppExecFwk { -class ContextDeal : public Context, public std::enable_shared_from_this { +class ContextDeal : public std::enable_shared_from_this { public: ContextDeal() = default; explicit ContextDeal(bool isCreateBySystemApp); @@ -34,7 +34,7 @@ public: * * @return ProcessInfo */ - std::shared_ptr GetProcessInfo() const override; + std::shared_ptr GetProcessInfo() const; /** * Called when setting the ProcessInfo @@ -49,7 +49,7 @@ public: * * @return Returns the ApplicationInfo for the current application. */ - std::shared_ptr GetApplicationInfo() const override; + std::shared_ptr GetApplicationInfo() const; /** * @brief Set ApplicationInfo @@ -63,7 +63,7 @@ public: * * @return Returns the Context object of the application. */ - std::shared_ptr GetApplicationContext() const override; + std::shared_ptr GetApplicationContext() const; /** * @brief Set ApplicationContext @@ -78,7 +78,7 @@ public: * * @return Returns the path of the package file. */ - std::string GetBundleCodePath() override; + std::string GetBundleCodePath(); /** * @brief SetBundleCodePath @@ -93,7 +93,7 @@ public: * * @return Returns the AbilityInfo object for the current ability. */ - const std::shared_ptr GetAbilityInfo() override; + const std::shared_ptr GetAbilityInfo(); /** * @brief Set AbilityInfo @@ -107,7 +107,7 @@ public: * * @return Returns the Context object of the ability. */ - std::shared_ptr GetContext() override; + std::shared_ptr GetContext(); /** * @brief Set Ability context @@ -122,14 +122,14 @@ public: * * @return Returns an IBundleMgr instance. */ - sptr GetBundleManager() const override; + sptr GetBundleManager() const; /** * @brief Obtains a resource manager. * * @return Returns a ResourceManager object. */ - std::shared_ptr GetResourceManager() const override; + std::shared_ptr GetResourceManager() const; /** * @brief Set Profile instance. @@ -152,19 +152,7 @@ public: * * @return Returns true if the file is deleted successfully; returns false otherwise. */ - bool DeleteFile(const std::string &fileName) override; - - /** - * @brief Destroys another ability that uses the AbilityInfo.AbilityType.SERVICE template. - * The current ability using either the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE - * template can call this method to destroy another ability that uses the AbilityInfo.AbilityType.SERVICE - * template. The current ability itself can be destroyed by calling the terminateAbility() method. - * - * @param want Indicates the Want containing information about the ability to destroy. - * - * @return Returns true if the ability is destroyed successfully; returns false otherwise. - */ - bool StopAbility(const AAFwk::Want &want) override; + bool DeleteFile(const std::string &fileName); /** * @brief Obtains the application-specific cache directory on the device's internal storage. The system @@ -173,21 +161,7 @@ public: * * @return Returns the application-specific cache directory. */ - std::string GetCacheDir() override; - - /** - * @brief Checks whether the configuration of this ability is changing. - * - * @return Returns true if the configuration of this ability is changing and false otherwise. - */ - bool IsUpdatingConfigurations() override; - - /** - * @brief Informs the system of the time required for drawing this Page ability. - * - * @return Returns the notification is successful or fail - */ - bool PrintDrawnCompleted() override; + std::string GetCacheDir(); /** * @brief Obtains the application-specific code-cache directory on the device's internal storage. @@ -196,7 +170,7 @@ public: * * @return Returns the application-specific code-cache directory. */ - std::string GetCodeCacheDir() override; + std::string GetCodeCacheDir(); /** * @brief Obtains the local database path. @@ -204,14 +178,14 @@ public: * * @return Returns the local database file. */ - std::string GetDatabaseDir() override; + std::string GetDatabaseDir(); /** * @brief Obtains the absolute path where all private data files of this application are stored. * * @return Returns the absolute path storing all private data files of this application. */ - std::string GetDataDir() override; + std::string GetDataDir(); /** * @brief Obtains the directory for storing custom data files of the application. @@ -224,34 +198,14 @@ public: * * @return Returns a File object for the requested directory. */ - std::string GetDir(const std::string &name, int mode) override; - - /** - * @brief Obtains the absolute path to the application-specific cache directory - * on the primary external or shared storage device. - * - * @return Returns the absolute path to the application-specific cache directory on the external or - * shared storage device; returns null if the external or shared storage device is temporarily unavailable. - */ - std::string GetExternalCacheDir() override; - - /** - * @brief Obtains the absolute path to the directory for storing files for the application on the - * primary external or shared storage device. - * - * @param type Indicates the type of the file directory to return - * - * @return Returns the absolute path to the application file directory on the external or shared storage - * device; returns null if the external or shared storage device is temporarily unavailable. - */ - std::string GetExternalFilesDir(std::string &type) override; + std::string GetDir(const std::string &name, int mode); /** * @brief Obtains the directory for storing files for the application on the device's internal storage. * * @return Returns the application file directory. */ - std::string GetFilesDir() override; + std::string GetFilesDir(); /** * @brief Obtains the absolute path which app created and will be excluded from automatic backup to remote storage. @@ -260,60 +214,21 @@ public: * @return The path of the directory holding application files that will not be automatically backed up to remote * storage. */ - std::string GetNoBackupFilesDir() override; - - /** - * @brief Checks whether the current process has the given permission. - * You need to call requestPermissionsFromUser(std::vector,std::vector, int) to request - * a permission only if the current process does not have the specific permission. - * - * @param permission Indicates the permission to check. This parameter cannot be null. - * - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ - int VerifySelfPermission(const std::string &permission) override; + std::string GetNoBackupFilesDir(); /** * @brief Obtains the bundle name of the current ability. * * @return Returns the bundle name of the current ability. */ - std::string GetBundleName() const override; + std::string GetBundleName() const; /** * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. * * @return Returns the path of the HAP containing this ability. */ - std::string GetBundleResourcePath() override; - - /** - * @brief Starts a new ability. - * An ability using the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE template uses this method - * to start a specific ability. The system locates the target ability from installed abilities based on the value - * of the want parameter and then starts it. You can specify the ability to start using the want parameter. - * - * @param want Indicates the Want containing information about the target ability to start. - * - * @param requestCode Indicates the request code returned after the ability using the AbilityInfo.AbilityType.PAGE - * template is started. You can define the request code to identify the results returned by abilities. The value - * ranges from 0 to 65535. This parameter takes effect only on abilities using the AbilityInfo.AbilityType.PAGE - * template. - * - * @return errCode ERR_OK on success, others on failure. - */ - ErrCode StartAbility(const AAFwk::Want &want, int requestCode) override; - - /** - * @brief Remove permissions for all users who have access to specific permissions - * - * @param permission Indicates the permission to unauth. This parameter cannot be null. - * @param uri Indicates the URI to unauth. This parameter cannot be null. - * @param uid Indicates the UID of the unauth to check. - * - */ - void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) override; + std::string GetBundleResourcePath(); /** * @brief Obtains an ability manager. @@ -321,7 +236,7 @@ public: * * @return Returns an IAbilityManager instance. */ - sptr GetAbilityManager() override; + sptr GetAbilityManager(); /** * @brief Obtains the type of this application. @@ -331,29 +246,7 @@ public: * returns other if it is released by a third-party vendor; * returns an empty string if the query fails. */ - std::string GetAppType() override; - - /** - * @brief Destroys another ability you had previously started by calling Ability.startAbilityForResult - * (ohos.aafwk.content.Want, int, ohos.aafwk.ability.startsetting.AbilityStartSetting) with the same requestCode - * passed. - * - * @param requestCode Indicates the request code passed for starting the ability. - * - * @return errCode ERR_OK on success, others on failure. - */ - ErrCode TerminateAbility(int requestCode) override; - - /** - * @brief Query whether the application of the specified PID and UID has been granted a certain permission - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param pid Process id - * @param uid - * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; - * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. - */ - virtual int VerifyPermission(const std::string &permission, int pid, int uid) override; + std::string GetAppType(); /** * @brief Obtains the distributed file path. @@ -362,97 +255,28 @@ public: * * @return Returns the distributed file. */ - std::string GetDistributedDir() override; + std::string GetDistributedDir(); /** * @brief Sets the pattern of this Context based on the specified pattern ID. * * @param patternId Indicates the resource ID of the pattern to set. */ - void SetPattern(int patternId) override; - - /** - * @brief Obtains the Context object of this ability. - * - * @return Returns the Context object of this ability. - */ - std::shared_ptr GetAbilityPackageContext() override; + void SetPattern(int patternId); /** * @brief Obtains the HapModuleInfo object of the application. * * @return Returns the HapModuleInfo object of the application. */ - std::shared_ptr GetHapModuleInfo() override; + std::shared_ptr GetHapModuleInfo(); /** * @brief Obtains the name of the current process. * * @return Returns the current process name. */ - std::string GetProcessName() override; - - /** - * @brief Obtains the bundle name of the ability that called the current ability. - * You can use the obtained bundle name to check whether the calling ability is allowed to receive the data you will - * send. If you did not use Ability.startAbilityForResult(ohos.aafwk.content.Want, int, - * ohos.aafwk.ability.startsetting.AbilityStartSetting) to start the calling ability, null is returned. - * - * @return Returns the bundle name of the calling ability; returns null if no calling ability is available. - */ - std::string GetCallingBundle() override; - - /** - * @brief Requests certain permissions from the system. - * This method is called for permission request. This is an asynchronous method. When it is executed, - * the task will be called back. - * - * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. - * @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null. - * @param task The callback or promise fo js interface. - */ - void RequestPermissionsFromUser(std::vector &permissions, std::vector &permissionsState, - PermissionRequestTask &&task) override; - - /** - * @brief Starts a new ability with special ability start setting. - * - * @param want Indicates the Want containing information about the target ability to start. - * @param requestCode Indicates the request code returned after the ability is started. You can define the request - * code to identify the results returned by abilities. The value ranges from 0 to 65535. - * @param abilityStartSetting Indicates the special start setting used in starting ability. - * - * @return errCode ERR_OK on success, others on failure. - */ - ErrCode StartAbility(const Want &want, int requestCode, const AbilityStartSetting &abilityStartSetting) override; - - /** - * @brief Destroys the current ability. - * - * @return errCode ERR_OK on success, others on failure. - */ - ErrCode TerminateAbility() override; - - /** - * @brief Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. - * - * @param want Indicates the want containing information about the ability to connect - * - * @param conn Indicates the callback object when the target ability is connected. - * - * @return True means success and false means failure - */ - bool ConnectAbility(const Want &want, const sptr &conn) override; - - /** - * @brief Disconnects the current ability from an ability - * - * @param conn Indicates the IAbilityConnection callback object passed by connectAbility after the connection - * is set up. The IAbilityConnection object uniquely identifies a connection between two abilities. - * - * @return errCode ERR_OK on success, others on failure. - */ - ErrCode DisconnectAbility(const sptr &conn) override; + std::string GetProcessName(); /** * @brief init the ResourceManager for ContextDeal. @@ -467,7 +291,7 @@ public: * * @return Returns the caller information. */ - Uri GetCaller() override; + Uri GetCaller(); /** * @brief SerUriString @@ -481,7 +305,7 @@ public: * * @return Returns the string of this Context. */ - std::string GetString(int resId) override; + std::string GetString(int resId); /** * @brief Get the string array of this Context based on the specified resource ID. @@ -490,7 +314,7 @@ public: * * @return Returns the string array of this Context. */ - std::vector GetStringArray(int resId) override; + std::vector GetStringArray(int resId); /** * @brief Get the integer array of this Context based on the specified resource ID. @@ -499,28 +323,28 @@ public: * * @return Returns the integer array of this Context. */ - std::vector GetIntArray(int resId) override; + std::vector GetIntArray(int resId); /** * @brief Obtains the theme of this Context. * * @return theme Returns the theme of this Context. */ - std::map GetTheme() override; + std::map GetTheme(); /** * @brief Sets the theme of this Context based on the specified theme ID. * * @param themeId Indicates the resource ID of the theme to set. */ - void SetTheme(int themeId) override; + void SetTheme(int themeId); /** * @brief Obtains the pattern of this Context. * * @return getPattern in interface Context */ - std::map GetPattern() override; + std::map GetPattern(); /** * @brief Get the color of this Context based on the specified resource ID. @@ -529,38 +353,21 @@ public: * * @return Returns the color value of this Context. */ - int GetColor(int resId) override; + int GetColor(int resId); /** * @brief Obtains the theme id of this Context. * * @return int Returns the theme id of this Context. */ - int GetThemeId() override; - - /** - * @brief - * Destroys this Service ability if the number of times it has been started equals the number represented by the - * given {@code startId}. This method is the same as calling {@link #terminateAbility} to destroy this Service - * ability, except that this method helps you avoid destroying it if a client has requested a Service - * ability startup in {@link ohos.aafwk.ability.Ability#onCommand} but you are unaware of it. - * - * @param startId Indicates the number of startup times of this Service ability passed to - * {@link ohos.aafwk.ability.Ability#onCommand}. The {@code startId} is - * incremented by 1 every time this ability is started. For example, - * if this ability has been started for six times, the value of {@code startId} is {@code 6}. - * - * @return Returns {@code true} if the {@code startId} matches the number of startup times - * and this Service ability will be destroyed; returns {@code false} otherwise. - */ - bool TerminateAbilityResult(int startId) override; + int GetThemeId(); /** * @brief Obtains the current display orientation of this ability. * * @return Returns the current display orientation. */ - int GetDisplayOrientation() override; + int GetDisplayOrientation(); /** * @brief Obtains the path storing the preference file of the application. @@ -568,21 +375,21 @@ public: * * @return Returns the preference file path . */ - std::string GetPreferencesDir() override; + std::string GetPreferencesDir(); /** * @brief Set color mode * * @param the value of color mode. */ - void SetColorMode(int mode) override; + void SetColorMode(int mode); /** * @brief Obtains color mode. * * @return Returns the color mode value. */ - int GetColorMode() override; + int GetColorMode(); /** * @brief Set the LifeCycleStateInfo to the deal. @@ -596,14 +403,7 @@ public: * * @return Returns the unique mission ID. */ - int GetMissionId() override; - - /** - * @brief Starts multiple abilities. - * - * @param wants Indicates the Want containing information array about the target ability to start. - */ - void StartAbilities(const std::vector &wants) override; + int GetMissionId(); /** * @brief Set EventRunner for main thread. @@ -648,7 +448,6 @@ public: int flags_ = 0x00000000; protected: - sptr GetToken() override; bool HapModuleInfoRequestInit(); private: diff --git a/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp b/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp index 97031c3096..7e63a2b41d 100644 --- a/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp +++ b/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp @@ -93,7 +93,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) std::string abilityName(data, size); std::string moduleName(data, size); abilityContext.SetCallingContext(deviceId, bundleName, abilityName, moduleName); - std::shared_ptr base = nullptr; + std::shared_ptr base = nullptr; abilityContext.AttachBaseContext(base); std::string type(data, size); abilityContext.GetExternalFilesDir(type); diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp index 30d0ac2264..6e13aff442 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp @@ -746,18 +746,6 @@ HWTEST_F(ContextContainerTest, VerifySelfPermission_0100, Function | MediumTest EXPECT_NE(context_->VerifySelfPermission(permission), AppExecFwk::Constants::PERMISSION_NOT_GRANTED); } -/** - * @tc.number: VerifySelfPermission_0200 - * @tc.name: VerifySelfPermission - * @tc.desc: VerifySelfPermission - */ -HWTEST_F(ContextContainerTest, VerifySelfPermission_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - std::string permission = "test_permission"; - EXPECT_EQ(context_->VerifySelfPermission(permission), AppExecFwk::Constants::PERMISSION_NOT_GRANTED); -} - /** * @tc.number: UnauthUriPermission_0100 * @tc.name: UnauthUriPermission @@ -1396,17 +1384,6 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_VerifySelfPermission_ EXPECT_EQ(context_->VerifySelfPermission("permission"), AppExecFwk::Constants::PERMISSION_GRANTED); } -/** - * @tc.number: AppExecFwk_ContextContainer_VerifySelfPermission_0200 - * @tc.name: Verify Self Permission - * @tc.desc: Test Verify Self Permission When baseContext is null. - * and verify whether the return value of Verify Self Permission is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_VerifySelfPermission_0200, Function | MediumTest | Level3) -{ - EXPECT_EQ(context_->VerifySelfPermission("permission"), AppExecFwk::Constants::PERMISSION_NOT_GRANTED); -} - /** * @tc.number: AppExecFwk_ContextContainer_UnauthUriPermission_0100 * @tc.name: Unauth Uri Permission diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp index 756616eef1..0d40f0783e 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp @@ -66,20 +66,6 @@ void ContextDealTest::SetUp(void) void ContextDealTest::TearDown(void) {} -/** - * @tc.number: AppExecFwk_ContextDeal_StartAbility_0100 - * @tc.name: StartAbility - * @tc.desc: Test whether startability is called normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_StartAbility_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_StartAbility_0100 start"; - AAFwk::Want want; - int requestCode = 0; - context_->StartAbility(want, requestCode); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_StartAbility_0100 end, StartAbility is empty"; -} - /** * @tc.number: AppExecFwk_ContextDeal_GetBundleName_0100 * @tc.name: GetBundleName @@ -780,89 +766,6 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_SetPattern_0200, Function | Med context_->SetPattern(patternId); } -/** - * @tc.number: AppExecFwk_ContextDeal_GetAbilityPackageContext_0100 - * @tc.name: GetAbilityPackageContext - * @tc.desc: Verify that the GetAbilityPackageContext execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetAbilityPackageContext_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - EXPECT_TRUE(context_->GetAbilityPackageContext() == nullptr); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetCallingBundle_0100 - * @tc.name: GetCallingBundle - * @tc.desc: Verify that the GetCallingBundle execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetCallingBundle_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - EXPECT_TRUE(context_->GetCallingBundle() == std::string("")); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_RequestPermissionsFromUser_0100 - * @tc.name: RequestPermissionsFromUser - * @tc.desc: Verify that the RequestPermissionsFromUser execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_RequestPermissionsFromUser_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - std::vector permissions; - std::vector permissionsState; - auto task = [] (const std::vector &listStr, const std::vector &listInt) {}; - context_->RequestPermissionsFromUser(permissions, permissionsState, task); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_TerminateAbility_0100 - * @tc.name: TerminateAbility - * @tc.desc: Verify that the TerminateAbility execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_TerminateAbility_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - EXPECT_EQ(context_->TerminateAbility(), ERR_INVALID_VALUE); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_ConnectAbility_0100 - * @tc.name: ConnectAbility - * @tc.desc: Verify that the ConnectAbility execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_ConnectAbility_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - const sptr conn; - Want want; - EXPECT_FALSE(context_->ConnectAbility(want, conn)); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_DisconnectAbility_0100 - * @tc.name: DisconnectAbility - * @tc.desc: Verify that the DisconnectAbility execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_DisconnectAbility_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - const sptr conn; - EXPECT_EQ(context_->DisconnectAbility(conn), ERR_INVALID_VALUE); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetToken_0100 - * @tc.name: GetToken - * @tc.desc: Verify that the GetToken execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetToken_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - EXPECT_TRUE(context_->GetToken() == nullptr); -} - /** * @tc.number: AppExecFwk_ContextDeal_GetCaller_0100 * @tc.name: GetCaller @@ -977,18 +880,6 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetPattern_0100, Function | Med EXPECT_FALSE(resMap2.empty()); } -/** - * @tc.number: AppExecFwk_ContextDeal_TerminateAbilityResult_0100 - * @tc.name: TerminateAbilityResult - * @tc.desc: Verify that the TerminateAbilityResult execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_TerminateAbilityResult_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - constexpr int32_t startId = 0; - EXPECT_FALSE(context_->TerminateAbilityResult(startId)); -} - /** * @tc.number: AppExecFwk_ContextDeal_GetPreferencesDir_0100 * @tc.name: GetPreferencesDir @@ -1036,18 +927,6 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetLifeCycleStateInfo_0100, Fun context_->GetLifeCycleStateInfo(); } -/** - * @tc.number: AppExecFwk_ContextDeal_StartAbilities_0100 - * @tc.name: StartAbilities - * @tc.desc: Verify that the StartAbilities execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_StartAbilities_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - const std::vector wants; - context_->StartAbilities(wants); -} - /** * @tc.number: AppExecFwk_ContextDeal_SetRunner_0100 * @tc.name: SetRunner From e8a774cd531cb6fad17171d8f7b5a813e0ac6b3c Mon Sep 17 00:00:00 2001 From: wangzhen Date: Fri, 21 Apr 2023 14:29:12 +0800 Subject: [PATCH 02/16] failed to call disconnectdone in fa mode someway Signed-off-by: wangzhen --- .../napi/featureAbility/feature_ability.cpp | 5 ++- .../js_napi_common_ability.h | 1 + .../napi_common_ability.cpp | 34 ++++++++++++++++++- .../napi_ability_common/napi_common_ability.h | 13 +++++-- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/frameworks/js/napi/featureAbility/feature_ability.cpp b/frameworks/js/napi/featureAbility/feature_ability.cpp index a4acac3012..617b747241 100644 --- a/frameworks/js/napi/featureAbility/feature_ability.cpp +++ b/frameworks/js/napi/featureAbility/feature_ability.cpp @@ -107,7 +107,10 @@ private: void JsFeatureAbility::Finalizer(NativeEngine *engine, void *data, void *hint) { HILOG_DEBUG("JsFeatureAbility::Finalizer is called"); - std::unique_ptr(static_cast(data)); + auto pthis = std::unique_ptr(static_cast(data)); + if (pthis) { + pthis->RemoveAllCallbacksLocked(); + } } NativeValue* JsFeatureAbilityInit(NativeEngine *engine, NativeValue *exports) diff --git a/frameworks/js/napi/inner/napi_ability_common/js_napi_common_ability.h b/frameworks/js/napi/inner/napi_ability_common/js_napi_common_ability.h index 0d69767ac5..554d2d8855 100644 --- a/frameworks/js/napi/inner/napi_ability_common/js_napi_common_ability.h +++ b/frameworks/js/napi/inner/napi_ability_common/js_napi_common_ability.h @@ -127,6 +127,7 @@ public: std::string ConvertErrorCode(int32_t errCode); void AddFreeInstallObserver(NativeEngine& engine, const AAFwk::Want &want, NativeValue* callback); sptr FindConnectionLocked(const Want &want, int64_t &id); + void RemoveAllCallbacksLocked(); bool CreateConnectionAndConnectAbilityLocked( std::shared_ptr callback, const Want &want, int64_t &id); void RemoveConnectionLocked(const Want &want); diff --git a/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp b/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp index d943127787..e4c0cf9dcb 100644 --- a/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp +++ b/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp @@ -3278,6 +3278,23 @@ size_t NAPIAbilityConnection::GetCallbackSize() return callbacks_.size(); } +size_t NAPIAbilityConnection::ReomveAllCallbacks(ConnectRemoveKeyType key) +{ + size_t result = 0; + std::lock_guard guard(lock_); + for (auto it = callbacks_.begin(); it != callbacks_.end();) { + auto callback = *it; + if (callback && callback->removeKey == key) { + it = callbacks_.erase(it); + result++; + } else { + ++it; + } + } + HILOG_INFO("ReomveAllCallbacks removed size:%{public}zu, left size:%{public}zu", result, callbacks_.size()); + return result; +} + void UvWorkOnAbilityConnectDone(uv_work_t *work, int status) { HILOG_INFO("UvWorkOnAbilityConnectDone, uv_queue_work"); @@ -3983,7 +4000,7 @@ NativeValue* JsNapiCommon::JsConnectAbility( return engine.CreateUndefined(); } - auto connectionCallback = std::make_shared(env, secondParam); + auto connectionCallback = std::make_shared(env, secondParam, this); bool result = false; int32_t errorVal = static_cast(NAPI_ERR_NO_ERROR); int64_t id = 0; @@ -4154,6 +4171,21 @@ sptr JsNapiCommon::FindConnectionLocked(const Want &want, return nullptr; } +void JsNapiCommon::RemoveAllCallbacksLocked() +{ + HILOG_DEBUG("RemoveAllCallbacksLocked begin"); + std::lock_guard lock(connectionsLock_); + for (auto it = connects_.begin(); it != connects_.end();) { + auto connection = it->second; + connection->ReomveAllCallbacks(this); + if (connection->GetCallbackSize() == 0) { + it = connects_.erase(it); + } else { + ++it; + } + } +} + void JsNapiCommon::RemoveConnectionLocked(const Want &want) { std::string deviceId = want.GetElement().GetDeviceID(); diff --git a/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.h b/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.h index 70870938e9..babf74352c 100644 --- a/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.h +++ b/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.h @@ -219,8 +219,10 @@ enum { CONNECTION_STATE_CONNECTING = 1 }; +class JsNapiCommon; +using ConnectRemoveKeyType = JsNapiCommon*; struct ConnectionCallback { - ConnectionCallback(napi_env env, napi_value cbInfo) + ConnectionCallback(napi_env env, napi_value cbInfo, ConnectRemoveKeyType key) { this->env = env; napi_value jsMethod = nullptr; @@ -230,16 +232,19 @@ struct ConnectionCallback { napi_create_reference(env, jsMethod, 1, &disconnectCallbackRef); napi_get_named_property(env, cbInfo, "onFailed", &jsMethod); napi_create_reference(env, jsMethod, 1, &failedCallbackRef); + removeKey = key; } ConnectionCallback(ConnectionCallback &) = delete; ConnectionCallback(ConnectionCallback &&other) : env(other.env), connectCallbackRef(other.connectCallbackRef), - disconnectCallbackRef(other.disconnectCallbackRef), failedCallbackRef(other.failedCallbackRef) + disconnectCallbackRef(other.disconnectCallbackRef), failedCallbackRef(other.failedCallbackRef), + removeKey(other.removeKey) { other.env = nullptr; other.connectCallbackRef = nullptr; other.disconnectCallbackRef = nullptr; other.failedCallbackRef = nullptr; + other.removeKey = nullptr; } const ConnectionCallback &operator=(ConnectionCallback &) = delete; const ConnectionCallback &operator=(ConnectionCallback &&other) @@ -253,6 +258,7 @@ struct ConnectionCallback { other.connectCallbackRef = nullptr; other.disconnectCallbackRef = nullptr; other.failedCallbackRef = nullptr; + other.removeKey = nullptr; return *this; } ~ConnectionCallback() @@ -276,12 +282,14 @@ struct ConnectionCallback { } env = nullptr; } + removeKey = nullptr; } napi_env env = nullptr; napi_ref connectCallbackRef = nullptr; napi_ref disconnectCallbackRef = nullptr; napi_ref failedCallbackRef = nullptr; + ConnectRemoveKeyType removeKey = nullptr; }; class NAPIAbilityConnection : public AAFwk::AbilityConnectionStub { @@ -295,6 +303,7 @@ public: int GetConnectionState() const; void SetConnectionState(int connectionState); size_t GetCallbackSize(); + size_t ReomveAllCallbacks(ConnectRemoveKeyType key); private: std::list> callbacks_; From 1b104af59c0393a6d86b7aa00411f07ba0025f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=BA=AE?= Date: Fri, 21 Apr 2023 16:21:52 +0800 Subject: [PATCH 03/16] =?UTF-8?q?StartDebugMode=E9=80=82=E9=85=8DFA/Stage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨亮 Change-Id: I63ce312bed4b35f3cd1d86a7f117056296467adf --- interfaces/inner_api/runtime/include/js_runtime.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 72f1966c6e..3ba0421bdc 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -96,6 +96,8 @@ public: bool NotifyHotReloadPage() override; void RegisterUncaughtExceptionHandler(JsEnv::UncaughtExceptionInfo uncaughtExceptionInfo); bool LoadScript(const std::string& path, std::vector* buffer = nullptr, bool isBundle = false); + bool StartDebugMode(const std::string& bundleName, bool needBreakPoint, uint32_t instanceId, + const DebuggerPostTask& debuggerPostTask = {}); NativeEngine* GetNativeEnginePointer() const; panda::ecmascript::EcmaVM* GetEcmaVm() const; @@ -137,8 +139,6 @@ private: void PreloadAce(const Options& options); bool InitLoop(const std::shared_ptr& eventRunner); inline bool IsUseAbilityRuntime(const Options& options) const; - bool StartDebugMode(const std::string& bundleName, bool needBreakPoint, uint32_t instanceId, - const DebuggerPostTask& debuggerPostTask = {}); void FreeNativeReference(std::unique_ptr uniqueNativeRef, std::shared_ptr&& sharedNativeRef); }; From 5b26ec9b0ea56790fd37bf72b74558630a522f57 Mon Sep 17 00:00:00 2001 From: jiwei <909560957@qq.com> Date: Sat, 22 Apr 2023 16:02:56 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E9=97=AE=E9=A2=98:=201=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=8E=9F=E5=AD=90=E5=8C=96=E6=9C=8D=E5=8A=A1=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E4=B8=8D=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98=202?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E9=9A=90=E5=BC=8F=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E8=A2=AB=E6=8B=A6=E6=88=AA=E9=97=AE=E9=A2=98=203=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DstartAbilityByCall=E7=AD=89=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=A2=AB=E6=8B=A6=E6=88=AA=E9=97=AE=E9=A2=98=20Signed-off-by:?= =?UTF-8?q?=20jw909=20<909560957@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0a35e0512729ef55dd16ba1210ee8a31b13c9565 --- services/abilitymgr/include/ability_util.h | 5 +++-- services/abilitymgr/src/ability_interceptor.cpp | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/services/abilitymgr/include/ability_util.h b/services/abilitymgr/include/ability_util.h index f2ffcbea8b..4fccf8f9df 100644 --- a/services/abilitymgr/include/ability_util.h +++ b/services/abilitymgr/include/ability_util.h @@ -274,7 +274,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi return false; } -[[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t callerUid) +[[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t userId) { auto bms = GetBundleManager(); if (!bms) { @@ -285,7 +285,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi std::string targetBundleName = want.GetBundle(); AppExecFwk::ApplicationInfo targetAppInfo; bool getTargetResult = IN_PROCESS_CALL(bms->GetApplicationInfo(targetBundleName, - AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, callerUid, targetAppInfo)); + AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, targetAppInfo)); if (!getTargetResult) { HILOG_ERROR("Get targetAppInfo failed in check atomic service."); return false; @@ -295,6 +295,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi return true; } + int callerUid = IPCSkeleton::GetCallingUid(); std::string callerBundleName; ErrCode err = IN_PROCESS_CALL(bms->GetNameForUid(callerUid, callerBundleName)); if (err != ERR_OK) { diff --git a/services/abilitymgr/src/ability_interceptor.cpp b/services/abilitymgr/src/ability_interceptor.cpp index 0524291080..b8e0166564 100644 --- a/services/abilitymgr/src/ability_interceptor.cpp +++ b/services/abilitymgr/src/ability_interceptor.cpp @@ -225,8 +225,11 @@ AbilityJumpInterceptor::~AbilityJumpInterceptor() ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int32_t userId, bool isForeground) { - int callerUid = IPCSkeleton::GetCallingUid(); - bool isStartIncludeAtomicService = AbilityUtil::IsStartIncludeAtomicService(want, callerUid); + if (!isForeground) { + HILOG_INFO("This startup is not foreground, keep going."); + return ERR_OK; + } + bool isStartIncludeAtomicService = AbilityUtil::IsStartIncludeAtomicService(want, userId); if (isStartIncludeAtomicService) { HILOG_INFO("This startup contain atomic service, keep going."); return ERR_OK; @@ -272,6 +275,10 @@ bool AbilityJumpInterceptor::CheckControl(sptr &bms, con HILOG_ERROR("GetBundleNameForUid from bms fail."); return false; } + if (controlRule.callerPkg.empty() || controlRule.targetPkg.empty()) { + HILOG_INFO("This startup is not explicitly, keep going."); + return false; + } if (controlRule.callerPkg == controlRule.targetPkg) { HILOG_INFO("jump within the same app."); return false; From 059a44895dc3824898dc7b74a6760718d08c71b7 Mon Sep 17 00:00:00 2001 From: jiwei <909560957@qq.com> Date: Sat, 22 Apr 2023 16:48:06 +0800 Subject: [PATCH 05/16] =?UTF-8?q?ets=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E9=80=82=E9=85=8D=20=20=20=20=20Signed-off-b?= =?UTF-8?q?y:=20jw909=20<909560957@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I071b89d54f08ce1a979ee805d902b4401a3f8737 --- .../entry/src/main/ets/pages/jumpInterceptorDialog.ets | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/jumpInterceptorDialog.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/jumpInterceptorDialog.ets index 0f2f433fe4..616c97d677 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/jumpInterceptorDialog.ets +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/jumpInterceptorDialog.ets @@ -13,11 +13,15 @@ * limitations under the License. */ +interface TipBtn { + color:string +} + @Entry @Component struct JumpInterceptorDialog { @State private deviceType: string = "phone"; - @State private btn: any = { color: "#FFFFFF" } + @State private btn: TipBtn = { color: "#FFFFFF" } private TAG = "JumpInterceptorDialog_Page" aboutToAppear() { From 1d8aa5d97984581199350e061d40114408d35dfd Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Sun, 23 Apr 2023 10:41:54 +0800 Subject: [PATCH 06/16] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- frameworks/native/runtime/js_source_map_operator.h | 2 +- js_environment/frameworks/js_environment/src/source_map.cpp | 1 - services/abilitymgr/src/ability_manager_service.cpp | 4 ++++ services/abilitymgr/src/implicit_start_processor.cpp | 4 ++-- services/abilitymgr/src/mission_list_manager.cpp | 4 ++++ services/appmgr/src/app_mgr_service_inner.cpp | 4 ++-- services/appmgr/src/app_running_manager.cpp | 4 ++++ .../uripermissionmanager_fuzzer.cpp | 3 +-- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/frameworks/native/runtime/js_source_map_operator.h b/frameworks/native/runtime/js_source_map_operator.h index 5a00c74a43..7cb29a1730 100644 --- a/frameworks/native/runtime/js_source_map_operator.h +++ b/frameworks/native/runtime/js_source_map_operator.h @@ -32,7 +32,7 @@ public: std::string TranslateBySourceMap(const std::string& stackStr) override; private: - std::string hapPath_; + const std::string hapPath_; bool isModular_ = false; std::shared_ptr bindSourceMaps_ = nullptr; }; diff --git a/js_environment/frameworks/js_environment/src/source_map.cpp b/js_environment/frameworks/js_environment/src/source_map.cpp index d60ca98a24..3c8ecc9a43 100644 --- a/js_environment/frameworks/js_environment/src/source_map.cpp +++ b/js_environment/frameworks/js_environment/src/source_map.cpp @@ -166,7 +166,6 @@ void SourceMap::SplitSourceMap(const std::string& sourceMapData) size_t rightBracket = 0; std::string value; while ((leftBracket = sourceMapData.find(": {", rightBracket)) != std::string::npos) { - std::string left = sourceMapData.substr(leftBracket); rightBracket = sourceMapData.find("},", leftBracket); uint32_t subLeftBracket = leftBracket; uint32_t subRightBracket = rightBracket; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index fff4873e79..a4361e2bf5 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -4732,6 +4732,10 @@ void AbilityManagerService::ScheduleRecoverAbility(const sptr& to return; } else { auto bms = GetBundleManager(); + if (bms == nullptr) { + HILOG_ERROR("bms is nullptr"); + return; + } AppExecFwk::BundleInfo bundleInfo; auto bundleName = want->GetElement().GetBundleName(); int32_t userId = GetUserId(); diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index 0333fa0480..4230d1d4bf 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -107,8 +107,8 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_ return ret; } if (dialogAllAppInfos.size() == 0) { - Want want = sysDialogScheduler->GetTipsDialogWant(request.callerToken); - abilityMgr->StartAbility(want); + Want dialogWant = sysDialogScheduler->GetTipsDialogWant(request.callerToken); + abilityMgr->StartAbility(dialogWant); return ERR_IMPLICIT_START_ABILITY_FAIL; } want = sysDialogScheduler->GetPcSelectorDialogWant(dialogAllAppInfos, request.want, diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 729ee14faf..dbd37726c9 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -529,6 +529,10 @@ void MissionListManager::GetTargetMissionAndAbility(const AbilityRequest &abilit } HILOG_DEBUG("Make new mission data."); targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (targetRecord == nullptr) { + HILOG_ERROR("targetRecord is nullptr"); + return; + } targetMission = std::make_shared(info.missionInfo.id, targetRecord, info.missionName, info.startMethod); targetRecord->UpdateRecoveryInfo(info.hasRecoverInfo); diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 9c2c624c8c..76bfccb4c9 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1662,8 +1662,8 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str std::vector overlayModuleInfo; HILOG_DEBUG("Check overlay app begin."); HITRACE_METER_NAME(HITRACE_TAG_APP, "BMS->GetOverlayModuleInfoForTarget"); - auto ret = IN_PROCESS_CALL(overlayMgrProxy->GetOverlayModuleInfoForTarget(bundleName, "", overlayModuleInfo, userId)); - if (ret == ERR_OK && overlayModuleInfo.size() != 0) { + auto targetRet = IN_PROCESS_CALL(overlayMgrProxy->GetOverlayModuleInfoForTarget(bundleName, "", overlayModuleInfo, userId)); + if (targetRet == ERR_OK && overlayModuleInfo.size() != 0) { HILOG_DEBUG("Start an overlay app process."); startMsg.flags = startMsg.flags | OVERLAY_FLAG; } diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 610a137806..d53d3bbe4a 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -779,6 +779,10 @@ bool AppRunningManager::IsApplicationBackground(const std::string &bundleName) std::lock_guard guard(lock_); for (const auto &item : appRunningRecordMap_) { const auto &appRecord = item.second; + if (appRecord == nullptr) { + HILOG_ERROR("appRecord is nullptr"); + return false; + } auto state = appRecord->GetState(); if (appRecord && appRecord->GetBundleName() == bundleName && state == ApplicationState::APP_STATE_FOREGROUND) { diff --git a/test/fuzztest/uripermissionmanager_fuzzer/uripermissionmanager_fuzzer.cpp b/test/fuzztest/uripermissionmanager_fuzzer/uripermissionmanager_fuzzer.cpp index aa08456598..e24324698e 100644 --- a/test/fuzztest/uripermissionmanager_fuzzer/uripermissionmanager_fuzzer.cpp +++ b/test/fuzztest/uripermissionmanager_fuzzer/uripermissionmanager_fuzzer.cpp @@ -37,8 +37,7 @@ public: UriPermissionManagerStubFuzzTest() = default; virtual ~UriPermissionManagerStubFuzzTest() {} - int GrantUriPermission(const Uri &uri, unsigned int flag, - std::string targetBundleName, + int GrantUriPermission(const Uri &uri, unsigned int flag, const std::string targetBundleName, int autoremove) override { return 0; From 6c55d0e7cada6c0fdf320cb8cbc85457e375077b Mon Sep 17 00:00:00 2001 From: jiwei <909560957@qq.com> Date: Sun, 23 Apr 2023 14:25:37 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E4=BB=85=E5=A4=84=E7=90=86=E5=88=B0pageAbility=E7=9A=84?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=20Signed-off-by:=20jw909=20<909560957@qq.com?= =?UTF-8?q?>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I9b29d189feb93649aa5d007c6d4aca21751401e0 --- services/abilitymgr/src/ability_interceptor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/abilitymgr/src/ability_interceptor.cpp b/services/abilitymgr/src/ability_interceptor.cpp index b8e0166564..8fd1ec63fb 100644 --- a/services/abilitymgr/src/ability_interceptor.cpp +++ b/services/abilitymgr/src/ability_interceptor.cpp @@ -17,6 +17,7 @@ #include +#include "ability_info.h" #include "ability_manager_errors.h" #include "accesstoken_kit.h" #include "app_jump_control_rule.h" @@ -240,6 +241,13 @@ ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int HILOG_ERROR("GetBundleManager failed"); return ERR_OK; } + AppExecFwk::AbilityInfo targetAbilityInfo; + IN_PROCESS_CALL_WITHOUT_RET(bms->QueryAbilityInfo(want, + AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, targetAbilityInfo)); + if (targetAbilityInfo.type != AppExecFwk::AbilityType::PAGE) { + HILOG_INFO("Target is not page Ability, keep going, abilityType:%{public}d", targetAbilityInfo.type); + return ERR_OK; + } AppExecFwk::AppJumpControlRule controlRule; if (CheckControl(bms, want, userId, controlRule)) { #ifdef SUPPORT_GRAPHICS From 29f1d37d190b8155fd8260208381d973d26b4221 Mon Sep 17 00:00:00 2001 From: Lotol Date: Thu, 20 Apr 2023 10:47:07 +0000 Subject: [PATCH 08/16] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E5=8C=96=E6=95=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=9A=E5=88=A0=E9=99=A4=E4=BE=9D=E8=B5=96=E7=9A=84?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?cesfwk=5Finnerkits=E7=9A=84=E5=A4=96=E9=83=A8=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lotol Change-Id: Ibb2fa9dfd7d1f90c283ed05522ecb711a65f90e3 --- .../abilityconnectmanager_fuzzer/BUILD.gn | 1 + .../abilityeventhandler_fuzzer/BUILD.gn | 1 + .../abilitytransitiondone_fuzzer/BUILD.gn | 1 + .../attachabilitythread_fuzzer/BUILD.gn | 1 + test/fuzztest/blockability_fuzzer/BUILD.gn | 1 + test/fuzztest/blockamsservice_fuzzer/BUILD.gn | 1 + test/fuzztest/blockappservice_fuzzer/BUILD.gn | 1 + test/fuzztest/closeability_fuzzer/BUILD.gn | 1 + .../completefirstframedrawing_fuzzer/BUILD.gn | 1 + test/fuzztest/connectability_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../doabilitybackground_fuzzer/BUILD.gn | 1 + .../doabilityforeground_fuzzer/BUILD.gn | 1 + .../dumpabilityinfodone_fuzzer/BUILD.gn | 1 + test/fuzztest/dumpstate_fuzzer/BUILD.gn | 1 + test/fuzztest/dumpsysstate_fuzzer/BUILD.gn | 1 + .../forcetimeoutfortest_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../getmissionidbytoken_fuzzer/BUILD.gn | 1 + .../getmissionsnapshot_fuzzer/BUILD.gn | 1 + test/fuzztest/gettopability_fuzzer/BUILD.gn | 1 + test/fuzztest/handledlpapp_fuzzer/BUILD.gn | 1 + test/fuzztest/minimizeability_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../releasedataability_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../sendresulttoability_fuzzer/BUILD.gn | 1 + .../setabilitycontroller_fuzzer/BUILD.gn | 1 + test/fuzztest/startability_fuzzer/BUILD.gn | 1 + .../startabilitybycall_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../terminateabilityresult_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../updatemissionsnapshot_fuzzer/BUILD.gn | 1 + .../ability_caller_fw_module_test/BUILD.gn | 1 + .../ability_delegator_test/BUILD.gn | 3 ++ test/moduletest/ability_test/BUILD.gn | 2 ++ .../BUILD.gn | 1 + .../BUILD.gn | 2 ++ .../ability_connect_manager_test/BUILD.gn | 1 + .../ability_extension_base_test/BUILD.gn | 1 + .../ability_extension_context_test/BUILD.gn | 1 + test/unittest/ability_extension_test/BUILD.gn | 1 + .../BUILD.gn | 1 + .../ability_manager_proxy_test/BUILD.gn | 1 + .../BUILD.gn | 1 + .../ability_manager_stub_test/BUILD.gn | 1 + .../ability_scheduler_proxy_test/BUILD.gn | 1 + .../ability_scheduler_stub_test/BUILD.gn | 1 + .../ability_service_extension_test/BUILD.gn | 1 + .../ability_token_proxy_test/BUILD.gn | 1 + .../unittest/ability_token_stub_test/BUILD.gn | 1 + test/unittest/app_recovery_test/BUILD.gn | 2 ++ .../application_context_test/BUILD.gn | 1 + test/unittest/connection_record_test/BUILD.gn | 1 + .../continuation_connector_test/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../data_ability_record_test/BUILD.gn | 1 + test/unittest/dlp_state_item_test/BUILD.gn | 1 + .../form_extension_context_test/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 29 +++++++++++++++++++ .../BUILD.gn | 4 +++ .../ability_delegator/BUILD.gn | 3 ++ test/unittest/image_info_test/BUILD.gn | 1 + test/unittest/mission_info_test/BUILD.gn | 1 + .../mission_list_manager_ut_test/BUILD.gn | 1 + test/unittest/mission_list_test/BUILD.gn | 1 + test/unittest/mission_test/BUILD.gn | 1 + test/unittest/pending_want_key_test/BUILD.gn | 1 + test/unittest/sender_info_test/BUILD.gn | 1 + .../service_extension_context_test/BUILD.gn | 1 + .../specified_mission_list_test/BUILD.gn | 1 + .../static_subscriber_proxy_test/BUILD.gn | 1 + .../static_subscriber_stub_imp_test/BUILD.gn | 1 + .../stop_user_callback_stub_test/BUILD.gn | 1 + .../want_receiver_proxy_test/BUILD.gn | 1 + .../unittest/want_receiver_stub_test/BUILD.gn | 1 + test/unittest/want_sender_info_test/BUILD.gn | 1 + test/unittest/want_sender_proxy_test/BUILD.gn | 1 + test/unittest/want_sender_stub_test/BUILD.gn | 1 + test/unittest/wants_info_test/BUILD.gn | 1 + 89 files changed, 127 insertions(+) diff --git a/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn b/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn index 01a178ac48..d68044afb7 100755 --- a/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("AbilityConnectManagerFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn b/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn index f7b94cb72f..545de032d6 100755 --- a/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn @@ -55,6 +55,7 @@ ohos_fuzztest("AbilityEventHandlerFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/abilitytransitiondone_fuzzer/BUILD.gn b/test/fuzztest/abilitytransitiondone_fuzzer/BUILD.gn index cf8af8fb98..7d22451956 100644 --- a/test/fuzztest/abilitytransitiondone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitytransitiondone_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("AbilityTransitionDoneFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/attachabilitythread_fuzzer/BUILD.gn b/test/fuzztest/attachabilitythread_fuzzer/BUILD.gn index 6acae07536..e44a44ddbf 100644 --- a/test/fuzztest/attachabilitythread_fuzzer/BUILD.gn +++ b/test/fuzztest/attachabilitythread_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("AttachAbilityThreadFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/blockability_fuzzer/BUILD.gn b/test/fuzztest/blockability_fuzzer/BUILD.gn index 81a7417d03..7bcd95b765 100644 --- a/test/fuzztest/blockability_fuzzer/BUILD.gn +++ b/test/fuzztest/blockability_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("BlockAbilityFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/blockamsservice_fuzzer/BUILD.gn b/test/fuzztest/blockamsservice_fuzzer/BUILD.gn index d7850142f0..45e2bdb019 100644 --- a/test/fuzztest/blockamsservice_fuzzer/BUILD.gn +++ b/test/fuzztest/blockamsservice_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("BlockAmsServiceFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/blockappservice_fuzzer/BUILD.gn b/test/fuzztest/blockappservice_fuzzer/BUILD.gn index bc8737b742..0cde63318f 100644 --- a/test/fuzztest/blockappservice_fuzzer/BUILD.gn +++ b/test/fuzztest/blockappservice_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("BlockAppServiceFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/closeability_fuzzer/BUILD.gn b/test/fuzztest/closeability_fuzzer/BUILD.gn index 70f97475f2..ef59fe7e2c 100644 --- a/test/fuzztest/closeability_fuzzer/BUILD.gn +++ b/test/fuzztest/closeability_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("CloseAbilityFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/completefirstframedrawing_fuzzer/BUILD.gn b/test/fuzztest/completefirstframedrawing_fuzzer/BUILD.gn index 8ee2fcbf32..ab6f613ed0 100644 --- a/test/fuzztest/completefirstframedrawing_fuzzer/BUILD.gn +++ b/test/fuzztest/completefirstframedrawing_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("CompleteFirstFrameDrawingFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/connectability_fuzzer/BUILD.gn b/test/fuzztest/connectability_fuzzer/BUILD.gn index cd67dcdb42..012a8e7bb8 100755 --- a/test/fuzztest/connectability_fuzzer/BUILD.gn +++ b/test/fuzztest/connectability_fuzzer/BUILD.gn @@ -57,6 +57,7 @@ ohos_fuzztest("ConnectAbilityFuzzTest") { "ability_runtime:ability_manager", "appspawn:appspawn_socket_client", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/delegatordoabilitybackground_fuzzer/BUILD.gn b/test/fuzztest/delegatordoabilitybackground_fuzzer/BUILD.gn index 3337414e19..b322a20b87 100644 --- a/test/fuzztest/delegatordoabilitybackground_fuzzer/BUILD.gn +++ b/test/fuzztest/delegatordoabilitybackground_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("DelegatorDoAbilityBackgroundFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/delegatordoabilityforeground_fuzzer/BUILD.gn b/test/fuzztest/delegatordoabilityforeground_fuzzer/BUILD.gn index 77e9ef9b41..45290f373c 100644 --- a/test/fuzztest/delegatordoabilityforeground_fuzzer/BUILD.gn +++ b/test/fuzztest/delegatordoabilityforeground_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("DelegatorDoAbilityForegroundFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/doabilitybackground_fuzzer/BUILD.gn b/test/fuzztest/doabilitybackground_fuzzer/BUILD.gn index bb5a5d94ae..b971e5e2d0 100644 --- a/test/fuzztest/doabilitybackground_fuzzer/BUILD.gn +++ b/test/fuzztest/doabilitybackground_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("DoAbilityBackgroundFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/doabilityforeground_fuzzer/BUILD.gn b/test/fuzztest/doabilityforeground_fuzzer/BUILD.gn index eb93949c14..b12ef07a99 100644 --- a/test/fuzztest/doabilityforeground_fuzzer/BUILD.gn +++ b/test/fuzztest/doabilityforeground_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("DoAbilityForegroundFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/dumpabilityinfodone_fuzzer/BUILD.gn b/test/fuzztest/dumpabilityinfodone_fuzzer/BUILD.gn index 29fbab149d..c8015a3199 100644 --- a/test/fuzztest/dumpabilityinfodone_fuzzer/BUILD.gn +++ b/test/fuzztest/dumpabilityinfodone_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("DumpAbilityInfoDoneFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/dumpstate_fuzzer/BUILD.gn b/test/fuzztest/dumpstate_fuzzer/BUILD.gn index 11368f75b2..afa58cd794 100644 --- a/test/fuzztest/dumpstate_fuzzer/BUILD.gn +++ b/test/fuzztest/dumpstate_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("DumpStateFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/dumpsysstate_fuzzer/BUILD.gn b/test/fuzztest/dumpsysstate_fuzzer/BUILD.gn index e4e239beeb..b6218882da 100644 --- a/test/fuzztest/dumpsysstate_fuzzer/BUILD.gn +++ b/test/fuzztest/dumpsysstate_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("DumpSysStateFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/forcetimeoutfortest_fuzzer/BUILD.gn b/test/fuzztest/forcetimeoutfortest_fuzzer/BUILD.gn index 4a2b008b29..31c0984738 100644 --- a/test/fuzztest/forcetimeoutfortest_fuzzer/BUILD.gn +++ b/test/fuzztest/forcetimeoutfortest_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("ForceTimeoutForTestFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/freeinstallabilityfromremote_fuzzer/BUILD.gn b/test/fuzztest/freeinstallabilityfromremote_fuzzer/BUILD.gn index aac4ce0618..6c1dfdb251 100644 --- a/test/fuzztest/freeinstallabilityfromremote_fuzzer/BUILD.gn +++ b/test/fuzztest/freeinstallabilityfromremote_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("FreeInstallAbilityFromRemoteFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/getmissionidbytoken_fuzzer/BUILD.gn b/test/fuzztest/getmissionidbytoken_fuzzer/BUILD.gn index dc7373ca50..17847caa30 100644 --- a/test/fuzztest/getmissionidbytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/getmissionidbytoken_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("GetMissionIdByTokenFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/getmissionsnapshot_fuzzer/BUILD.gn b/test/fuzztest/getmissionsnapshot_fuzzer/BUILD.gn index d1ad35121b..8f6745baa3 100644 --- a/test/fuzztest/getmissionsnapshot_fuzzer/BUILD.gn +++ b/test/fuzztest/getmissionsnapshot_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("GetMissionSnapshotFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/gettopability_fuzzer/BUILD.gn b/test/fuzztest/gettopability_fuzzer/BUILD.gn index a3936837d1..c20e8fa21a 100755 --- a/test/fuzztest/gettopability_fuzzer/BUILD.gn +++ b/test/fuzztest/gettopability_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("GetTopAbilityFuzzTest") { "ability_base:zuri", "appspawn:appspawn_socket_client", "bundle_framework:appexecfwk_base", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "relational_store:native_dataability", ] diff --git a/test/fuzztest/handledlpapp_fuzzer/BUILD.gn b/test/fuzztest/handledlpapp_fuzzer/BUILD.gn index 0f4493aaa8..5dae380e56 100644 --- a/test/fuzztest/handledlpapp_fuzzer/BUILD.gn +++ b/test/fuzztest/handledlpapp_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("HandleDlpAppFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/minimizeability_fuzzer/BUILD.gn b/test/fuzztest/minimizeability_fuzzer/BUILD.gn index 0126754e6d..abf0b55106 100644 --- a/test/fuzztest/minimizeability_fuzzer/BUILD.gn +++ b/test/fuzztest/minimizeability_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("MinimizeAbilityFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/registerabilitylifecyclecallback_fuzzer/BUILD.gn b/test/fuzztest/registerabilitylifecyclecallback_fuzzer/BUILD.gn index 17c3556020..653d6a1e5c 100644 --- a/test/fuzztest/registerabilitylifecyclecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/registerabilitylifecyclecallback_fuzzer/BUILD.gn @@ -42,6 +42,7 @@ ohos_fuzztest("RegisterAbilityLifecycleCallbackFuzzTest") { external_deps = [ "ability_base:want", "c_utils:utils", + "common_event_service:cesfwk_innerkits", ] } diff --git a/test/fuzztest/registerenvironmentcallback_fuzzer/BUILD.gn b/test/fuzztest/registerenvironmentcallback_fuzzer/BUILD.gn index 71a14e0cdd..87224c7d4f 100644 --- a/test/fuzztest/registerenvironmentcallback_fuzzer/BUILD.gn +++ b/test/fuzztest/registerenvironmentcallback_fuzzer/BUILD.gn @@ -43,6 +43,7 @@ ohos_fuzztest("RegisterEnvironmentCallbackFuzzTest") { external_deps = [ "ability_base:want", "c_utils:utils", + "common_event_service:cesfwk_innerkits", ] } diff --git a/test/fuzztest/releasedataability_fuzzer/BUILD.gn b/test/fuzztest/releasedataability_fuzzer/BUILD.gn index 7efa184631..4c7eed3c6f 100644 --- a/test/fuzztest/releasedataability_fuzzer/BUILD.gn +++ b/test/fuzztest/releasedataability_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("ReleaseDataAbilityFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/schedulecommandabilitydone_fuzzer/BUILD.gn b/test/fuzztest/schedulecommandabilitydone_fuzzer/BUILD.gn index 93d3950886..1a8cb87c5f 100644 --- a/test/fuzztest/schedulecommandabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/schedulecommandabilitydone_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("ScheduleCommandAbilityDoneFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/scheduleconnectabilitydone_fuzzer/BUILD.gn b/test/fuzztest/scheduleconnectabilitydone_fuzzer/BUILD.gn index dec39bc32d..d79e1608af 100644 --- a/test/fuzztest/scheduleconnectabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/scheduleconnectabilitydone_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("ScheduleConnectAbilityDoneFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/scheduledisconnectabilitydone_fuzzer/BUILD.gn b/test/fuzztest/scheduledisconnectabilitydone_fuzzer/BUILD.gn index 1973c08dee..01db102a6e 100644 --- a/test/fuzztest/scheduledisconnectabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/scheduledisconnectabilitydone_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("ScheduleDisconnectAbilityDoneFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/sendresulttoability_fuzzer/BUILD.gn b/test/fuzztest/sendresulttoability_fuzzer/BUILD.gn index 2667a60495..130423b534 100644 --- a/test/fuzztest/sendresulttoability_fuzzer/BUILD.gn +++ b/test/fuzztest/sendresulttoability_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("SendResultToAbilityFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/setabilitycontroller_fuzzer/BUILD.gn b/test/fuzztest/setabilitycontroller_fuzzer/BUILD.gn index a1ab642098..f65c7e1f3b 100644 --- a/test/fuzztest/setabilitycontroller_fuzzer/BUILD.gn +++ b/test/fuzztest/setabilitycontroller_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("SetAbilityControllerFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/startability_fuzzer/BUILD.gn b/test/fuzztest/startability_fuzzer/BUILD.gn index 2075c8686c..942e85a89f 100644 --- a/test/fuzztest/startability_fuzzer/BUILD.gn +++ b/test/fuzztest/startability_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("StartAbilityFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", ] } diff --git a/test/fuzztest/startabilitybycall_fuzzer/BUILD.gn b/test/fuzztest/startabilitybycall_fuzzer/BUILD.gn index c17c12e908..976189994b 100644 --- a/test/fuzztest/startabilitybycall_fuzzer/BUILD.gn +++ b/test/fuzztest/startabilitybycall_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("StartAbilityByCallFuzzTest") { "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/fuzztest/startserviceextensionability_fuzzer/BUILD.gn b/test/fuzztest/startserviceextensionability_fuzzer/BUILD.gn index a58c7361a6..f81ee5298f 100755 --- a/test/fuzztest/startserviceextensionability_fuzzer/BUILD.gn +++ b/test/fuzztest/startserviceextensionability_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("StartServiceExtensionAbilityFuzzTest") { "ability_runtime:ability_manager", "appspawn:appspawn_socket_client", "bundle_framework:appexecfwk_base", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/stopserviceextensionability_fuzzer/BUILD.gn b/test/fuzztest/stopserviceextensionability_fuzzer/BUILD.gn index 0965b6455d..9e52c1b829 100755 --- a/test/fuzztest/stopserviceextensionability_fuzzer/BUILD.gn +++ b/test/fuzztest/stopserviceextensionability_fuzzer/BUILD.gn @@ -52,6 +52,7 @@ ohos_fuzztest("StopServiceExtensionAbilityFuzzTest") { "ability_runtime:ability_manager", "appspawn:appspawn_socket_client", "bundle_framework:appexecfwk_base", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/terminateabilityresult_fuzzer/BUILD.gn b/test/fuzztest/terminateabilityresult_fuzzer/BUILD.gn index 15f85b234b..81eee679cf 100644 --- a/test/fuzztest/terminateabilityresult_fuzzer/BUILD.gn +++ b/test/fuzztest/terminateabilityresult_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("TerminateAbilityResultFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/test/fuzztest/unregisterabilitylifecyclecallback_fuzzer/BUILD.gn b/test/fuzztest/unregisterabilitylifecyclecallback_fuzzer/BUILD.gn index 3b224853ae..704c74c693 100644 --- a/test/fuzztest/unregisterabilitylifecyclecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/unregisterabilitylifecyclecallback_fuzzer/BUILD.gn @@ -42,6 +42,7 @@ ohos_fuzztest("UnregisterAbilityLifecycleCallbackFuzzTest") { external_deps = [ "ability_base:want", "c_utils:utils", + "common_event_service:cesfwk_innerkits", ] } diff --git a/test/fuzztest/unregisterenvironmentcallback_fuzzer/BUILD.gn b/test/fuzztest/unregisterenvironmentcallback_fuzzer/BUILD.gn index c9384737fc..45697ea3fe 100644 --- a/test/fuzztest/unregisterenvironmentcallback_fuzzer/BUILD.gn +++ b/test/fuzztest/unregisterenvironmentcallback_fuzzer/BUILD.gn @@ -42,6 +42,7 @@ ohos_fuzztest("UnregisterEnvironmentCallbackFuzzTest") { external_deps = [ "ability_base:want", "c_utils:utils", + "common_event_service:cesfwk_innerkits", ] } diff --git a/test/fuzztest/updatemissionsnapshot_fuzzer/BUILD.gn b/test/fuzztest/updatemissionsnapshot_fuzzer/BUILD.gn index a26331d4c2..becbf4e789 100644 --- a/test/fuzztest/updatemissionsnapshot_fuzzer/BUILD.gn +++ b/test/fuzztest/updatemissionsnapshot_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("UpdateMissionSnapShotFuzzTest") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ipc:ipc_core", "relational_store:native_dataability", diff --git a/test/moduletest/ability_caller_fw_module_test/BUILD.gn b/test/moduletest/ability_caller_fw_module_test/BUILD.gn index 5ece4067a0..fdb3371640 100644 --- a/test/moduletest/ability_caller_fw_module_test/BUILD.gn +++ b/test/moduletest/ability_caller_fw_module_test/BUILD.gn @@ -49,6 +49,7 @@ ohos_moduletest("ability_caller_fw_module_test") { "ability_base:session_info", "ability_base:want", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/moduletest/ability_delegator_test/BUILD.gn b/test/moduletest/ability_delegator_test/BUILD.gn index 0c99e687b7..b6c9a07955 100644 --- a/test/moduletest/ability_delegator_test/BUILD.gn +++ b/test/moduletest/ability_delegator_test/BUILD.gn @@ -132,6 +132,7 @@ ohos_moduletest("ability_delegator_registry_moduletest") { "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] @@ -186,6 +187,7 @@ ohos_moduletest("ability_delegator_moduletest") { "ability_base:want", "ability_runtime:ability_manager", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -219,6 +221,7 @@ ohos_moduletest("js_test_runner_moduletest") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ets_runtime:libark_jsruntime", "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", diff --git a/test/moduletest/ability_test/BUILD.gn b/test/moduletest/ability_test/BUILD.gn index d529a4abb7..7f15ea4ab4 100644 --- a/test/moduletest/ability_test/BUILD.gn +++ b/test/moduletest/ability_test/BUILD.gn @@ -165,6 +165,7 @@ ohos_moduletest("ability_thread_call_request_module_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", ] @@ -256,6 +257,7 @@ ohos_moduletest("data_ability_helper_module_test") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/ability_connect_callback_proxy_test/BUILD.gn b/test/unittest/ability_connect_callback_proxy_test/BUILD.gn index 8aff264783..9a61c9c9cc 100644 --- a/test/unittest/ability_connect_callback_proxy_test/BUILD.gn +++ b/test/unittest/ability_connect_callback_proxy_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ability_connect_callback_proxy_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_connect_callback_stub_test/BUILD.gn b/test/unittest/ability_connect_callback_stub_test/BUILD.gn index 7e78941273..8eaadc2252 100644 --- a/test/unittest/ability_connect_callback_stub_test/BUILD.gn +++ b/test/unittest/ability_connect_callback_stub_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ability_connect_callback_stub_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", @@ -106,6 +107,7 @@ ohos_unittest("ability_connect_callback_recipient_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_connect_manager_test/BUILD.gn b/test/unittest/ability_connect_manager_test/BUILD.gn index 10ffc29141..023fdc0489 100644 --- a/test/unittest/ability_connect_manager_test/BUILD.gn +++ b/test/unittest/ability_connect_manager_test/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("ability_connect_manager_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_extension_base_test/BUILD.gn b/test/unittest/ability_extension_base_test/BUILD.gn index 1fd9222001..488a3233be 100644 --- a/test/unittest/ability_extension_base_test/BUILD.gn +++ b/test/unittest/ability_extension_base_test/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("ability_extension_base_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/ability_extension_context_test/BUILD.gn b/test/unittest/ability_extension_context_test/BUILD.gn index 7118581560..856832f1cb 100644 --- a/test/unittest/ability_extension_context_test/BUILD.gn +++ b/test/unittest/ability_extension_context_test/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("ability_extension_context_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/ability_extension_test/BUILD.gn b/test/unittest/ability_extension_test/BUILD.gn index 2d8e839957..e61db269a4 100644 --- a/test/unittest/ability_extension_test/BUILD.gn +++ b/test/unittest/ability_extension_test/BUILD.gn @@ -45,6 +45,7 @@ ohos_unittest("ability_extension_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/ability_manager_client_branch_test/BUILD.gn b/test/unittest/ability_manager_client_branch_test/BUILD.gn index f28ea7ced5..d8f87f6ba8 100644 --- a/test/unittest/ability_manager_client_branch_test/BUILD.gn +++ b/test/unittest/ability_manager_client_branch_test/BUILD.gn @@ -60,6 +60,7 @@ ohos_unittest("ability_manager_client_branch_test") { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hitrace_native:hitrace_meter", diff --git a/test/unittest/ability_manager_proxy_test/BUILD.gn b/test/unittest/ability_manager_proxy_test/BUILD.gn index 4690d55b36..c065aab5ac 100644 --- a/test/unittest/ability_manager_proxy_test/BUILD.gn +++ b/test/unittest/ability_manager_proxy_test/BUILD.gn @@ -57,6 +57,7 @@ ohos_unittest("ability_manager_proxy_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_manager_service_dialog_test/BUILD.gn b/test/unittest/ability_manager_service_dialog_test/BUILD.gn index 90aa40a92c..e353f5c595 100644 --- a/test/unittest/ability_manager_service_dialog_test/BUILD.gn +++ b/test/unittest/ability_manager_service_dialog_test/BUILD.gn @@ -35,6 +35,7 @@ ohos_unittest("ability_manager_service_dialog_test") { "ability_runtime:ability_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", ] } diff --git a/test/unittest/ability_manager_stub_test/BUILD.gn b/test/unittest/ability_manager_stub_test/BUILD.gn index 3161e9b65c..494aec2947 100644 --- a/test/unittest/ability_manager_stub_test/BUILD.gn +++ b/test/unittest/ability_manager_stub_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("ability_manager_stub_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_scheduler_proxy_test/BUILD.gn b/test/unittest/ability_scheduler_proxy_test/BUILD.gn index 28c42b523f..119fc92c70 100644 --- a/test/unittest/ability_scheduler_proxy_test/BUILD.gn +++ b/test/unittest/ability_scheduler_proxy_test/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("ability_scheduler_proxy_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_scheduler_stub_test/BUILD.gn b/test/unittest/ability_scheduler_stub_test/BUILD.gn index 6d56e836ec..d155a9597b 100644 --- a/test/unittest/ability_scheduler_stub_test/BUILD.gn +++ b/test/unittest/ability_scheduler_stub_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_scheduler_stub_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_service_extension_test/BUILD.gn b/test/unittest/ability_service_extension_test/BUILD.gn index 8007183659..b00d1af2b3 100644 --- a/test/unittest/ability_service_extension_test/BUILD.gn +++ b/test/unittest/ability_service_extension_test/BUILD.gn @@ -57,6 +57,7 @@ ohos_unittest("ability_service_extension_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/ability_token_proxy_test/BUILD.gn b/test/unittest/ability_token_proxy_test/BUILD.gn index cf40a0cb0e..422f5734a3 100644 --- a/test/unittest/ability_token_proxy_test/BUILD.gn +++ b/test/unittest/ability_token_proxy_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_token_proxy_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/ability_token_stub_test/BUILD.gn b/test/unittest/ability_token_stub_test/BUILD.gn index 5685bc0e07..34dcc0342b 100644 --- a/test/unittest/ability_token_stub_test/BUILD.gn +++ b/test/unittest/ability_token_stub_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("ability_token_stub_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/app_recovery_test/BUILD.gn b/test/unittest/app_recovery_test/BUILD.gn index ebf4cc8261..a005f1ae96 100644 --- a/test/unittest/app_recovery_test/BUILD.gn +++ b/test/unittest/app_recovery_test/BUILD.gn @@ -61,6 +61,7 @@ ohos_unittest("AppRecoveryUnitTest") { "access_token:libtoken_callback_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "faultloggerd:libdfx_dumpcatcher", "form_fwk:fmskit_native", @@ -119,6 +120,7 @@ ohos_unittest("AbilityRecoveryUnitTest") { "access_token:libtoken_callback_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "faultloggerd:libdfx_dumpcatcher", "form_fwk:fmskit_native", diff --git a/test/unittest/application_context_test/BUILD.gn b/test/unittest/application_context_test/BUILD.gn index 570e5a4391..8281beab39 100644 --- a/test/unittest/application_context_test/BUILD.gn +++ b/test/unittest/application_context_test/BUILD.gn @@ -46,6 +46,7 @@ ohos_unittest("application_context_test") { "ability_runtime:abilitykit_native", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/connection_record_test/BUILD.gn b/test/unittest/connection_record_test/BUILD.gn index 8e872100a1..f0854bb3a1 100644 --- a/test/unittest/connection_record_test/BUILD.gn +++ b/test/unittest/connection_record_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("connection_record_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn index 5de75636f0..a92ce0e2ca 100644 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn +++ b/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("continuation_connector_test") { "ability_base:want", "ability_runtime:ability_manager", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn index 4a2bb4a637..7ca0ed312a 100644 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn +++ b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn @@ -92,6 +92,7 @@ ohos_unittest("continuation_register_manager_proxy_test") { "ability_base:want", "ability_runtime:ability_manager", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "resource_management:global_resmgr", diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn index 218e8b3e9a..191fd7b3d6 100644 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn +++ b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn @@ -92,6 +92,7 @@ ohos_unittest("continuation_register_manager_test") { "ability_base:want", "ability_runtime:ability_manager", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "resource_management:global_resmgr", diff --git a/test/unittest/data_ability_record_test/BUILD.gn b/test/unittest/data_ability_record_test/BUILD.gn index f9ccfadb65..a450bf7b3d 100644 --- a/test/unittest/data_ability_record_test/BUILD.gn +++ b/test/unittest/data_ability_record_test/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("data_ability_record_test") { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/dlp_state_item_test/BUILD.gn b/test/unittest/dlp_state_item_test/BUILD.gn index 544c912dd0..175a172835 100644 --- a/test/unittest/dlp_state_item_test/BUILD.gn +++ b/test/unittest/dlp_state_item_test/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("dlp_state_item_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/form_extension_context_test/BUILD.gn b/test/unittest/form_extension_context_test/BUILD.gn index e36a06d797..ca4446f400 100644 --- a/test/unittest/form_extension_context_test/BUILD.gn +++ b/test/unittest/form_extension_context_test/BUILD.gn @@ -61,6 +61,7 @@ ohos_unittest("form_extension_context_test") { "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn b/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn index 5489647ad4..35bde06662 100644 --- a/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ability_context_impl_test") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index e9b33698fe..3754e90cf9 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -112,6 +112,7 @@ ohos_unittest("ability_test") { "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -254,6 +255,7 @@ ohos_unittest("ability_context_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "napi:ace_napi", @@ -289,6 +291,7 @@ ohos_unittest("page_ability_impl_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -321,6 +324,7 @@ ohos_unittest("service_ability_impl_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -396,6 +400,7 @@ ohos_unittest("data_ability_helper_test") { "ability_base:want", "ability_base:zuri", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", @@ -451,6 +456,7 @@ ohos_unittest("data_ability_helper_impl_test") { "ability_base:want", "ability_base:zuri", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", @@ -635,6 +641,7 @@ ohos_unittest("ability_thread_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -683,6 +690,7 @@ ohos_unittest("service_extension_module_loader_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -727,6 +735,7 @@ ohos_unittest("ability_process_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -768,6 +777,7 @@ ohos_unittest("extension_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -810,6 +820,7 @@ ohos_unittest("form_extension_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "form_fwk:form_manager", "hiviewdfx_hilog_native:libhilog", @@ -849,6 +860,7 @@ ohos_unittest("ability_thread_call_request_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", ] @@ -986,6 +998,7 @@ ohos_unittest("data_ability_impl_test") { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", @@ -1041,6 +1054,7 @@ ohos_unittest("data_ability_impl_file_secondpart_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -1089,6 +1103,7 @@ ohos_unittest("data_ability_impl_file_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -1139,6 +1154,7 @@ ohos_unittest("ability_thread_dataability_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -1224,6 +1240,7 @@ ohos_unittest("extension_impl_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "form_fwk:form_manager", "hiviewdfx_hilog_native:libhilog", @@ -1267,6 +1284,7 @@ ohos_unittest("form_js_event_handler_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "form_fwk:fmskit_native", "form_fwk:form_manager", @@ -1494,6 +1512,7 @@ ohos_unittest("continuation_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -1557,6 +1576,7 @@ ohos_unittest("new_ability_impl_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -1589,6 +1609,7 @@ ohos_unittest("reserse_continuation_scheduler_primary_stub_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -1625,6 +1646,7 @@ ohos_unittest("reserse_continuation_scheduler_primary_proxy_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -1699,6 +1721,7 @@ ohos_unittest("ability_window_test") { "ace_engine:ace_uicontent", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -1741,6 +1764,7 @@ ohos_unittest("ability_handler_test") { "ability_runtime:ability_context_native", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", ] @@ -1785,6 +1809,7 @@ ohos_unittest("ability_impl_factory_test") { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", @@ -1819,6 +1844,7 @@ ohos_unittest("ability_loader_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -1849,6 +1875,7 @@ ohos_unittest("ability_local_record_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -1879,6 +1906,7 @@ ohos_unittest("reverse_continuation_scheduler_replica_proxy_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", @@ -1947,6 +1975,7 @@ ohos_unittest("ability_connection_manager_test") { "access_token:libtoken_callback_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "faultloggerd:libdfx_dumpcatcher", "hichecker_native:libhichecker", "hitrace_native:hitrace_meter", diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index f47f452d5c..8f0db28255 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -158,6 +158,7 @@ ohos_unittest("context_container_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -200,6 +201,7 @@ ohos_unittest("context_deal_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -342,6 +344,7 @@ ohos_unittest("mix_stack_dumper_test") { external_deps = [ "ability_runtime:abilitykit_native", "ability_runtime:runtime", + "common_event_service:cesfwk_innerkits", "faultloggerd:libdfx_dumpcatcher", ] } @@ -414,6 +417,7 @@ ohos_unittest("form_extension_context_test") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "form_fwk:fmskit_native", "form_fwk:form_manager", "hiviewdfx_hilog_native:libhilog", diff --git a/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/BUILD.gn index 48e9809505..70c89c7976 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/BUILD.gn @@ -138,6 +138,7 @@ ohos_unittest("ability_delegator_unittest") { "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -190,6 +191,7 @@ ohos_unittest("ability_delegator_registry_unittest") { "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] @@ -222,6 +224,7 @@ ohos_unittest("js_test_runner_unittest") { "ability_runtime:runtime", "bundle_framework:appexecfwk_base", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "ets_runtime:libark_jsruntime", "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", diff --git a/test/unittest/image_info_test/BUILD.gn b/test/unittest/image_info_test/BUILD.gn index 5eb31da6fc..0959a80486 100755 --- a/test/unittest/image_info_test/BUILD.gn +++ b/test/unittest/image_info_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("image_info_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/mission_info_test/BUILD.gn b/test/unittest/mission_info_test/BUILD.gn index 2029b3d64c..46ee0568e1 100755 --- a/test/unittest/mission_info_test/BUILD.gn +++ b/test/unittest/mission_info_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("mission_info_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/mission_list_manager_ut_test/BUILD.gn b/test/unittest/mission_list_manager_ut_test/BUILD.gn index d882d3d4f5..02287a9671 100644 --- a/test/unittest/mission_list_manager_ut_test/BUILD.gn +++ b/test/unittest/mission_list_manager_ut_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("mission_list_manager_ut_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/mission_list_test/BUILD.gn b/test/unittest/mission_list_test/BUILD.gn index ca5cfa0bf1..dd72f69e93 100644 --- a/test/unittest/mission_list_test/BUILD.gn +++ b/test/unittest/mission_list_test/BUILD.gn @@ -92,6 +92,7 @@ ohos_unittest("mission_list_test_call") { "ability_base:want", "ability_base:zuri", "bundle_framework:appexecfwk_base", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", ] diff --git a/test/unittest/mission_test/BUILD.gn b/test/unittest/mission_test/BUILD.gn index 9d040eb2c7..e0ea34e66c 100644 --- a/test/unittest/mission_test/BUILD.gn +++ b/test/unittest/mission_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("mission_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/pending_want_key_test/BUILD.gn b/test/unittest/pending_want_key_test/BUILD.gn index 09bbd618ff..cc4121f33a 100644 --- a/test/unittest/pending_want_key_test/BUILD.gn +++ b/test/unittest/pending_want_key_test/BUILD.gn @@ -45,6 +45,7 @@ ohos_unittest("pending_want_key_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/sender_info_test/BUILD.gn b/test/unittest/sender_info_test/BUILD.gn index 6dd53328d9..0f49a3e00b 100644 --- a/test/unittest/sender_info_test/BUILD.gn +++ b/test/unittest/sender_info_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("sender_info_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/service_extension_context_test/BUILD.gn b/test/unittest/service_extension_context_test/BUILD.gn index 5c1fc8c174..0eebc04e35 100644 --- a/test/unittest/service_extension_context_test/BUILD.gn +++ b/test/unittest/service_extension_context_test/BUILD.gn @@ -61,6 +61,7 @@ ohos_unittest("service_extension_context_test") { "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", diff --git a/test/unittest/specified_mission_list_test/BUILD.gn b/test/unittest/specified_mission_list_test/BUILD.gn index d66ebe8000..d38ae0e967 100644 --- a/test/unittest/specified_mission_list_test/BUILD.gn +++ b/test/unittest/specified_mission_list_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("specified_mission_list_test") { "ability_base:want", "ability_base:zuri", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/static_subscriber_proxy_test/BUILD.gn b/test/unittest/static_subscriber_proxy_test/BUILD.gn index 6bfe286323..e553b542dc 100755 --- a/test/unittest/static_subscriber_proxy_test/BUILD.gn +++ b/test/unittest/static_subscriber_proxy_test/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("static_subscriber_proxy_test") { external_deps = [ "ability_base:want", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/static_subscriber_stub_imp_test/BUILD.gn b/test/unittest/static_subscriber_stub_imp_test/BUILD.gn index 30f8e271ae..3d221f1bec 100755 --- a/test/unittest/static_subscriber_stub_imp_test/BUILD.gn +++ b/test/unittest/static_subscriber_stub_imp_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("static_subscriber_stub_imp_test") { "ability_base:want", "ability_runtime:runtime", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/stop_user_callback_stub_test/BUILD.gn b/test/unittest/stop_user_callback_stub_test/BUILD.gn index b87935b20c..0b73be6006 100644 --- a/test/unittest/stop_user_callback_stub_test/BUILD.gn +++ b/test/unittest/stop_user_callback_stub_test/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("stop_user_callback_stub_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", diff --git a/test/unittest/want_receiver_proxy_test/BUILD.gn b/test/unittest/want_receiver_proxy_test/BUILD.gn index 6e1ac08792..894ac49e58 100644 --- a/test/unittest/want_receiver_proxy_test/BUILD.gn +++ b/test/unittest/want_receiver_proxy_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("want_receiver_proxy_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/want_receiver_stub_test/BUILD.gn b/test/unittest/want_receiver_stub_test/BUILD.gn index cfe401a41c..55cf8d0784 100644 --- a/test/unittest/want_receiver_stub_test/BUILD.gn +++ b/test/unittest/want_receiver_stub_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("want_receiver_stub_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/want_sender_info_test/BUILD.gn b/test/unittest/want_sender_info_test/BUILD.gn index 79c1a579a9..c1ac91e5ad 100644 --- a/test/unittest/want_sender_info_test/BUILD.gn +++ b/test/unittest/want_sender_info_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("want_sender_info_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/want_sender_proxy_test/BUILD.gn b/test/unittest/want_sender_proxy_test/BUILD.gn index 458277aea1..0e08bc7adf 100644 --- a/test/unittest/want_sender_proxy_test/BUILD.gn +++ b/test/unittest/want_sender_proxy_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("want_sender_proxy_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/want_sender_stub_test/BUILD.gn b/test/unittest/want_sender_stub_test/BUILD.gn index 8c52f563b6..3880caed5e 100644 --- a/test/unittest/want_sender_stub_test/BUILD.gn +++ b/test/unittest/want_sender_stub_test/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("want_sender_stub_test") { "ability_base:zuri", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/test/unittest/wants_info_test/BUILD.gn b/test/unittest/wants_info_test/BUILD.gn index b76fee5596..160a2f3f3a 100644 --- a/test/unittest/wants_info_test/BUILD.gn +++ b/test/unittest/wants_info_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("wants_info_test") { "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", + "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", From 0268a98457c93e240e2102739c9e5b2bf6ae0741 Mon Sep 17 00:00:00 2001 From: ht Date: Sun, 23 Apr 2023 07:30:43 +0000 Subject: [PATCH 09/16] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ht --- services/dataobsmgr/src/dataobs_mgr_inner_ext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dataobsmgr/src/dataobs_mgr_inner_ext.cpp b/services/dataobsmgr/src/dataobs_mgr_inner_ext.cpp index 2cd745fa95..f322fce7e3 100644 --- a/services/dataobsmgr/src/dataobs_mgr_inner_ext.cpp +++ b/services/dataobsmgr/src/dataobs_mgr_inner_ext.cpp @@ -94,7 +94,7 @@ Status DataObsMgrInnerExt::HandleNotifyChange(const ChangeInfo &changeInfo) } } if (changeRes.empty()) { - HILOG_ERROR("no obs for this uris, changeType:%{public}ud, num of uris:%{public}zu, data is " + HILOG_DEBUG("no obs for this uris, changeType:%{public}ud, num of uris:%{public}zu, data is " "nullptr:%{public}d, size:%{public}ud", changeInfo.changeType_, changeInfo.uris_.size(), changeInfo.data_ == nullptr, changeInfo.size_); return NO_OBS_FOR_URI; From f9087fe77ec88ea8c54600d71c6fd962183558d8 Mon Sep 17 00:00:00 2001 From: ht Date: Sun, 23 Apr 2023 07:33:07 +0000 Subject: [PATCH 10/16] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ht --- services/dataobsmgr/src/data_ability_observer_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dataobsmgr/src/data_ability_observer_stub.cpp b/services/dataobsmgr/src/data_ability_observer_stub.cpp index 269e9da5f5..1eceeae9af 100644 --- a/services/dataobsmgr/src/data_ability_observer_stub.cpp +++ b/services/dataobsmgr/src/data_ability_observer_stub.cpp @@ -35,7 +35,7 @@ DataAbilityObserverStub::~DataAbilityObserverStub() {} int DataAbilityObserverStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - HILOG_INFO("code: %{public}d, flags: %{public}d, callingPid:%{public}d", code, option.GetFlags(), + HILOG_DEBUG("code: %{public}d, flags: %{public}d, callingPid:%{public}d", code, option.GetFlags(), IPCSkeleton::GetCallingPid()); std::u16string descriptor = DataAbilityObserverStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); From 1ebb0d86db91ea254d3faf9b858a48e1ae504d39 Mon Sep 17 00:00:00 2001 From: yuwenze Date: Sun, 23 Apr 2023 07:44:54 +0000 Subject: [PATCH 11/16] offline requestPermissionsFromUser Signed-off-by: yuwenze Change-Id: Ia2002259475eaf1746c4d59e7bbf5f655cc80350 --- .../napi/ability_context/ability_context.js | 4 - .../ability_runtime/ability_context_impl.cpp | 145 ------------------ .../ability_runtime/js_ability_context.cpp | 68 -------- .../ability/ability_runtime/ability_context.h | 11 -- .../ability_runtime/ability_context_impl.h | 14 -- .../ability_runtime/js_ability_context.h | 4 - 6 files changed, 246 deletions(-) diff --git a/frameworks/js/napi/ability_context/ability_context.js b/frameworks/js/napi/ability_context/ability_context.js index 67c2f186cf..7eb17d152b 100644 --- a/frameworks/js/napi/ability_context/ability_context.js +++ b/frameworks/js/napi/ability_context/ability_context.js @@ -135,10 +135,6 @@ class AbilityContext extends Context { return this.__context_impl__.terminateSelfWithResult(abilityResult, callback) } - requestPermissionsFromUser(permissions, resultCallback) { - return this.__context_impl__.requestPermissionsFromUser(permissions, resultCallback) - } - restoreWindowStage(contentStorage) { return this.__context_impl__.restoreWindowStage(contentStorage) } diff --git a/frameworks/native/ability/ability_runtime/ability_context_impl.cpp b/frameworks/native/ability/ability_runtime/ability_context_impl.cpp index d46f05d90a..a1ad631094 100644 --- a/frameworks/native/ability/ability_runtime/ability_context_impl.cpp +++ b/frameworks/native/ability/ability_runtime/ability_context_impl.cpp @@ -18,34 +18,18 @@ #include #include "ability_manager_client.h" -#include "accesstoken_kit.h" -#include "authorization_result.h" #include "hitrace_meter.h" #include "connection_manager.h" #include "dialog_request_callback_impl.h" #include "hilog_wrapper.h" -#include "permission_list_state.h" #include "remote_object_wrapper.h" #include "request_constants.h" #include "string_wrapper.h" #include "want_params_wrapper.h" -using OHOS::Security::AccessToken::AccessTokenKit; -using OHOS::Security::AccessToken::PermissionListState; -using OHOS::Security::AccessToken::TypePermissionOper; - namespace OHOS { namespace AbilityRuntime { const size_t AbilityContext::CONTEXT_TYPE_ID(std::hash {} ("AbilityContext")); -const std::string GRANT_ABILITY_BUNDLE_NAME = "com.ohos.permissionmanager"; -const std::string GRANT_ABILITY_ABILITY_NAME = "com.ohos.permissionmanager.GrantAbility"; -const std::string PERMISSION_KEY = "ohos.user.grant.permission"; -const std::string STATE_KEY = "ohos.user.grant.permission.state"; -const std::string TOKEN_KEY = "ohos.ability.params.token"; -const std::string CALLBACK_KEY = "ohos.ability.params.callback"; - -std::mutex AbilityContextImpl::mutex_; -std::map AbilityContextImpl::permissionRequestCallbacks; struct RequestResult { int32_t resultCode {0}; @@ -432,135 +416,6 @@ sptr AbilityContextImpl::GetToken() return token_; } -void AbilityContextImpl::RequestPermissionsFromUser(NativeEngine& engine, const std::vector& permissions, - int requestCode, PermissionRequestTask&& task) -{ - HILOG_INFO("%{public}s called.", __func__); - if (permissions.empty()) { - HILOG_ERROR("%{public}s. The params are invalid.", __func__); - return; - } - - std::vector permList; - for (const auto& permission : permissions) { - HILOG_DEBUG("%{public}s. permission: %{public}s.", __func__, permission.c_str()); - PermissionListState permState; - permState.permissionName = permission; - permState.state = -1; - permList.emplace_back(permState); - } - HILOG_DEBUG("%{public}s. permList size: %{public}zu, permissions size: %{public}zu.", - __func__, permList.size(), permissions.size()); - - auto ret = AccessTokenKit::GetSelfPermissionsState(permList); - if (permList.size() != permissions.size()) { - HILOG_ERROR("%{public}s. Returned permList size: %{public}zu.", __func__, permList.size()); - return; - } - - std::vector permissionsState; - for (const auto& permState : permList) { - HILOG_DEBUG("%{public}s. permissions: %{public}s. permissionsState: %{public}u", - __func__, permState.permissionName.c_str(), permState.state); - permissionsState.emplace_back(permState.state); - } - HILOG_DEBUG("%{public}s. permissions size: %{public}zu. permissionsState size: %{public}zu", - __func__, permissions.size(), permissionsState.size()); - - if (ret == TypePermissionOper::DYNAMIC_OPER) { - StartGrantExtension(engine, permissions, permissionsState, requestCode, std::move(task)); - } else { - HILOG_DEBUG("%{public}s. No dynamic popup required.", __func__); - if (task) { - task(permissions, permissionsState); - } - } -} - -void AbilityContextImpl::StartGrantExtension(NativeEngine& engine, const std::vector& permissions, - const std::vector& permissionsState, int requestCode, PermissionRequestTask&& task) -{ - AAFwk::Want want; - want.SetElementName(GRANT_ABILITY_BUNDLE_NAME, GRANT_ABILITY_ABILITY_NAME); - want.SetParam(PERMISSION_KEY, permissions); - want.SetParam(STATE_KEY, permissionsState); - want.SetParam(TOKEN_KEY, token_); - - { - std::lock_guard lock(mutex_); - permissionRequestCallbacks.insert(make_pair(requestCode, std::move(task))); - } - auto resultTask = - [&engine, requestCode](const std::vector& permissions, const std::vector& grantResults) { - auto retCB = new ResultCallback(); - retCB->permissions_ = permissions; - retCB->grantResults_ = grantResults; - retCB->requestCode_ = requestCode; - - auto loop = engine.GetUVLoop(); - if (loop == nullptr) { - HILOG_ERROR("StartGrantExtension, fail to get uv loop."); - return; - } - auto work = new uv_work_t; - work->data = static_cast(retCB); - int rev = uv_queue_work( - loop, - work, - [](uv_work_t* work) {}, - ResultCallbackJSThreadWorker); - if (rev != 0) { - if (retCB != nullptr) { - delete retCB; - retCB = nullptr; - } - if (work != nullptr) { - delete work; - work = nullptr; - } - } - }; - - sptr remoteObject = new AuthorizationResult(std::move(resultTask)); - want.SetParam(CALLBACK_KEY, remoteObject); - - ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, -1); - HILOG_DEBUG("%{public}s. End calling StartExtension. ret=%{public}d", __func__, err); -} - -void AbilityContextImpl::ResultCallbackJSThreadWorker(uv_work_t* work, int status) -{ - HILOG_DEBUG("ResultCallbackJSThreadWorker is called."); - if (work == nullptr) { - HILOG_ERROR("ResultCallbackJSThreadWorker, uv_queue_work input work is nullptr"); - return; - } - ResultCallback* retCB = static_cast(work->data); - if (retCB == nullptr) { - HILOG_ERROR("ResultCallbackJSThreadWorker, retCB is nullptr"); - delete work; - work = nullptr; - return; - } - - std::lock_guard lock(mutex_); - auto requestCode = retCB->requestCode_; - auto iter = permissionRequestCallbacks.find(requestCode); - if (iter != permissionRequestCallbacks.end() && iter->second) { - auto task = iter->second; - if (task) { - HILOG_DEBUG("%{public}s. calling js task.", __func__); - task(retCB->permissions_, retCB->grantResults_); - } - permissionRequestCallbacks.erase(iter); - } - - delete retCB; - retCB = nullptr; - delete work; - work = nullptr; -} - ErrCode AbilityContextImpl::RestoreWindowStage(NativeEngine& engine, NativeValue* contentStorage) { HILOG_INFO("%{public}s begin.", __func__); diff --git a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp index 5d7e1304e8..f05e642126 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp @@ -165,12 +165,6 @@ NativeValue* JsAbilityContext::TerminateSelfWithResult(NativeEngine* engine, Nat return (me != nullptr) ? me->OnTerminateSelfWithResult(*engine, *info) : nullptr; } -NativeValue* JsAbilityContext::RequestPermissionsFromUser(NativeEngine* engine, NativeCallbackInfo* info) -{ - JsAbilityContext* me = CheckParamsAndGetThis(engine, info); - return (me != nullptr) ? me->OnRequestPermissionsFromUser(*engine, *info) : nullptr; -} - NativeValue* JsAbilityContext::RestoreWindowStage(NativeEngine* engine, NativeCallbackInfo* info) { JsAbilityContext* me = CheckParamsAndGetThis(engine, info); @@ -1081,56 +1075,6 @@ NativeValue* JsAbilityContext::OnTerminateSelf(NativeEngine& engine, NativeCallb return result; } -NativeValue* JsAbilityContext::OnRequestPermissionsFromUser(NativeEngine& engine, NativeCallbackInfo& info) -{ - HILOG_INFO("OnRequestPermissionsFromUser is called"); - - if (info.argc < ARGC_ONE) { - HILOG_ERROR("Not enough params"); - ThrowTooFewParametersError(engine); - return engine.CreateUndefined(); - } - - std::vector permissionList; - if (!OHOS::AppExecFwk::UnwrapArrayStringFromJS(reinterpret_cast(&engine), - reinterpret_cast(info.argv[0]), permissionList)) { - HILOG_ERROR("%{public}s called, the first parameter is invalid.", __func__); - ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); - return engine.CreateUndefined(); - } - - if (permissionList.size() == 0) { - HILOG_ERROR("%{public}s called, params do not meet specification.", __func__); - } - - NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[ARGC_ONE]; - NativeValue* result = nullptr; - auto uasyncTask = CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, nullptr, &result); - std::shared_ptr asyncTask = std::move(uasyncTask); - PermissionRequestTask task = - [&engine, asyncTask](const std::vector &permissions, const std::vector &grantResults) { - HILOG_INFO("OnRequestPermissionsFromUser async callback is called"); - NativeValue* requestResult = JsAbilityContext::WrapPermissionRequestResult(engine, permissions, grantResults); - if (requestResult == nullptr) { - HILOG_WARN("wrap requestResult failed"); - asyncTask->Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INNER)); - } else { - asyncTask->Resolve(engine, requestResult); - } - HILOG_INFO("OnRequestPermissionsFromUser async callback is called end"); - }; - auto context = context_.lock(); - if (context == nullptr) { - HILOG_WARN("context is released"); - asyncTask->Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT)); - } else { - curRequestCode_ = (curRequestCode_ == INT_MAX) ? 0 : (curRequestCode_ + 1); - context->RequestPermissionsFromUser(engine, permissionList, curRequestCode_, std::move(task)); - } - HILOG_INFO("OnRequestPermissionsFromUser is called end"); - return result; -} - NativeValue* JsAbilityContext::OnRestoreWindowStage(NativeEngine& engine, NativeCallbackInfo& info) { HILOG_INFO("OnRestoreWindowStage is called, argc = %{public}d", static_cast(info.argc)); @@ -1279,16 +1223,6 @@ NativeValue* JsAbilityContext::WrapAbilityResult(NativeEngine& engine, const int return jAbilityResult; } -NativeValue* JsAbilityContext::WrapPermissionRequestResult(NativeEngine& engine, - const std::vector &permissions, const std::vector &grantResults) -{ - NativeValue* jsPermissionRequestResult = engine.CreateObject(); - NativeObject* permissionRequestResult = ConvertNativeValueTo(jsPermissionRequestResult); - permissionRequestResult->SetProperty("permissions", CreateNativeArray(engine, permissions)); - permissionRequestResult->SetProperty("authResults", CreateNativeArray(engine, grantResults)); - return jsPermissionRequestResult; -} - void JsAbilityContext::InheritWindowMode(AAFwk::Want &want) { HILOG_INFO("%{public}s called.", __func__); @@ -1407,8 +1341,6 @@ NativeValue* CreateJsAbilityContext(NativeEngine& engine, std::shared_ptr &permissions, - int requestCode, PermissionRequestTask &&task) = 0; - /** * @brief Get ContentStorage. * diff --git a/interfaces/kits/native/ability/ability_runtime/ability_context_impl.h b/interfaces/kits/native/ability/ability_runtime/ability_context_impl.h index 2b6147f00d..d648c286f2 100644 --- a/interfaces/kits/native/ability/ability_runtime/ability_context_impl.h +++ b/interfaces/kits/native/ability/ability_runtime/ability_context_impl.h @@ -87,9 +87,6 @@ public: sptr GetToken() override; - void RequestPermissionsFromUser(NativeEngine& engine, const std::vector &permissions, int requestCode, - PermissionRequestTask &&task) override; - ErrCode RestoreWindowStage(NativeEngine& engine, NativeValue* contentStorage) override; void SetStageContext(const std::shared_ptr &stageContext); @@ -201,8 +198,6 @@ public: #endif private: - static std::mutex mutex_; - static std::map permissionRequestCallbacks; sptr token_ = nullptr; std::shared_ptr abilityInfo_ = nullptr; std::shared_ptr stageContext_ = nullptr; @@ -214,17 +209,8 @@ private: bool isTerminating_ = false; int32_t missionId_ = -1; - static void ResultCallbackJSThreadWorker(uv_work_t* work, int status); static void RequestDialogResultJSThreadWorker(uv_work_t* work, int status); void OnAbilityResultInner(int requestCode, int resultCode, const AAFwk::Want &resultData); - void StartGrantExtension(NativeEngine& engine, const std::vector& permissions, - const std::vector& permissionsState, int requestCode, PermissionRequestTask &&task); - - struct ResultCallback { - std::vector permissions_; - std::vector grantResults_; - int requestCode_; - }; }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/kits/native/ability/native/ability_runtime/js_ability_context.h b/interfaces/kits/native/ability/native/ability_runtime/js_ability_context.h index 2b35daa354..a4729fbd4a 100644 --- a/interfaces/kits/native/ability/native/ability_runtime/js_ability_context.h +++ b/interfaces/kits/native/ability/native/ability_runtime/js_ability_context.h @@ -55,7 +55,6 @@ public: static NativeValue* DisconnectAbility(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* TerminateSelf(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* TerminateSelfWithResult(NativeEngine* engine, NativeCallbackInfo* info); - static NativeValue* RequestPermissionsFromUser(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* RestoreWindowStage(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* RequestDialogService(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* IsTerminating(NativeEngine* engine, NativeCallbackInfo* info); @@ -94,7 +93,6 @@ private: NativeValue* OnConnectAbilityWithAccount(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnDisconnectAbility(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnTerminateSelf(NativeEngine& engine, NativeCallbackInfo& info); - NativeValue* OnRequestPermissionsFromUser(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnRestoreWindowStage(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnRequestDialogService(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnIsTerminating(NativeEngine& engine, NativeCallbackInfo& info); @@ -103,8 +101,6 @@ private: static NativeValue* WrapWant(NativeEngine& engine, const AAFwk::Want& want); static bool UnWrapAbilityResult(NativeEngine& engine, NativeValue* argv, int& resultCode, AAFwk::Want& want); static NativeValue* WrapAbilityResult(NativeEngine& engine, const int& resultCode, const AAFwk::Want& want); - static NativeValue* WrapPermissionRequestResult(NativeEngine& engine, - const std::vector &permissions, const std::vector &grantResults); void InheritWindowMode(AAFwk::Want &want); static NativeValue* WrapRequestDialogResult(NativeEngine& engine, int32_t resultCode); void AddFreeInstallObserver(NativeEngine& engine, const AAFwk::Want &want, NativeValue* callback, From c0c8cc173f5e8e059b609a6cf73c444f84b5e081 Mon Sep 17 00:00:00 2001 From: wangzhen Date: Sun, 23 Apr 2023 17:06:08 +0800 Subject: [PATCH 12/16] deal with code-review Signed-off-by: wangzhen --- .../napi/inner/napi_ability_common/napi_common_ability.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp b/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp index e4c0cf9dcb..a0ecd13d55 100644 --- a/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp +++ b/frameworks/js/napi/inner/napi_ability_common/napi_common_ability.cpp @@ -4177,6 +4177,11 @@ void JsNapiCommon::RemoveAllCallbacksLocked() std::lock_guard lock(connectionsLock_); for (auto it = connects_.begin(); it != connects_.end();) { auto connection = it->second; + if (!connection) { + HILOG_ERROR("connection is nullptr"); + it = connects_.erase(it); + continue; + } connection->ReomveAllCallbacks(this); if (connection->GetCallbackSize() == 0) { it = connects_.erase(it); From f2e5c03e2027d888b27d9056e5385ef7b6819897 Mon Sep 17 00:00:00 2001 From: "zhangyafei.echo" Date: Thu, 20 Apr 2023 16:44:22 +0800 Subject: [PATCH 13/16] Description:InnerAPI manage. Sig:SIG_ApplicationFramework Feature or BugFix: Feature Binary Source: No Signed-off-by: zhangyafei.echo Change-Id: Icbb4ebfd5d007f5616df5f96f7f93f310b420d70 --- ability_runtime.gni | 6 +- bundle.json | 18 +- frameworks/native/ability/native/BUILD.gn | 1 + frameworks/native/appkit/BUILD.gn | 22 +- frameworks/native/appkit/app/main_thread.cpp | 12 +- .../ability_simulator/src/simulator.cpp | 6 + interfaces/inner_api/deps_wrapper/BUILD.gn | 6 +- .../deps_wrapper}/include/sa_mgr_client.h | 0 .../deps_wrapper}/src/sa_mgr_client.cpp | 0 services/abilitymgr/BUILD.gn | 6 +- services/abilitymgr/include/ability_util.h | 24 +-- services/abilitymgr/libabilityms.map | 1 - .../src/ability_manager_service.cpp | 8 +- .../src/implicit_start_processor.cpp | 8 +- .../src/system_dialog_scheduler.cpp | 8 +- services/common/include/event_report.h | 27 +-- services/common/src/event_report.cpp | 114 +++------- test/fuzztest/abilitymgrrest_fuzzer/BUILD.gn | 1 + .../pendingwantmanager_fuzzer/BUILD.gn | 1 + .../libs/sa_mgr/BUILD.gn | 2 +- .../ability_connect_manager_test/BUILD.gn | 1 + test/unittest/ability_manager_test/BUILD.gn | 1 + test/unittest/ability_record_test/BUILD.gn | 2 + .../application_context_test/BUILD.gn | 1 + .../event_report_test/event_report_test.cpp | 195 ------------------ .../BUILD.gn | 2 + .../BUILD.gn | 3 + .../pending_want_manager_test/BUILD.gn | 1 + .../pending_want_record_test/BUILD.gn | 1 + 29 files changed, 84 insertions(+), 394 deletions(-) rename {services/abilitymgr => interfaces/inner_api/deps_wrapper}/include/sa_mgr_client.h (100%) rename {services/abilitymgr => interfaces/inner_api/deps_wrapper}/src/sa_mgr_client.cpp (100%) diff --git a/ability_runtime.gni b/ability_runtime.gni index 2f1a663f84..c8d759b711 100644 --- a/ability_runtime.gni +++ b/ability_runtime.gni @@ -19,8 +19,6 @@ ability_runtime_innerkits_path = "${ability_runtime_path}/interfaces/inner_api" ability_runtime_native_path = "${ability_runtime_path}/frameworks/native" ability_runtime_services_path = "${ability_runtime_path}/services" ability_runtime_test_path = "${ability_runtime_path}/test" -ability_runtime_system_test_app_path = - "${ability_runtime_path}/test/resource/amssystemtestability/abilitySrc" ace_engine_path = "//foundation/arkui/ace_engine" arkui_path = "//foundation/arkui" @@ -33,9 +31,6 @@ windowmanager_path = "//foundation/window/window_manager" graphic_path = "//foundation/graphic/graphic_2d" global_path = "//base/global" distributedschedule_path = "//foundation/systemabilitymgr" -notification_path = "//base/notification" -ans_core_path = - "${notification_path}/distributed_notification_service/frameworks/core" eventhandler_path = "//base/notification/eventhandler" distributeddatamgr_path = "//foundation/distributeddatamgr" form_fwk_napi_path = "${form_fwk_path}/frameworks/js/napi" @@ -45,6 +40,7 @@ appspawn_path = "//base/startup/appspawn" init_path = "//base/startup/init" ipc_native_path = "//foundation/communication/ipc/ipc/native" third_party_path = "//third_party" +webview_path = "//base/web/webview" declare_args() { background_task_mgr_continuous_task_enable = true diff --git a/bundle.json b/bundle.json index 2808da5bf5..a04c69414b 100644 --- a/bundle.json +++ b/bundle.json @@ -95,7 +95,7 @@ "//foundation/ability/ability_runtime/service_router_framework:srms_target", "//foundation/ability/ability_runtime/service_router_framework:jsapi_target" ], - "inner_kits": [ + "inner_api": [ { "header": { "header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/deps_wrapper/include", @@ -228,14 +228,6 @@ }, "name": "//foundation/ability/ability_runtime/interfaces/inner_api/connectionobs_manager:connection_obs_manager" }, - { - "header": { - "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/", - "header_files": [ - ] - }, - "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:static_subscriber_extension" - }, { "header": { "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/", @@ -245,14 +237,6 @@ }, "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:service_extension" }, - { - "header": { - "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/", - "header_files": [ - ] - }, - "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:ui_extension" - }, { "header": { "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/", diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index d789c07e45..a9b833450e 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -286,6 +286,7 @@ ohos_shared_library("abilitykit_native") { "ipc:ipc_core", "ipc:ipc_napi_common", "relational_store:native_rdb", + "resource_management:global_resmgr", "samgr:samgr_proxy", ] diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index f33631326a..a6a65c613d 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -129,13 +129,12 @@ ohos_shared_library("appkit_native") { "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", ] - public_deps = - [ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ] external_deps = [ "ability_base:configuration", "ability_base:extractresourcemanager", "ability_base:string_utils", "ability_base:want", + "ability_runtime:ability_deps_wrapper", "ability_runtime:ability_manager", "ability_runtime:abilitykit_native", "ability_runtime:app_manager", @@ -154,13 +153,14 @@ ohos_shared_library("appkit_native") { "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", "ipc:ipc_core", + "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (ability_runtime_graphics) { deps += [ "//third_party/icu/icu4c:shared_icuuc" ] - public_deps += [ "${global_path}/i18n/frameworks/intl:intl_util" ] + external_deps += [ "i18n:intl_util" ] } defines = [] @@ -169,9 +169,9 @@ ohos_shared_library("appkit_native") { } if (defined(global_parts_info.web_webview)) { - public_deps += [ "//base/web/webview/ohos_adapter:nweb_ohos_adapter" ] + deps += [ "${webview_path}/ohos_adapter:nweb_ohos_adapter" ] - include_dirs += [ "//base/web/webview/ohos_adapter/interfaces" ] + include_dirs += [ "${webview_path}/ohos_adapter/interfaces" ] external_deps += [ "webview:libnweb" ] @@ -208,9 +208,6 @@ ohos_shared_library("app_context") { } deps = [] - public_deps = - [ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ] - external_deps = [ "ability_base:configuration", "ability_base:want", @@ -225,12 +222,13 @@ ohos_shared_library("app_context") { "init:libbegetutil", "ipc:ipc_core", "napi:ace_napi", + "resource_management:global_resmgr", "samgr:samgr_proxy", ] if (ability_runtime_graphics) { deps += [ "//third_party/icu/icu4c:shared_icuuc" ] - public_deps += [ "${global_path}/i18n/frameworks/intl:intl_util" ] + external_deps += [ "i18n:intl_util" ] } subsystem_name = "ability" @@ -263,9 +261,6 @@ ohos_shared_library("app_context_utils") { "${ability_runtime_native_path}/appkit:application_context_manager", ] - public_deps = - [ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ] - external_deps = [ "ability_runtime:ability_runtime_error_util", "ability_runtime:app_manager", @@ -277,12 +272,13 @@ ohos_shared_library("app_context_utils") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "napi:ace_napi", + "resource_management:global_resmgr", "resource_management:resmgr_napi_core", ] if (ability_runtime_graphics) { deps += [ "//third_party/icu/icu4c:shared_icuuc" ] - public_deps += [ "${global_path}/i18n/frameworks/intl:intl_util" ] + external_deps += [ "i18n:intl_util" ] } subsystem_name = "ability" diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 88cf3bcd02..35a7ea5877 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -15,10 +15,11 @@ #include "main_thread.h" +#include #include #include +#include #include -#include #include "constants.h" #include "ability_delegator.h" @@ -941,7 +942,7 @@ bool MainThread::InitResourceManager(std::shared_ptrOnOverlayChanged(data, resourceManager, bundleName, moduleName, loadPath); - }; + }; auto subscriber = std::make_shared(subscribeInfo, callback); bool subResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber); HILOG_INFO("Overlay event subscriber register result is %{public}d", subResult); @@ -1022,7 +1023,7 @@ void MainThread::HandleOnOverlayChanged(const EventFwk::CommonEventData &data, if (res != ERR_OK) { return; } - + // 2.add/remove overlay hapPath if (loadPath.empty() || overlayModuleInfos.size() == 0) { HILOG_WARN("There is not any hapPath in overlayModuleInfo"); @@ -1360,6 +1361,11 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con HILOG_ERROR("HandleLaunchApplication app or appmgr is null"); return; } + + if (prctl(PR_SET_NAME, "preStartNWeb") < 0) { + HILOG_WARN("Set thread name failed with %{public}d", errno); + } + std::string nwebPath = app->GetAppContext()->GetCacheDir() + "/web"; bool isFirstStartUpWeb = (access(nwebPath.c_str(), F_OK) != 0); if (!isFirstStartUpWeb) { diff --git a/frameworks/simulator/ability_simulator/src/simulator.cpp b/frameworks/simulator/ability_simulator/src/simulator.cpp index 226c52e3d6..f944b67d5e 100644 --- a/frameworks/simulator/ability_simulator/src/simulator.cpp +++ b/frameworks/simulator/ability_simulator/src/simulator.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -169,6 +170,11 @@ bool SimulatorImpl::Initialize(const Options& options) if (nativeEngine_ == nullptr) { return; } + + if (prctl(PR_SET_NAME, "simulatorInit") < 0) { + HILOG_WARN("Set thread name failed with %{public}d", errno); + } + bool initResult = OnInit(); if (!initResult) { waiter.NotifyResult(false); diff --git a/interfaces/inner_api/deps_wrapper/BUILD.gn b/interfaces/inner_api/deps_wrapper/BUILD.gn index ba6901f21d..3dfdb1e998 100644 --- a/interfaces/inner_api/deps_wrapper/BUILD.gn +++ b/interfaces/inner_api/deps_wrapper/BUILD.gn @@ -31,7 +31,10 @@ config("ability_deps_wrapper_config") { } ohos_shared_library("ability_deps_wrapper") { - sources = [ "src/os_account_manager_wrapper.cpp" ] + sources = [ + "src/os_account_manager_wrapper.cpp", + "src/sa_mgr_client.cpp", + ] public_configs = [ ":ability_deps_wrapper_config" ] @@ -40,6 +43,7 @@ ohos_shared_library("ability_deps_wrapper") { external_deps = [ "c_utils:utils", "hiviewdfx_hilog_native:libhilog", + "samgr:samgr_proxy", ] if (os_account_part_enabled) { diff --git a/services/abilitymgr/include/sa_mgr_client.h b/interfaces/inner_api/deps_wrapper/include/sa_mgr_client.h similarity index 100% rename from services/abilitymgr/include/sa_mgr_client.h rename to interfaces/inner_api/deps_wrapper/include/sa_mgr_client.h diff --git a/services/abilitymgr/src/sa_mgr_client.cpp b/interfaces/inner_api/deps_wrapper/src/sa_mgr_client.cpp similarity index 100% rename from services/abilitymgr/src/sa_mgr_client.cpp rename to interfaces/inner_api/deps_wrapper/src/sa_mgr_client.cpp diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 92c4a99294..690e14019b 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -35,6 +35,7 @@ config("abilityms_config") { "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_innerkits_path}/app_manager/include", "${ability_runtime_innerkits_path}/connectionobs_manager/include", + "${ability_runtime_innerkits_path}/deps_wrapper/include", "${ability_base_path}/interfaces/inner_api/base/include", "${ability_base_kits_path}/extractortool/include", "${ability_base_kits_path}/uri/include", @@ -107,7 +108,6 @@ config("abilityms_config") { ohos_shared_library("abilityms") { shlib_type = "sa" sources = abilityms_files - sources += [ "src/sa_mgr_client.cpp" ] cflags_cc = [] configs = [ ":abilityms_config", @@ -174,13 +174,13 @@ ohos_shared_library("abilityms") { "//third_party/icu/icu4c:shared_icuuc", "//third_party/libjpeg-turbo:turbojpeg_static", ] - public_deps = - [ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ] + external_deps += [ "ability_base:session_info", "i18n:intl_util", "input:libmmi-client", "multimedia_image_framework:image_native", + "resource_management:global_resmgr", "window_manager:libdm", ] } diff --git a/services/abilitymgr/include/ability_util.h b/services/abilitymgr/include/ability_util.h index f2ffcbea8b..0777ebca7a 100644 --- a/services/abilitymgr/include/ability_util.h +++ b/services/abilitymgr/include/ability_util.h @@ -49,14 +49,6 @@ const std::string JUMP_INTERCEPTOR_DIALOG_CALLER_PKG = "interceptor_callerPkg"; // dlp White list const std::unordered_set WHITE_LIST_DLP_SET = { BUNDLE_NAME_SELECTOR_DIALOG }; -static constexpr unsigned int CHANGE_CONFIG_ALL_CHANGED = 0xFFFFFFFF; -static constexpr unsigned int CHANGE_CONFIG_NONE = 0x00000000; -static constexpr unsigned int CHANGE_CONFIG_LOCALE = 0x00000001; -static constexpr unsigned int CHANGE_CONFIG_LAYOUT = 0x00000002; -static constexpr unsigned int CHANGE_CONFIG_FONTSIZE = 0x00000004; -static constexpr unsigned int CHANGE_CONFIG_ORIENTATION = 0x00000008; -static constexpr unsigned int CHANGE_CONFIG_DENSITY = 0x00000010; - #define CHECK_POINTER_CONTINUE(object) \ if (!object) { \ HILOG_ERROR("pointer is nullptr."); \ @@ -182,20 +174,6 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi return iface_cast(bundleObj); } -[[maybe_unused]] static sptr GetEcologicalRuleMgr() -{ - // should remove when AG SA online - int32_t ECOLOGICAL_RULE_SA_ID = 9999; - auto remoteObject = - OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(ECOLOGICAL_RULE_SA_ID); - if (remoteObject == nullptr) { - HILOG_ERROR("%{public}s error, failed to get ecological rule manager service.", __func__); - return nullptr; - } - - return iface_cast(remoteObject); -} - [[maybe_unused]] static sptr CheckEcologicalRuleMgr() { // should remove when AG SA online @@ -231,7 +209,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi targetPkg = targetWant.GetElement().GetBundleName(); return !callerPkg.empty() && !targetPkg.empty(); } - + [[maybe_unused]] static bool AddAbilityJumpRuleToBms(const std::string &callerPkg, const std::string &targetPkg, int32_t userId) { diff --git a/services/abilitymgr/libabilityms.map b/services/abilitymgr/libabilityms.map index ead5fc801f..53c028ac0a 100644 --- a/services/abilitymgr/libabilityms.map +++ b/services/abilitymgr/libabilityms.map @@ -62,7 +62,6 @@ *PendingWantManager*; *PendingWantRecord*; *ResidentProcessManager*; - *SaMgrClient*; *StartOptions*; *SystemDialogScheduler*; *TaskDataPersistenceMgr*; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index fff4873e79..ab4c5ae5ce 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -3767,13 +3767,7 @@ int AbilityManagerService::UninstallApp(const std::string &bundleName, int32_t u sptr AbilityManagerService::GetBundleManager() { if (iBundleManager_ == nullptr) { - auto bundleObj = - OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (bundleObj == nullptr) { - HILOG_ERROR("Failed to get bundle manager service."); - return nullptr; - } - iBundleManager_ = iface_cast(bundleObj); + iBundleManager_ = AbilityUtil::GetBundleManager(); } return iBundleManager_; } diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index 0333fa0480..822a445968 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -314,13 +314,7 @@ int ImplicitStartProcessor::CallStartAbilityInner(int32_t userId, sptr ImplicitStartProcessor::GetBundleManager() { if (iBundleManager_ == nullptr) { - auto bundleObj = - OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (bundleObj == nullptr) { - HILOG_ERROR("Failed to get bundle manager service."); - return nullptr; - } - iBundleManager_ = iface_cast(bundleObj); + iBundleManager_ = AbilityUtil::GetBundleManager(); } return iBundleManager_; } diff --git a/services/abilitymgr/src/system_dialog_scheduler.cpp b/services/abilitymgr/src/system_dialog_scheduler.cpp index 1acde0dc6b..30bd27e472 100644 --- a/services/abilitymgr/src/system_dialog_scheduler.cpp +++ b/services/abilitymgr/src/system_dialog_scheduler.cpp @@ -444,13 +444,7 @@ void SystemDialogScheduler::GetAppNameFromResource(int32_t labelId, sptr SystemDialogScheduler::GetBundleManager() { if (iBundleManager_ == nullptr) { - auto bundleObj = - OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (bundleObj == nullptr) { - HILOG_ERROR("Failed to get bundle manager service."); - return nullptr; - } - iBundleManager_ = iface_cast(bundleObj); + iBundleManager_ = AbilityUtil::GetBundleManager(); } return iBundleManager_; } diff --git a/services/common/include/event_report.h b/services/common/include/event_report.h index a784db7290..dc4790e561 100644 --- a/services/common/include/event_report.h +++ b/services/common/include/event_report.h @@ -25,11 +25,9 @@ using HiSysEvent = OHOS::HiviewDFX::HiSysEvent; namespace OHOS { namespace AAFwk { - struct EventInfo { int32_t pid = -1; int32_t userId = -1; - int64_t formId = -1; int32_t extensionType = -1; uint32_t versionCode = 0; int32_t errCode = -1; @@ -71,19 +69,6 @@ enum class EventName { CONNECT_SERVICE, DISCONNECT_SERVICE, - // form behavior event - ADD_FORM, - REQUEST_FORM, - DELETE_FORM, - CASTTEMP_FORM, - ACQUIREFORMSTATE_FORM, - MESSAGE_EVENT_FORM, - ROUTE_EVENT_FORM, - BACKGROUND_EVENT_FORM, - RELEASE_FORM, - DELETE_INVALID_FORM, - SET_NEXT_REFRESH_TIME_FORM, - // app behavior event APP_ATTACH, APP_LAUNCH, @@ -96,14 +81,10 @@ enum class EventName { class EventReport { public: - static void SendAppEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo); - static void SendAbilityEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo); - static void SendExtensionEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo); - static void SendFormEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo); + static void SendAppEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo); + static void SendAbilityEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo); + static void SendExtensionEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo); + private: static std::string ConvertEventName(const EventName &eventName); }; diff --git a/services/common/src/event_report.cpp b/services/common/src/event_report.cpp index d6c080037b..485d158f19 100644 --- a/services/common/src/event_report.cpp +++ b/services/common/src/event_report.cpp @@ -22,29 +22,27 @@ namespace OHOS { namespace AAFwk { namespace { // event params -const std::string TYPE = "TYPE"; -const std::string EVENT_KEY_APP_PID = "APP_PID"; -const std::string EVENT_KEY_USERID = "USER_ID"; -const std::string EVENT_KEY_FORM_ID = "FORM_ID"; -const std::string EVENT_KEY_ERROR_CODE = "ERROR_CODE"; -const std::string EVENT_KEY_BUNDLE_NAME = "BUNDLE_NAME"; -const std::string EVENT_KEY_MODULE_NAME = "MODULE_NAME"; -const std::string EVENT_KEY_ABILITY_NAME = "ABILITY_NAME"; -const std::string EVENT_KEY_ABILITY_TYPE = "ABILITY_TYPE"; -const std::string EVENT_KEY_VERSION_NAME = "VERSION_NAME"; -const std::string EVENT_KEY_VERSION_CODE = "VERSION_CODE"; -const std::string EVENT_KEY_PROCESS_NAME = "PROCESS_NAME"; -const std::string EVENT_KEY_EXTENSION_TYPE = "EXTENSION_TYPE"; -const std::string EVENT_KEY_STARTUP_TIME = "STARTUP_TIME"; -const std::string EVENT_KEY_STARTUP_ABILITY_TYPE = "STARTUP_ABILITY_TYPE"; -const std::string EVENT_KEY_STARTUP_EXTENSION_TYPE = "STARTUP_EXTENSION_TYPE"; -const std::string EVENT_KEY_CALLER_BUNDLE_NAME = "CALLER_BUNDLE_NAME"; -const std::string EVENT_KEY_CALLER_UID = "CALLER_UID"; -const std::string EVENT_KEY_CALLER_PROCESS_NAME = "CALLER_PROCESS_NAME"; -const std::string EVENT_KEY_EXIT_TIME = "EXIT_TIME"; -const std::string EVENT_KEY_EXIT_RESULT = "EXIT_RESULT"; -const std::string EVENT_KEY_EXIT_PID = "EXIT_PID"; -const std::string EVENT_KEY_BUNDLE_TYPE = "BUNDLE_TYPE"; +constexpr const char *EVENT_KEY_APP_PID = "APP_PID"; +constexpr const char *EVENT_KEY_USERID = "USER_ID"; +constexpr const char *EVENT_KEY_ERROR_CODE = "ERROR_CODE"; +constexpr const char *EVENT_KEY_BUNDLE_NAME = "BUNDLE_NAME"; +constexpr const char *EVENT_KEY_MODULE_NAME = "MODULE_NAME"; +constexpr const char *EVENT_KEY_ABILITY_NAME = "ABILITY_NAME"; +constexpr const char *EVENT_KEY_ABILITY_TYPE = "ABILITY_TYPE"; +constexpr const char *EVENT_KEY_VERSION_NAME = "VERSION_NAME"; +constexpr const char *EVENT_KEY_VERSION_CODE = "VERSION_CODE"; +constexpr const char *EVENT_KEY_PROCESS_NAME = "PROCESS_NAME"; +constexpr const char *EVENT_KEY_EXTENSION_TYPE = "EXTENSION_TYPE"; +constexpr const char *EVENT_KEY_STARTUP_TIME = "STARTUP_TIME"; +constexpr const char *EVENT_KEY_STARTUP_ABILITY_TYPE = "STARTUP_ABILITY_TYPE"; +constexpr const char *EVENT_KEY_STARTUP_EXTENSION_TYPE = "STARTUP_EXTENSION_TYPE"; +constexpr const char *EVENT_KEY_CALLER_BUNDLE_NAME = "CALLER_BUNDLE_NAME"; +constexpr const char *EVENT_KEY_CALLER_UID = "CALLER_UID"; +constexpr const char *EVENT_KEY_CALLER_PROCESS_NAME = "CALLER_PROCESS_NAME"; +constexpr const char *EVENT_KEY_EXIT_TIME = "EXIT_TIME"; +constexpr const char *EVENT_KEY_EXIT_RESULT = "EXIT_RESULT"; +constexpr const char *EVENT_KEY_EXIT_PID = "EXIT_PID"; +constexpr const char *EVENT_KEY_BUNDLE_TYPE = "BUNDLE_TYPE"; const std::map eventNameToStrMap_ = { std::map::value_type(EventName::START_ABILITY_ERROR, "START_ABILITY_ERROR"), std::map::value_type(EventName::TERMINATE_ABILITY_ERROR, "TERMINATE_ABILITY_ERROR"), @@ -63,18 +61,6 @@ const std::map eventNameToStrMap_ = { std::map::value_type(EventName::STOP_SERVICE, "STOP_SERVICE"), std::map::value_type(EventName::CONNECT_SERVICE, "CONNECT_SERVICE"), std::map::value_type(EventName::DISCONNECT_SERVICE, "DISCONNECT_SERVICE"), - std::map::value_type(EventName::ADD_FORM, "ADD_FORM"), - std::map::value_type(EventName::REQUEST_FORM, "REQUEST_FORM"), - std::map::value_type(EventName::REQUEST_FORM, "REQUEST_FORM"), - std::map::value_type(EventName::DELETE_FORM, "DELETE_FORM"), - std::map::value_type(EventName::CASTTEMP_FORM, "CASTTEMP_FORM"), - std::map::value_type(EventName::ACQUIREFORMSTATE_FORM, "ACQUIREFORMSTATE_FORM"), - std::map::value_type(EventName::MESSAGE_EVENT_FORM, "MESSAGE_EVENT_FORM"), - std::map::value_type(EventName::ROUTE_EVENT_FORM, "ROUTE_EVENT_FORM"), - std::map::value_type(EventName::BACKGROUND_EVENT_FORM, "BACKGROUND_EVENT_FORM"), - std::map::value_type(EventName::RELEASE_FORM, "RELEASE_FORM"), - std::map::value_type(EventName::DELETE_INVALID_FORM, "DELETE_INVALID_FORM"), - std::map::value_type(EventName::SET_NEXT_REFRESH_TIME_FORM, "SET_NEXT_REFRESH_TIME_FORM"), std::map::value_type(EventName::APP_ATTACH, "APP_ATTACH"), std::map::value_type(EventName::APP_LAUNCH, "APP_LAUNCH"), std::map::value_type(EventName::APP_FOREGROUND, "APP_FOREGROUND"), @@ -85,8 +71,7 @@ const std::map eventNameToStrMap_ = { }; } -void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo) +void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo) { constexpr int32_t defaultVal = -1; std::string name = ConvertEventName(eventName); @@ -140,6 +125,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type, EVENT_KEY_PROCESS_NAME, eventInfo.processName, EVENT_KEY_BUNDLE_TYPE, eventInfo.bundleType, EVENT_KEY_CALLER_BUNDLE_NAME, eventInfo.callerBundleName); + break; case EventName::APP_BACKGROUND: HiSysEventWrite( HiSysEvent::Domain::AAFWK, @@ -151,6 +137,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type, EVENT_KEY_VERSION_CODE, eventInfo.versionCode, EVENT_KEY_PROCESS_NAME, eventInfo.processName, EVENT_KEY_BUNDLE_TYPE, eventInfo.bundleType); + break; default: HiSysEventWrite( HiSysEvent::Domain::AAFWK, @@ -165,8 +152,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type, } } -void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo) +void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo) { std::string name = ConvertEventName(eventName); if (name == "INVALIDEVENTNAME") { @@ -244,8 +230,7 @@ void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType ty } } -void EventReport::SendExtensionEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo) +void EventReport::SendExtensionEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo) { std::string name = ConvertEventName(eventName); if (name == "INVALIDEVENTNAME") { @@ -299,53 +284,6 @@ void EventReport::SendExtensionEvent(const EventName &eventName, HiSysEventType } } -void EventReport::SendFormEvent(const EventName &eventName, HiSysEventType type, - const EventInfo& eventInfo) -{ - std::string name = ConvertEventName(eventName); - if (name == "INVALIDEVENTNAME") { - HILOG_ERROR("invalid eventName"); - return; - } - switch (eventName) { - case EventName::DELETE_INVALID_FORM: - HiSysEventWrite(HiSysEvent::Domain::AAFWK, name, type); - break; - case EventName::ACQUIREFORMSTATE_FORM: - case EventName::MESSAGE_EVENT_FORM: - HiSysEventWrite( - HiSysEvent::Domain::AAFWK, - name, - type, - EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName, - EVENT_KEY_MODULE_NAME, eventInfo.moduleName, - EVENT_KEY_ABILITY_NAME, eventInfo.abilityName); - break; - case EventName::ADD_FORM: - case EventName::REQUEST_FORM: - case EventName::BACKGROUND_EVENT_FORM: - case EventName::ROUTE_EVENT_FORM: - HiSysEventWrite( - HiSysEvent::Domain::AAFWK, - name, - type, - EVENT_KEY_FORM_ID, eventInfo.formId, - EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName, - EVENT_KEY_MODULE_NAME, eventInfo.moduleName, - EVENT_KEY_ABILITY_NAME, eventInfo.abilityName); - break; - case EventName::DELETE_FORM: - case EventName::CASTTEMP_FORM: - case EventName::RELEASE_FORM: - case EventName::SET_NEXT_REFRESH_TIME_FORM: - HiSysEventWrite( - HiSysEvent::Domain::AAFWK, name, type, EVENT_KEY_FORM_ID, eventInfo.formId); - break; - default: - break; - } -} - std::string EventReport::ConvertEventName(const EventName &eventName) { auto it = eventNameToStrMap_.find(eventName); diff --git a/test/fuzztest/abilitymgrrest_fuzzer/BUILD.gn b/test/fuzztest/abilitymgrrest_fuzzer/BUILD.gn index 68864fb7fd..78ec04f92a 100755 --- a/test/fuzztest/abilitymgrrest_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymgrrest_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("AbilityMgrRestFuzzTest") { "ability_base:session_info", "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", "appspawn:appspawn_socket_client", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", diff --git a/test/fuzztest/pendingwantmanager_fuzzer/BUILD.gn b/test/fuzztest/pendingwantmanager_fuzzer/BUILD.gn index 40e33f2b4a..2bd054e411 100755 --- a/test/fuzztest/pendingwantmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/pendingwantmanager_fuzzer/BUILD.gn @@ -55,6 +55,7 @@ ohos_fuzztest("PendingWantManagerFuzzTest") { external_deps = [ "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", "ability_runtime:connection_obs_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", diff --git a/test/mock/services_abilitymgr_test/libs/sa_mgr/BUILD.gn b/test/mock/services_abilitymgr_test/libs/sa_mgr/BUILD.gn index fcef304b24..50e6203898 100644 --- a/test/mock/services_abilitymgr_test/libs/sa_mgr/BUILD.gn +++ b/test/mock/services_abilitymgr_test/libs/sa_mgr/BUILD.gn @@ -16,7 +16,7 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") config("sa_mgr_mock_config") { include_dirs = [ - "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_innerkits_path}/deps_wrapper/include", "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", ] cflags = [] diff --git a/test/unittest/ability_connect_manager_test/BUILD.gn b/test/unittest/ability_connect_manager_test/BUILD.gn index 10ffc29141..96877cacff 100644 --- a/test/unittest/ability_connect_manager_test/BUILD.gn +++ b/test/unittest/ability_connect_manager_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("ability_connect_manager_test") { external_deps = [ "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", diff --git a/test/unittest/ability_manager_test/BUILD.gn b/test/unittest/ability_manager_test/BUILD.gn index ee9bc7c718..3d648efee7 100644 --- a/test/unittest/ability_manager_test/BUILD.gn +++ b/test/unittest/ability_manager_test/BUILD.gn @@ -46,6 +46,7 @@ ohos_unittest("ability_manager_test") { external_deps = [ "ability_base:want", + "ability_runtime:ability_deps_wrapper", "ability_runtime:ability_manager", "ability_runtime:abilitykit_native", "c_utils:utils", diff --git a/test/unittest/ability_record_test/BUILD.gn b/test/unittest/ability_record_test/BUILD.gn index a19e61ca9b..37cb9e25c0 100644 --- a/test/unittest/ability_record_test/BUILD.gn +++ b/test/unittest/ability_record_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("ability_record_test") { "ability_base:session_info", "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", @@ -63,6 +64,7 @@ ohos_unittest("ability_record_test") { "hiviewdfx_hilog_native:libhilog", "init:libbeget_proxy", "ipc:ipc_core", + "resource_management:global_resmgr", ] if (background_task_mgr_continuous_task_enable) { diff --git a/test/unittest/application_context_test/BUILD.gn b/test/unittest/application_context_test/BUILD.gn index 570e5a4391..5e523acd74 100644 --- a/test/unittest/application_context_test/BUILD.gn +++ b/test/unittest/application_context_test/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("application_context_test") { "c_utils:utils", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "resource_management:global_resmgr", ] } diff --git a/test/unittest/event_report_test/event_report_test.cpp b/test/unittest/event_report_test/event_report_test.cpp index 588fb1abf1..434fe62fd6 100755 --- a/test/unittest/event_report_test/event_report_test.cpp +++ b/test/unittest/event_report_test/event_report_test.cpp @@ -418,200 +418,5 @@ HWTEST_F(EventReportTest, SendExtensionEvent_0900, TestSize.Level0) EventInfo eventInfo; EventReport::SendExtensionEvent(eventName, type, eventInfo); } - -/** - * @tc.name: SendExtensionEvent_1000 - * @tc.desc: Check SendExtensionEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendExtensionEvent_1000, TestSize.Level0) -{ - EventName eventName = EventName::DELETE_INVALID_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "DELETE_INVALID_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendExtensionEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0100 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0100, TestSize.Level0) -{ - EventName eventName = static_cast(-1); - EXPECT_EQ(EventReport::ConvertEventName(eventName), "INVALIDEVENTNAME"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0200 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0200, TestSize.Level0) -{ - EventName eventName = EventName::DELETE_INVALID_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "DELETE_INVALID_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0300 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0300, TestSize.Level0) -{ - EventName eventName = EventName::ACQUIREFORMSTATE_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "ACQUIREFORMSTATE_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0400 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0400, TestSize.Level0) -{ - EventName eventName = EventName::MESSAGE_EVENT_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "MESSAGE_EVENT_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0500 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0500, TestSize.Level0) -{ - EventName eventName = EventName::ADD_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "ADD_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0600 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0600, TestSize.Level0) -{ - EventName eventName = EventName::REQUEST_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "REQUEST_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0700 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI6D9OM - */ -HWTEST_F(EventReportTest, SendFormEvent_0700, TestSize.Level0) -{ - EventName eventName = EventName::BACKGROUND_EVENT_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "BACKGROUND_EVENT_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0800 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0800, TestSize.Level0) -{ - EventName eventName = EventName::ROUTE_EVENT_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "ROUTE_EVENT_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_0900 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_0900, TestSize.Level0) -{ - EventName eventName = EventName::DELETE_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "DELETE_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_1000 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_1000, TestSize.Level0) -{ - EventName eventName = EventName::CASTTEMP_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "CASTTEMP_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_1100 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_1100, TestSize.Level0) -{ - EventName eventName = EventName::RELEASE_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "RELEASE_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} - -/** - * @tc.name: SendFormEvent_1200 - * @tc.desc: Check SendFormEvent Test - * @tc.type: FUNC - * @tc.require: issueI67H0J - */ -HWTEST_F(EventReportTest, SendFormEvent_1200, TestSize.Level0) -{ - EventName eventName = EventName::SET_NEXT_REFRESH_TIME_FORM; - EXPECT_EQ(EventReport::ConvertEventName(eventName), "SET_NEXT_REFRESH_TIME_FORM"); - HiSysEventType type = HiSysEventType::BEHAVIOR; - EventInfo eventInfo; - EventReport::SendFormEvent(eventName, type, eventInfo); -} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index 3a56aba4be..b91831c0b6 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -642,6 +642,7 @@ ohos_unittest("ability_thread_test") { "relational_store:native_appdatafwk", "relational_store:native_dataability", "relational_store:native_rdb", + "resource_management:global_resmgr", ] if (ability_runtime_graphics) { @@ -852,6 +853,7 @@ ohos_unittest("ability_thread_call_request_test") { "c_utils:utils", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", + "resource_management:global_resmgr", ] } diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index 87857f2e5e..44109cf12c 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -127,6 +127,7 @@ ohos_unittest("application_test") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "resource_management:global_resmgr", ] } @@ -206,6 +207,7 @@ ohos_unittest("context_deal_test") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "resource_management:global_resmgr", ] } @@ -388,6 +390,7 @@ ohos_unittest("ability_stage_test") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "resource_management:global_resmgr", ] } diff --git a/test/unittest/pending_want_manager_test/BUILD.gn b/test/unittest/pending_want_manager_test/BUILD.gn index 515aa86c1f..6535da4057 100644 --- a/test/unittest/pending_want_manager_test/BUILD.gn +++ b/test/unittest/pending_want_manager_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("pending_want_manager_test") { external_deps = [ "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", diff --git a/test/unittest/pending_want_record_test/BUILD.gn b/test/unittest/pending_want_record_test/BUILD.gn index 03a7f451c7..627861ef02 100644 --- a/test/unittest/pending_want_record_test/BUILD.gn +++ b/test/unittest/pending_want_record_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("pending_want_record_test") { external_deps = [ "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", "ability_runtime:ability_manager", "access_token:libaccesstoken_sdk", "c_utils:utils", From 8c908d37727ede1a275e0f8647d88318d84b539b Mon Sep 17 00:00:00 2001 From: liuliu Date: Fri, 21 Apr 2023 11:33:17 +0800 Subject: [PATCH 14/16] add tdd Signed-off-by: liuliu Change-Id: I54a109ad79f55963ea62a8f9982b1452a91c8652 --- .../ams_ipc_app_mgr_module_test.cpp | 8 + .../ams_app_running_record_test.cpp | 21 ++ test/unittest/app_mgr_client_test/BUILD.gn | 8 +- .../app_mgr_client_test.cpp | 33 ++- .../app_mgr_service_inner_test.cpp | 2 + .../app_state_observer_manager_test.cpp | 210 ++++++++++++++++++ 6 files changed, 280 insertions(+), 2 deletions(-) diff --git a/test/moduletest/common/ams/ipc_app_mgr_test/ams_ipc_app_mgr_module_test.cpp b/test/moduletest/common/ams/ipc_app_mgr_test/ams_ipc_app_mgr_module_test.cpp index f87dc18ab8..93e15bc5bf 100644 --- a/test/moduletest/common/ams/ipc_app_mgr_test/ams_ipc_app_mgr_module_test.cpp +++ b/test/moduletest/common/ams/ipc_app_mgr_test/ams_ipc_app_mgr_module_test.cpp @@ -257,10 +257,14 @@ HWTEST_F(AmsIpcAppmgrModuleTest, ExcuteAppmgrIPCInterface_09, TestSize.Level3) auto& r1 = result.emplace_back(); r1.processName_ = testBundleName_1; r1.pid_ = testApp1Pid; + r1.processType_ = ProcessType::NORMAL; + r1.extensionType_ = ExtensionAbilityType::UNSPECIFIED; auto& r2 = result.emplace_back(); r2.processName_ = testBundleName_2; r2.pid_ = testApp2Pid; + r2.processType_ = ProcessType::EXTENSION; + r2.extensionType_ = ExtensionAbilityType::INPUTMETHOD; mockMockAppMgr->Post(); @@ -275,7 +279,11 @@ HWTEST_F(AmsIpcAppmgrModuleTest, ExcuteAppmgrIPCInterface_09, TestSize.Level3) EXPECT_TRUE(allRunningProcessInfo.size() == 2); EXPECT_EQ(allRunningProcessInfo[0].processName_, testBundleName_1); EXPECT_EQ(allRunningProcessInfo[0].pid_, testApp1Pid); + EXPECT_EQ(allRunningProcessInfo[0].processType_, ProcessType::NORMAL); + EXPECT_EQ(allRunningProcessInfo[0].extensionType_, ExtensionAbilityType::UNSPECIFIED); EXPECT_EQ(allRunningProcessInfo[1].processName_, testBundleName_2); EXPECT_EQ(allRunningProcessInfo[1].pid_, testApp2Pid); + EXPECT_EQ(allRunningProcessInfo[1].processType_, ProcessType::EXTENSION); + EXPECT_EQ(allRunningProcessInfo[1].extensionType_, ExtensionAbilityType::INPUTMETHOD); } } diff --git a/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp b/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp index 9ceaf55f37..c8d72ef1f4 100644 --- a/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp +++ b/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp @@ -1915,6 +1915,27 @@ HWTEST_F(AmsAppRunningRecordTest, SetHostBundleName_001, TestSize.Level1) EXPECT_EQ(renderRecord->GetHostBundleName(), hostBundleName); } +/* + * Feature: AMS + * Function: Set/GetProcessName + * SubFunction: Set/GetProcessName + * FunctionPoints: check params + * EnvConditions: Mobile that can run ohos test framework + * CaseDescription: Set/Get GetProcessName + */ +HWTEST_F(AmsAppRunningRecordTest, SetProcessName_001, TestSize.Level1) +{ + pid_t hostPid = 0; + std::string renderParam = "test_render_param"; + std::shared_ptr host; + RenderRecord* renderRecord = + new RenderRecord(hostPid, renderParam, 0, 0, 0, host); + EXPECT_NE(renderRecord, nullptr); + std::string hostProcessName = "testhostProcessName"; + renderRecord->SetProcessName(hostProcessName); + EXPECT_EQ(renderRecord->GetProcessName(), hostProcessName); +} + /* * Feature: AMS * Function: GetRenderParam diff --git a/test/unittest/app_mgr_client_test/BUILD.gn b/test/unittest/app_mgr_client_test/BUILD.gn index 1eb6451b45..e623f3905c 100644 --- a/test/unittest/app_mgr_client_test/BUILD.gn +++ b/test/unittest/app_mgr_client_test/BUILD.gn @@ -25,12 +25,16 @@ ohos_unittest("AppMgrClientTest") { ] include_dirs = [ + "${ability_runtime_test_path}/mock/common/include", "${ability_runtime_services_path}/abilitymgr/include", "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", "${ability_runtime_services_path}/appmgr/test/unittest/mocks", ] - sources = [ "app_mgr_client_test.cpp" ] + sources = [ + "${ability_runtime_test_path}/mock/common/src/mock_native_token.cpp", + "app_mgr_client_test.cpp", + ] deps = [ "${ability_runtime_services_path}/abilitymgr:abilityms", @@ -46,6 +50,8 @@ ohos_unittest("AppMgrClientTest") { "ability_base:zuri", "ability_runtime:app_manager", "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", diff --git a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp index 4cf33745bd..8c1a0c44ac 100644 --- a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp @@ -22,6 +22,7 @@ #include "ability_record.h" #include "app_mgr_constants.h" #include "hilog_wrapper.h" +#include "mock_native_token.h" #undef protected #undef private @@ -51,7 +52,9 @@ public: }; void AppMgrClientTest::SetUpTestCase(void) -{} +{ + MockNativeToken::SetNativeToken(); +} void AppMgrClientTest::TearDownTestCase(void) {} @@ -120,6 +123,34 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_UpdateExtensionState_001, TestSize.Level EXPECT_EQ(ret, AppMgrResultCode::RESULT_OK); } +/** + * @tc.name: AppMgrClient_GetAllRunningProcesses_001 + * @tc.desc: get all running processes. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrClientTest, AppMgrClient_GetAllRunningProcesses_001, TestSize.Level0) +{ + HILOG_INFO("GetAllRunningProcesses_001 start"); + auto appMgrClient = std::make_unique(); + EXPECT_NE(appMgrClient, nullptr); + + std::vector info; + appMgrClient->GetAllRunningProcesses(info); + EXPECT_NE(info.size(), APP_NUMBER_ZERO); + for (int i = 0; i < info.size(); i++) { + HILOG_DEBUG("running %{public}d: name: %{public}s, processType: %{public}d, extensionType: %{public}d", + i, info[i].processName_.c_str(), info[i].processType_, info[i].extensionType_); + if (info[i].processName_ == "com.ohos.systemui") { + EXPECT_EQ(info[i].processType_, ProcessType::EXTENSION); + EXPECT_EQ(info[i].extensionType_, ExtensionAbilityType::SERVICE); + } else if (info[i].processName_ == "com.ohos.launcher") { + EXPECT_EQ(info[i].processType_, ProcessType::EXTENSION); + EXPECT_EQ(info[i].extensionType_, ExtensionAbilityType::SERVICE); + } + } + HILOG_INFO("GetAllRunningProcesses_001 end"); +} + /** * @tc.name: AppMgrClient_GetRunningProcessInfoByToken_001 * @tc.desc: can not get the not running process info by token. diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 1e45c7bee9..d4c05dff11 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -1592,6 +1592,8 @@ HWTEST_F(AppMgrServiceInnerTest, StartProcess_001, TestSize.Level0) appMgrServiceInner->StartProcess(appName, processName, 0, nullptr, 0, bundleName, 0); appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleName, 0); appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleName, 1); + appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleName, 0, false); + appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleName, 1, false); appMgrServiceInner->SetBundleManager(nullptr); appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleName, 0); diff --git a/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp b/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp index 5f2fa298fa..db4809a0e0 100644 --- a/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp +++ b/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp @@ -48,6 +48,10 @@ public: {} void OnAppStateChanged(const AppStateData &appStateData) override {} + void OnAppStarted(const AppStateData &appStateData) override + {} + void OnAppStopped(const AppStateData &appStateData) override + {} sptr AsObject() override { return {}; @@ -146,6 +150,42 @@ HWTEST_F(AppSpawnSocketTest, UnregisterApplicationStateObserver_001, TestSize.Le EXPECT_EQ(res, ERR_PERMISSION_DENIED); } +/* + * Feature: AppStateObserverManager + * Function: OnAppStarted + * SubFunction: NA + * FunctionPoints: AppStateObserverManager OnAppStarted + * EnvConditions: NA + * CaseDescription: Verify OnAppStarted + */ +HWTEST_F(AppSpawnSocketTest, OnAppStarted_001, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::shared_ptr appRecord; + manager->OnAppStarted(appRecord); + manager->Init(); + manager->OnAppStarted(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: OnAppStopped + * SubFunction: NA + * FunctionPoints: AppStateObserverManager OnAppStopped + * EnvConditions: NA + * CaseDescription: Verify OnAppStopped + */ +HWTEST_F(AppSpawnSocketTest, OnAppStopped_001, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::shared_ptr appRecord; + manager->OnAppStopped(appRecord); + manager->Init(); + manager->OnAppStopped(appRecord); +} + /* * Feature: AppStateObserverManager * Function: OnAppStateChanged @@ -292,6 +332,176 @@ HWTEST_F(AppSpawnSocketTest, StateChangedNotifyObserver_001, TestSize.Level0) manager->StateChangedNotifyObserver(abilityStateData, isAbility); } +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStarted + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStarted + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStarted + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStarted_001, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + manager->HandleOnAppStarted(nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName = "com.ohos.unittest"; + appRecord->mainBundleName_ = bundleName; + bundleNameList.push_back(bundleName); + manager->appStateObserverMap_.emplace(observer_, bundleNameList); + manager->HandleOnAppStarted(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStarted + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStarted + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStarted + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStarted_002, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName = "com.ohos.unittest"; + appRecord->mainBundleName_ = bundleName; + manager->appStateObserverMap_.emplace(observer_, bundleNameList); + manager->HandleOnAppStarted(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStarted + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStarted + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStarted + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStarted_003, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName1 = "com.ohos.unittest1"; + std::string bundleName2 = "com.ohos.unittest2"; + appRecord->mainBundleName_ = bundleName1; + bundleNameList.push_back(bundleName2); + manager->appStateObserverMap_.emplace(observer_, bundleNameList); + manager->HandleOnAppStarted(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStarted + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStarted + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStarted + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStarted_004, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName = "com.ohos.unittest"; + appRecord->mainBundleName_ = bundleName; + bundleNameList.push_back(bundleName); + manager->appStateObserverMap_.emplace(nullptr, bundleNameList); + manager->HandleOnAppStarted(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStopped + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStopped + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStopped + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStopped_001, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + manager->HandleOnAppStopped(nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName = "com.ohos.unittest"; + appRecord->mainBundleName_ = bundleName; + bundleNameList.push_back(bundleName); + manager->appStateObserverMap_.emplace(observer_, bundleNameList); + manager->HandleOnAppStopped(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStopped + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStopped + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStopped + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStopped_002, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName = "com.ohos.unittest"; + appRecord->mainBundleName_ = bundleName; + manager->appStateObserverMap_.emplace(observer_, bundleNameList); + manager->HandleOnAppStopped(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStopped + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStopped + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStopped + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStopped_003, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName1 = "com.ohos.unittest1"; + std::string bundleName2 = "com.ohos.unittest2"; + appRecord->mainBundleName_ = bundleName1; + bundleNameList.push_back(bundleName2); + manager->appStateObserverMap_.emplace(observer_, bundleNameList); + manager->HandleOnAppStopped(appRecord); +} + +/* + * Feature: AppStateObserverManager + * Function: HandleOnAppStopped + * SubFunction: NA + * FunctionPoints: AppStateObserverManager HandleOnAppStopped + * EnvConditions: NA + * CaseDescription: Verify HandleOnAppStopped + */ +HWTEST_F(AppSpawnSocketTest, HandleOnAppStopped_004, TestSize.Level0) +{ + auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); + std::vector bundleNameList; + std::shared_ptr appRecord = MockAppRecord(); + std::string bundleName = "com.ohos.unittest"; + appRecord->mainBundleName_ = bundleName; + bundleNameList.push_back(bundleName); + manager->appStateObserverMap_.emplace(nullptr, bundleNameList); + manager->HandleOnAppStopped(appRecord); +} + /* * Feature: AppStateObserverManager * Function: HandleAppStateChanged From 48a8b5bc73bfd8e9451febc119a5212ca9d1f05e Mon Sep 17 00:00:00 2001 From: wangyong Date: Mon, 24 Apr 2023 11:47:13 +0800 Subject: [PATCH 15/16] Add moveMissionsToForeground/moveMissionsToBackground Signed-off-by: wangyong Change-Id: I64c1b26d6b040b20dbfd7f821814938679502b16 --- .../js_mission_info_utils.cpp | 1 + .../js_mission_manager/mission_manager.cpp | 123 ++++++++++++++++++ .../include/ability_manager_client.h | 20 ++- .../include/ability_manager_interface.h | 18 ++- .../ability_manager/include/mission_info.h | 1 + .../include/window_manager_service_handler.h | 10 ++ .../window_manager_service_handler_proxy.h | 7 +- .../window_manager_service_handler_stub.h | 2 + .../window_manager_service_handler_proxy.cpp | 72 ++++++++++ .../window_manager_service_handler_stub.cpp | 25 ++++ .../include/ability_manager_proxy.h | 7 +- .../include/ability_manager_service.h | 5 + .../abilitymgr/include/ability_manager_stub.h | 2 + services/abilitymgr/include/ability_record.h | 1 + .../abilitymgr/include/mission_info_mgr.h | 10 ++ .../abilitymgr/src/ability_manager_client.cpp | 17 +++ .../abilitymgr/src/ability_manager_proxy.cpp | 67 ++++++++++ .../src/ability_manager_service.cpp | 41 ++++++ .../abilitymgr/src/ability_manager_stub.cpp | 34 +++++ services/abilitymgr/src/ability_record.cpp | 22 ++-- services/abilitymgr/src/mission_info.cpp | 4 + services/abilitymgr/src/mission_info_mgr.cpp | 16 +++ .../AMS/mock_serviceability_manager_service.h | 2 + .../include/mock_ability_manager_service.h | 2 + .../mock_ability_delegator_stub.h | 4 + .../include/mock_ability_mgr_service.h | 2 + .../AMS/mock_ability_manager_service.h | 2 + .../AMS/mock_serviceability_manager_service.h | 2 + .../mock/include/mock_ability_mgr_service.h | 2 + .../ability_manager_client_branch_test.cpp | 25 ++++ .../ability_manager_stub_mock_test.h | 2 + .../ability_manager_proxy_test.cpp | 37 ++++++ .../ability_manager_stub_mock.h | 2 + .../ability_manager_service_test.cpp | 32 ++++- .../ability_manager_stub_impl_mock.h | 8 ++ .../ability_manager_stub_test.cpp | 34 +++++ .../ability_manager_stub_mock.h | 2 + .../mission_list_manager_test.cpp | 10 ++ .../ability_manager_stub_mock.h | 2 + .../mock_ability_manager_service.h | 2 + tools/test/mock/mock_ability_manager_stub.h | 2 + 41 files changed, 662 insertions(+), 17 deletions(-) diff --git a/frameworks/js/napi/js_mission_manager/js_mission_info_utils.cpp b/frameworks/js/napi/js_mission_manager/js_mission_info_utils.cpp index f1175928ed..12c3eff77b 100755 --- a/frameworks/js/napi/js_mission_manager/js_mission_info_utils.cpp +++ b/frameworks/js/napi/js_mission_manager/js_mission_info_utils.cpp @@ -44,6 +44,7 @@ NativeValue* CreateJsMissionInfo(NativeEngine &engine, const AAFwk::MissionInfo object->SetProperty("want", CreateJsWant(engine, missionInfo.want)); object->SetProperty("label", CreateJsValue(engine, missionInfo.label)); object->SetProperty("iconPath", CreateJsValue(engine, missionInfo.iconPath)); + object->SetProperty("abilityState", CreateJsValue(engine, missionInfo.abilityState)); return objValue; } diff --git a/frameworks/js/napi/js_mission_manager/mission_manager.cpp b/frameworks/js/napi/js_mission_manager/mission_manager.cpp index 8175f9af09..07017700b9 100755 --- a/frameworks/js/napi/js_mission_manager/mission_manager.cpp +++ b/frameworks/js/napi/js_mission_manager/mission_manager.cpp @@ -25,6 +25,7 @@ #include "js_runtime_utils.h" #include "mission_snapshot.h" #include "napi_common_start_options.h" +#include "native_engine/native_value.h" #include "permission_constants.h" #ifdef SUPPORT_GRAPHICS #include "pixel_map_napi.h" @@ -119,6 +120,18 @@ public: return (me != nullptr) ? me->OnMoveMissionToFront(*engine, *info) : nullptr; } + static NativeValue* MoveMissionsToForeground(NativeEngine* engine, NativeCallbackInfo* info) + { + JsMissionManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnMoveMissionsToForeground(*engine, *info) : nullptr; + } + + static NativeValue* MoveMissionsToBackground(NativeEngine* engine, NativeCallbackInfo* info) + { + JsMissionManager* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnMoveMissionsToBackground(*engine, *info) : nullptr; + } + private: NativeValue* OnRegisterMissionListener(NativeEngine &engine, NativeCallbackInfo &info) { @@ -522,6 +535,112 @@ private: return result; } + NativeValue *OnMoveMissionsToForeground(NativeEngine &engine, NativeCallbackInfo &info) + { + HILOG_INFO("%{public}s is called", __FUNCTION__); + std::vector missionIds; + if (info.argc < ARGC_ONE) { + HILOG_ERROR("OnMoveMissionsToForeground Not enough params"); + ThrowTooFewParametersError(engine); + return engine.CreateUndefined(); + } + NativeArray *nativeArray = ConvertNativeValueTo(info.argv[0]); + if (nativeArray == nullptr) { + HILOG_ERROR("OnMoveMissionsToForeground Parse missionIds array failed"); + ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + return engine.CreateUndefined(); + } + for (uint32_t i = 0; i < nativeArray->GetLength(); i++) { + int32_t missionId; + if (!ConvertFromJsValue(engine, nativeArray->GetElement(i), missionId)) { + HILOG_ERROR("OnMoveMissionsToForeground Parse missionId failed"); + ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + return engine.CreateUndefined(); + } + missionIds.push_back(missionId); + } + + int topMissionId = -1; + decltype(info.argc) unwrapArgc = 1; + if (info.argc > ARGC_ONE && info.argv[1]->TypeOf() == NATIVE_NUMBER) { + if (!ConvertFromJsValue(engine, info.argv[1], topMissionId)) { + HILOG_ERROR("OnMoveMissionsToForeground Parse topMissionId failed"); + ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + return engine.CreateUndefined(); + } + unwrapArgc++; + } + + AsyncTask::CompleteCallback complete = + [missionIds, topMissionId](NativeEngine &engine, AsyncTask &task, int32_t status) { + auto ret = + AAFwk::AbilityManagerClient::GetInstance()->MoveMissionsToForeground(missionIds, topMissionId); + if (ret == 0) { + task.ResolveWithNoError(engine, engine.CreateUndefined()); + } else { + task.Reject(engine, + CreateJsErrorByNativeErr(engine, ret, PermissionConstants::PERMISSION_MANAGE_MISSION)); + } + }; + + NativeValue* lastParam = (info.argc > unwrapArgc) ? info.argv[unwrapArgc] : nullptr; + NativeValue *result = nullptr; + AsyncTask::Schedule("MissioManager::OnMoveMissionsToForeground", engine, + CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } + + NativeValue* OnMoveMissionsToBackground(NativeEngine &engine, NativeCallbackInfo &info) + { + HILOG_INFO("%{public}s is called", __FUNCTION__); + std::vector missionIds; + + if (info.argc < ARGC_ONE) { + HILOG_ERROR("OnMoveMissionsToBackground Not enough params"); + ThrowTooFewParametersError(engine); + return engine.CreateUndefined(); + } + NativeArray *nativeArray = ConvertNativeValueTo(info.argv[0]); + if (nativeArray == nullptr) { + HILOG_ERROR("OnMoveMissionsToBackground Parse missionIds array failed"); + ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + return engine.CreateUndefined(); + } + for (uint32_t i = 0; i < nativeArray->GetLength(); i++) { + int32_t missionId; + if (!ConvertFromJsValue(engine, nativeArray->GetElement(i), missionId)) { + HILOG_ERROR("OnMoveMissionsToBackground Parse topMissionId failed"); + ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + return engine.CreateUndefined(); + } + missionIds.push_back(missionId); + } + + AsyncTask::CompleteCallback complete = + [missionIds](NativeEngine &engine, AsyncTask &task, int32_t status) { + std::vector resultMissionIds; + auto ret = AbilityManagerClient::GetInstance()->MoveMissionsToBackground(missionIds, resultMissionIds); + if (ret == 0) { + NativeValue* arrayValue = engine.CreateArray(resultMissionIds.size()); + NativeArray* array = ConvertNativeValueTo(arrayValue); + uint32_t index = 0; + for (const auto &missionId : resultMissionIds) { + array->SetElement(index++, CreateJsValue(engine, missionId)); + } + task.ResolveWithNoError(engine, arrayValue); + } else { + task.Reject(engine, + CreateJsErrorByNativeErr(engine, ret, PermissionConstants::PERMISSION_MANAGE_MISSION)); + } + }; + + NativeValue* lastParam = (info.argc <= 1) ? nullptr : info.argv[1]; + NativeValue* result = nullptr; + AsyncTask::Schedule("MissioManager::OnMoveMissionsToBackground", + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; + } + private: bool CheckOnOffType(NativeEngine &engine, NativeCallbackInfo &info) { @@ -583,6 +702,10 @@ NativeValue* JsMissionManagerInit(NativeEngine* engine, NativeValue* exportObj) BindNativeFunction(*engine, *object, "clearMission", moduleName, JsMissionManager::ClearMission); BindNativeFunction(*engine, *object, "clearAllMissions", moduleName, JsMissionManager::ClearAllMissions); BindNativeFunction(*engine, *object, "moveMissionToFront", moduleName, JsMissionManager::MoveMissionToFront); + BindNativeFunction(*engine, *object, + "moveMissionsToForeground", moduleName, JsMissionManager::MoveMissionsToForeground); + BindNativeFunction(*engine, *object, + "moveMissionsToBackground", moduleName, JsMissionManager::MoveMissionsToBackground); return engine->CreateUndefined(); } } // namespace AbilityRuntime diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index fe89b12be4..a53b0ffdd5 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -620,6 +620,22 @@ public: ErrCode MoveMissionToFront(int32_t missionId); ErrCode MoveMissionToFront(int32_t missionId, const StartOptions &startOptions); + /** + * Move missions to front + * @param missionIds Ids of target missions + * @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId); + + /** + * Move missions to background + * @param missionIds Ids of target missions + * @param result The result of move missions to background, and the array is sorted by zOrder + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode MoveMissionsToBackground(const std::vector& missionIds, std::vector& result); + /** * @brief Get mission id by ability token. * @@ -903,7 +919,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode AcquireShareData(const int32_t &missionId, const sptr &shareData); - + /** * Notify sharing data finished. * @param resultCode The result of sharing data. @@ -913,7 +929,7 @@ public: */ ErrCode ShareDataDone( const sptr &token, const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam); - + private: class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient { public: diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 95baac0150..2363b77dfc 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -564,6 +564,16 @@ public: virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) = 0; + virtual int MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) + { + return 0; + } + + virtual int MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) + { + return 0; + } + /** * Start Ability, connect session with common ability. * @@ -846,7 +856,7 @@ public: { return 0; } - + /** * Notify sharing data finished. * @param token The token of ability. @@ -1155,6 +1165,8 @@ public: REGISTER_SNAPSHOT_HANDLER = 1114, GET_MISSION_SNAPSHOT_INFO = 1115, UPDATE_MISSION_SNAPSHOT = 1116, + MOVE_MISSIONS_TO_FOREGROUND = 1117, + MOVE_MISSIONS_TO_BACKGROUND = 1118, // ipc id for user test(1120) START_USER_TEST = 1120, @@ -1184,9 +1196,9 @@ public: ABILITY_RECOVERY_ENABLE = 3011, QUERY_MISSION_VAILD = 3012, - + VERIFY_PERMISSION = 3013, - + ACQUIRE_SHARE_DATA = 4001, SHARE_DATA_DONE = 4002, }; diff --git a/interfaces/inner_api/ability_manager/include/mission_info.h b/interfaces/inner_api/ability_manager/include/mission_info.h index 748e0a5c31..19657cb4c8 100644 --- a/interfaces/inner_api/ability_manager/include/mission_info.h +++ b/interfaces/inner_api/ability_manager/include/mission_info.h @@ -40,6 +40,7 @@ struct MissionInfo : public Parcelable { std::string label; std::string iconPath; Want want; + int32_t abilityState = -1; }; /** diff --git a/interfaces/inner_api/ability_manager/include/window_manager_service_handler.h b/interfaces/inner_api/ability_manager/include/window_manager_service_handler.h index 28a839a5ff..296b574e5c 100644 --- a/interfaces/inner_api/ability_manager/include/window_manager_service_handler.h +++ b/interfaces/inner_api/ability_manager/include/window_manager_service_handler.h @@ -44,6 +44,10 @@ public: virtual void NotifyAnimationAbilityDied(sptr info) = 0; + virtual int32_t MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) = 0; + + virtual int32_t MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) = 0; + enum WMSCmd { // ipc id for NotifyWindowTransition ON_NOTIFY_WINDOW_TRANSITION, @@ -62,6 +66,12 @@ public: // ipc id for NotifyAnimationAbilityDied ON_NOTIFY_ANIMATION_ABILITY_DIED, + + // ipc id for MoveMissionsToForeground + ON_MOVE_MISSINONS_TO_FOREGROUND, + + // ipc id for MoveMissionsToBackground + ON_MOVE_MISSIONS_TO_BACKGROUND, }; }; } // namespace AAFwk diff --git a/interfaces/inner_api/ability_manager/include/window_manager_service_handler_proxy.h b/interfaces/inner_api/ability_manager/include/window_manager_service_handler_proxy.h index 24abcbe771..845abb3cb8 100644 --- a/interfaces/inner_api/ability_manager/include/window_manager_service_handler_proxy.h +++ b/interfaces/inner_api/ability_manager/include/window_manager_service_handler_proxy.h @@ -41,7 +41,12 @@ public: virtual void NotifyAnimationAbilityDied(sptr info) override; -private: + virtual int32_t MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) override; + + virtual int32_t MoveMissionsToBackground(const std::vector& missionIds, + std::vector& result) override; + + private: static inline BrokerDelegator delegator_; }; } // namespace AAFwk diff --git a/interfaces/inner_api/ability_manager/include/window_manager_service_handler_stub.h b/interfaces/inner_api/ability_manager/include/window_manager_service_handler_stub.h index 4cf2622b84..2a32fabb49 100644 --- a/interfaces/inner_api/ability_manager/include/window_manager_service_handler_stub.h +++ b/interfaces/inner_api/ability_manager/include/window_manager_service_handler_stub.h @@ -42,6 +42,8 @@ private: int StartingWindowHot(MessageParcel &data, MessageParcel &reply); int CancelStartingWindowInner(MessageParcel &data, MessageParcel &reply); int NotifyAnimationAbilityDiedInner(MessageParcel &data, MessageParcel &reply); + int MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply); + int MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply); using RequestFuncType = int (WindowManagerServiceHandlerStub::*)(MessageParcel &data, MessageParcel &reply); std::map requestFuncMap_; diff --git a/interfaces/inner_api/ability_manager/src/window_manager_service_handler_proxy.cpp b/interfaces/inner_api/ability_manager/src/window_manager_service_handler_proxy.cpp index a88a5a3fb2..cce3ba4fa6 100644 --- a/interfaces/inner_api/ability_manager/src/window_manager_service_handler_proxy.cpp +++ b/interfaces/inner_api/ability_manager/src/window_manager_service_handler_proxy.cpp @@ -177,6 +177,78 @@ void WindowManagerServiceHandlerProxy::NotifyAnimationAbilityDied(sptr& missionIds, + int32_t topMissionId) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) { + HILOG_ERROR("WriteInterfaceToken failed"); + return ERR_AAFWK_PARCEL_FAIL; + } + + if (!data.WriteInt32Vector(missionIds)) { + HILOG_ERROR("Write missionIds failed"); + return ERR_AAFWK_PARCEL_FAIL; + } + + if (!data.WriteInt32(topMissionId)) { + HILOG_ERROR("Write TopMissionId failed"); + return ERR_AAFWK_PARCEL_FAIL; + } + + auto remote = Remote(); + if (remote == nullptr) { + HILOG_ERROR("remote is nullptr."); + return ERR_INVALID_CONTINUATION_FLAG; + } + int error = remote->SendRequest(WMSCmd::ON_MOVE_MISSINONS_TO_FOREGROUND, data, reply, option); + if (error != ERR_NONE) { + HILOG_ERROR("SendoRequest failed, error: %{public}d", error); + return ERR_AAFWK_PARCEL_FAIL; + } + return reply.ReadInt32(); +} + +int32_t WindowManagerServiceHandlerProxy::MoveMissionsToBackground(const std::vector& missionIds, + std::vector& result) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) { + HILOG_ERROR("WriteInterfaceToken failed"); + return ERR_AAFWK_PARCEL_FAIL; + } + + if (!data.WriteInt32Vector(missionIds)) { + HILOG_ERROR("Write missionIds failed"); + return ERR_AAFWK_PARCEL_FAIL; + } + + auto remote = Remote(); + if (remote == nullptr) { + HILOG_ERROR("remote is nullptr."); + return ERR_INVALID_CONTINUATION_FLAG; + } + int error = remote->SendRequest(WMSCmd::ON_MOVE_MISSIONS_TO_BACKGROUND, data, reply, option); + if (error != ERR_NONE) { + HILOG_ERROR("SendoRequest failed, error: %{public}d", error); + return ERR_AAFWK_PARCEL_FAIL; + } + if (!reply.ReadInt32Vector(&result)) { + HILOG_ERROR("Read hide result failed"); + return ERR_AAFWK_PARCEL_FAIL; + }; + return reply.ReadInt32(); +} + } // namespace AAFwk } // namespace OHOS #endif diff --git a/interfaces/inner_api/ability_manager/src/window_manager_service_handler_stub.cpp b/interfaces/inner_api/ability_manager/src/window_manager_service_handler_stub.cpp index 61faece3b9..20b65aa77c 100644 --- a/interfaces/inner_api/ability_manager/src/window_manager_service_handler_stub.cpp +++ b/interfaces/inner_api/ability_manager/src/window_manager_service_handler_stub.cpp @@ -40,6 +40,8 @@ void WindowManagerServiceHandlerStub::Init() requestFuncMap_[ON_CANCEL_STARTING_WINDOW] = &WindowManagerServiceHandlerStub::CancelStartingWindowInner; requestFuncMap_[ON_NOTIFY_ANIMATION_ABILITY_DIED] = &WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner; + requestFuncMap_[ON_MOVE_MISSINONS_TO_FOREGROUND] = &WindowManagerServiceHandlerStub::MoveMissionsToForegroundInner; + requestFuncMap_[ON_MOVE_MISSIONS_TO_BACKGROUND] = &WindowManagerServiceHandlerStub::MoveMissionsToBackgroundInner; } int WindowManagerServiceHandlerStub::OnRemoteRequest( @@ -165,6 +167,29 @@ int WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner(MessageParc NotifyAnimationAbilityDied(info); return ERR_OK; } + +int WindowManagerServiceHandlerStub::MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + std::vector missionIds; + data.ReadInt32Vector(&missionIds); + int32_t topMissionId = data.ReadInt32(); + auto errCode = MoveMissionsToForeground(missionIds, topMissionId); + reply.WriteInt32(errCode); + return errCode; +} + +int WindowManagerServiceHandlerStub::MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + std::vector missionIds; + std::vector result; + data.ReadInt32Vector(&missionIds); + auto errCode = MoveMissionsToBackground(missionIds, result); + reply.WriteInt32Vector(result); + return errCode; +} + } // namespace AAFwk } // namespace OHOS #endif diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index b9a58dc4a3..42d41ceb6b 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -485,6 +485,11 @@ public: virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; + virtual int MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) override; + + virtual int MoveMissionsToBackground(const std::vector& missionIds, + std::vector& result) override; + /** * Start Ability, connect session with common ability. * @@ -712,7 +717,7 @@ public: const int32_t &missionId, const sptr &shareData) override; virtual int32_t ShareDataDone(const sptr &token, const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam) override; - + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 8ddf4bcd04..236db32d48 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -591,6 +591,11 @@ public: virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; + virtual int MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) override; + + virtual int MoveMissionsToBackground(const std::vector& missionIds, + std::vector& result) override; + virtual int32_t GetMissionIdByToken(const sptr &token) override; virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index b2084645af..42ccd56ff2 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -137,6 +137,8 @@ private: int CleanMissionInner(MessageParcel &data, MessageParcel &reply); int CleanAllMissionsInner(MessageParcel &data, MessageParcel &reply); int MoveMissionToFrontInner(MessageParcel &data, MessageParcel &reply); + int MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply); + int MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply); int GetMissionIdByTokenInner(MessageParcel &data, MessageParcel &reply); // for new version ability (call ability) diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index b16cf6a04a..a3c30a6d75 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -920,6 +920,7 @@ private: const AbilityRequest &abilityRequest); void InitColdStartingWindowResource(const std::shared_ptr &resourceMgr); void GetColdStartingWindowResource(std::shared_ptr &bg, uint32_t &bgColor); + void SetAbilityStateInner(AbilityState state); #endif static int64_t abilityRecordId; diff --git a/services/abilitymgr/include/mission_info_mgr.h b/services/abilitymgr/include/mission_info_mgr.h index 2e4b531f50..ecc047fa1c 100644 --- a/services/abilitymgr/include/mission_info_mgr.h +++ b/services/abilitymgr/include/mission_info_mgr.h @@ -21,6 +21,7 @@ #include #include +#include "ability_state.h" #include "inner_mission_info.h" #include "mission_listener_controller.h" #include "mission_snapshot.h" @@ -121,6 +122,15 @@ public: */ int UpdateMissionLabel(int32_t missionId, const std::string& label); + /** + * @brief Set mission abilityState. + * + * @param missionId indicates this mission id. + * @param abilityState indicates this mission abilityState. + * @return 0 if success. + */ + void SetMissionAbilityState(int32_t missionId, AbilityState state); + /** * @brief dump mission info * diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index ac4e12a8c9..527c42e626 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -744,6 +744,23 @@ ErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId, const StartO return abms->MoveMissionToFront(missionId, startOptions); } +ErrCode AbilityManagerClient::MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) +{ + HILOG_INFO("MoveMissionsToForeground begin."); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + return abms->MoveMissionsToForeground(missionIds, topMissionId); +} + +ErrCode AbilityManagerClient::MoveMissionsToBackground(const std::vector& missionIds, + std::vector& result) +{ + HILOG_INFO("MoveMissionsToBackground begin."); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + return abms->MoveMissionsToBackground(missionIds, result); +} + ErrCode AbilityManagerClient::GetMissionIdByToken(const sptr &token, int32_t &missionId) { auto abms = GetAbilityManager(); diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index c4ea736cee..7614df9e8b 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -2352,6 +2352,73 @@ int AbilityManagerProxy::MoveMissionToFront(int32_t missionId, const StartOption return reply.ReadInt32(); } +int AbilityManagerProxy::MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + return INNER_ERR; + } + + if (!data.WriteInt32Vector(missionIds)) { + HILOG_ERROR("mission id write failed."); + return INNER_ERR; + } + + if (!data.WriteInt32(topMissionId)) { + HILOG_ERROR("top mission id write failed."); + return INNER_ERR; + } + + auto remote = Remote(); + if (remote == nullptr) { + HILOG_ERROR("%{public}s remote is null", __func__); + return ERR_NULL_OBJECT; + } + + auto error = remote->SendRequest(IAbilityManager::MOVE_MISSIONS_TO_FOREGROUND, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("query front missionInfo failed: send request error: %{public}d", error); + return error; + } + + return reply.ReadInt32(); +} + +int AbilityManagerProxy::MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + return INNER_ERR; + } + + if (!data.WriteInt32Vector(missionIds)) { + HILOG_ERROR("mission id write failed."); + return INNER_ERR; + } + + auto remote = Remote(); + if (remote == nullptr) { + HILOG_ERROR("%{public}s remote is null", __func__); + return ERR_NULL_OBJECT; + } + + auto error = remote->SendRequest(IAbilityManager::MOVE_MISSIONS_TO_BACKGROUND, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("query front missionInfo failed: send request error: %{public}d", error); + return error; + } + + if (!reply.ReadInt32Vector(&result)) { + HILOG_ERROR("read result failed"); + return INNER_ERR; + } + return reply.ReadInt32(); +} + int AbilityManagerProxy::StartUser(int userId) { int error; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 0b306f6f59..9b1cdbed39 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -35,6 +35,7 @@ #include "ability_manager_errors.h" #include "ability_util.h" #include "application_util.h" +#include "errors.h" #include "hitrace_meter.h" #include "bundle_mgr_client.h" #include "distributed_client.h" @@ -43,6 +44,7 @@ #include "if_system_ability_manager.h" #include "in_process_call_wrapper.h" #include "ipc_skeleton.h" +#include "ipc_types.h" #include "iservice_registry.h" #include "itest_observer.h" #include "mission_info_mgr.h" @@ -2609,6 +2611,45 @@ int AbilityManagerService::MoveMissionToFront(int32_t missionId, const StartOpti return currentMissionListManager_->MoveMissionToFront(missionId, options); } +int AbilityManagerService::MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) +{ + CHECK_CALLER_IS_SYSTEM_APP; + if (!PermissionVerification::GetInstance()->VerifyMissionPermission()) { + HILOG_ERROR("%{public}s: Permission verification failed", __func__); + return CHECK_PERMISSION_FAILED; + } + if (wmsHandler_) { + auto ret = wmsHandler_->MoveMissionsToForeground(missionIds, topMissionId); + if (ret) { + HILOG_ERROR("MoveMissionsToForeground failed, missiondIds may be invalid"); + return ERR_INVALID_VALUE; + } else { + return NO_ERROR; + } + } + return ERR_NO_INIT; +} + +int AbilityManagerService::MoveMissionsToBackground(const std::vector& missionIds, + std::vector& result) +{ + CHECK_CALLER_IS_SYSTEM_APP; + if (!PermissionVerification::GetInstance()->VerifyMissionPermission()) { + HILOG_ERROR("%{public}s: Permission verification failed", __func__); + return CHECK_PERMISSION_FAILED; + } + if (wmsHandler_) { + auto ret = wmsHandler_->MoveMissionsToBackground(missionIds, result); + if (ret) { + HILOG_ERROR("MoveMissionsToBackground failed, missiondIds may be invalid"); + return ERR_INVALID_VALUE; + } else { + return NO_ERROR; + } + } + return ERR_NO_INIT; +} + int32_t AbilityManagerService::GetMissionIdByToken(const sptr &token) { HILOG_INFO("request GetMissionIdByToken."); diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index b3fe3c9d4d..f8024797dc 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -112,6 +112,8 @@ void AbilityManagerStub::SecondStepInit() requestFuncMap_[CLEAN_ALL_MISSIONS] = &AbilityManagerStub::CleanAllMissionsInner; requestFuncMap_[MOVE_MISSION_TO_FRONT] = &AbilityManagerStub::MoveMissionToFrontInner; requestFuncMap_[MOVE_MISSION_TO_FRONT_BY_OPTIONS] = &AbilityManagerStub::MoveMissionToFrontByOptionsInner; + requestFuncMap_[MOVE_MISSIONS_TO_FOREGROUND] = &AbilityManagerStub::MoveMissionsToForegroundInner; + requestFuncMap_[MOVE_MISSIONS_TO_BACKGROUND] = &AbilityManagerStub::MoveMissionsToBackgroundInner; requestFuncMap_[START_CALL_ABILITY] = &AbilityManagerStub::StartAbilityByCallInner; requestFuncMap_[CALL_REQUEST_DONE] = &AbilityManagerStub::CallRequestDoneInner; requestFuncMap_[RELEASE_CALL_ABILITY] = &AbilityManagerStub::ReleaseCallInner; @@ -1154,6 +1156,38 @@ int AbilityManagerStub::MoveMissionToFrontByOptionsInner(MessageParcel &data, Me return NO_ERROR; } +int AbilityManagerStub::MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + std::vector missionIds; + data.ReadInt32Vector(&missionIds); + int32_t topMissionId = data.ReadInt32(); + int32_t errCode = MoveMissionsToForeground(missionIds, topMissionId); + if (!reply.WriteInt32(errCode)) { + return ERR_INVALID_VALUE; + } + return errCode; +} + +int AbilityManagerStub::MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + std::vector missionIds; + std::vector result; + + data.ReadInt32Vector(&missionIds); + int32_t errCode = MoveMissionsToBackground(missionIds, result); + HILOG_DEBUG("%{public}s is called. resultSize: %{public}zu", __func__, result.size()); + if (!reply.WriteInt32Vector(result)) { + HILOG_ERROR("%{public}s is called. WriteInt32Vector Failed", __func__); + return ERR_INVALID_VALUE; + } + if (!reply.WriteInt32(errCode)) { + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} + int AbilityManagerStub::StartAbilityByCallInner(MessageParcel &data, MessageParcel &reply) { HILOG_DEBUG("AbilityManagerStub::StartAbilityByCallInner begin."); diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 89cb4c2739..15cdc3b7f6 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -329,7 +329,7 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag) // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. - currentState_ = AbilityState::FOREGROUNDING; + SetAbilityStateInner(AbilityState::FOREGROUNDING); foregroundingTime_ = AbilityUtil::SystemTimeMillis(); lifeCycleStateInfo_.sceneFlag = sceneFlag; lifecycleDeal_->ForegroundNew(want_, lifeCycleStateInfo_, sessionInfo_); @@ -1002,7 +1002,7 @@ void AbilityRecord::BackgroundAbility(const Closure &task) // schedule background after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. - currentState_ = AbilityState::BACKGROUNDING; + SetAbilityStateInner(AbilityState::BACKGROUNDING); lifecycleDeal_->BackgroundNew(want_, lifeCycleStateInfo_, sessionInfo_); } @@ -1043,9 +1043,15 @@ bool AbilityRecord::IsForeground() const return currentState_ == AbilityState::FOREGROUND || currentState_ == AbilityState::FOREGROUNDING; } -void AbilityRecord::SetAbilityState(AbilityState state) +void AbilityRecord::SetAbilityStateInner(AbilityState state) { currentState_ = state; + DelayedSingleton::GetInstance()->SetMissionAbilityState(missionId_, currentState_); +} + +void AbilityRecord::SetAbilityState(AbilityState state) +{ + SetAbilityStateInner(state); if (state == AbilityState::FOREGROUND || state == AbilityState::ACTIVE || state == AbilityState::BACKGROUND) { SetRestarting(false); } @@ -1181,7 +1187,7 @@ void AbilityRecord::Activate() // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. - currentState_ = AbilityState::ACTIVATING; + SetAbilityStateInner(AbilityState::ACTIVATING); lifecycleDeal_->Activate(want_, lifeCycleStateInfo_); // update ability state to appMgr service when restart @@ -1206,7 +1212,7 @@ void AbilityRecord::Inactivate() // schedule inactive after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. - currentState_ = AbilityState::INACTIVATING; + SetAbilityStateInner(AbilityState::INACTIVATING); lifecycleDeal_->Inactivate(want_, lifeCycleStateInfo_, sessionInfo_); } @@ -1231,7 +1237,7 @@ void AbilityRecord::Terminate(const Closure &task) } // schedule background after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. - currentState_ = AbilityState::TERMINATING; + SetAbilityStateInner(AbilityState::TERMINATING); lifecycleDeal_->Terminate(want_, lifeCycleStateInfo_); } @@ -1728,7 +1734,7 @@ void AbilityRecord::DumpAbilityState( if (callContainer_) { callContainer_->Dump(info); } - + std::string isKeepAlive = isKeepAlive_ ? "true" : "false"; dumpInfo = " isKeepAlive: " + isKeepAlive; info.push_back(dumpInfo); @@ -1768,7 +1774,7 @@ void AbilityRecord::DumpService(std::vector &info, std::vector lock(mutex_); + auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) { + return missionId == info.missionInfo.id; + }); + if (it == missionInfoList_.end()) { + HILOG_ERROR("SetMissionAbilityState failed, missionId %{public}d not exists", missionId); + return; + } + it->missionInfo.abilityState = state; +} + bool MissionInfoMgr::LoadAllMissionInfo() { std::lock_guard lock(mutex_); diff --git a/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h b/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h index e2ca44a0cc..260d17d1a2 100644 --- a/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h +++ b/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h @@ -139,6 +139,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr& token)); MOCK_METHOD2(AcquireShareData, int32_t(const int32_t &missionId, const sptr &shareData)); MOCK_METHOD4(ShareDataDone, int32_t(const sptr &token, diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h index 0e5296ea91..a484a52aa4 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h @@ -122,6 +122,8 @@ public: const std::shared_ptr& icon)); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr& token)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); diff --git a/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h b/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h index 1565ff96f5..881914aad6 100644 --- a/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h +++ b/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h @@ -112,6 +112,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string&)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector& info)); @@ -257,6 +259,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD1(ClearUpApplicationData, int(const std::string&)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector& info)); diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h index b9a6e24fb0..758664a4f8 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h @@ -73,6 +73,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr& token)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); diff --git a/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h b/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h index 35553fbeb1..018e41ca34 100644 --- a/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h +++ b/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h @@ -133,6 +133,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); diff --git a/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h b/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h index 08ff86d33d..af53517f7a 100644 --- a/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h +++ b/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h @@ -136,6 +136,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); diff --git a/test/moduletest/mock/include/mock_ability_mgr_service.h b/test/moduletest/mock/include/mock_ability_mgr_service.h index ee04164585..4ea1f04ced 100644 --- a/test/moduletest/mock/include/mock_ability_mgr_service.h +++ b/test/moduletest/mock/include/mock_ability_mgr_service.h @@ -96,6 +96,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp index a9b54357b1..7c60c83ed5 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp @@ -519,6 +519,31 @@ HWTEST_F(AbilityManagerClientBranchTest, MoveMissionToFront_0200, TestSize.Level } +/** + * @tc.name: AbilityManagerClient_MoveMissionsToForeground_0100 + * @tc.desc: MoveMissionsToForeground + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AbilityManagerClientBranchTest, MoveMissionsToForeground_0100, TestSize.Level1) +{ + auto result = client_->MoveMissionsToForeground({1, 2, 3}, 1); + EXPECT_EQ(result, ERR_OK); +} + +/** + * @tc.name: AbilityManagerClient_MoveMissionsToBackground_0100 + * @tc.desc: MoveMissionsToBackground + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AbilityManagerClientBranchTest, MoveMissionsToBackground_0100, TestSize.Level1) +{ + std::vector rs; + auto result = client_->MoveMissionsToBackground({1, 2, 3}, rs); + EXPECT_EQ(result, ERR_OK); +} + /** * @tc.name: AbilityManagerClient_GetAbilityRunningInfos_0100 * @tc.desc: GetAbilityRunningInfos diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h b/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h index 97e259f663..18c2a2f5a9 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h @@ -299,6 +299,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr& target, std::shared_ptr& info)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); diff --git a/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp b/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp index 907d87a6cd..9da47a5052 100644 --- a/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp +++ b/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp @@ -1471,6 +1471,43 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_MoveMissionToFront_001, Te EXPECT_EQ(res, NO_ERROR); } +/* + * Feature: AbilityManagerService + * Function: MoveMissionsToForeground + * SubFunction: NA + * FunctionPoints: AbilityManagerService MoveMissionsToForeground + * EnvConditions: NA + * CaseDescription: Verify the normal process of MoveMissionsToForeground + */ +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_MoveMissionsToForeground_001, TestSize.Level1) +{ + EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) + .Times(1) + .WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest)); + auto res = proxy_->MoveMissionsToForeground({1, 2, 3}, 1); + EXPECT_EQ(IAbilityManager::MOVE_MISSIONS_TO_FOREGROUND, mock_->code_); + EXPECT_EQ(res, NO_ERROR); +} + +/* + * Feature: AbilityManagerService + * Function: MoveMissionsToBackground + * SubFunction: NA + * FunctionPoints: AbilityManagerService MoveMissionsToBackground + * EnvConditions: NA + * CaseDescription: Verify the normal process of MoveMissionsToBackground + */ +HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_MoveMissionsToBackground_001, TestSize.Level1) +{ + EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) + .Times(1) + .WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest)); + std::vector rs; + auto res = proxy_->MoveMissionsToBackground({1, 2, 3}, rs); + EXPECT_EQ(IAbilityManager::MOVE_MISSIONS_TO_BACKGROUND, mock_->code_); + EXPECT_EQ(res, NO_ERROR); +} + /* * Feature: AbilityManagerService * Function: StartUser diff --git a/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h b/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h index a08ffab35e..7a55410079 100644 --- a/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h @@ -299,6 +299,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); diff --git a/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp b/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp index 1b27b37cd6..09461a1da4 100755 --- a/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp +++ b/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp @@ -680,7 +680,7 @@ HWTEST_F(AbilityManagerServiceTest, StartRemoteAbility_001, TestSize.Level1) Want want; // AddStartControlParam EXPECT_EQ(abilityMs_->StartRemoteAbility(want, 1, 1, nullptr), ERR_INVALID_VALUE); - + // IsStartFreeInstall MyFlag::flag_ = 1; unsigned int flag = 0x00000800; @@ -696,7 +696,7 @@ HWTEST_F(AbilityManagerServiceTest, StartRemoteAbility_001, TestSize.Level1) want.SetFlags(0); want.SetParam("ohos.aafwk.param.startAbilityForResult", true); EXPECT_EQ(abilityMs_->StartRemoteAbility(want, 1, 1, nullptr), ERR_INVALID_VALUE); - + want.SetParam("test", true); sptr callerToken = MockToken(AbilityType::PAGE); EXPECT_EQ(abilityMs_->StartRemoteAbility(want, 1, 1, callerToken), ERR_INVALID_VALUE); @@ -1360,6 +1360,34 @@ HWTEST_F(AbilityManagerServiceTest, MoveMissionToFront_002, TestSize.Level1) HILOG_INFO("AbilityManagerServiceTest MoveMissionToFront_002 end"); } +/* + * Feature: AbilityManagerService + * Function: MoveMissionsToForeground + * SubFunction: NA + * FunctionPoints: AbilityManagerService MoveMissionToFront + */ +HWTEST_F(AbilityManagerServiceTest, MoveMissionsToForeground_001, TestSize.Level1) +{ + HILOG_INFO("AbilityManagerServiceTest MoveMissionsToForeground_001 start"); + EXPECT_EQ(abilityMs_->MoveMissionsToForeground({1, 2, 3}, 1), CHECK_PERMISSION_FAILED); + HILOG_INFO("AbilityManagerServiceTest MoveMissionsToForeground_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: MoveMissionsToBackground + * SubFunction: NA + * FunctionPoints: AbilityManagerService MoveMissionToFront + */ +HWTEST_F(AbilityManagerServiceTest, MoveMissionsToBackground_001, TestSize.Level1) +{ + HILOG_INFO("AbilityManagerServiceTest MoveMissionsToBackground_001 start"); + std::vector rs; + EXPECT_EQ(abilityMs_->MoveMissionsToBackground({1, 2, 3}, rs), CHECK_PERMISSION_FAILED); + EXPECT_TRUE(rs.empty()); + HILOG_INFO("AbilityManagerServiceTest MoveMissionsToBackground_001 end"); +} + /* * Feature: AbilityManagerService * Function: GetMissionIdByToken diff --git a/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h b/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h index c104c6d2b6..0e94a9bda7 100644 --- a/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h +++ b/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h @@ -253,6 +253,14 @@ public: { return 0; } + int MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) override + { + return 0; + } + int MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) override + { + return 0; + } int32_t GetMissionIdByToken(const sptr& token) override { return 0; diff --git a/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp b/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp index 8ba4adf6ca..60150c6a68 100644 --- a/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp +++ b/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp @@ -1439,6 +1439,40 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_MoveMissionToFrontInner_001, EXPECT_EQ(res, NO_ERROR); } +/* + * Feature: AbilityManagerService + * Function: MoveMissionsToForegroundInner + * SubFunction: NA + * FunctionPoints: AbilityManagerService MoveMissionsToForegroundInner + * EnvConditions: NA + * CaseDescription: Verify the function MoveMissionsToForegroundInner is normal flow. + */ +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_MoveMissionsToForegroundInner_001, TestSize.Level1) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + MessageParcel data; + MessageParcel reply; + auto res = stub_->MoveMissionsToForegroundInner(data, reply); + EXPECT_EQ(res, NO_ERROR); +} + +/* + * Feature: AbilityManagerService + * Function: MoveMissionsToBackgroundInner + * SubFunction: NA + * FunctionPoints: AbilityManagerService MoveMissionsToBackgroundInner + * EnvConditions: NA + * CaseDescription: Verify the function MoveMissionsToBackgroundInner is normal flow. + */ +HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_MoveMissionsToBackgroundInner_001, TestSize.Level1) +{ + HILOG_DEBUG("%{public}s is called.", __func__); + MessageParcel data; + MessageParcel reply; + auto res = stub_->MoveMissionsToBackgroundInner(data, reply); + EXPECT_EQ(res, NO_ERROR); +} + /* * Feature: AbilityManagerService * Function: GetMissionIdByTokenInner diff --git a/test/unittest/ability_manager_test/ability_manager_stub_mock.h b/test/unittest/ability_manager_test/ability_manager_stub_mock.h index c803b904e9..fe453adc5e 100644 --- a/test/unittest/ability_manager_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_test/ability_manager_stub_mock.h @@ -309,6 +309,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr& target, std::shared_ptr& info)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); diff --git a/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp b/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp index 9782b161b3..1280d31756 100644 --- a/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp +++ b/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp @@ -109,6 +109,16 @@ public: g_cancelStartingWindowCalled = true; } + virtual int32_t MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) + { + return 0; + } + + virtual int32_t MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) + { + return 0; + } + virtual sptr AsObject() { return nullptr; diff --git a/test/unittest/service_extension_context_test/ability_manager_stub_mock.h b/test/unittest/service_extension_context_test/ability_manager_stub_mock.h index 3c4071910f..96d0556221 100644 --- a/test/unittest/service_extension_context_test/ability_manager_stub_mock.h +++ b/test/unittest/service_extension_context_test/ability_manager_stub_mock.h @@ -299,6 +299,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(GetWantSenderInfo, int(const sptr& target, std::shared_ptr& info)); MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector& info)); diff --git a/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h b/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h index 26d61aed00..abed1d7b9b 100644 --- a/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h +++ b/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h @@ -124,6 +124,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 31d4846f0b..a9c580016c 100644 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -107,6 +107,8 @@ public: MOCK_METHOD0(CleanAllMissions, int()); MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId)); MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions)); + MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector& missionIds, int32_t topMissionId)); + MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector& missionIds, std::vector& result)); MOCK_METHOD2(SetMissionLabel, int(const sptr& token, const std::string& label)); MOCK_METHOD2(SetMissionIcon, int(const sptr& token, const std::shared_ptr& icon)); From c30189175caf1ec9fe5513822a4ff52b95211465 Mon Sep 17 00:00:00 2001 From: wangkailong Date: Thu, 13 Apr 2023 19:42:06 +0800 Subject: [PATCH 16/16] back Signed-off-by: wangkailong Change-Id: Ia69c71d746aebf25f603aa5083f45164a32a03cc --- .../include/mock_form_mgr_proxy.h | 1 + .../include/mock_form_mgr_service.h | 5 +++++ .../form_extension_context_mock_test.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_proxy.h b/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_proxy.h index 120c7fb629..3e1c3bb9a3 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_proxy.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_proxy.h @@ -49,6 +49,7 @@ public: MOCK_METHOD2(DumpFormInfoByBundleName, int(const std::string &bundleName, std::string &formInfos)); MOCK_METHOD3(AcquireFormState, int(const Want &want, const sptr &callerToken, FormStateInfo &stateInfo)); MOCK_METHOD0(CheckFMSReady, bool()); + MOCK_METHOD2(SetBackgroundFunction, int32_t(const std::string method, const std::string params)); }; } } diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_service.h b/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_service.h index b3822c1451..c92ce020cf 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_service.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_form_mgr_service.h @@ -227,6 +227,11 @@ public: { return 0; } + + int32_t SetBackgroundFunction(const std::string method, const std::string params) + { + return ERR_OK; + }; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/frameworks_kits_appkit_native_test/form_extension_context_mock_test.h b/test/unittest/frameworks_kits_appkit_native_test/form_extension_context_mock_test.h index f7fd5b6ea0..aa8fe043ae 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/form_extension_context_mock_test.h +++ b/test/unittest/frameworks_kits_appkit_native_test/form_extension_context_mock_test.h @@ -196,6 +196,10 @@ public: { return false; } + int32_t SetBackgroundFunction(const std::string method, const std::string params) override + { + return 0; + } }; } // namespace AppExecFwk } // namespace OHOS