mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
Description:sync exit sa
Match-id-9b195d96119e260de35b902663bd9f29404ae86d
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 "dinput_sa_process_state.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "distributed_hardware_log.h"
|
||||
|
||||
#include "constants_dinput.h"
|
||||
#include "hisysevent_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
enum DInputSAState : uint32_t {
|
||||
DINPUT_SA_EXIT_STATE_START = 0,
|
||||
DINPUT_SA_EXIT_STATE_STOP = 1
|
||||
};
|
||||
|
||||
DInputSAState g_sinkSAState = DINPUT_SA_EXIT_STATE_START;
|
||||
DInputSAState g_sourceSAState = DINPUT_SA_EXIT_STATE_START;
|
||||
std::mutex g_saProcessState;
|
||||
|
||||
void SetSinkProcessExit()
|
||||
{
|
||||
DHLOGI("set sink process exit.");
|
||||
std::lock_guard<std::mutex> autoLock(g_saProcessState);
|
||||
g_sinkSAState = DINPUT_SA_EXIT_STATE_STOP;
|
||||
DHLOGI("g_sourceSAState = %d g_sinkSAState = %d", g_sourceSAState, g_sinkSAState);
|
||||
if (g_sourceSAState == DINPUT_SA_EXIT_STATE_START || g_sinkSAState == DINPUT_SA_EXIT_STATE_START) {
|
||||
return;
|
||||
}
|
||||
DHLOGI("exit sa process success.");
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_EXIT, "dinput sink sa exit success.");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void SetSourceProcessExit()
|
||||
{
|
||||
DHLOGI("set sources process exit.");
|
||||
std::lock_guard<std::mutex> autoLock(g_saProcessState);
|
||||
g_sourceSAState = DINPUT_SA_EXIT_STATE_STOP;
|
||||
DHLOGI("g_sourceSAState = %d g_sinkSAState = %d", g_sourceSAState, g_sinkSAState);
|
||||
if (g_sourceSAState == DINPUT_SA_EXIT_STATE_START || g_sinkSAState == DINPUT_SA_EXIT_STATE_START) {
|
||||
return;
|
||||
}
|
||||
DHLOGI("exit sa process success.");
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_EXIT, "dinput source sa exit success.");
|
||||
exit(0);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 DINPUT_SA_PROCESS_STATE_H
|
||||
#define DINPUT_SA_PROCESS_STATE_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
void SetSinkProcessExit();
|
||||
void SetSourceProcessExit();
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // DINPUT_SA_PROCESS_STATE_H
|
||||
@@ -588,8 +588,8 @@ std::string InputHub::StringPrintf(const char* format, ...) const
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string result;
|
||||
size_t ret = vsnprintf_s(space, sizeof(space), sizeof(space) - 1, format, ap);
|
||||
if (ret >= DH_SUCCESS && ret < sizeof(space)) {
|
||||
int32_t ret = vsnprintf_s(space, sizeof(space), sizeof(space) - 1, format, ap);
|
||||
if (ret >= DH_SUCCESS && (size_t)ret < sizeof(space)) {
|
||||
result = space;
|
||||
} else {
|
||||
return "the buffer is overflow!";
|
||||
|
||||
@@ -42,6 +42,7 @@ ohos_shared_library("libdinput_sink") {
|
||||
"src/distributed_input_sink_event_handler.cpp",
|
||||
"${ipc_path}/src/distributed_input_sink_stub.cpp",
|
||||
"${common_path}/include/white_list_util.cpp",
|
||||
"${common_path}/include/dinput_sa_process_state.cpp",
|
||||
"${ipc_path}/src/start_d_input_server_call_back_proxy.cpp",
|
||||
"${ipc_path}/src/start_d_input_server_call_back_stub.cpp",
|
||||
]
|
||||
@@ -68,6 +69,7 @@ ohos_shared_library("libdinput_sink") {
|
||||
"safwk:system_ability_fwk",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"hisysevent_native:libhisysevent",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "distributed_input_sink_transport.h"
|
||||
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_sa_process_state.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
#include "hidumper.h"
|
||||
#include "white_list_util.h"
|
||||
@@ -300,7 +301,7 @@ int32_t DistributedInputSinkManager::Release()
|
||||
|
||||
serviceRunningState_ = ServiceSinkRunningState::STATE_NOT_START;
|
||||
DHLOGI("exit dinput sink sa.");
|
||||
exit(0);
|
||||
SetSinkProcessExit();
|
||||
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
sources = [
|
||||
"${common_path}/include/white_list_util.cpp",
|
||||
"${common_path}/include/input_hub.cpp",
|
||||
"${common_path}/include/dinput_sa_process_state.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp",
|
||||
@@ -91,6 +92,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
"safwk:system_ability_fwk",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"hisysevent_native:libhisysevent",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
@@ -42,6 +42,7 @@ ohos_shared_library("libdinput_source") {
|
||||
"src/distributed_input_source_manager.cpp",
|
||||
"src/distributed_input_source_event_handler.cpp",
|
||||
"${common_path}/include/white_list_util.cpp",
|
||||
"${common_path}/include/dinput_sa_process_state.cpp",
|
||||
"${ipc_path}/src/add_white_list_infos_call_back_proxy.cpp",
|
||||
"${ipc_path}/src/add_white_list_infos_call_back_stub.cpp",
|
||||
"${ipc_path}/src/del_white_list_infos_call_back_proxy.cpp",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "constants_dinput.h"
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_hitrace.h"
|
||||
#include "dinput_sa_process_state.h"
|
||||
#include "distributed_input_inject.h"
|
||||
#include "distributed_input_source_transport.h"
|
||||
#include "hisysevent_util.h"
|
||||
@@ -535,7 +536,7 @@ int32_t DistributedInputSourceManager::Release()
|
||||
|
||||
serviceRunningState_ = ServiceSourceRunningState::STATE_NOT_START;
|
||||
DHLOGI("exit dinput source sa.");
|
||||
exit(0);
|
||||
SetSourceProcessExit();
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ ohos_unittest("distributed_input_sourcemanager_test") {
|
||||
"//foundation/distributedhardware/distributed_input/services/source/sourcemanager/src/distributed_input_source_manager.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/sourcemanager/src/distributed_input_source_event_handler.cpp",
|
||||
"distributed_input_sourcemanager_test.cpp",
|
||||
"${common_path}/include/dinput_sa_process_state.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/src/distributed_input_inject.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/src/distributed_input_node_manager.cpp",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/src/virtual_device.cpp",
|
||||
|
||||
@@ -74,8 +74,6 @@ void DistributedInputSinkHandler::FinishStartSA(const std::string ¶ms, const
|
||||
|
||||
int32_t DistributedInputSinkHandler::ReleaseSink()
|
||||
{
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_EXIT,
|
||||
"dinput exit sink sa release.");
|
||||
return DistributedInputClient::GetInstance().ReleaseSink();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,6 @@ void DistributedInputSourceHandler::FinishStartSA(const std::string ¶ms, con
|
||||
|
||||
int32_t DistributedInputSourceHandler::ReleaseSource()
|
||||
{
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_EXIT,
|
||||
"dinput exit source sa release.");
|
||||
return DistributedInputClient::GetInstance().ReleaseSource();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user