Michael Bestas | 3a0209e | 2023-05-04 01:15:47 +0300 | [diff] [blame] | 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.1-service-qti" |
| 22 | |
| 23 | #include <android/hardware/gnss/1.1/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_1::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 | |
| 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 | if (vendorEnhanced) { |
| 64 | #ifdef LOC_HIDL_VERSION |
| 65 | #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so" |
| 66 | |
| 67 | void* libHandle = NULL; |
| 68 | vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*) |
| 69 | dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main"); |
| 70 | if (NULL != vendorEnhancedMainMethod) { |
| 71 | (*vendorEnhancedMainMethod)(0, NULL); |
| 72 | } |
| 73 | #else |
| 74 | ALOGE("LOC_HIDL_VERSION not defined."); |
| 75 | #endif |
| 76 | } |
| 77 | |
| 78 | joinRpcThreadpool(); |
| 79 | |
| 80 | } else { |
| 81 | ALOGE("Error while registering IGnss 1.1 service: %d", status); |
| 82 | } |
| 83 | |
| 84 | return 0; |
| 85 | } |