Implement the GrpcWakeupClient.
Implement a remoteaccess HAL implementation that talks with
the wake up client using grpc.
Test: local build.
Bug: 241483300
Change-Id: I02a51f41427fa2854930d2076ca3a49791488fd9
diff --git a/automotive/remoteaccess/impl/default/client/Android.bp b/automotive/remoteaccess/impl/default/client/Android.bp
index 38c79af..6327637 100644
--- a/automotive/remoteaccess/impl/default/client/Android.bp
+++ b/automotive/remoteaccess/impl/default/client/Android.bp
@@ -32,6 +32,11 @@
"libbinder_ndk",
"liblog",
"libutils",
+ "libgrpc++",
+ "libprotobuf-cpp-full",
+ ],
+ cflags: [
+ "-Wno-unused-parameter",
],
}
@@ -45,10 +50,17 @@
],
whole_static_libs: [
"android.hardware.automotive.remoteaccess-V1-ndk",
+ "wakeup_client_protos",
],
shared_libs: [
+ "libbase",
"libbinder_ndk",
"liblog",
"libutils",
+ "libgrpc++",
+ "libprotobuf-cpp-full",
+ ],
+ cflags: [
+ "-Wno-unused-parameter",
],
}
diff --git a/automotive/remoteaccess/impl/default/client/include/RemoteAccessService.h b/automotive/remoteaccess/impl/default/client/include/RemoteAccessService.h
index c54aefe..f060b6c 100644
--- a/automotive/remoteaccess/impl/default/client/include/RemoteAccessService.h
+++ b/automotive/remoteaccess/impl/default/client/include/RemoteAccessService.h
@@ -19,8 +19,10 @@
#include <aidl/android/hardware/automotive/remoteaccess/ApState.h>
#include <aidl/android/hardware/automotive/remoteaccess/BnRemoteAccess.h>
#include <aidl/android/hardware/automotive/remoteaccess/IRemoteTaskCallback.h>
+#include <wakeup_client.grpc.pb.h>
#include <string>
+#include <thread>
namespace android {
namespace hardware {
@@ -30,9 +32,11 @@
class RemoteAccessService
: public aidl::android::hardware::automotive::remoteaccess::BnRemoteAccess {
public:
+ RemoteAccessService(WakeupClient::StubInterface* grpcStub);
+
ndk::ScopedAStatus getDeviceId(std::string* deviceId) override;
- ndk::ScopedAStatus getWakeupServiceName(std::string* wakeupServerName) override;
+ ndk::ScopedAStatus getWakeupServiceName(std::string* wakeupServiceName) override;
ndk::ScopedAStatus setRemoteTaskCallback(
const std::shared_ptr<
@@ -43,6 +47,14 @@
ndk::ScopedAStatus notifyApStateChange(
const aidl::android::hardware::automotive::remoteaccess::ApState& newState) override;
+
+ private:
+ WakeupClient::StubInterface* mGrpcStub;
+ std::shared_ptr<aidl::android::hardware::automotive::remoteaccess::IRemoteTaskCallback>
+ mRemoteTaskCallback;
+ std::thread mThread;
+
+ void taskLoop();
};
} // namespace remoteaccess
diff --git a/automotive/remoteaccess/impl/default/client/src/RemoteAccessImpl.cpp b/automotive/remoteaccess/impl/default/client/src/RemoteAccessImpl.cpp
index 91a6419..7431898 100644
--- a/automotive/remoteaccess/impl/default/client/src/RemoteAccessImpl.cpp
+++ b/automotive/remoteaccess/impl/default/client/src/RemoteAccessImpl.cpp
@@ -25,8 +25,9 @@
int main(int /* argc */, char* /* argv */[]) {
ALOGI("Registering RemoteAccessService as service...");
+ // TODO(b/241483300): Create GrpcClientStub here.
auto service = ndk::SharedRefBase::make<
- android::hardware::automotive::remoteaccess::RemoteAccessService>();
+ android::hardware::automotive::remoteaccess::RemoteAccessService>(nullptr);
binder_exception_t err = AServiceManager_addService(
service->asBinder().get(), "android.hardware.automotive.remote.IRemoteAccess/default");
diff --git a/automotive/remoteaccess/impl/default/client/src/RemoteAccessService.cpp b/automotive/remoteaccess/impl/default/client/src/RemoteAccessService.cpp
index e24293f..f567113 100644
--- a/automotive/remoteaccess/impl/default/client/src/RemoteAccessService.cpp
+++ b/automotive/remoteaccess/impl/default/client/src/RemoteAccessService.cpp
@@ -16,30 +16,58 @@
#include "RemoteAccessService.h"
+#include <android/binder_status.h>
+#include <grpc++/grpc++.h>
+#include <utils/Log.h>
+#include <chrono>
+#include <thread>
+
namespace android {
namespace hardware {
namespace automotive {
namespace remoteaccess {
+namespace {
+
using ::aidl::android::hardware::automotive::remoteaccess::ApState;
using ::aidl::android::hardware::automotive::remoteaccess::IRemoteTaskCallback;
+using ::grpc::ClientContext;
+using ::grpc::ClientReader;
+using ::grpc::Status;
+using ::grpc::StatusCode;
using ::ndk::ScopedAStatus;
-ScopedAStatus RemoteAccessService::getDeviceId([[maybe_unused]] std::string* deviceId) {
+const std::string WAKEUP_SERVICE_NAME = "com.google.vehicle.wakeup";
+
+} // namespace
+
+RemoteAccessService::RemoteAccessService(WakeupClient::StubInterface* grpcStub)
+ : mGrpcStub(grpcStub) {
+ // mThread = std::thread([this]() { taskLoop(); });
+}
+
+void RemoteAccessService::taskLoop() {
+ // TODO(b/241483300): handle remote tasks.
+}
+
+ScopedAStatus RemoteAccessService::getDeviceId(std::string* deviceId) {
+ // TODO(b/241483300): Call VHAL to get VIN.
return ScopedAStatus::ok();
}
-ScopedAStatus RemoteAccessService::getWakeupServiceName(
- [[maybe_unused]] std::string* wakeupServiceName) {
+ScopedAStatus RemoteAccessService::getWakeupServiceName(std::string* wakeupServiceName) {
+ *wakeupServiceName = WAKEUP_SERVICE_NAME;
return ScopedAStatus::ok();
}
ScopedAStatus RemoteAccessService::setRemoteTaskCallback(
[[maybe_unused]] const std::shared_ptr<IRemoteTaskCallback>& callback) {
+ mRemoteTaskCallback = callback;
return ScopedAStatus::ok();
}
ScopedAStatus RemoteAccessService::clearRemoteTaskCallback() {
+ mRemoteTaskCallback.reset();
return ScopedAStatus::ok();
}