OSDN Git Service

Add ANQP query binder interface to wificond
[android-x86/system-connectivity-wificond.git] / client_interface_binder.cpp
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
17 #include "wificond/client_interface_binder.h"
18
19 #include <vector>
20
21 #include <binder/Status.h>
22
23 #include "wificond/client_interface_impl.h"
24
25 using android::binder::Status;
26 using android::net::wifi::IANQPDoneCallback;
27 using std::vector;
28
29 namespace android {
30 namespace wificond {
31
32 ClientInterfaceBinder::ClientInterfaceBinder(ClientInterfaceImpl* impl)
33     : impl_(impl) {
34 }
35
36 ClientInterfaceBinder::~ClientInterfaceBinder() {
37 }
38
39 Status ClientInterfaceBinder::enableSupplicant(bool* success) {
40   *success = impl_ && impl_->EnableSupplicant();
41   return Status::ok();
42 }
43
44 Status ClientInterfaceBinder::disableSupplicant(bool* success) {
45   *success = impl_ && impl_->DisableSupplicant();
46   return Status::ok();
47 }
48
49 Status ClientInterfaceBinder::getPacketCounters(
50     vector<int32_t>* out_packet_counters) {
51   if (impl_ == nullptr) {
52     return Status::ok();
53   }
54   impl_->GetPacketCounters(out_packet_counters);
55   return Status::ok();
56 }
57
58 Status ClientInterfaceBinder::signalPoll(
59     vector<int32_t>* out_signal_poll_results) {
60   if (impl_ == nullptr) {
61     return Status::ok();
62   }
63   impl_->SignalPoll(out_signal_poll_results);
64   return Status::ok();
65 }
66
67 Status ClientInterfaceBinder::getMacAddress(vector<uint8_t>* out_mac_address) {
68   if (impl_ == nullptr) {
69     return Status::ok();
70   }
71   *out_mac_address = impl_->GetMacAddress();
72   return Status::ok();
73 }
74
75 Status ClientInterfaceBinder::getInterfaceName(std::string* out_name) {
76   if (impl_ == nullptr) {
77     return Status::ok();
78   }
79   *out_name = impl_->GetInterfaceName();
80   return Status::ok();
81 }
82
83 Status ClientInterfaceBinder::requestANQP(
84     const vector<uint8_t>& bssid,
85     const sp<IANQPDoneCallback>& callback,
86     bool* out_success) {
87   if (impl_ == nullptr) {
88     *out_success = false;
89     return Status::ok();
90   }
91   *out_success = impl_->requestANQP(bssid, callback);
92   return Status::ok();
93 }
94
95 }  // namespace wificond
96 }  // namespace android