Mount ptp separately from mtp

Ptp is now mounted in its own directory so the
mtp endpoint does not need to be closed to write
the ptp descriptors.

Bug: 72877174
Test: switch config to mtp/ptp
Change-Id: I9cec66eeb882fbf23851cdaf2e3906e8b3150b0a
This commit is contained in:
Jerry Zhang
2017-12-06 16:20:18 -08:00
parent aa948d8357
commit 0c556bbbac
2 changed files with 19 additions and 4 deletions

View File

@@ -335,8 +335,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;
@@ -351,6 +350,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) {