From 4230b87e5afd0985492343236c196e6f5ed44f69 Mon Sep 17 00:00:00 2001 From: pumahsu Date: Wed, 6 Jun 2018 11:25:27 +0800 Subject: Fix PTP mount path (sync from commit:0c556bbbac9d3a2366d5d244cd5be720a42c0677) Ptp is now mounted in its own directory so the mtp endpoint does not need to be closed to write the ptp descriptors. Bug: 113145145 Test: Switch function between MTP/PTP/none Change-Id: Ib28a4e232e042ff2d6f49005ea12d3c7e64e7295 Signed-off-by: pumahsu (cherry picked from commit da48caba738fcc31d5c391cff6674112d7949f9e) --- usb/UsbGadget.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp index 0941aed1..bc1756df 100644 --- a/usb/UsbGadget.cpp +++ b/usb/UsbGadget.cpp @@ -433,8 +433,7 @@ V1_0::Status UsbGadget::setupFunctions( int i = 0; std::string bootMode = GetProperty(PERSISTENT_BOOT_MODE, ""); - if (((functions & GadgetFunction::PTP) != 0) || - ((functions & GadgetFunction::MTP) != 0)) { + if (((functions & GadgetFunction::MTP) != 0)) { ffsEnabled = true; ALOGI("setCurrentUsbFunctions mtp"); if (!WriteStringToFile("1", DESC_USE_PATH)) return Status::ERROR; @@ -448,6 +447,21 @@ V1_0::Status UsbGadget::setupFunctions( mEndpointList.push_back("/dev/usb-ffs/mtp/ep1"); mEndpointList.push_back("/dev/usb-ffs/mtp/ep2"); mEndpointList.push_back("/dev/usb-ffs/mtp/ep3"); + } else if (((functions & GadgetFunction::PTP) != 0)) { + ffsEnabled = true; + ALOGI("setCurrentUsbFunctions ptp"); + if (!WriteStringToFile("1", DESC_USE_PATH)) return Status::ERROR; + + if (inotify_add_watch(inotifyFd, "/dev/usb-ffs/ptp/", IN_ALL_EVENTS) == -1) + return Status::ERROR; + + + if (linkFunction("ffs.ptp", i++)) return Status::ERROR; + + // Add endpoints to be monitored. + mEndpointList.push_back("/dev/usb-ffs/ptp/ep1"); + mEndpointList.push_back("/dev/usb-ffs/ptp/ep2"); + mEndpointList.push_back("/dev/usb-ffs/ptp/ep3"); } if ((functions & GadgetFunction::MIDI) != 0) { -- cgit v1.2.3