1 /*
2 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
3 * Not a Contribution
4 */
5 /*
6 * Copyright (C) 2016 The Android Open Source Project
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 #define LOG_TAG "android.hardware.gnss@1.0-service-qti"
22
23 #include <android/hardware/gnss/1.0/IGnss.h>
24 #include <hidl/LegacySupport.h>
25 #include "loc_cfg.h"
26 #include "loc_misc_utils.h"
27
28 extern "C" {
29 #include "vndfwk-detect.h"
30 }
31
32 #ifdef ARCH_ARM_32
33 #define DEFAULT_HW_BINDER_MEM_SIZE 65536
34 #endif
35
36 using android::hardware::gnss::V1_0::IGnss;
37
38 using android::hardware::configureRpcThreadpool;
39 using android::hardware::registerPassthroughServiceImplementation;
40 using android::hardware::joinRpcThreadpool;
41
42 using android::status_t;
43 using android::OK;
44
45 typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []);
46
main()47 int main() {
48
49 ALOGI("%s", __FUNCTION__);
50
51 bool vendorEnhanced = isRunningWithVendorEnhancedFramework();
52 setVendorEnhanced(vendorEnhanced);
53
54 #ifdef ARCH_ARM_32
55 android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE));
56 #endif
57 configureRpcThreadpool(1, true);
58 status_t status;
59
60 status = registerPassthroughServiceImplementation<IGnss>();
61 if (status == OK) {
62 if (vendorEnhanced) {
63 #ifdef LOC_HIDL_VERSION
64 #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
65
66 void* libHandle = NULL;
67 vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
68 dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
69 if (NULL != vendorEnhancedMainMethod) {
70 (*vendorEnhancedMainMethod)(0, NULL);
71 }
72 #else
73 ALOGE("LOC_HIDL_VERSION not defined.");
74 #endif
75 }
76
77 joinRpcThreadpool();
78
79 } else {
80 ALOGE("Error while registering IGnss 1.0 service: %d", status);
81 }
82
83 return 0;
84 }
85