fastboot: Introduce connect / disconnect for network-connected devices
Use introduced FileLock and network-connected devices storage entities
to introduce fastboot connect / disconnect commands
Test: everything works like discussed here go/fastboot-connect-disconnect on windows/linux
Bug: 267507450
Bug: 267506875
Change-Id: I2d6495ad567a3ddadd471a89b82d78c8c36a3d52
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
diff --git a/fastboot/storage.cpp b/fastboot/storage.cpp
index db13dd6..d6e00cf 100644
--- a/fastboot/storage.cpp
+++ b/fastboot/storage.cpp
@@ -43,20 +43,20 @@
devices_lock_path_ = home_fastboot_path + kPathSeparator + "devices.lock";
}
-void ConnectedDevicesStorage::WriteDevices(const std::set<std::string>& devices) {
+void ConnectedDevicesStorage::WriteDevices(const FileLock&, const std::set<std::string>& devices) {
std::ofstream devices_stream(devices_path_);
std::copy(devices.begin(), devices.end(),
std::ostream_iterator<std::string>(devices_stream, "\n"));
}
-std::set<std::string> ConnectedDevicesStorage::ReadDevices() {
+std::set<std::string> ConnectedDevicesStorage::ReadDevices(const FileLock&) {
std::ifstream devices_stream(devices_path_);
std::istream_iterator<std::string> start(devices_stream), end;
std::set<std::string> devices(start, end);
return devices;
}
-void ConnectedDevicesStorage::Clear() {
+void ConnectedDevicesStorage::Clear(const FileLock&) {
if (!android::base::RemoveFileIfExists(devices_path_)) {
LOG(FATAL) << "Failed to clear connected device list: " << devices_path_;
}