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 "wifi_system/hostapd_manager.h"
18 
19 #include <android-base/logging.h>
20 #include <cutils/properties.h>
21 
22 namespace android {
23 namespace wifi_system {
24 const char kHostapdServiceName[] = "hostapd";
25 
26 bool HostapdManager::StartHostapd() {
27   if (property_set("ctl.start", kHostapdServiceName) != 0) {
28     LOG(ERROR) << "Failed to start SoftAP";
29     return false;
30   }
31 
32   LOG(DEBUG) << "SoftAP started successfully";
33   return true;
34 }
35 
36 bool HostapdManager::StopHostapd() {
37   LOG(DEBUG) << "Stopping the SoftAP service...";
38 
39   if (property_set("ctl.stop", kHostapdServiceName) < 0) {
40     LOG(ERROR) << "Failed to stop hostapd service!";
41     return false;
42   }
43 
44   LOG(DEBUG) << "SoftAP stopped successfully";
45   return true;
46 }
47 }  // namespace wifi_system
48 }  // namespace android
49