Home | History | Annotate | Download | only in launch
      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 <string>
     18 
     19 #include <glog/logging.h>
     20 
     21 #include "common/vsoc/lib/wifi_exchange_view.h"
     22 #include "host/commands/launch/pre_launch_initializers.h"
     23 #include "host/libs/config/cuttlefish_config.h"
     24 
     25 using vsoc::wifi::WifiExchangeView;
     26 
     27 void InitializeWifiRegion() {
     28   auto region = WifiExchangeView::GetInstance(vsoc::GetDomain().c_str());
     29   auto config = vsoc::CuttlefishConfig::Get();
     30   if (!region) {
     31     LOG(FATAL) << "Wifi region not found";
     32     return;
     33   }
     34   WifiExchangeView::MacAddress guest_mac, host_mac;
     35   if (!WifiExchangeView::ParseMACAddress(config->wifi_guest_mac_addr(),
     36                                          &guest_mac)) {
     37     LOG(FATAL) << "Unable to parse guest mac address: "
     38                << config->wifi_guest_mac_addr();
     39     return;
     40   }
     41   LOG(INFO) << "Setting guest mac to " << config->wifi_guest_mac_addr();
     42   region->SetGuestMACAddress(guest_mac);
     43   if (!WifiExchangeView::ParseMACAddress(config->wifi_host_mac_addr(),
     44                                          &host_mac)) {
     45     LOG(FATAL) << "Unable to parse guest mac address: "
     46                << config->wifi_guest_mac_addr();
     47     return;
     48   }
     49   LOG(INFO) << "Setting host mac to " << config->wifi_host_mac_addr();
     50   region->SetHostMACAddress(host_mac);
     51 }
     52