diff options
| author | pumahsu <pumahsu@google.com> | 2018-06-06 11:25:27 +0800 |
|---|---|---|
| committer | Puma Hsu <pumahsu@google.com> | 2018-06-06 03:41:13 +0000 |
| commit | da48caba738fcc31d5c391cff6674112d7949f9e (patch) | |
| tree | 31248d8cc8e1531896bb4e994b46658dbd653d29 /usb | |
| parent | 82a43a9293136698588a9817f7e17aca1de89714 (diff) | |
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: 80653696
Test: Switch function between MTP/PTP/none
Change-Id: Ib28a4e232e042ff2d6f49005ea12d3c7e64e7295
Signed-off-by: pumahsu <pumahsu@google.com>
Diffstat (limited to 'usb')
| -rw-r--r-- | usb/UsbGadget.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp index 1976dac..c464ac7 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) { |
