Update UE to remove MessageLoop::current()->WatchFileDescriptor.
MessageLoop::current()->WatchFileDescriptor is deprecated. And UE should
remove usages of it.
Test: mma && unittest
Change-Id: Ib1ef2e6b6a38ad2a8d07b78bcd72fdb3b7f82226
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 298a65c..3e197fb 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -129,12 +129,7 @@
if (!ok || eof) {
// There was either an error or an EOF condition, so we are done watching
// the file descriptor.
-#ifdef __ANDROID__
- MessageLoop::current()->CancelTask(record->stdout_task_id);
- record->stdout_task_id = MessageLoop::kTaskIdNull;
-#else
record->stdout_controller.reset();
-#endif // __ANDROID__
return;
}
} while (bytes_read);
@@ -149,12 +144,7 @@
// Make sure we read any remaining process output and then close the pipe.
OnStdoutReady(record);
-#ifdef __ANDROID__
- MessageLoop::current()->CancelTask(record->stdout_task_id);
- record->stdout_task_id = MessageLoop::kTaskIdNull;
-#else
record->stdout_controller.reset();
-#endif // __ANDROID__
// Don't print any log if the subprocess exited with exit code 0.
if (info.si_code != CLD_EXITED) {
@@ -209,18 +199,9 @@
<< record->stdout_fd << ".";
}
-#ifdef __ANDROID__
- record->stdout_task_id = MessageLoop::current()->WatchFileDescriptor(
- FROM_HERE,
- record->stdout_fd,
- MessageLoop::WatchMode::kWatchRead,
- true,
- base::Bind(&Subprocess::OnStdoutReady, record.get()));
-#else
record->stdout_controller = base::FileDescriptorWatcher::WatchReadable(
record->stdout_fd,
base::BindRepeating(&Subprocess::OnStdoutReady, record.get()));
-#endif // __ANDROID__
subprocess_records_[pid] = std::move(record);
return pid;
diff --git a/common/subprocess.h b/common/subprocess.h
index f1b9f1f..432d4cb 100644
--- a/common/subprocess.h
+++ b/common/subprocess.h
@@ -123,12 +123,8 @@
// These are used to monitor the stdout of the running process, including
// the stderr if it was redirected.
-#ifdef __ANDROID__
- brillo::MessageLoop::TaskId stdout_task_id{
- brillo::MessageLoop::kTaskIdNull};
-#else
std::unique_ptr<base::FileDescriptorWatcher::Controller> stdout_controller;
-#endif // __ANDROID__
+
int stdout_fd{-1};
std::string stdout;
};
diff --git a/common/subprocess_unittest.cc b/common/subprocess_unittest.cc
index bc52b83..e71d3d8 100644
--- a/common/subprocess_unittest.cc
+++ b/common/subprocess_unittest.cc
@@ -74,9 +74,7 @@
brillo::BaseMessageLoop loop_{&base_loop_};
brillo::AsynchronousSignalHandler async_signal_handler_;
Subprocess subprocess_;
-#ifndef __ANDROID__
unique_ptr<base::FileDescriptorWatcher::Controller> watcher_;
-#endif // __ANDROID__
};
@@ -261,23 +259,6 @@
int fifo_fd = HANDLE_EINTR(open(fifo_path.c_str(), O_RDONLY));
EXPECT_GE(fifo_fd, 0);
-#ifdef __ANDROID__
- loop_.WatchFileDescriptor(FROM_HERE,
- fifo_fd,
- MessageLoop::WatchMode::kWatchRead,
- false,
- base::Bind(
- [](int fifo_fd, uint32_t tag) {
- char c;
- EXPECT_EQ(1,
- HANDLE_EINTR(read(fifo_fd, &c, 1)));
- EXPECT_EQ('X', c);
- LOG(INFO) << "Killing tag " << tag;
- Subprocess::Get().KillExec(tag);
- },
- fifo_fd,
- tag));
-#else
watcher_ = base::FileDescriptorWatcher::WatchReadable(
fifo_fd,
base::Bind(
@@ -295,7 +276,6 @@
base::Unretained(&watcher_),
fifo_fd,
tag));
-#endif // __ANDROID__
// This test would leak a callback that runs when the child process exits
// unless we wait for it to run.