MtpServer: create new ffs handle if current one fails
- fixes MTP not working after USB unplugged and plugged Change-Id: Iea684107d7de20ff92828543881f6fbec1848b77
This commit is contained in:
+10
-1
@@ -164,8 +164,17 @@ bool MtpServer::hasStorage(MtpStorageID id) {
|
||||
|
||||
void MtpServer::run() {
|
||||
if (mHandle->start(mPtp)) {
|
||||
MTPE("Failed to start usb driver!");
|
||||
MTPE("Failed to start usb driver!\n");
|
||||
mHandle->close();
|
||||
int controlFd = open(FFS_MTP_EP0, O_RDWR);
|
||||
bool ffs_ok = access(FFS_MTP_EP0, W_OK) == 0;
|
||||
if (ffs_ok) {
|
||||
bool aio_compat = android::base::GetBoolProperty("sys.usb.ffs.aio_compat", false);
|
||||
mHandle = aio_compat ? new MtpFfsCompatHandle(controlFd) : new MtpFfsHandle(controlFd);
|
||||
mHandle->writeDescriptors(mPtp);
|
||||
} else {
|
||||
mHandle = new MtpDevHandle(controlFd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user