From 31ae338f945c0c3d743958649c6535f58a234ced Mon Sep 17 00:00:00 2001 From: oh_ci Date: Fri, 13 Sep 2024 09:01:22 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!2094=20?= =?UTF-8?q?:=20=E5=88=9B=E5=BB=BA=E5=B8=90=E5=8F=B7=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=8D=E8=BF=9B=E8=A1=8C=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9B=91=E6=8E=A7'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/common/BUILD.gn | 6 --- .../common/utils/include/account_constants.h | 10 ----- .../common/utils/src/account_constants.cpp | 45 ------------------- .../osaccount/inner_os_account_manager.cpp | 4 -- .../src/osaccount/os_account_stub.cpp | 23 +++++----- 5 files changed, 13 insertions(+), 75 deletions(-) delete mode 100644 frameworks/common/utils/src/account_constants.cpp diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn index 8b0d66ce9..905bea406 100644 --- a/frameworks/common/BUILD.gn +++ b/frameworks/common/BUILD.gn @@ -45,7 +45,6 @@ ohos_shared_library("libaccount_common") { "file_operator/src/account_file_operator.cpp", "log/src/account_log_wrapper.cpp", "perf_stat/src/perf_stat.cpp", - "utils/src/account_constants.cpp", "utils/src/account_permission_manager.cpp", "utils/src/memory_guard.cpp", ] @@ -86,11 +85,6 @@ ohos_shared_library("libaccount_common") { cflags += [ "-DWITH_SELINUX" ] } - if (hicollie_enable == true) { - external_deps += [ "hicollie:libhicollie" ] - cflags_cc += [ "-DHICOLLIE_ENABLE" ] - } - subsystem_name = "account" innerapi_tags = [ "platformsdk" ] part_name = "os_account" diff --git a/frameworks/common/utils/include/account_constants.h b/frameworks/common/utils/include/account_constants.h index 84d266ebe..adf567063 100644 --- a/frameworks/common/utils/include/account_constants.h +++ b/frameworks/common/utils/include/account_constants.h @@ -15,7 +15,6 @@ #ifndef OS_ACCOUNT_FRAMEWORKS_ACCOUNT_CONSTANTS_H #define OS_ACCOUNT_FRAMEWORKS_ACCOUNT_CONSTANTS_H -#include #define TOKEN_ID_LOWMASK 0xffffffff namespace OHOS { @@ -26,15 +25,6 @@ const uint32_t TIMEOUT = 30; // 30s constexpr const char TIMER_NAME[] = "AccountMgrTimer"; #endif // HICOLLIE_ENABLE -class AccountTimer { -public: - AccountTimer(bool needInit = true); - ~AccountTimer(); - void Init(); - -private: - int64_t timerId_ = -1; -}; } // namespace AccountSA } // namespace OHOS #endif // OS_ACCOUNT_FRAMEWORKS_ACCOUNT_CONSTANTS_H \ No newline at end of file diff --git a/frameworks/common/utils/src/account_constants.cpp b/frameworks/common/utils/src/account_constants.cpp deleted file mode 100644 index 25a9b84c4..000000000 --- a/frameworks/common/utils/src/account_constants.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "account_constants.h" - -#ifdef HICOLLIE_ENABLE -#include "xcollie/xcollie.h" -#endif // HICOLLIE_ENABLE - -namespace OHOS { -namespace AccountSA { -AccountTimer::AccountTimer(bool needInit) -{ - if (needInit) { - Init(); - } -} - -AccountTimer::~AccountTimer() -{ -#ifdef HICOLLIE_ENABLE - HiviewDFX::XCollie::GetInstance().CancelTimer(timerId_); -#endif // HICOLLIE_ENABLE -} - -void AccountTimer::Init() -{ -#ifdef HICOLLIE_ENABLE - timerId_ = HiviewDFX::XCollie::GetInstance().SetTimer( - TIMER_NAME, TIMEOUT, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG); -#endif // HICOLLIE_ENABLE -} -} // namespace AccountSA -} // namespace OHOS diff --git a/services/accountmgr/src/osaccount/inner_os_account_manager.cpp b/services/accountmgr/src/osaccount/inner_os_account_manager.cpp index 4475047a7..0eb293dba 100644 --- a/services/accountmgr/src/osaccount/inner_os_account_manager.cpp +++ b/services/accountmgr/src/osaccount/inner_os_account_manager.cpp @@ -419,7 +419,6 @@ ErrCode IInnerOsAccountManager::CreateOsAccount( ACCOUNT_LOGI("Not allow creation account."); return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_PLUGIN_NOT_ALLOWED_CREATION_ERROR; } - AccountTimer timer; unsigned int osAccountNum = 0; GetCreatedOsAccountsCount(osAccountNum); if (!AccountPermissionManager::CheckSaCall() && osAccountNum >= config_.maxOsAccountNum) { @@ -447,7 +446,6 @@ ErrCode IInnerOsAccountManager::CreateOsAccount(const std::string &localName, co ACCOUNT_LOGI("Not allow creation account."); return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_PLUGIN_NOT_ALLOWED_CREATION_ERROR; } - AccountTimer timer; osAccountInfo.SetLocalName(localName); #ifdef ENABLE_ACCOUNT_SHORT_NAME OsAccountInfo accountInfoOld; @@ -515,7 +513,6 @@ ErrCode IInnerOsAccountManager::CreateOsAccountWithFullInfo(OsAccountInfo &osAcc ACCOUNT_LOGI("Not allow creation account."); return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_PLUGIN_NOT_ALLOWED_CREATION_ERROR; } - AccountTimer timer; if (!CheckAndAddLocalIdOperating(osAccountInfo.GetLocalId())) { ACCOUNT_LOGW("Account id = %{public}d already in operating", osAccountInfo.GetLocalId()); return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_OPERATING_ERROR; @@ -655,7 +652,6 @@ ErrCode IInnerOsAccountManager::CreateOsAccountForDomain( ACCOUNT_LOGI("Not allow creation account."); return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_PLUGIN_NOT_ALLOWED_CREATION_ERROR; } - AccountTimer timer; std::vector osAccountInfos; (void)QueryAllCreatedOsAccounts(osAccountInfos); if (CheckDomainAccountBound(osAccountInfos, domainInfo)) { diff --git a/services/accountmgr/src/osaccount/os_account_stub.cpp b/services/accountmgr/src/osaccount/os_account_stub.cpp index 8097e3149..f675a0b74 100644 --- a/services/accountmgr/src/osaccount/os_account_stub.cpp +++ b/services/accountmgr/src/osaccount/os_account_stub.cpp @@ -29,12 +29,6 @@ namespace AccountSA { #ifdef HICOLLIE_ENABLE constexpr std::int32_t RECOVERY_TIMEOUT = 6; // timeout 6s #endif // HICOLLIE_ENABLE -const std::set WATCH_DOG_WHITE_LIST = { - static_cast(OsAccountInterfaceCode::CREATE_OS_ACCOUNT), - static_cast(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_WITH_SHORT_NAME), - static_cast(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_WITH_FULL_INFO), - static_cast(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_FOR_DOMAIN), -}; const std::map messageProcMap = { { static_cast(OsAccountInterfaceCode::CREATE_OS_ACCOUNT), @@ -511,10 +505,10 @@ int OsAccountStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa return ERR_ACCOUNT_COMMON_CHECK_DESCRIPTOR_ERROR; } - AccountTimer timer(false); - if (WATCH_DOG_WHITE_LIST.find(code) == WATCH_DOG_WHITE_LIST.end()) { - timer.Init(); - } +#ifdef HICOLLIE_ENABLE + int timerId = + HiviewDFX::XCollie::GetInstance().SetTimer(TIMER_NAME, TIMEOUT, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG); +#endif // HICOLLIE_ENABLE auto messageProc = messageProcMap_.find(code); if (messageProc != messageProcMap_.end()) { @@ -523,12 +517,21 @@ int OsAccountStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa ErrCode result = AccountPermissionManager::CheckSystemApp(); if (result != ERR_OK) { ACCOUNT_LOGE("is not system application, result = %{public}u.", result); +#ifdef HICOLLIE_ENABLE + HiviewDFX::XCollie::GetInstance().CancelTimer(timerId); +#endif // HICOLLIE_ENABLE return result; } } int ret = (messageProcFunction.messageProcFunction)(this, data, reply); +#ifdef HICOLLIE_ENABLE + HiviewDFX::XCollie::GetInstance().CancelTimer(timerId); +#endif // HICOLLIE_ENABLE return ret; } +#ifdef HICOLLIE_ENABLE + HiviewDFX::XCollie::GetInstance().CancelTimer(timerId); +#endif // HICOLLIE_ENABLE return IPCObjectStub::OnRemoteRequest(code, data, reply, option); }