Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fc9d997 authored by Myles Watson's avatar Myles Watson
Browse files

binder: Call writeParcelFileDescriptor()

Fixes: 69678755
Test: manual inspection using lsof
Change-Id: Ifcb5af2d5797e667c20d4c41ad836cf7626e9909
parent 4784b0ff
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -25,11 +25,8 @@ namespace android {
namespace os {

status_t ParcelFileDescriptor::writeToParcel(Parcel* parcel) const {
  status_t status = parcel->writeInt32(0);
  if (status != OK) return status;

  status = parcel->writeDupFileDescriptor(fd);
  return status;
  CHECK(fd_ >= 0);
  return parcel->writeParcelFileDescriptor(fd_, takeOwnership_);
}

status_t ParcelFileDescriptor::readFromParcel(const Parcel* parcel) {
@@ -37,5 +34,10 @@ status_t ParcelFileDescriptor::readFromParcel(const Parcel* parcel) {
  return OK;
}

void ParcelFileDescriptor::setFileDescriptor(int fd, bool takeOwnership) {
  fd_ = fd;
  takeOwnership_ = takeOwnership;
}

}  // namespace os
}  // namespace android
+6 −2
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ namespace os {

class ParcelFileDescriptor : public android::Parcelable {
 public:
  ParcelFileDescriptor() = default;
  ParcelFileDescriptor() : fd_(-1), takeOwnership_(false) {}
  ~ParcelFileDescriptor() = default;

  // Write |this| parcelable to the given |parcel|.  Keep in mind that
@@ -41,7 +41,11 @@ class ParcelFileDescriptor : public android::Parcelable {
  // Returns android::OK on success and an appropriate error otherwise.
  android::status_t readFromParcel(const android::Parcel* parcel) override;

  int fd;
  void setFileDescriptor(int fd, bool takeOwnership);

 private:
  int fd_;
  bool takeOwnership_;
};

}  // namespace os