1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include "wificond/scanning/offload/offload_service_utils.h" 17 18 #include <android-base/logging.h> 19 #include <cutils/properties.h> 20 21 #include "wificond/scanning/offload/offload_scan_manager.h" 22 #include "wificond/scanning/scanner_impl.h" 23 24 using ::android::hardware::wifi::offload::V1_0::IOffload; 25 26 namespace android { 27 namespace wificond { 28 GetOffloadService()29android::sp<IOffload> OffloadServiceUtils::GetOffloadService() { 30 return IOffload::tryGetService(); 31 } 32 GetOffloadCallback(OffloadCallbackHandlers * handlers)33android::sp<OffloadCallback> OffloadServiceUtils::GetOffloadCallback( 34 OffloadCallbackHandlers* handlers) { 35 return new OffloadCallback(handlers); 36 } 37 GetOffloadDeathRecipient(OffloadDeathRecipientHandler handler)38OffloadDeathRecipient* OffloadServiceUtils::GetOffloadDeathRecipient( 39 OffloadDeathRecipientHandler handler) { 40 return new OffloadDeathRecipient(handler); 41 } 42 IsOffloadScanSupported() const43bool OffloadServiceUtils::IsOffloadScanSupported() const { 44 if (property_get_bool("persist.wifi.offload.enable", false)) { 45 LOG(INFO) << "Offload HAL supported"; 46 return true; 47 } 48 LOG(INFO) << "Offload HAL not supported "; 49 return false; 50 } 51 52 std::shared_ptr<OffloadScanCallbackInterfaceImpl> GetOffloadScanCallbackInterface(ScannerImpl * parent)53OffloadServiceUtils::GetOffloadScanCallbackInterface(ScannerImpl* parent) { 54 return std::make_shared<OffloadScanCallbackInterfaceImpl>(parent); 55 } 56 GetOffloadScanManager(std::weak_ptr<OffloadServiceUtils> service_utils,std::shared_ptr<OffloadScanCallbackInterfaceImpl> callback_interface)57std::shared_ptr<OffloadScanManager> OffloadServiceUtils::GetOffloadScanManager( 58 std::weak_ptr<OffloadServiceUtils> service_utils, 59 std::shared_ptr<OffloadScanCallbackInterfaceImpl> callback_interface) { 60 return std::make_shared<OffloadScanManager>(service_utils, callback_interface); 61 } 62 OffloadDeathRecipient(OffloadDeathRecipientHandler handler)63OffloadDeathRecipient::OffloadDeathRecipient( 64 OffloadDeathRecipientHandler handler) 65 : handler_(handler) {} 66 67 } // namespace wificond 68 } // namespace android 69