mirror of
https://github.com/openharmony/security_device_auth.git
synced 2026-08-25 09:19:33 -04:00
@@ -16,6 +16,9 @@
|
||||
"subsystem": "security",
|
||||
"syscap": [ "SystemCapability.Security.DeviceAuth" ],
|
||||
"features": [],
|
||||
"hisysevent_config": [
|
||||
"//base/security/device_auth/hisysevent.yaml"
|
||||
],
|
||||
"adapted_system_type": [
|
||||
"standard",
|
||||
"small",
|
||||
@@ -33,6 +36,7 @@
|
||||
"common",
|
||||
"utils_base",
|
||||
"hiviewdfx_hilog_native",
|
||||
"hisysevent_native",
|
||||
"samgr_standard",
|
||||
"ipc"
|
||||
],
|
||||
|
||||
@@ -32,6 +32,7 @@ class ServiceDevAuth : public IRemoteStub<IMethodsIpcCall> {
|
||||
public:
|
||||
ServiceDevAuth();
|
||||
~ServiceDevAuth();
|
||||
int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
|
||||
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option) override;
|
||||
void ResetCallMap(void);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "permission_adapter.h"
|
||||
#include "securec.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "hidump_adapter.h"
|
||||
|
||||
using namespace std;
|
||||
namespace OHOS {
|
||||
@@ -48,6 +49,13 @@ ServiceDevAuth::~ServiceDevAuth()
|
||||
callMapElemNum = 0;
|
||||
}
|
||||
|
||||
int32_t ServiceDevAuth::Dump(int32_t fd, const std::vector<std::u16string>& args)
|
||||
{
|
||||
DevAuthDump(fd);
|
||||
(void)args;
|
||||
return 0;
|
||||
}
|
||||
|
||||
IpcServiceCall ServiceDevAuth::GetCallMethodByMethodId(int32_t methodId)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
domain: DEVICE_AUTH
|
||||
|
||||
CORE_FUNCTION:
|
||||
__BASE: {type: STATISTIC, level: MINOR, desc: the frequency of function calling}
|
||||
EVENT: {type: INT32, desc: event id}
|
||||
APP_ID: {type: STRING, desc: app id}
|
||||
TYPE: {type: INT32, desc: the type of group or auth}
|
||||
BATCH_NUMBER: {type: INT32, desc: the number of batch operation}
|
||||
RESULT: {type: INT32, desc: ret of call}
|
||||
OS_ACCOUNT_ID: {type: INT32, desc: os account id}
|
||||
@@ -29,8 +29,10 @@ if (os_level == "mini" || os_level == "small") {
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
sources = deviceauth_files
|
||||
sources += hiview_adapter_mock_files
|
||||
deps = [
|
||||
"${deps_adapter_path}:${hal_module_name}",
|
||||
"//build/lite/config/component/cJSON:cjson_shared",
|
||||
@@ -40,6 +42,7 @@ if (os_level == "mini" || os_level == "small") {
|
||||
|
||||
defines = [ "HILOG_ENABLE" ]
|
||||
defines += deviceauth_defines
|
||||
defines += [ "DISABLE_HIVIEW" ]
|
||||
if (board_toolchain_type == "iccarm") {
|
||||
cflags = [
|
||||
"--diag_suppress",
|
||||
@@ -81,9 +84,11 @@ if (os_level == "mini" || os_level == "small") {
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"${frameworks_path}/inc/lite",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
|
||||
sources = deviceauth_ipc_files
|
||||
sources += hiview_adapter_mock_files
|
||||
sources += [
|
||||
"${frameworks_path}/src/ipc_service.c",
|
||||
"${frameworks_path}/src/lite/ipc_service_init.c",
|
||||
@@ -117,6 +122,7 @@ if (os_level == "mini" || os_level == "small") {
|
||||
"${frameworks_path}/inc/lite",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/c/ipc/include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
|
||||
sources = deviceauth_ipc_files
|
||||
@@ -146,9 +152,11 @@ if (os_level == "mini" || os_level == "small") {
|
||||
include_dirs += [
|
||||
"//third_party/cJSON",
|
||||
"${frameworks_path}/inc/standard",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
|
||||
sources = deviceauth_files
|
||||
sources += hiview_adapter_files
|
||||
cflags = [ "-DHILOG_ENABLE" ]
|
||||
defines = deviceauth_defines
|
||||
cflags += build_flags
|
||||
@@ -167,6 +175,8 @@ if (os_level == "mini" || os_level == "small") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"dsoftbus:softbus_client",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
if (support_jsapi) {
|
||||
@@ -194,6 +204,7 @@ if (os_level == "mini" || os_level == "small") {
|
||||
"//third_party/cJSON",
|
||||
"${frameworks_path}/inc/standard",
|
||||
"${dev_frameworks_path}/inc/permission_adapter",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
|
||||
sources = deviceauth_ipc_files
|
||||
@@ -215,6 +226,8 @@ if (os_level == "mini" || os_level == "small") {
|
||||
external_deps = [
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
@@ -231,10 +244,12 @@ if (os_level == "mini" || os_level == "small") {
|
||||
"//third_party/cJSON",
|
||||
"${frameworks_path}/inc/standard",
|
||||
"${dev_frameworks_path}/inc/permission_adapter",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
|
||||
sources = deviceauth_ipc_files
|
||||
sources += permission_adapter_files
|
||||
sources += hiview_adapter_files
|
||||
sources += [ "${frameworks_path}/src/ipc_sdk.c" ]
|
||||
|
||||
defines = [
|
||||
@@ -255,6 +270,8 @@ if (os_level == "mini" || os_level == "small") {
|
||||
external_deps = [
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "hc_string_vector.h"
|
||||
#include "hc_types.h"
|
||||
#include "securec.h"
|
||||
#include "hidump_adapter.h"
|
||||
|
||||
typedef struct {
|
||||
DECLARE_TLV_STRUCT(9)
|
||||
@@ -1146,6 +1147,51 @@ int32_t SaveOsAccountDb(int32_t osAccountId)
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_HIVIEW
|
||||
static void DumpGroups(int fd, GroupEntryVec *vec)
|
||||
{
|
||||
dprintf(fd, "---- GROUP INFO ----\n");
|
||||
uint32_t index;
|
||||
TrustedGroupEntry **entry;
|
||||
FOR_EACH_HC_VECTOR(*vec, index, entry) {
|
||||
dprintf(fd, "GROUP NAME: %s", (*entry)->name);
|
||||
dprintf(fd, "GROUP ID: %s", (*entry)->id);
|
||||
dprintf(fd, "GROUP TYPE: %s", (*entry)->type);
|
||||
dprintf(fd, "GROUP VISIBILITY: %s", (*entry)->visibility);
|
||||
dprintf(fd, "GROUP OWNER: %s", (*entry)->managers);
|
||||
}
|
||||
}
|
||||
|
||||
static void DumpDevices(int fd, DeviceEntryVec *vec)
|
||||
{
|
||||
dprintf(fd, "---- DEVICE INFO ----\n");
|
||||
uint32_t index;
|
||||
TrustedDeviceEntry **entry;
|
||||
FOR_EACH_HC_VECTOR(*vec, index, entry) {
|
||||
dprintf(fd, "DEVICES ID: %s", (*entry)->udid);
|
||||
dprintf(fd, "GROUP ID: %s", (*entry)->groupId);
|
||||
}
|
||||
}
|
||||
|
||||
static void DevAuthDataBaseDump(int fd)
|
||||
{
|
||||
if (g_databaseMutex == NULL) {
|
||||
LOGE("[DB]: Init mutex failed");
|
||||
return;
|
||||
}
|
||||
g_databaseMutex->lock(g_databaseMutex);
|
||||
|
||||
uint32_t index;
|
||||
OsAccountTrustedInfo *info;
|
||||
FOR_EACH_HC_VECTOR(g_deviceauthDb, index, info) {
|
||||
dprintf(fd, "OS ACCOUNT ID: %s\n;", info->osAccountId);
|
||||
DumpGroups(fd, &info->groups);
|
||||
DumpDevices(fd, &info->devices);
|
||||
}
|
||||
|
||||
g_databaseMutex->unlock(g_databaseMutex);
|
||||
}
|
||||
#endif
|
||||
int32_t InitDatabase(void)
|
||||
{
|
||||
if (g_databaseMutex == NULL) {
|
||||
@@ -1163,6 +1209,9 @@ int32_t InitDatabase(void)
|
||||
}
|
||||
g_deviceauthDb = CREATE_HC_VECTOR(DeviceAuthDb);
|
||||
LoadDeviceAuthDb();
|
||||
#ifndef DISABLE_HIVIEW
|
||||
RegisterDumpFunc(DevAuthDataBaseDump);
|
||||
#endif
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,16 @@ os_account_adapter_lite_files = [ "${dev_frameworks_path}/src/os_account_adapter
|
||||
permission_adapter_files =
|
||||
[ "${dev_frameworks_path}/src/permission_adapter/permission_adapter.cpp" ]
|
||||
|
||||
hiview_adapter_files = [
|
||||
"${dev_frameworks_path}/src/hiview_adapter/hidump_adapter.c",
|
||||
"${dev_frameworks_path}/src/hiview_adapter/hisysevent_adapter.cpp",
|
||||
"${dev_frameworks_path}/src/hiview_adapter/dev_auth_hievent.c",
|
||||
"${dev_frameworks_path}/src/hiview_adapter/hitrace_adapter.cpp",
|
||||
]
|
||||
|
||||
hiview_adapter_mock_files =
|
||||
[ "${dev_frameworks_path}/src/hiview_adapter/hiview_mock.c" ]
|
||||
|
||||
group_auth_files = [
|
||||
"${group_auth_path}/src/group_auth_manager/group_auth_data_operation.c",
|
||||
"${group_auth_path}/src/group_auth_manager/group_auth_manager.c",
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 DEV_AUTH_BIGDATA_EVENT_H
|
||||
#define DEV_AUTH_BIGDATA_EVENT_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "json_utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ReportHiEventCoreFuncInvoke(int32_t eventId, int32_t osAccountId, CJson *params, int32_t result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DEV_AUTH_BIGDATA_EVENT_H
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 HIDUMP_ADAPTER_H
|
||||
#define HIDUMP_ADAPTER_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef void (*DumpCallBack)(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void DevAuthDump(int fd);
|
||||
|
||||
void RegisterDumpFunc(DumpCallBack func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 HISYSEVENT_ADAPTER_H
|
||||
#define HISYSEVENT_ADAPTER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define EVENT_APPID_LEN 128
|
||||
|
||||
|
||||
enum InvokeEventId {
|
||||
EVENT_ID_CREATE_GROUP = 0,
|
||||
EVENT_ID_DELETE_GROUP = 1,
|
||||
EVENT_ID_ADD_MEMBER = 2,
|
||||
EVENT_ID_DELETE_MEMBER = 3,
|
||||
EVENT_ID_GET_REGISTER_INFO = 4,
|
||||
EVENT_ID_ADD_MULTI_MEMBERS = 5,
|
||||
EVENT_ID_DELETE_MULTI_MEMBERS = 6,
|
||||
EVENT_ID_AUTH_DEVICE = 7,
|
||||
};
|
||||
|
||||
typedef struct InvokeEvent {
|
||||
int32_t eventId;
|
||||
char appId[EVENT_APPID_LEN];
|
||||
int32_t type;
|
||||
int32_t batchNumber;
|
||||
int32_t result;
|
||||
int32_t osAccountId;
|
||||
} InvokeEvent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ReportCoreFuncInvokeEvent(const InvokeEvent *event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SERVICE_DSLM_BIGDATA_H
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 HITRACE_ADAPTER_H
|
||||
#define HITRACE_ADAPTER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define TRACE_TAG_AUTH_PROCESS "auth_process"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void DevAuthStartTrace(const char *value);
|
||||
|
||||
void DevAuthFinishTrace(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HITRACE_ADAPTER_H
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "dev_auth_hievent.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "securec.h"
|
||||
#include "hc_types.h"
|
||||
|
||||
#include "hisysevent_adapter.h"
|
||||
#include "device_auth_defines.h"
|
||||
#include "device_auth.h"
|
||||
|
||||
void ReportHiEventCoreFuncInvoke(int32_t eventId, int32_t osAccountId, CJson *params, int32_t result)
|
||||
{
|
||||
if (params == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
InvokeEvent event;
|
||||
(void)memset_s(&event, sizeof(InvokeEvent), 0, sizeof(InvokeEvent));
|
||||
|
||||
int32_t groupType = PEER_TO_PEER_GROUP;
|
||||
if (GetIntFromJson(params, FIELD_GROUP_TYPE, &groupType) != HC_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.eventId = eventId;
|
||||
event.type = groupType;
|
||||
event.batchNumber = 0;
|
||||
event.result = result;
|
||||
event.osAccountId = osAccountId;
|
||||
|
||||
const char *appId = GetStringFromJson(params, FIELD_APP_ID);
|
||||
if (appId == NULL) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(event.appId, EVENT_APPID_LEN, appId, HcStrlen(appId)) != EOK) {
|
||||
(void)memset_s(event.appId, EVENT_APPID_LEN, 0, EVENT_APPID_LEN);
|
||||
}
|
||||
|
||||
ReportCoreFuncInvokeEvent(&event);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 "hidump_adapter.h"
|
||||
|
||||
static DumpCallBack g_dumpCallBack = NULL;
|
||||
|
||||
void DevAuthDump(int fd)
|
||||
{
|
||||
if (g_dumpCallBack != NULL) {
|
||||
g_dumpCallBack(fd);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterDumpFunc(DumpCallBack func)
|
||||
{
|
||||
g_dumpCallBack = func;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "hisysevent_adapter.h"
|
||||
#include "hisysevent.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
constexpr char STR_EVENT_CORE_FUNCTION[] = "CORE_FUNCTION";
|
||||
constexpr char STR_EVENT[] = "EVENT";
|
||||
constexpr char STR_APP_ID[] = "APP_ID";
|
||||
constexpr char STR_BATCH_NUMBER[] = "BATCH_NUMBER";
|
||||
constexpr char STR_RESULT[] = "RESULT";
|
||||
constexpr char STR_OS_ACCOUNT_ID[] = "OS_ACCOUNT_ID";
|
||||
|
||||
void ReportCoreFuncInvokeEvent(const InvokeEvent *event)
|
||||
{
|
||||
if (event == nullptr) {
|
||||
return;
|
||||
}
|
||||
OHOS::HiviewDFX::HiSysEvent::Write(
|
||||
OHOS::HiviewDFX::HiSysEvent::Domain::DEVICE_AUTH,
|
||||
STR_EVENT_CORE_FUNCTION,
|
||||
OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC,
|
||||
STR_EVENT, event->eventId,
|
||||
STR_APP_ID, event->appId,
|
||||
STR_BATCH_NUMBER, event->batchNumber,
|
||||
STR_RESULT, event->result,
|
||||
STR_OS_ACCOUNT_ID, event->osAccountId);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "hitrace_adapter.h"
|
||||
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void DevAuthStartTrace(const char *value)
|
||||
{
|
||||
if (value == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
StartTrace(HITRACE_TAG_APP, value);
|
||||
}
|
||||
|
||||
void DevAuthFinishTrace(void)
|
||||
{
|
||||
FinishTrace(HITRACE_TAG_APP);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "dev_auth_hievent.h"
|
||||
#include "hidump_adapter.h"
|
||||
#include "hisysevent_adapter.h"
|
||||
#include "hitrace_adapter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// dev_auth_hievent
|
||||
void ReportHiEventCoreFuncInvoke(int32_t eventId, int32_t osAccountId, CJson *params, int32_t result)
|
||||
{
|
||||
(void)eventId;
|
||||
(void)osAccountId;
|
||||
(void)params;
|
||||
(void)result;
|
||||
}
|
||||
|
||||
// hidump_adapter
|
||||
void DevAuthDump(int fd)
|
||||
{
|
||||
(void)fd;
|
||||
}
|
||||
|
||||
void RegisterDumpFunc(DumpCallBack func)
|
||||
{
|
||||
(void)func;
|
||||
}
|
||||
|
||||
// hisysevent_adapter
|
||||
void ReportCoreFuncInvokeEvent(const InvokeEvent *event)
|
||||
{
|
||||
(void)event;
|
||||
}
|
||||
|
||||
// hitrace_adapter
|
||||
void DevAuthStartTrace(const char *value)
|
||||
{
|
||||
(void)value;
|
||||
}
|
||||
|
||||
void DevAuthFinishTrace(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "hc_vector.h"
|
||||
#include "account_module.h"
|
||||
#include "version_util.h"
|
||||
#include "hitrace_adapter.h"
|
||||
|
||||
DECLARE_HC_VECTOR(AuthModuleVec, void *);
|
||||
IMPLEMENT_HC_VECTOR(AuthModuleVec, void *, 1)
|
||||
@@ -185,7 +186,9 @@ int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int32_t *status, in
|
||||
LOGE("Unsupported method in the module, moduleType: %d.", moduleType);
|
||||
return HC_ERR_UNSUPPORTED_METHOD;
|
||||
}
|
||||
DevAuthStartTrace(TRACE_TAG_AUTH_PROCESS);
|
||||
int32_t res = module->processTask(taskId, in, out, status);
|
||||
DevAuthFinishTrace();
|
||||
if (res != HC_SUCCESS) {
|
||||
LOGE("Process task failed, taskId: %d, moduleType: %d, res: %d.", taskId, moduleType, res);
|
||||
return res;
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
#include "across_account_group.h"
|
||||
#include "identical_account_group.h"
|
||||
#include "peer_to_peer_group.h"
|
||||
|
||||
#include "dev_auth_hievent.h"
|
||||
#include "hisysevent_adapter.h"
|
||||
|
||||
static bool IsGroupTypeSupported(int groupType)
|
||||
{
|
||||
@@ -559,6 +560,9 @@ static void DoCreateGroup(HcTaskBase *baseTask)
|
||||
LOGI("[Start]: DoCreateGroup! [ReqId]: %" PRId64, task->reqId);
|
||||
char *returnJsonStr = NULL;
|
||||
int32_t result = CreateGroup(task->osAccountId, task->params, &returnJsonStr);
|
||||
|
||||
ReportHiEventCoreFuncInvoke(EVENT_ID_CREATE_GROUP, task->osAccountId, task->params, result);
|
||||
|
||||
if (result != HC_SUCCESS) {
|
||||
ProcessErrorCallback(task->reqId, GROUP_CREATE, result, NULL, task->cb);
|
||||
} else {
|
||||
@@ -577,6 +581,9 @@ static void DoDeleteGroup(HcTaskBase *baseTask)
|
||||
LOGI("[Start]: DoDeleteGroup! [ReqId]: %" PRId64, task->reqId);
|
||||
char *returnJsonStr = NULL;
|
||||
int32_t result = DeleteGroup(task->osAccountId, task->params, &returnJsonStr);
|
||||
|
||||
ReportHiEventCoreFuncInvoke(EVENT_ID_DELETE_GROUP, task->osAccountId, task->params, result);
|
||||
|
||||
if (result != HC_SUCCESS) {
|
||||
ProcessErrorCallback(task->reqId, GROUP_DISBAND, result, NULL, task->cb);
|
||||
} else {
|
||||
@@ -594,6 +601,9 @@ static void DoAddMember(HcTaskBase *baseTask)
|
||||
GroupManagerTask *task = (GroupManagerTask *)baseTask;
|
||||
LOGI("[Start]: DoAddMember! [ReqId]: %" PRId64, task->reqId);
|
||||
(void)AddMemberToPeerToPeerGroup(task->osAccountId, task->reqId, task->params, task->cb);
|
||||
|
||||
// 0 means success
|
||||
ReportHiEventCoreFuncInvoke(EVENT_ID_ADD_MEMBER, task->osAccountId, task->params, 0);
|
||||
}
|
||||
|
||||
static void DoDeleteMember(HcTaskBase *baseTask)
|
||||
@@ -605,6 +615,9 @@ static void DoDeleteMember(HcTaskBase *baseTask)
|
||||
GroupManagerTask *task = (GroupManagerTask *)baseTask;
|
||||
LOGI("[Start]: DoDeleteMember! [ReqId]: %" PRId64, task->reqId);
|
||||
(void)DeleteMemberFromPeerToPeerGroup(task->osAccountId, task->reqId, task->params, task->cb);
|
||||
|
||||
// 0 means success
|
||||
ReportHiEventCoreFuncInvoke(EVENT_ID_DELETE_MEMBER, task->osAccountId, task->params, 0);
|
||||
}
|
||||
|
||||
static void DoProcessBindData(HcTaskBase *baseTask)
|
||||
@@ -781,6 +794,8 @@ static int32_t RequestAddMultiMembersToGroup(int32_t osAccountId, const char *ap
|
||||
res = HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
FreeJson(params);
|
||||
|
||||
ReportHiEventCoreFuncInvoke(EVENT_ID_ADD_MULTI_MEMBERS, osAccountId, params, res);
|
||||
LOGI("[End]: RequestAddMultiMembersToGroup!");
|
||||
return res;
|
||||
}
|
||||
@@ -820,6 +835,7 @@ static int32_t RequestDelMultiMembersFromGroup(int32_t osAccountId, const char *
|
||||
res = HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
FreeJson(params);
|
||||
ReportHiEventCoreFuncInvoke(EVENT_ID_DELETE_MULTI_MEMBERS, osAccountId, params, res);
|
||||
LOGI("[End]: RequestDelMultiMembersFromGroup!");
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ ohos_unittest("deviceauth_llt") {
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
"${dev_frameworks_path}/inc/hiview_adapter",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -58,6 +59,7 @@ ohos_unittest("deviceauth_llt") {
|
||||
"${os_adapter_path}/impl/src/linux/hc_types.c",
|
||||
]
|
||||
sources += deviceauth_files
|
||||
sources += hiview_adapter_mock_files
|
||||
sources += [ "source/deviceauth_standard_test.cpp" ]
|
||||
|
||||
deps = [
|
||||
|
||||
Reference in New Issue
Block a user