问题描述
在Android的6.0,MTP不再自动工作的:
In Android 6.0, MTP no longer works automatically:
设备连接现在默认设置为充电-only模式。要访问设备及其通过USB连接的内容,用户必须明确授予权限这种互动。如果您的应用支持与设备上的USB端口的用户交互,考虑到交互必须显式启用。
MTP需要至少每您在插入USB电缆,可能更频繁地超过该时间重新授权(超时?)。
MTP needs to be re-authorized at least every time you plug in the USB cable, and possibly more frequently than that (timeouts?).
启用USB调试,我发现让MTP共享设备上工作的唯一的解决办法是:
With USB debugging enabled, the only solution that I have found to get MTP sharing to work on the device is to:
- 走进设置>开发者选项
- 向下滚动到选择USB配置
- 该选项的值切换到任何的但的MTP,如仅充电(如果是在MTP现在)
- 该选项的值切换到MTP
- 刷新MTP客户端(例如,在Ubuntu 15.04,关闭并重新打开显示设备中的内容的窗口)
- Go into Settings > Developer options
- Scroll down to "Select USB Configuration"
- Switch the value of that option to anything but MTP, such as "Charging only" (if it is on MTP right now)
- Switch the value of that option to MTP
- Refresh your MTP client (e.g., on Ubuntu 15.04, close and re-open the window showing the contents of the device)
这是加剧的,当你试图用一个设备上的外部存储的文件进行操作。
This is aggravating when you are trying to work with a device's files on external storage.
是否有一个命令行的方式来获得MTP去,总之写UIAutomator测试,它可以自动上述过程的?或者说,有一些其他的方式来获得MTP在没有这种$ P $聚丙烯工艺的工作?
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?
推荐答案
我怀疑没有某种超能力的它不会是可能的: - (
I suspect it will not be possible without some sort of super power :-(
adb shell svc usb setFunction mtp
抛出 java.lang.SecurityException异常:无论是用户还是2000当前进程具有android.permission.MANAGE_USB
和 MANAGE_USB
是签名|特权
许可。我提起这个作为。它已投入状态的分配的并标记为的缺陷25596495 的
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.
这篇关于我们如何切换MTP上更容易出现调试启用的Android 6.0设备上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!