1 /* 2 * Copyright (C) 2020 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 17 #ifndef CHRE_UTIL_SYSTEM_WIFI_UTIL_H_ 18 #define CHRE_UTIL_SYSTEM_WIFI_UTIL_H_ 19 20 #include <chre.h> 21 22 namespace chre { 23 24 // Return a v1.4-compliant chreWifiScanParams from a v1.5+ one. translateToLegacyWifiScanParams(const struct chreWifiScanParams * params)25struct chreWifiScanParams translateToLegacyWifiScanParams( 26 const struct chreWifiScanParams *params) { 27 // Copy v1.4-compliant fields over. 28 struct chreWifiScanParams legacyParams = {}; 29 legacyParams.scanType = params->scanType; 30 legacyParams.maxScanAgeMs = params->maxScanAgeMs; 31 legacyParams.frequencyListLen = params->frequencyListLen; 32 legacyParams.frequencyList = params->frequencyList; 33 legacyParams.ssidListLen = params->ssidListLen; 34 legacyParams.ssidList = params->ssidList; 35 legacyParams.radioChainPref = params->radioChainPref; 36 37 // channelSet is ignored by v1.4- platforms. 38 39 if (params->scanType == CHRE_WIFI_SCAN_TYPE_NO_PREFERENCE) { 40 if (params->channelSet == CHRE_WIFI_CHANNEL_SET_NON_DFS) { 41 legacyParams.scanType = CHRE_WIFI_SCAN_TYPE_ACTIVE; 42 } else { 43 legacyParams.scanType = CHRE_WIFI_SCAN_TYPE_ACTIVE_PLUS_PASSIVE_DFS; 44 } 45 } 46 47 return legacyParams; 48 } 49 50 } // namespace chre 51 52 #endif // CHRE_UTIL_SYSTEM_WIFI_UTIL_H_ 53