using android::net::wifi::IApInterface;
using android::wifi_system::HostapdManager;
using android::wifi_system::InterfaceTool;
+using std::endl;
using std::string;
using std::unique_ptr;
using std::vector;
netlink_utils_(netlink_utils),
if_tool_(if_tool),
hostapd_manager_(hostapd_manager),
- binder_(new ApInterfaceBinder(this)) {
+ binder_(new ApInterfaceBinder(this)),
+ number_of_associated_stations_(0) {
// This log keeps compiler happy.
LOG(DEBUG) << "Created ap interface " << interface_name_
<< " with index " << interface_index_;
return binder_;
}
+void ApInterfaceImpl::Dump(std::stringstream* ss) const {
+ *ss << "------- Dump of AP interface with index: "
+ << interface_index_ << " and name: " << interface_name_
+ << "-------" << endl;
+ *ss << "Number of associated stations: "
+ << number_of_associated_stations_ << endl;
+ *ss << "------- Dump End -------" << endl;
+}
+
bool ApInterfaceImpl::StartHostapd() {
return hostapd_manager_->StartHostapd();
}
LOG(INFO) << "New station "
<< LoggingUtils::GetMacString(mac_address)
<< " associated with hotspot";
+ number_of_associated_stations_++;
} else if (event == DEL_STATION) {
LOG(INFO) << "Station "
<< LoggingUtils::GetMacString(mac_address)
<< " disassociated from hotspot";
+ if (number_of_associated_stations_ <= 0) {
+ LOG(ERROR) << "Received DEL_STATION event when station counter is: "
+ << number_of_associated_stations_;
+ } else {
+ number_of_associated_stations_--;
+ }
}
}
+int ApInterfaceImpl::GetNumberOfAssociatedStations() const {
+ return number_of_associated_stations_;
+}
+
} // namespace wificond
} // namespace android