mirror of
https://github.com/openharmony/distributed_screen.git
synced 2026-07-19 17:04:08 -04:00
@@ -27,6 +27,7 @@ ohos_shared_library("distributed_screen_utils") {
|
||||
sources = [
|
||||
"src/dscreen_hisysevent.cpp",
|
||||
"src/dscreen_log.cpp",
|
||||
"src/dscreen_sa_process_state.cpp",
|
||||
"src/dscreen_util.cpp",
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 DSCREEN_SA_PROCESS_STATE_H
|
||||
#define DSCREEN_SA_PROCESS_STATE_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SetSinkProcessExit();
|
||||
void SetSourceProcessExit();
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // DSCREEN_SA_PROCESS_STATE_H
|
||||
@@ -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 "dscreen_sa_process_state.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "dscreen_constants.h"
|
||||
#include "dscreen_hisysevent.h"
|
||||
#include "dscreen_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
enum DScreenSAState : uint32_t {
|
||||
DSCREEN_SA_EXIT_STATE_START = 0,
|
||||
DSCREEN_SA_EXIT_STATE_STOP = 1
|
||||
};
|
||||
|
||||
DScreenSAState g_sinkSAState = DSCREEN_SA_EXIT_STATE_START;
|
||||
DScreenSAState g_sourceSAState = DSCREEN_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 = DSCREEN_SA_EXIT_STATE_STOP;
|
||||
DHLOGI("g_sourceSAState = %d g_sinkSAState = %d", g_sourceSAState, g_sinkSAState);
|
||||
if (g_sourceSAState == DSCREEN_SA_EXIT_STATE_START || g_sinkSAState == DSCREEN_SA_EXIT_STATE_START) {
|
||||
return;
|
||||
}
|
||||
DHLOGI("exit sa process success.");
|
||||
ReportSaEvent(DSCREEN_EXIT, DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, "dscreen sink sa exit success.");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void SetSourceProcessExit()
|
||||
{
|
||||
DHLOGI("set sources process exit.");
|
||||
std::lock_guard<std::mutex> autoLock(g_saProcessState);
|
||||
g_sourceSAState = DSCREEN_SA_EXIT_STATE_STOP;
|
||||
DHLOGI("g_sourceSAState = %d g_sinkSAState = %d", g_sourceSAState, g_sinkSAState);
|
||||
if (g_sourceSAState == DSCREEN_SA_EXIT_STATE_START || g_sinkSAState == DSCREEN_SA_EXIT_STATE_START) {
|
||||
return;
|
||||
}
|
||||
DHLOGI("exit sa process success.");
|
||||
ReportSaEvent(DSCREEN_EXIT, DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, "dscreen source sa exit success.");
|
||||
exit(0);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
#include "dscreen_constants.h"
|
||||
#include "dscreen_errcode.h"
|
||||
#include "dscreen_hisysevent.h"
|
||||
#include "dscreen_log.h"
|
||||
#include "dscreen_sa_process_state.h"
|
||||
#include "dscreen_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -79,8 +79,7 @@ int32_t DScreenSinkService::ReleaseSink()
|
||||
DHLOGI("ReleaseSink");
|
||||
ScreenRegionManager::GetInstance().ReleaseAllRegions();
|
||||
DHLOGI("exit sink sa process");
|
||||
ReportSaEvent(DSCREEN_EXIT, DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, "dscreen sink sa exit success.");
|
||||
exit(0);
|
||||
SetSinkProcessExit();
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ int32_t DScreenManager::EnableDistributedScreen(const std::string &devId, const
|
||||
|
||||
std::string dScreenIdx = devId + SEPERATOR + dhId;
|
||||
std::shared_ptr<DScreen> dScreen = nullptr;
|
||||
std::lock_guard<std::mutex> lock(dScreenMapMtx_);
|
||||
if (dScreens_.count(dScreenIdx) != 0) {
|
||||
dScreen = dScreens_[dScreenIdx];
|
||||
}
|
||||
@@ -248,6 +249,7 @@ int32_t DScreenManager::DisableDistributedScreen(const std::string &devId, const
|
||||
GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str());
|
||||
|
||||
std::string dScreenIdx = devId + SEPERATOR + dhId;
|
||||
std::lock_guard<std::mutex> lock(dScreenMapMtx_);
|
||||
if (dScreens_.count(dScreenIdx) == 0) {
|
||||
DHLOGE("dscreen not found, devId: %s, dhId: %s",
|
||||
GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str());
|
||||
@@ -310,6 +312,7 @@ void DScreenManager::GetScreenDumpInfo(std::string &result)
|
||||
DHLOGI("GetScreenDumpInfo.");
|
||||
result.clear();
|
||||
result.append("RemoteScreens OnLine:\n[\n");
|
||||
std::lock_guard<std::mutex> lock(dScreenMapMtx_);
|
||||
if (dScreens_.size() == 0) {
|
||||
result.append("]");
|
||||
DHLOGD("no virtualscreen");
|
||||
@@ -448,6 +451,7 @@ void DScreenManager::HandleNotifySetUpResult(const std::string &remoteDevId, con
|
||||
std::string errContent = eventContentJson[KEY_ERR_CONTENT];
|
||||
|
||||
std::string dScreenIdx = remoteDevId + SEPERATOR + dhId;
|
||||
std::lock_guard<std::mutex> lock(dScreenMapMtx_);
|
||||
if (dScreens_.count(dScreenIdx) == 0) {
|
||||
DHLOGE("dScreen not found, remoteDevId:%s, dhId:%s",
|
||||
GetAnonyString(remoteDevId).c_str(), GetAnonyString(dhId).c_str());
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "dscreen_errcode.h"
|
||||
#include "dscreen_hisysevent.h"
|
||||
#include "dscreen_log.h"
|
||||
#include "dscreen_sa_process_state.h"
|
||||
#include "dscreen_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -95,8 +96,7 @@ int32_t DScreenSourceService::ReleaseSource()
|
||||
return ret;
|
||||
}
|
||||
DHLOGI("exit source sa process");
|
||||
ReportSaEvent(DSCREEN_EXIT, DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, "dscreen source sa exit success.");
|
||||
exit(0);
|
||||
SetSourceProcessExit();
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user