• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 #include "chre/apps/wifi_offload/scan_config.h"
18 
19 namespace wifi_offload {
20 
operator ==(const ScanConfig & other) const21 bool ScanConfig::operator==(const ScanConfig &other) const {
22   if (this == &other) {
23     return true;
24   }
25   return scan_params_ == other.scan_params_ &&
26          scan_filter_ == other.scan_filter_;
27 }
28 
Serialize(flatbuffers::FlatBufferBuilder * builder) const29 flatbuffers::Offset<ScanConfig::FbsType> ScanConfig::Serialize(
30     flatbuffers::FlatBufferBuilder *builder) const {
31   auto params_offset = scan_params_.Serialize(builder);
32   auto filter_offset = scan_filter_.Serialize(builder);
33   return fbs::CreateScanConfig(*builder, params_offset, filter_offset);
34 }
35 
Deserialize(const ScanConfig::FbsType & fbs_config)36 bool ScanConfig::Deserialize(const ScanConfig::FbsType &fbs_config) {
37   if (fbs_config.scan_params() == nullptr ||
38       fbs_config.scan_filter() == nullptr) {
39     LOGE("Failed to deserialize ScanConfig. Null or incomplete members.");
40     return false;
41   }
42 
43   return scan_params_.Deserialize(*fbs_config.scan_params()) &&
44          scan_filter_.Deserialize(*fbs_config.scan_filter());
45 }
46 
Log() const47 void ScanConfig::Log() const {
48   scan_params_.Log();
49   scan_filter_.Log();
50 }
51 
52 }  // namespace wifi_offload
53