libbinder: move FdTrigger to RpcSession

We need triggers accessible in RpcSession, RpcServer, and RpcState in
order to shut down the join + connection + rpc handler threads (the
RpcServer connection threads get transformed into becoming RpcSession
threads). In order for this to be used in all these places, the most
convenient location is RpcSession, since the RpcServer header imports
this and the C++ standard doesn't allow for nested classes to be forward
declared.

Bug: 185167543
Test: binderRpcTest
Change-Id: I3e655277bd183fddc6d5001280cf17a10672bea3
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index 05fa49e..4efa6bb 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -113,6 +113,16 @@
     return state()->sendDecStrong(connection.fd(), address);
 }
 
+std::unique_ptr<RpcSession::FdTrigger> RpcSession::FdTrigger::make() {
+    auto ret = std::make_unique<RpcSession::FdTrigger>();
+    if (!android::base::Pipe(&ret->mRead, &ret->mWrite)) return nullptr;
+    return ret;
+}
+
+void RpcSession::FdTrigger::trigger() {
+    mWrite.reset();
+}
+
 status_t RpcSession::readId() {
     {
         std::lock_guard<std::mutex> _l(mMutex);