diff --git a/access_token.gni b/access_token.gni index d62e2c4a4b363d44f82ee9dd9b40512174681eaa..74996a534c2ea817b76ed50805dbc271ea4fbfaa 100644 --- a/access_token.gni +++ b/access_token.gni @@ -98,13 +98,6 @@ if (!defined(global_parts_info) || security_component_enhance_enable = false } -if (!defined(global_parts_info) || - defined(global_parts_info.resourceschedule_ffrt)) { - resourceschedule_ffrt_enable = true -} else { - resourceschedule_ffrt_enable = false -} - if (!defined(global_parts_info) || defined(global_parts_info.customization_config_policy)) { customization_config_policy_enable = true diff --git a/bundle.json b/bundle.json index 9a569db586553ce268493299cd781be24b951201..f98e6ef958c31ca975c3b74d70b9750ff01167c8 100644 --- a/bundle.json +++ b/bundle.json @@ -41,7 +41,6 @@ "device_manager", "dsoftbus", "eventhandler", - "ffrt", "hicollie", "hisysevent", "hitrace", diff --git a/services/accesstokenmanager/BUILD.gn b/services/accesstokenmanager/BUILD.gn index 7d5f3bbd0e628b98d10e352fa5754b48d693b9e4..aae43a11faa7a3137c709e6573572d4e4a45b762 100644 --- a/services/accesstokenmanager/BUILD.gn +++ b/services/accesstokenmanager/BUILD.gn @@ -176,11 +176,6 @@ if (is_standard_system) { external_deps += [ "hitrace:hitrace_meter" ] } - if (resourceschedule_ffrt_enable) { - external_deps += [ "ffrt:libffrt" ] - cflags_cc += [ "-DRESOURCESCHEDULE_FFRT_ENABLE" ] - } - if (access_token_background_task_mgr_continuous_task_enable == true) { cflags_cc += [ "-DBGTASKMGR_CONTINUOUS_TASK_ENABLE" ] include_dirs += [ diff --git a/services/accesstokenmanager/main/cpp/include/callback/callback_manager.h b/services/accesstokenmanager/main/cpp/include/callback/callback_manager.h index 56f976f7caac5921fc41b7a6ee64f81e436969a3..5999aee8faff237e31bd5d46950fe3d0e8a75ec3 100644 --- a/services/accesstokenmanager/main/cpp/include/callback/callback_manager.h +++ b/services/accesstokenmanager/main/cpp/include/callback/callback_manager.h @@ -21,9 +21,6 @@ #include "access_token.h" #include "accesstoken_common_log.h" -#ifdef RESOURCESCHEDULE_FFRT_ENABLE -#include "ffrt.h" -#endif #include "i_permission_state_callback.h" #include "permission_state_change_info.h" #include "accesstoken_callback_proxys.h" @@ -59,11 +56,7 @@ private: int32_t changeType); void GetCallbackObjectList(AccessTokenID tokenID, const std::string& permName, std::vector>& list); -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - ffrt::mutex mutex_; -#else std::mutex mutex_; -#endif std::vector callbackInfoList_; sptr callbackDeathRecipient_; }; diff --git a/services/accesstokenmanager/main/cpp/include/token/token_modify_notifier.h b/services/accesstokenmanager/main/cpp/include/token/token_modify_notifier.h index 7f30196bdffe49ee6b12a8c8c0fa09fa2ff4fef9..bff43d416d4796c173b37b86dbd266054a2c4233 100644 --- a/services/accesstokenmanager/main/cpp/include/token/token_modify_notifier.h +++ b/services/accesstokenmanager/main/cpp/include/token/token_modify_notifier.h @@ -24,9 +24,7 @@ #include "i_token_sync_callback.h" #include "nocopyable.h" #include "rwlock.h" -#ifndef RESOURCESCHEDULE_FFRT_ENABLE #include "thread_pool.h" -#endif #include "callback_death_recipients.h" namespace OHOS { @@ -44,11 +42,6 @@ public: int32_t GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID); int32_t RegisterTokenSyncCallback(const sptr& callback); int32_t UnRegisterTokenSyncCallback(); -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - int32_t GetCurTaskNum(); - void AddCurTaskNum(); - void ReduceCurTaskNum(); -#endif private: TokenModifyNotifier(); @@ -58,11 +51,7 @@ private: OHOS::Utils::RWLock initLock_; OHOS::Utils::RWLock listLock_; OHOS::Utils::RWLock notifyLock_; -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - std::atomic_int32_t curTaskNum_; -#else OHOS::ThreadPool notifyTokenWorker_; -#endif std::set observationSet_; std::vector deleteTokenList_; std::vector modifiedTokenList_; diff --git a/services/accesstokenmanager/main/cpp/src/callback/callback_manager.cpp b/services/accesstokenmanager/main/cpp/src/callback/callback_manager.cpp index 70a6d93d824e9b34dc5ccdd188117795a5ccd6cf..a5bb529082a5d444471a0e6689c3f65d2286f2cc 100644 --- a/services/accesstokenmanager/main/cpp/src/callback/callback_manager.cpp +++ b/services/accesstokenmanager/main/cpp/src/callback/callback_manager.cpp @@ -30,9 +30,7 @@ namespace Security { namespace AccessToken { namespace { static const uint32_t MAX_CALLBACK_SIZE = 1024; -#ifndef RESOURCESCHEDULE_FFRT_ENABLE static const int MAX_PTHREAD_NAME_LEN = 15; // pthread name max length -#endif std::recursive_mutex g_instanceMutex; } @@ -66,11 +64,7 @@ int32_t CallbackManager::AddCallback(const PermStateChangeScope& scopeRes, const } auto callbackScopePtr = std::make_shared(scopeRes); -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - std::lock_guard lock(mutex_); -#else std::lock_guard lock(mutex_); -#endif if (callbackInfoList_.size() >= MAX_CALLBACK_SIZE) { LOGE(ATM_DOMAIN, ATM_TAG, "Callback size has reached limitation"); return AccessTokenError::ERR_CALLBACKS_EXCEED_LIMITATION; @@ -96,11 +90,7 @@ int32_t CallbackManager::RemoveCallback(const sptr& callback) return AccessTokenError::ERR_PARAM_INVALID; } -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - std::lock_guard lock(mutex_); -#else std::lock_guard lock(mutex_); -#endif for (auto it = callbackInfoList_.begin(); it != callbackInfoList_.end(); ++it) { if (callback == (*it).callbackObject_) { @@ -140,23 +130,6 @@ void CallbackManager::ExecuteAllCallback(std::vector>& list, const std::string& permName, int32_t changeType) { for (auto it = list.begin(); it != list.end(); ++it) { -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - auto callbackSingle = [it, tokenID, permName, changeType]() { - sptr callback = new PermissionStateChangeCallbackProxy(*it); - if (callback != nullptr) { - LOGI(ATM_DOMAIN, ATM_TAG, "Callback execute, id=%{public}u perm=%{public}s changeType=%{public}d", - tokenID, permName.c_str(), changeType); - PermStateChangeInfo resInfo; - resInfo.permStateChangeType = changeType; - resInfo.permissionName = permName; - resInfo.tokenID = tokenID; - callback->PermStateChangeCallback(resInfo); - LOGI(ATM_DOMAIN, ATM_TAG, "Callback execute end, " - "id=%{public}u perm=%{public}s changeType=%{public}d", tokenID, permName.c_str(), changeType); - } - }; - ffrt::submit(callbackSingle, {}, {}, ffrt::task_attr().qos(ffrt::qos_default)); -#else sptr callback = new PermissionStateChangeCallbackProxy(*it); if (callback != nullptr) { LOGI(ATM_DOMAIN, ATM_TAG, "Callback execute"); @@ -166,21 +139,13 @@ void CallbackManager::ExecuteAllCallback(std::vector>& list, resInfo.tokenID = tokenID; callback->PermStateChangeCallback(resInfo); } -#endif } -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - ffrt::wait(); -#endif } void CallbackManager::GetCallbackObjectList(AccessTokenID tokenID, const std::string& permName, std::vector>& list) { -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - std::lock_guard lock(mutex_); -#else std::lock_guard lock(mutex_); -#endif for (auto it = callbackInfoList_.begin(); it != callbackInfoList_.end(); ++it) { std::shared_ptr scopePtr = (*it).scopePtr_; if (scopePtr == nullptr) { @@ -204,23 +169,15 @@ void CallbackManager::ExecuteCallbackAsync(AccessTokenID tokenID, const std::str auto callbackStart = [this, tokenID, permName, changeType]() { LOGI(ATM_DOMAIN, ATM_TAG, "CallbackStart, id=%{public}u perm=%{public}s changeType=%{public}d", tokenID, permName.c_str(), changeType); -#ifndef RESOURCESCHEDULE_FFRT_ENABLE std::string name = "AtmCallback"; pthread_setname_np(pthread_self(), name.substr(0, MAX_PTHREAD_NAME_LEN).c_str()); -#endif std::vector> list; this->GetCallbackObjectList(tokenID, permName, list); this->ExecuteAllCallback(list, tokenID, permName, changeType); }; -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - std::string taskName = "AtmCallback"; - ffrt::submit_h(callbackStart, {}, {}, - ffrt::task_attr().qos(ffrt::qos_default).name(taskName.c_str())); -#else std::packaged_task callbackTask(callbackStart); std::make_unique(std::move(callbackTask))->detach(); -#endif LOGD(ATM_DOMAIN, ATM_TAG, "The callback execution is complete"); } } // namespace AccessToken diff --git a/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp b/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp index 5d22d190d1f8ff95c2c17bba7e4888539d0d7c1e..7f60382a86a3d8588632c06467eeb937bae90b31 100644 --- a/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp +++ b/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp @@ -602,7 +602,7 @@ int32_t PermissionManager::AddPermStateChangeCallback( if (result != RET_SUCCESS) { return result; } - return CallbackManager::GetInstance().AddCallback(scope, callback); + return CallbackManager::GetInstance().AddCallback(scopeRes, callback); } int32_t PermissionManager::RemovePermStateChangeCallback(const sptr& callback) diff --git a/services/accesstokenmanager/main/cpp/src/permission/temp_permission_observer.cpp b/services/accesstokenmanager/main/cpp/src/permission/temp_permission_observer.cpp index 6536aa1c34a04450d96c62efcede0850028454d4..60765bbd3cd21494df5da5cc7c77fa87fa6c9352 100644 --- a/services/accesstokenmanager/main/cpp/src/permission/temp_permission_observer.cpp +++ b/services/accesstokenmanager/main/cpp/src/permission/temp_permission_observer.cpp @@ -37,7 +37,9 @@ namespace { static const std::string TASK_NAME_TEMP_PERMISSION = "atm_permission_manager_temp_permission"; static const std::string FORM_INVISIBLE_NAME = "#0"; static const std::string FORM_VISIBLE_NAME = "#1"; +#ifndef ATM_BUILD_VARIANT_USER_ENABLE static constexpr int32_t ROOT_UID = 0; +#endif static constexpr int32_t FOREGROUND_FLAG = 0; static constexpr int32_t FORMS_FLAG = 1; static constexpr int32_t CONTINUOUS_TASK_FLAG = 2; diff --git a/services/accesstokenmanager/main/cpp/src/token/token_modify_notifier.cpp b/services/accesstokenmanager/main/cpp/src/token/token_modify_notifier.cpp index 525a1b52ba5da43843f2252b8b24b35f9d4d6d76..1592e423ebe0607cb7fa2465d0190145aab22b90 100644 --- a/services/accesstokenmanager/main/cpp/src/token/token_modify_notifier.cpp +++ b/services/accesstokenmanager/main/cpp/src/token/token_modify_notifier.cpp @@ -20,9 +20,6 @@ #include "accesstoken_info_manager.h" #include "accesstoken_common_log.h" #include "access_token_error.h" -#ifdef RESOURCESCHEDULE_FFRT_ENABLE -#include "ffrt.h" -#endif #include "hap_token_info.h" #include "hap_token_info_inner.h" #include "libraryloader.h" @@ -35,20 +32,14 @@ namespace { std::recursive_mutex g_instanceMutex; } -#ifdef RESOURCESCHEDULE_FFRT_ENABLE -TokenModifyNotifier::TokenModifyNotifier() : hasInited_(false), curTaskNum_(0) {} -#else TokenModifyNotifier::TokenModifyNotifier() : hasInited_(false), notifyTokenWorker_("TokenModify") {} -#endif TokenModifyNotifier::~TokenModifyNotifier() { if (!hasInited_) { return; } -#ifndef RESOURCESCHEDULE_FFRT_ENABLE this->notifyTokenWorker_.Stop(); -#endif this->hasInited_ = false; } @@ -101,9 +92,7 @@ TokenModifyNotifier& TokenModifyNotifier::GetInstance() if (!instance->hasInited_) { Utils::UniqueWriteGuard infoGuard(instance->initLock_); if (!instance->hasInited_) { -#ifndef RESOURCESCHEDULE_FFRT_ENABLE instance->notifyTokenWorker_.Start(1); -#endif instance->hasInited_ = true; } } @@ -205,41 +194,8 @@ int32_t TokenModifyNotifier::UnRegisterTokenSyncCallback() return ERR_OK; } -#ifdef RESOURCESCHEDULE_FFRT_ENABLE -int32_t TokenModifyNotifier::GetCurTaskNum() -{ - return curTaskNum_.load(); -} - -void TokenModifyNotifier::AddCurTaskNum() -{ - LOGI(ATM_DOMAIN, ATM_TAG, "Add task!"); - curTaskNum_++; -} - -void TokenModifyNotifier::ReduceCurTaskNum() -{ - LOGI(ATM_DOMAIN, ATM_TAG, "Reduce task!"); - curTaskNum_--; -} -#endif - void TokenModifyNotifier::NotifyTokenChangedIfNeed() { -#ifdef RESOURCESCHEDULE_FFRT_ENABLE - if (GetCurTaskNum() > 1) { - LOGI(ATM_DOMAIN, ATM_TAG, "Has notify task! taskNum is %{public}d.", GetCurTaskNum()); - return; - } - - std::string taskName = "TokenModify"; - auto tokenModify = []() { - TokenModifyNotifier::GetInstance().NotifyTokenSyncTask(); - TokenModifyNotifier::GetInstance().ReduceCurTaskNum(); - }; - ffrt::submit(tokenModify, {}, {}, ffrt::task_attr().qos(ffrt::qos_default).name(taskName.c_str())); - AddCurTaskNum(); -#else if (notifyTokenWorker_.GetCurTaskNum() > 1) { LOGI(ATM_DOMAIN, ATM_TAG, " has notify task! taskNum is %{public}zu.", notifyTokenWorker_.GetCurTaskNum()); return; @@ -248,7 +204,6 @@ void TokenModifyNotifier::NotifyTokenChangedIfNeed() notifyTokenWorker_.AddTask([]() { TokenModifyNotifier::GetInstance().NotifyTokenSyncTask(); }); -#endif } } // namespace AccessToken } // namespace Security