mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 10:10:11 +00:00
commit
582dd67c16
@ -45,6 +45,7 @@ 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",
|
||||
]
|
||||
@ -85,6 +86,11 @@ 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"
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#ifndef OS_ACCOUNT_FRAMEWORKS_ACCOUNT_CONSTANTS_H
|
||||
#define OS_ACCOUNT_FRAMEWORKS_ACCOUNT_CONSTANTS_H
|
||||
#include <stdint.h>
|
||||
|
||||
#define TOKEN_ID_LOWMASK 0xffffffff
|
||||
namespace OHOS {
|
||||
@ -25,6 +26,15 @@ 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
|
45
frameworks/common/utils/src/account_constants.cpp
Normal file
45
frameworks/common/utils/src/account_constants.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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
|
@ -419,6 +419,7 @@ 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) {
|
||||
@ -446,6 +447,7 @@ 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;
|
||||
@ -513,6 +515,7 @@ 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;
|
||||
@ -652,6 +655,7 @@ ErrCode IInnerOsAccountManager::CreateOsAccountForDomain(
|
||||
ACCOUNT_LOGI("Not allow creation account.");
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_ACCOUNT_PLUGIN_NOT_ALLOWED_CREATION_ERROR;
|
||||
}
|
||||
AccountTimer timer;
|
||||
std::vector<OsAccountInfo> osAccountInfos;
|
||||
(void)QueryAllCreatedOsAccounts(osAccountInfos);
|
||||
if (CheckDomainAccountBound(osAccountInfos, domainInfo)) {
|
||||
|
@ -29,6 +29,12 @@ namespace AccountSA {
|
||||
#ifdef HICOLLIE_ENABLE
|
||||
constexpr std::int32_t RECOVERY_TIMEOUT = 6; // timeout 6s
|
||||
#endif // HICOLLIE_ENABLE
|
||||
const std::set<uint32_t> WATCH_DOG_WHITE_LIST = {
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::CREATE_OS_ACCOUNT),
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_WITH_SHORT_NAME),
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_WITH_FULL_INFO),
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::CREATE_OS_ACCOUNT_FOR_DOMAIN),
|
||||
};
|
||||
const std::map<uint32_t, OsAccountStub::OsAccountMessageProc> messageProcMap = {
|
||||
{
|
||||
static_cast<uint32_t>(OsAccountInterfaceCode::CREATE_OS_ACCOUNT),
|
||||
@ -505,10 +511,10 @@ int OsAccountStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa
|
||||
return ERR_ACCOUNT_COMMON_CHECK_DESCRIPTOR_ERROR;
|
||||
}
|
||||
|
||||
#ifdef HICOLLIE_ENABLE
|
||||
int timerId =
|
||||
HiviewDFX::XCollie::GetInstance().SetTimer(TIMER_NAME, TIMEOUT, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG);
|
||||
#endif // HICOLLIE_ENABLE
|
||||
AccountTimer timer(false);
|
||||
if (WATCH_DOG_WHITE_LIST.find(code) == WATCH_DOG_WHITE_LIST.end()) {
|
||||
timer.Init();
|
||||
}
|
||||
|
||||
auto messageProc = messageProcMap_.find(code);
|
||||
if (messageProc != messageProcMap_.end()) {
|
||||
@ -517,21 +523,12 @@ 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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user