1 /*
2 * Copyright (c) 2017-2019, 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@2.0-service-qti"
22
23 #include <android/hardware/gnss/2.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::V2_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 int vendorInfo = getVendorEnhancedInfo();
52 bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo );
53 setVendorEnhanced(vendorEnhanced);
54
55 #ifdef ARCH_ARM_32
56 android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE));
57 #endif
58 configureRpcThreadpool(1, true);
59 status_t status;
60
61 status = registerPassthroughServiceImplementation<IGnss>();
62 if (status == OK) {
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 ALOGI("LOC_HIDL_VERSION not defined.");
74 #endif
75
76 joinRpcThreadpool();
77
78 } else {
79 ALOGE("Error while registering IGnss 2.0 service: %d", status);
80 }
81
82 return 0;
83 }
84