Home | History | Annotate | Download | only in wificond
      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::IWifiScannerImpl;
     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::getPacketCounters(
     40     vector<int32_t>* out_packet_counters) {
     41   if (impl_ == nullptr) {
     42     return Status::ok();
     43   }
     44   impl_->GetPacketCounters(out_packet_counters);
     45   return Status::ok();
     46 }
     47 
     48 Status ClientInterfaceBinder::signalPoll(
     49     vector<int32_t>* out_signal_poll_results) {
     50   if (impl_ == nullptr) {
     51     return Status::ok();
     52   }
     53   impl_->SignalPoll(out_signal_poll_results);
     54   return Status::ok();
     55 }
     56 
     57 Status ClientInterfaceBinder::getMacAddress(vector<uint8_t>* out_mac_address) {
     58   if (impl_ == nullptr) {
     59     return Status::ok();
     60   }
     61   *out_mac_address = impl_->GetMacAddress();
     62   return Status::ok();
     63 }
     64 
     65 Status ClientInterfaceBinder::getInterfaceName(std::string* out_name) {
     66   if (impl_ == nullptr) {
     67     return Status::ok();
     68   }
     69   *out_name = impl_->GetInterfaceName();
     70   return Status::ok();
     71 }
     72 
     73 Status ClientInterfaceBinder::getWifiScannerImpl(
     74     sp<IWifiScannerImpl>* out_wifi_scanner_impl) {
     75   if (impl_ == nullptr) {
     76     *out_wifi_scanner_impl = nullptr;
     77     return Status::ok();
     78   }
     79   *out_wifi_scanner_impl = impl_->GetScanner();
     80   return Status::ok();
     81 }
     82 
     83 
     84 Status ClientInterfaceBinder::setMacAddress(const vector<uint8_t>& mac, bool* success) {
     85   *success = impl_ && impl_->SetMacAddress(mac);
     86   return Status::ok();
     87 }
     88 
     89 }  // namespace wificond
     90 }  // namespace android
     91