Reputation: 1007484
In Android 6.0, MTP no longer works automatically:
Device connections through the USB port are now set to charge-only mode by default. To access the device and its content over a USB connection, users must explicitly grant permission for such interactions. If your app supports user interactions with the device over a USB port, take into consideration that the interaction must be explicitly enabled.
MTP needs to be re-authorized at least every time you plug in the USB cable, and possibly more frequently than that (timeouts?).
With USB debugging enabled, the only solution that I have found to get MTP sharing to work on the device is to:
This is aggravating when you are trying to work with a device's files on external storage.
Is there a command-line way to get MTP going, short of writing a UIAutomator "test" that automates the above process? Or, is there some other way to get MTP to work without this sort of prep process?
Upvotes: 17
Views: 5624
Reputation: 1878
In Marshmallow (6.0 and 6.0.1) it is not possible without some sort of super power :-(
adb shell svc usb setFunction mtp
throws java.lang.SecurityException: Neither user 2000 nor current process has android.permission.MANAGE_USB.
and MANAGE_USB
is a signature|privileged
permission. I filed this as issue#193062. It has been put into state Assigned and labeled as Defect-25596495. It is fixed in N developer preview.
Upvotes: 18