Remove configure() from Mtp
Instead of configuring the server each
time the connection happens, UsbService
will now pass in the control fd with the
descriptors already written. Also, PTP
endpoints have been moved to their own
directory at /dev/usb-ffs/ptp rather than
using the same ones as mtp.
Bug: 72877174
Test: Verify PTP and MTP config changes work
Change-Id: I9a0336afd610aa397c9947568c308afb89b27c08
diff --git a/media/mtp/tests/MtpFfsHandle_test.cpp b/media/mtp/tests/MtpFfsHandle_test.cpp
index 9c916b7..2174893 100644
--- a/media/mtp/tests/MtpFfsHandle_test.cpp
+++ b/media/mtp/tests/MtpFfsHandle_test.cpp
@@ -64,7 +64,7 @@
MtpFfsHandleTest() {
int fd[2];
- handle = std::make_unique<T>();
+ handle = std::make_unique<T>(-1);
EXPECT_EQ(pipe(fd), 0);
control.reset(fd[0]);
@@ -84,7 +84,7 @@
intr.reset(fd[0]);
handle->mIntr.reset(fd[1]);
- EXPECT_EQ(handle->start(), 0);
+ EXPECT_EQ(handle->start(false), 0);
}
~MtpFfsHandleTest() {
@@ -95,8 +95,8 @@
typedef ::testing::Types<MtpFfsHandle, MtpFfsCompatHandle> mtpHandles;
TYPED_TEST_CASE(MtpFfsHandleTest, mtpHandles);
-TYPED_TEST(MtpFfsHandleTest, testControl) {
- EXPECT_TRUE(this->handle->writeDescriptors());
+TYPED_TEST(MtpFfsHandleTest, testMtpControl) {
+ EXPECT_TRUE(this->handle->writeDescriptors(false));
struct desc_v2 desc;
struct functionfs_strings strings;
EXPECT_EQ(read(this->control, &desc, sizeof(desc)), (long)sizeof(desc));
@@ -105,6 +105,16 @@
EXPECT_TRUE(std::memcmp(&strings, &mtp_strings, sizeof(strings)) == 0);
}
+TYPED_TEST(MtpFfsHandleTest, testPtpControl) {
+ EXPECT_TRUE(this->handle->writeDescriptors(true));
+ struct desc_v2 desc;
+ struct functionfs_strings strings;
+ EXPECT_EQ(read(this->control, &desc, sizeof(desc)), (long)sizeof(desc));
+ EXPECT_EQ(read(this->control, &strings, sizeof(strings)), (long)sizeof(strings));
+ EXPECT_TRUE(std::memcmp(&desc, &ptp_desc_v2, sizeof(desc)) == 0);
+ EXPECT_TRUE(std::memcmp(&strings, &mtp_strings, sizeof(strings)) == 0);
+}
+
TYPED_TEST(MtpFfsHandleTest, testRead) {
EXPECT_EQ(write(this->bulk_out, dummyDataStr.c_str(), TEST_PACKET_SIZE), TEST_PACKET_SIZE);
char buf[TEST_PACKET_SIZE + 1];