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 #include "device_wiphy_capabilities.h"
18 
19 #include <android-base/logging.h>
20 
21 #include "wificond/parcelable_utils.h"
22 
23 using android::status_t;
24 
25 namespace android {
26 namespace net {
27 namespace wifi {
28 namespace nl80211 {
29 
DeviceWiphyCapabilities()30 DeviceWiphyCapabilities::DeviceWiphyCapabilities() {
31   is80211nSupported_ = false;
32   is80211acSupported_ = false;
33   is80211axSupported_ = false;
34   is80211beSupported_ = false;
35   is160MhzSupported_ = false;
36   is80p80MhzSupported_ = false;
37   is320MhzSupported_ = false;
38   maxTxStreams_ = 1;
39   maxRxStreams_ = 1;
40   maxNumAkms_ = 1;
41 }
42 
writeToParcel(::android::Parcel * parcel) const43 status_t DeviceWiphyCapabilities::writeToParcel(::android::Parcel* parcel) const {
44   RETURN_IF_FAILED(parcel->writeBool(is80211nSupported_));
45   RETURN_IF_FAILED(parcel->writeBool(is80211acSupported_));
46   RETURN_IF_FAILED(parcel->writeBool(is80211axSupported_));
47   RETURN_IF_FAILED(parcel->writeBool(is80211beSupported_));
48   RETURN_IF_FAILED(parcel->writeBool(is160MhzSupported_ ));
49   RETURN_IF_FAILED(parcel->writeBool(is80p80MhzSupported_));
50   RETURN_IF_FAILED(parcel->writeBool(is320MhzSupported_ ));
51   RETURN_IF_FAILED(parcel->writeUint32(maxTxStreams_));
52   RETURN_IF_FAILED(parcel->writeUint32(maxRxStreams_));
53   RETURN_IF_FAILED(parcel->writeUint32(maxNumAkms_));
54   return ::android::OK;
55 }
56 
readFromParcel(const::android::Parcel * parcel)57 status_t DeviceWiphyCapabilities::readFromParcel(const ::android::Parcel* parcel) {
58   RETURN_IF_FAILED(parcel->readBool(&is80211nSupported_));
59   RETURN_IF_FAILED(parcel->readBool(&is80211acSupported_));
60   RETURN_IF_FAILED(parcel->readBool(&is80211axSupported_));
61   RETURN_IF_FAILED(parcel->readBool(&is80211beSupported_));
62   RETURN_IF_FAILED(parcel->readBool(&is160MhzSupported_));
63   RETURN_IF_FAILED(parcel->readBool(&is80p80MhzSupported_));
64   RETURN_IF_FAILED(parcel->readBool(&is320MhzSupported_));
65   RETURN_IF_FAILED(parcel->readUint32(&maxTxStreams_));
66   RETURN_IF_FAILED(parcel->readUint32(&maxRxStreams_));
67   RETURN_IF_FAILED(parcel->readUint32(&maxNumAkms_));
68 
69   return ::android::OK;
70 }
71 
72 }  // namespace nl80211
73 }  // namespace wifi
74 }  // namespace net
75 }  // namespace android
76