SA crash pull up sdk

Signed-off-by: l30054665 <lishang21@huawei.com>
This commit is contained in:
l30054665
2024-01-25 20:18:31 +08:00
parent d77a30a5c4
commit 08fbd5698d
3 changed files with 62 additions and 4 deletions
@@ -115,6 +115,7 @@ public:
void CheckSinkRegisterCallback();
void CheckSharingDhIdsCallback();
void CheckSinkScreenInfoCallback();
int32_t RestoreRegisterListenerAndCallback();
public:
class RegisterDInputCb : public OHOS::DistributedHardware::DistributedInput::RegisterDInputCallbackStub {
@@ -190,6 +191,8 @@ private:
sptr<ISimulationEventListener> unregSimulationEventListener_ = nullptr;
std::set<sptr<ISharingDhIdListener>> sharingDhIdListeners_;
std::set<sptr<GetSinkScreenInfosCb>> getSinkScreenInfosCallbacks_;
std::set<sptr<ISimulationEventListener>> addSaListeners_;
sptr<ISessionStateCallback> addSaCallback_ = nullptr;
std::shared_ptr<DistributedInputClient::DInputClientEventHandler> eventHandler_;
@@ -220,6 +223,8 @@ private:
std::mutex sharingDhIdsMtx_;
// sharing local dhids
std::set<std::string> sharingDhIds_;
std::mutex addSaListenersMtx_;
std::mutex addSaCallbackMtx_;
};
} // namespace DistributedInput
} // namespace DistributedHardware
+13 -4
View File
@@ -21,6 +21,7 @@
#include "constants_dinput.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "distributed_input_client.h"
namespace OHOS {
namespace DistributedHardware {
@@ -76,8 +77,12 @@ void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAb
DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG");
AppExecFwk::InnerEvent::Pointer msgEvent =
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG, systemAbilityId);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent, DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent,
DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
int32_t result = DistributedInputClient::GetInstance().RestoreRegisterListenerAndCallback();
if (result != DH_SUCCESS) {
DHLOGE("source sa execute RestoreRegisterListenerAndCallback fail, result = %d", result);
}
}
@@ -88,8 +93,12 @@ void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAb
DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG");
AppExecFwk::InnerEvent::Pointer msgEvent =
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG, systemAbilityId);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent, DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent,
DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME, AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
int32_t result = DistributedInputClient::GetInstance().RestoreRegisterListenerAndCallback();
if (result != DH_SUCCESS) {
DHLOGE("sink sa execute RestoreRegisterListenerAndCallback fail, result = %d", result);
}
}
DHLOGI("sa %d is added.", systemAbilityId);
@@ -581,8 +581,10 @@ int32_t DistributedInputClient::RegisterSimulationEventListener(sptr<ISimulation
}
int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(listener);
std::lock_guard<std::mutex> lock(addSaListenersMtx_);
if (ret == DH_SUCCESS) {
isSimulationEventCbReg = true;
addSaListeners_.insert(listener);
} else {
isSimulationEventCbReg = false;
regSimulationEventListener_ = listener;
@@ -607,6 +609,9 @@ int32_t DistributedInputClient::UnregisterSimulationEventListener(sptr<ISimulati
if (ret != DH_SUCCESS) {
DHLOGE("UnregisterSimulationEventListener Failed, ret = %d", ret);
}
std::lock_guard<std::mutex> lock(addSaListenersMtx_);
addSaListeners_.erase(listener);
return ret;
}
@@ -749,6 +754,8 @@ int32_t DistributedInputClient::RegisterSessionStateCb(sptr<ISessionStateCallbac
DHLOGE("RegisterSessionStateCb callback is null.");
return ERR_DH_INPUT_CLIENT_REGISTER_SESSION_STATE_FAIL;
}
std::lock_guard<std::mutex> lock(addSaCallbackMtx_);
addSaCallback_ = (callback);
return DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSessionStateCb(callback);
}
@@ -758,8 +765,45 @@ int32_t DistributedInputClient::UnregisterSessionStateCb()
DHLOGE("DinputStart client fail.");
return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL;
}
std::lock_guard<std::mutex> lock(addSaCallbackMtx_);
addSaCallback_ = nullptr;
return DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterSessionStateCb();
}
int32_t DistributedInputClient::RestoreRegisterListenerAndCallback()
{
DHLOGI("Restore RegisterPublisherListener");
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
DHLOGE("RestoreRegisterSimulationEventListener proxy error, client fail");
return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL;
}
int32_t result = DH_SUCCESS;
std::lock_guard<std::mutex> lock(addSaListenersMtx_);
for (const auto& listener : addSaListeners_) {
int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(listener);
if (ret != DH_SUCCESS) {
result = ret;
DHLOGE("SA execute RegisterSimulationEventListener fail, ret = %d", ret);
}
}
DHLOGI("Restore RegisterSessionStateCb");
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
DHLOGE("Restore RegisterSessionStateCb client fail.");
return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL;
}
{
std::lock_guard<std::mutex> lock(addSaCallbackMtx_);
int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSessionStateCb(addSaCallback_);
if (ret != DH_SUCCESS) {
result = ret;
DHLOGE("SA execute RegisterSessionStateCb fail, ret = %d", ret);
}
return result;
}
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS