mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-24 13:55:31 -04:00
@@ -19,6 +19,7 @@
|
||||
#include "i_distributed_source_input.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
#include "iremote_stub.h"
|
||||
|
||||
@@ -57,6 +58,8 @@ private:
|
||||
int32_t HandleRegisterSimulationEventListener(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleUnregisterSimulationEventListener(MessageParcel &data, MessageParcel &reply);
|
||||
DISALLOW_COPY_AND_MOVE(DistributedInputSourceStub);
|
||||
private:
|
||||
std::atomic<bool> sourceInitFlag_ {false};
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -31,11 +31,16 @@ DistributedInputSourceStub::~DistributedInputSourceStub()
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply)
|
||||
{
|
||||
if (sourceInitFlag_.load()) {
|
||||
DHLOGE("DistributedInputSourceStub already init.");
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
int32_t ret = Init();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
DHLOGE("DistributedInputSourceStub Init write ret failed");
|
||||
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
|
||||
}
|
||||
sourceInitFlag_.store(true);
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user