Add IGnssConfiguration AIDL HAL (hardware/interfaces)
In default implementation, both AIDL HAL and the v2.1 HIDL HAL services
are running in the same process. The HIDL HAL implementation is able to
interact with the AIDL HAL implementation.
Bug: 168111993
Bug: 150192654
Test: on cuttlefish
Change-Id: Ib2770780b62a939f6ca447dfb6a6ab888c526fec
diff --git a/gnss/aidl/default/service.cpp b/gnss/aidl/default/service.cpp
index c79a271..09f1ad2 100644
--- a/gnss/aidl/default/service.cpp
+++ b/gnss/aidl/default/service.cpp
@@ -14,22 +14,45 @@
* limitations under the License.
*/
-#include "Gnss.h"
+#define LOG_TAG "Gnss-main"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
+#include <hidl/HidlSupport.h>
+#include <hidl/HidlTransportSupport.h>
+#include <log/log.h>
+#include <pthread.h>
+#include "Gnss.h"
+#include "GnssHidlHal.h"
using aidl::android::hardware::gnss::Gnss;
+using aidl::android::hardware::gnss::GnssHidlHal;
+using ::android::OK;
+using ::android::sp;
+using ::android::hardware::configureRpcThreadpool;
+using ::android::hardware::joinRpcThreadpool;
+using ::android::hardware::gnss::V2_1::IGnss;
int main() {
- ABinderProcess_setThreadPoolMaxThreadCount(0);
- std::shared_ptr<Gnss> vib = ndk::SharedRefBase::make<Gnss>();
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+ std::shared_ptr<Gnss> gnssAidl = ndk::SharedRefBase::make<Gnss>();
const std::string instance = std::string() + Gnss::descriptor + "/default";
- binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str());
+ binder_status_t status =
+ AServiceManager_addService(gnssAidl->asBinder().get(), instance.c_str());
CHECK(status == STATUS_OK);
+ sp<IGnss> gnss = new GnssHidlHal(gnssAidl);
+ configureRpcThreadpool(1, true /* will join */);
+ if (gnss->registerAsService() != OK) {
+ ALOGE("Could not register gnss 2.1 service.");
+ return 0;
+ }
+
+ joinRpcThreadpool();
ABinderProcess_joinThreadPool();
+
return EXIT_FAILURE; // should not reach
}