2020-09-10 02:25:02 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2020, The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-10-01 02:01:53 +02:00
|
|
|
#define LOG_TAG "Gnss-main"
|
2020-09-10 02:25:02 +02:00
|
|
|
|
|
|
|
#include <android-base/logging.h>
|
|
|
|
#include <android/binder_manager.h>
|
|
|
|
#include <android/binder_process.h>
|
2020-10-01 02:01:53 +02:00
|
|
|
#include <hidl/HidlSupport.h>
|
|
|
|
#include <hidl/HidlTransportSupport.h>
|
|
|
|
#include <log/log.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "Gnss.h"
|
2020-09-10 02:25:02 +02:00
|
|
|
|
|
|
|
using aidl::android::hardware::gnss::Gnss;
|
2020-10-01 02:01:53 +02:00
|
|
|
using ::android::OK;
|
|
|
|
using ::android::sp;
|
|
|
|
using ::android::hardware::configureRpcThreadpool;
|
|
|
|
using ::android::hardware::joinRpcThreadpool;
|
2020-09-10 02:25:02 +02:00
|
|
|
|
|
|
|
int main() {
|
2020-10-01 02:01:53 +02:00
|
|
|
ABinderProcess_setThreadPoolMaxThreadCount(1);
|
|
|
|
ABinderProcess_startThreadPool();
|
2020-09-10 02:25:02 +02:00
|
|
|
|
2020-10-01 02:01:53 +02:00
|
|
|
std::shared_ptr<Gnss> gnssAidl = ndk::SharedRefBase::make<Gnss>();
|
2020-09-10 02:25:02 +02:00
|
|
|
const std::string instance = std::string() + Gnss::descriptor + "/default";
|
2020-10-01 02:01:53 +02:00
|
|
|
binder_status_t status =
|
|
|
|
AServiceManager_addService(gnssAidl->asBinder().get(), instance.c_str());
|
2021-12-14 02:45:47 +01:00
|
|
|
CHECK_EQ(status, STATUS_OK);
|
2020-09-10 02:25:02 +02:00
|
|
|
|
|
|
|
ABinderProcess_joinThreadPool();
|
2020-10-01 02:01:53 +02:00
|
|
|
|
2020-09-10 02:25:02 +02:00
|
|
|
return EXIT_FAILURE; // should not reach
|
|
|
|
}
|