diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2023-10-15 15:43:51 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2023-10-26 00:41:55 +0300 |
commit | 5d6e250cf1175ede73764514b3cd9359467ddcaf (patch) | |
tree | b987927fc37c3e39d8114559485a10cc7d447231 /homescreen/src/AglShellGrpcClient.cpp | |
parent | 36e2c9697e431414ae0263635f3ebf1f3c200723 (diff) |
AglShellGrpcClient: Activate windows with gRPC
In order to use HomescreenHandler we need to have a way to pass it, so
extend the callback mechanism to be able to pass other objects as well.
HomescreenHandler is the one that handles, indirectly, the activation
and that keeps track of the application status. We used in the direct
wayland event handler to we're going to re-use it as well.
Bug-AGL: SPEC-4912
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I6eae6a5c4e144f3024dfcad6e5e0a54a8fec78a6
Diffstat (limited to 'homescreen/src/AglShellGrpcClient.cpp')
-rw-r--r-- | homescreen/src/AglShellGrpcClient.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/homescreen/src/AglShellGrpcClient.cpp b/homescreen/src/AglShellGrpcClient.cpp index 6f4ff24..ee7510f 100644 --- a/homescreen/src/AglShellGrpcClient.cpp +++ b/homescreen/src/AglShellGrpcClient.cpp @@ -3,6 +3,7 @@ #include <mutex> #include <condition_variable> +#include <chrono> #include <grpc/grpc.h> #include <grpcpp/grpcpp.h> #include <grpcpp/server.h> @@ -14,6 +15,9 @@ #include "AglShellGrpcClient.h" #include "agl_shell.grpc.pb.h" +#include "hmi-debug.h" + +using namespace std::chrono; namespace { const char kDefaultGrpcServiceAddress[] = "127.0.0.1:14005"; @@ -21,9 +25,25 @@ namespace { GrpcClient::GrpcClient() { + struct timespec ts; auto channel = grpc::CreateChannel(kDefaultGrpcServiceAddress, grpc::InsecureChannelCredentials()); + clock_gettime(CLOCK_MONOTONIC, &ts); + ts.tv_sec = 0; + ts.tv_nsec = 500 * 1000 * 1000; // 500ms + + bool try_to_connect = true; + grpc_connectivity_state state = channel->GetState(try_to_connect); + + while (state != GRPC_CHANNEL_READY) { + state = channel->GetState(try_to_connect); + + HMI_DEBUG("HomesScreen", "waiting for channel state to be ready, current state %d", state); + nanosleep(&ts, NULL); + } + + // init the stub here m_stub = agl_shell_ipc::AglShellManagerService::NewStub(channel); reader = new Reader(m_stub.get()); @@ -159,9 +179,9 @@ GrpcClient::Wait(void) } void -GrpcClient::AppStatusState(Callback callback) +GrpcClient::AppStatusState(Callback callback, void *data) { - reader->AppStatusState(callback); + reader->AppStatusState(callback, data); } std::vector<std::string> |