mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-23 06:59:59 +00:00
!1427 storage_service接入xcollie支持watchdog功能
Merge pull request !1427 from lianwei/master
This commit is contained in:
commit
b4a53d4e72
@ -47,6 +47,7 @@
|
||||
"FreeBSD",
|
||||
"file_api",
|
||||
"gptfdisk",
|
||||
"hicollie",
|
||||
"hilog",
|
||||
"hisysevent",
|
||||
"hitrace",
|
||||
|
@ -121,6 +121,7 @@ ohos_executable("storage_daemon") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
@ -280,12 +281,14 @@ ohos_shared_library("storage_common_utils") {
|
||||
"./utils/mount_argument_utils.cpp",
|
||||
"./utils/set_flag_utils.cpp",
|
||||
"./utils/storage_radar.cpp",
|
||||
"./utils/storage_xcollie.cpp",
|
||||
"./utils/string_utils.cpp",
|
||||
"./utils/zip_util.cpp",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"zlib:shared_libz",
|
||||
|
30
services/storage_daemon/include/utils/storage_xcollie.h
Normal file
30
services/storage_daemon/include/utils/storage_xcollie.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef FILEMANAGEMENT_STORAGE_XCOLLIE_H
|
||||
#define FILEMANAGEMENT_STORAGE_XCOLLIE_H
|
||||
|
||||
#include "xcollie/xcollie.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageDaemon {
|
||||
class StorageXCollie {
|
||||
public:
|
||||
static int SetTimer(const std::string &name, uint32_t timeout);
|
||||
static void CancelTimer(int timerId);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif //FILEMANAGEMENT_STORAGE_XCOLLIE_H
|
@ -19,10 +19,12 @@
|
||||
#include "storage_service_errno.h"
|
||||
#include "storage_service_log.h"
|
||||
#include "string_ex.h"
|
||||
#include "utils/storage_xcollie.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageDaemon {
|
||||
using namespace std;
|
||||
const unsigned int LOCAL_TIME_OUT_SECONDS = 10;
|
||||
|
||||
StorageDaemonStub::StorageDaemonStub()
|
||||
{
|
||||
@ -425,8 +427,9 @@ int32_t StorageDaemonStub::HandleGenerateUserKeys(MessageParcel &data, MessagePa
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
uint32_t flags = data.ReadUint32();
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:GenerateUserKeys", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = GenerateUserKeys(userId, flags);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -437,8 +440,9 @@ int32_t StorageDaemonStub::HandleGenerateUserKeys(MessageParcel &data, MessagePa
|
||||
int32_t StorageDaemonStub::HandleDeleteUserKeys(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:DeleteUserKeys", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = DeleteUserKeys(userId);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -458,7 +462,9 @@ int32_t StorageDaemonStub::HandleUpdateUserAuth(MessageParcel &data, MessageParc
|
||||
data.ReadUInt8Vector(&oldSecret);
|
||||
data.ReadUInt8Vector(&newSecret);
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:UpdateUserAuth", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = UpdateUserAuth(userId, secureUid, token, oldSecret, newSecret);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -500,7 +506,9 @@ int32_t StorageDaemonStub::HandleActiveUserKey(MessageParcel &data, MessageParce
|
||||
data.ReadUInt8Vector(&token);
|
||||
data.ReadUInt8Vector(&secret);
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:ActiveUserKey", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = ActiveUserKey(userId, token, secret);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -512,7 +520,9 @@ int32_t StorageDaemonStub::HandleInactiveUserKey(MessageParcel &data, MessagePar
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:InactiveUserKey", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = InactiveUserKey(userId);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -524,7 +534,9 @@ int32_t StorageDaemonStub::HandleLockUserScreen(MessageParcel &data, MessageParc
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:LockUserScreen", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = LockUserScreen(userId);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -541,7 +553,9 @@ int32_t StorageDaemonStub::HandleUnlockUserScreen(MessageParcel &data, MessagePa
|
||||
data.ReadUInt8Vector(&token);
|
||||
data.ReadUInt8Vector(&secret);
|
||||
|
||||
int timerId = StorageXCollie::SetTimer("storage:UnlockUserScreen", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = UnlockUserScreen(userId, token, secret);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -553,7 +567,9 @@ int32_t StorageDaemonStub::HandleGetLockScreenStatus(MessageParcel &data, Messag
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
bool lockScreenStatus = false;
|
||||
int timerId = StorageXCollie::SetTimer("storage:GetLockScreenStatus", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = GetLockScreenStatus(userId, lockScreenStatus);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteBool(lockScreenStatus)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -569,7 +585,9 @@ int32_t StorageDaemonStub::HandleGenerateAppkey(MessageParcel &data, MessageParc
|
||||
uint32_t userId = data.ReadUint32();
|
||||
uint32_t hashId = data.ReadUint32();
|
||||
std::string keyId;
|
||||
int timerId = StorageXCollie::SetTimer("storage:GenerateAppkey", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = GenerateAppkey(userId, hashId, keyId);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteString(keyId)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -584,7 +602,9 @@ int32_t StorageDaemonStub::HandleDeleteAppkey(MessageParcel &data, MessageParcel
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
std::string keyId = data.ReadString();
|
||||
int timerId = StorageXCollie::SetTimer("storage:DeleteAppkey", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = DeleteAppkey(userId, keyId);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -624,7 +644,9 @@ int32_t StorageDaemonStub::HandleSetRecoverKey(MessageParcel &data, MessageParce
|
||||
int32_t StorageDaemonStub::HandleUpdateKeyContext(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint32_t userId = data.ReadUint32();
|
||||
int timerId = StorageXCollie::SetTimer("storage:UpdateKeyContext", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = UpdateKeyContext(userId);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
@ -778,7 +800,9 @@ int32_t StorageDaemonStub::HandleGetFileEncryptStatus(MessageParcel &data, Messa
|
||||
uint32_t userId = data.ReadUint32();
|
||||
bool needCheckDirMount = data.ReadBool();
|
||||
bool isEncrypted = true;
|
||||
int timerId = StorageXCollie::SetTimer("storage:GetFileEncryptStatus", LOCAL_TIME_OUT_SECONDS);
|
||||
int err = GetFileEncryptStatus(userId, isEncrypted, needCheckDirMount);
|
||||
StorageXCollie::CancelTimer(timerId);
|
||||
if (!reply.WriteInt32(err)) {
|
||||
return E_WRITE_REPLY_ERR;
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ ohos_unittest("storage_daemon_test") {
|
||||
"c_utils:utils",
|
||||
"dfs_service:cloud_daemon_kit_inner",
|
||||
"eventhandler:libeventhandler",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"huks:libhukssdk",
|
||||
@ -192,6 +193,7 @@ ohos_unittest("storage_daemon_stub_test") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"huks:libhukssdk",
|
||||
"init:libbegetutil",
|
||||
|
30
services/storage_daemon/utils/storage_xcollie.cpp
Normal file
30
services/storage_daemon/utils/storage_xcollie.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 "utils/storage_xcollie.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageDaemon {
|
||||
int StorageXCollie::SetTimer(const std::string &name, uint32_t timeout)
|
||||
{
|
||||
return HiviewDFX::XCollie::GetInstance().SetTimer(name, timeout, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG);
|
||||
}
|
||||
|
||||
void StorageXCollie::CancelTimer(int timerId)
|
||||
{
|
||||
HiviewDFX::XCollie::GetInstance().CancelTimer(timerId);
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::StorageDaemon
|
@ -46,6 +46,7 @@ ohos_fuzztest("StorageDaemonFuzzTest") {
|
||||
"${storage_daemon_path}/utils/mount_argument_utils.cpp",
|
||||
"${storage_daemon_path}/utils/set_flag_utils.cpp",
|
||||
"${storage_daemon_path}/utils/storage_radar.cpp",
|
||||
"${storage_daemon_path}/utils/storage_xcollie.cpp",
|
||||
"${storage_daemon_path}/utils/string_utils.cpp",
|
||||
"${storage_daemon_path}/utils/zip_util.cpp",
|
||||
"${storage_service_path}/test/fuzztest/storagedaemon_fuzzer/storagedaemon_fuzzer.cpp",
|
||||
@ -72,6 +73,7 @@ ohos_fuzztest("StorageDaemonFuzzTest") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"huks:libhukssdk",
|
||||
|
@ -45,6 +45,7 @@ ohos_fuzztest("StorageDaemonCreateShareFileFuzzTest") {
|
||||
"${storage_daemon_path}/utils/mount_argument_utils.cpp",
|
||||
"${storage_daemon_path}/utils/set_flag_utils.cpp",
|
||||
"${storage_daemon_path}/utils/storage_radar.cpp",
|
||||
"${storage_daemon_path}/utils/storage_xcollie.cpp",
|
||||
"${storage_daemon_path}/utils/string_utils.cpp",
|
||||
"${storage_daemon_path}/utils/zip_util.cpp",
|
||||
"${storage_service_path}/test/fuzztest/storagedaemoncreatesharefile_fuzzer/storagedaemoncreatesharefile_fuzzer.cpp",
|
||||
@ -68,6 +69,7 @@ ohos_fuzztest("StorageDaemonCreateShareFileFuzzTest") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"huks:libhukssdk",
|
||||
|
@ -45,6 +45,7 @@ ohos_fuzztest("StorageDaemonDeleteShareFileFuzzTest") {
|
||||
"${storage_daemon_path}/utils/mount_argument_utils.cpp",
|
||||
"${storage_daemon_path}/utils/set_flag_utils.cpp",
|
||||
"${storage_daemon_path}/utils/storage_radar.cpp",
|
||||
"${storage_daemon_path}/utils/storage_xcollie.cpp",
|
||||
"${storage_daemon_path}/utils/string_utils.cpp",
|
||||
"${storage_daemon_path}/utils/zip_util.cpp",
|
||||
"${storage_service_path}/test/fuzztest/storagedaemondeletesharefile_fuzzer/storagedaemondeletesharefile_fuzzer.cpp",
|
||||
@ -68,6 +69,7 @@ ohos_fuzztest("StorageDaemonDeleteShareFileFuzzTest") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"huks:libhukssdk",
|
||||
|
Loading…
Reference in New Issue
Block a user