OSDN Git Service

release-request-c9e3b153-009d-4386-b83e-337752602795-for-git_oc-mr1-release-4111654...
[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 android::net::wifi::IWifiScannerImpl;
28 using std::vector;
29
30 namespace android {
31 namespace wificond {
32
33 ClientInterfaceBinder::ClientInterfaceBinder(ClientInterfaceImpl* impl)
34     : impl_(impl) {
35 }
36
37 ClientInterfaceBinder::~ClientInterfaceBinder() {
38 }
39
40 Status ClientInterfaceBinder::enableSupplicant(bool* success) {
41   *success = impl_ && impl_->EnableSupplicant();
42   return Status::ok();
43 }
44
45 Status ClientInterfaceBinder::disableSupplicant(bool* success) {
46   *success = impl_ && impl_->DisableSupplicant();
47   return Status::ok();
48 }
49
50 Status ClientInterfaceBinder::getPacketCounters(
51     vector<int32_t>* out_packet_counters) {
52   if (impl_ == nullptr) {
53     return Status::ok();
54   }
55   impl_->GetPacketCounters(out_packet_counters);
56   return Status::ok();
57 }
58
59 Status ClientInterfaceBinder::signalPoll(
60     vector<int32_t>* out_signal_poll_results) {
61   if (impl_ == nullptr) {
62     return Status::ok();
63   }
64   impl_->SignalPoll(out_signal_poll_results);
65   return Status::ok();
66 }
67
68 Status ClientInterfaceBinder::getMacAddress(vector<uint8_t>* out_mac_address) {
69   if (impl_ == nullptr) {
70     return Status::ok();
71   }
72   *out_mac_address = impl_->GetMacAddress();
73   return Status::ok();
74 }
75
76 Status ClientInterfaceBinder::getInterfaceName(std::string* out_name) {
77   if (impl_ == nullptr) {
78     return Status::ok();
79   }
80   *out_name = impl_->GetInterfaceName();
81   return Status::ok();
82 }
83
84 Status ClientInterfaceBinder::getWifiScannerImpl(
85     sp<IWifiScannerImpl>* out_wifi_scanner_impl) {
86   if (impl_ == nullptr) {
87     *out_wifi_scanner_impl = nullptr;
88     return Status::ok();
89   }
90   *out_wifi_scanner_impl = impl_->GetScanner();
91   return Status::ok();
92 }
93
94 Status ClientInterfaceBinder::requestANQP(
95     const vector<uint8_t>& bssid,
96     const sp<IANQPDoneCallback>& callback,
97     bool* out_success) {
98   if (impl_ == nullptr) {
99     *out_success = false;
100     return Status::ok();
101   }
102   *out_success = impl_->requestANQP(bssid, callback);
103   return Status::ok();
104 }
105
106 }  // namespace wificond
107 }  // namespace android