diff options
author | Mike Lockwood <lockwood@android.com> | 2010-06-15 10:28:47 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-06-22 16:37:56 -0400 |
commit | 78c1e5ecb7a1c6474485c94276fb6c2bffebd2dc (patch) | |
tree | 36037771ad792a1f8b4d357fc727cebf0030fffe | |
parent | 9e6f25df13d5242d83fda224f8cc0b2bf22a727c (diff) | |
download | frameworks_av-78c1e5ecb7a1c6474485c94276fb6c2bffebd2dc.zip frameworks_av-78c1e5ecb7a1c6474485c94276fb6c2bffebd2dc.tar.gz frameworks_av-78c1e5ecb7a1c6474485c94276fb6c2bffebd2dc.tar.bz2 |
mtptest: Add option to specify storage path at the command line.
Change-Id: Iac8a34ffb8177018a9164b3f2f97b2e84c3d8f1c
Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r-- | media/mtp/MtpStorage.cpp | 1 | ||||
-rw-r--r-- | media/mtp/mtptest.cpp | 13 |
2 files changed, 10 insertions, 4 deletions
diff --git a/media/mtp/MtpStorage.cpp b/media/mtp/MtpStorage.cpp index 5e08816..ed2376e 100644 --- a/media/mtp/MtpStorage.cpp +++ b/media/mtp/MtpStorage.cpp @@ -36,6 +36,7 @@ MtpStorage::MtpStorage(MtpStorageID id, const char* filePath, MtpDatabase* db) mDatabase(db), mMaxCapacity(0) { + printf("MtpStorage id: %d path: %s\n", id, filePath); } MtpStorage::~MtpStorage() { diff --git a/media/mtp/mtptest.cpp b/media/mtp/mtptest.cpp index 0d9d45a..767cf2e 100644 --- a/media/mtp/mtptest.cpp +++ b/media/mtp/mtptest.cpp @@ -29,25 +29,30 @@ using namespace android; -static void enable_usb_function(const char* name, bool enable) { +static bool enable_usb_function(const char* name, bool enable) { char path[PATH_MAX]; snprintf(path, sizeof(path), "/sys/class/usb_composite/%s/enable", name); int fd = open(path, O_RDWR); if (fd < 0) { fprintf(stderr, "could not open %s in enable_usb_function\n", path); - exit(1); + return false; } write(fd, enable ? "1" : "0", 2); close(fd); + return true; } int main(int argc, char* argv[]) { bool usePTP = false; + const char* storagePath = "/sdcard"; for (int i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-p")) + const char* arg = argv[i]; + if (!strcmp(arg, "-p")) usePTP = true; + else if (arg[0] == '/') + storagePath = arg; } int fd = open("/dev/mtp_usb", O_RDWR); @@ -71,7 +76,7 @@ int main(int argc, char* argv[]) { enable_usb_function("mtp", true); MtpServer server(fd, "/data/data/mtp/mtp.db"); - server.addStorage("/sdcard"); + server.addStorage(storagePath); server.scanStorage(); server.run(); |