MtpDevice::sendObject is using int to define object size,
if the object size is bigger than 2GB, the size will be type-cast to
a negative number. And it will cause a endless loop in MtpDataPacket::write
until DUT auto reboot.
And JNI api android_mtp_MtpDevice_send_object requires that object
size must be uint32_t , so MtpDevice::sendObject works well after its
size parameter is changed from int to uint32_t.
Also change the return type of below API from int to int64_5
int64_t MtpDataPacket::write(struct usb_request *request, UrbPacketDivisionMode divisionMode,
int fd, size_t size)
so that it can return the right size in the case of writing 2~4G file.
Test: manual - connect Android device to Android Automotive
Test: manual - select MTP/File Transfer in android device
Test: manual - copy a file which is bigger than 2GB from automotive to the android device.
bug: 115451170
Change-Id: I65b89f195ef0527a802bccefc90721e536683b87
Signed-off-by: robinz1x <robinx.zhang@intel.com>
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
Linux uses UTF8 but java and MTP both
use UTF16. In a few places, this results
in the top byte of a UTF16 string being
truncated on conversion to UTF8.
Also, the hardcoded UTF to byte serialization
in MtpStringBuffer is incorrect.
Replace it with conversions from std, and
replace usages of MtpString with MtpStringBuffer.
Remove any remaining usages of libutils
and replace them with corresponding std
libraries.
Bug: 70546563
Test: Mtp works, tests pass
Test: file/folder names containing emoji can be transferred to/from
windows
Change-Id: Idbcb73f1beac17ce8a90843fa254e759dd1a6369
When sending a MtpDataPacket to a MTP device, the kernel driver splits
it into multiple URB packets so that the URB packet size does not exceed
the buffer size at the MTP device.
Previously MtpDataPacket sends its header first, then sends the
payload. It means the first URB packet only contains the header of
MtpDataPacket and the URB packet size is smaller than the maximum URB
packet size (short packet). Some MTP devices regard the short packet as
the end of the sequencail URB packets, thus the devices do not accept
the following URB packets that contain the payload.
The MTP spec says if the responder (MTP device) sends the data in a way
where the first pacekt contains only the header, the initiator (MTP
host) must send data in the same way. Otherwise the initiator must not
send a short packet in the sequencial URB packets.
The CL fixes the MTP host implementation so that it remembers how the
MTP device sends data, and uses the same way when sending data
from the host.
Bug: 31165557
Test: Manually invokes MtpDevice#sendObject
Change-Id: Ic76eb4241ed74957414aef2990be08cd77a9f5a9
According to the MTP spec, the sendObject request must follow
sendObjectInfo request and we could not send an object handle with
sendObject request. The CL stops sending object handle with a sendObject
request. Instead it checks if the given object handle equals to the
object handle returned by the previous sendObjectInfo request.
Bug: 31918048
Test: manually invoked sendObjectInfo and sendObject.
Change-Id: I0a80bdf67bf2913522821ac705f3dc548d3edead
In the MTP spec, the object size is stored in MtpObjectInfo as unsigned
32-bit integer and fetched by the getObjectInfo operation. For the
objects that are more than 4GB, the object size is provided as one of
extra properties, which are fetched by different operation.
The CL adds to getObjectPropValue method to MtpDevice class so that
client code can obtain 4GB+ object size from object property.
BUG=27805369
Change-Id: I0b91facd07cdc19866cb29f7df08bb1698bcf60b
Both MtpObjectHandle and MtpStorageID are typedef of uint32_t, but
MtpStorageID is more appropriate semantically.
BUG=None
Change-Id: Ibf5bb2105c54f7b73df559132d8737c272a1cefa
The CL was previously reviewed at ag/842911.
> The CL makes MtpDevice#reapEvent return event parameters as well as
> event code.
>
> BUG=26480986
Change-Id: Ie750a58248068cd0e804f20b57e7e86eef19d315
Two issues are resolved:
- sendObject changed to accept raw arguments instead of objectinfo,
as calling getObjectInfo after sentObjectInfo is illegal,
- send buffer decreased to 16K, as this is the maximum size working
per comments in other places.
Change-Id: If71644dcbc508dd92c3fe74a2fdb7c6798059b42
Previously the two functions have separate but similar implementation. ag/750097
fixed a bug in importFile, but we have a same bug in getObject. Instead fixing
the bug separately, the CL adds a common function that can be used from both
getObject and importFile.
BUG=23264575
Change-Id: I0bdc876ee9b11301ba4c445cc16556e9c951a8b4
This will allow to read files on Java side without copying all bytes to
memory first, which is problematic for large files such as movies.
Bug:22908937
Change-Id: I67b116cf01d9e44af69f94c8edc64fd8fbf7b9a3
Previously we did not sanity check incoming MTP packets,
which could result in crashes due to reading off the edge of a packet.
Now all MTP packet getter functions return a boolean result
(true for OK, false for reading off the edge of the packet)
and we now return errors for malformed packets.
Bug: 18113092
Change-Id: Ic7623ee96f00652bdfb4f66acb16a93db5a1c105
This replaces the previous ContentProvider based interface
Change-Id: I4cea2544854adb9fdcc04345e4d73d8ef05380f3
Signed-off-by: Mike Lockwood <lockwood@android.com>
This will happen if the device needs to report an error rather than returning the data.
Change-Id: I477512b3676c2f0518a85a4135832ed4475fbc2d
Signed-off-by: Mike Lockwood <lockwood@android.com>
Now the file copy is done completely within the media process
rather than pushing data to the client via ContProvider.openFile().
File system writes are now interleaved with USB reads, which allows us
to copy the data faster and prevents the camera from timing out during transfer.
File is automatically inserted in the media provider after a successful import
and a Uri is returned to the client.
BUG: 2994234
Change-Id: Ie75c63da76f623343d3d966c6a707aa1ae871972
Signed-off-by: Mike Lockwood <lockwood@android.com>
Also added some support for sending files to the device that hasn't been debugged yet.
Add locking to MtpDevice to prevent it from attempting multiple transactions simultaneously.
Change-Id: I2b995ba0af086cc6920bd6b8c869f540ad78560a
Signed-off-by: Mike Lockwood <lockwood@android.com>
At this point much of the plumbing is in place, but only a few simple queries
are supported.
This is enough to support a proof of concept sample program that navigates
the file hierarchy of a digital camera connected via USB.
Also removed obsolete ptptest host test program.
Change-Id: I17644344b9f0ce1ecc302bc0478c1f3d44a1647f
Signed-off-by: Mike Lockwood <lockwood@android.com>