ICS MTP; GB UMS

Ice Cream Sandwich explained: MTP - what is it, why use it, and how to set it up

By  Jerry Hildenbrand   25 Nov 2011 5:04 pm

MTP (Media Transfer Protocol) first showed up as default on Android devices with Honeycomb.  It's a bit of a change from the normal USB Mass Storage (UMS) file transfer that we're used to, where you plug in your phone, hit "USB mode" and start moving files. And because it's become the standard in Ice Cream Sandwich on the Galaxy Nexus, it's time to have a look at it.  Hit the break where we see what it is, why we're using it, and how to set it up on your computer for easy file transfer.

Check out our Ultimate Ice Cream Sandwich Guide

What is MTP?

MTP is a set of custom extensions for PTP (Picture Transfer Protocol) that is beefed up to allow files and their associated metadata to be transferred across USB. Still with us?

Originally part of the Windows Media framework, in 2008 the USB Implementers Forum device working group standardized MTP as a USB device type, making it a recognized standard.  If you had an old iriver or Creative MP3 player, or an old PDA device, you've probably used MTP.  If you use a standalone digital camera that automatically mounts as a device when you plug it in, you're using PTP, which is essentially the same thing.  It's not new, but it's new to Android as of Honeycomb, and it's about to be seen by a lot more eyeballs in Ice Cream Sandwich.

If you're like me, change is scary and nobody likes it.  Chances are you aren't like me and want new features and ideas, so let's have a look at why it's used, and more importantly, how to set it up.

Why use MTP instead of USB Mass Storage?

Simply put, MTP is now the standard being used to stop OEM's and carriers from giving you oodles of  "storage space" and very little application space.  That's not the ramblings of a crotchety old Android geek, but the word right from Android engineer Dan Morril:

We didn't do this because we wanted to use ext3 (although that is a side benefit.) We did it because we wanted to be able to merge the "public shared storage" (i.e. for music and photos) with the internal private app storage.

We got tired of seeing OEMs include many GB of internal storage for music, while users were still running out of space for apps and data. This approach lets us merge everything on one volume, which is way better.

USB Mass Storage has one big drawback -- when you mount the storage partition (whether it's an SD card or an internal block like the Nexus S has), you've dedicated the entire partition as in use by another machine.  This means the original host (that'd be your phone or tablet) doesn't have access to it, and the new host (the computer you've plugged your phone or tablet into) is allowed to do bad things that might mess it all up. That's why moving some applications to the SD card -- and especially widgets -- would sometimes end up in wonkiness.

As a bonus, using MTP means that Android device makers no longer have to use FAT file systems on device storage, and can use ext formatting to make things work a bit better and faster.  Devices will still be sold with SDcard slots, and they will be able to use the same USB Mass Storage mode that we're used to, but new devices without removable storage should all use MTP from Ice Cream Sandwich forward.

Setting it up

Since Windows XP, MTP devices "just work" in Windows.  Plug your Galaxy Nexus in, choose MTP as the connection type, and Windows will find the driver and you're ready to go.  You can browse and transfer files between your phone and computer without any issues, and it's easy and magical.  But not everyone uses Windows, do they?  Here's how to set up things on the other 10 percent of computers out there, Linux and Mac.

Mac OS

The folks at Android have made it easy as possible to use MTP devices on a Mac.  Simply download and install the Android File Transfer program, connect your device to your computer, and double click the AFT application to start it up.  You can then drag and drop any file (up to 4GB in size) to and from the device.  There's even a dedicated help page in case you hit a snag. 

Linux

On a Linux install, things aren't quite as easy.  On the plus side you have a bit of control how things are mounted, but there's no one click solution.  Don't be discouraged, you can have MTP set up and running in no time with a bit of terminal command fun.  Here's a walkthrough for using the Galaxy Nexus with Ubuntu:

Set up a UDEV rule via the terminal by opening the rules file

sudo nano -w /etc/udev/rules.d/51-android.rules

And entering the following line at the end of the file (be sure to use your user name at the end!):

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<your-username>"

Now install the tools and set a mount point by entering the following commands one line at a time

  • sudo apt-get install mtpfs
  • sudo mkdir /media/GNexus
  • sudo chmod 775 /media/GNexus

Plug your Galaxy Nexus in, and enter the next line in the same terminal window:

sudo mtpfs -o allow_other /media/GNexus

Drag and drop through Nautilus, and when you're done and need to unmount, enter the following:

sudo umount mtpfs

This will have to suffice until someone writes a couple scripts or a front end.  You don't have to install mtpfs, make the mount point, or chmod it after the first time.  You may have to mount the device manually each time, I'll know more when I get one to play with.

An alternative

I have a Galaxy Tab 10.1, that uses MTP for transfer mode, and never ever hook it up to the PC.  I use a combination of  and  from the market and transfer files across my LAN at home.  You might want to look into this yourself if you're like me and hate wires.

Related devices:

### UMS、RNDISMTP 模式的切换方法 #### 1. **UMS (USB Mass Storage)** 切换配置 UMS 是一种传统的 USB 存储模式,允许设备作为外部硬盘被主机识别。然而,在 Android 5.1 及以上版本中已不再支持该模式[^4]。 - 如果需要启用 UMS 模式,则需依赖于旧版 Android 设备或自定义 ROM 的支持。 - 对于开发人员而言,可以通过修改 `fstab` 文件以及调整 `/system/etc/vold.conf` 来重新激活此功能。具体操作如下: ```bash # 修改 vold.conf 中的 ums 启动参数 vold.fstab=/etc/vold.fstab ``` 需要注意的是,现代 Android 系统更倾向于使用 MTP 或者其他高级协议代替传统 UMS 模式。 --- #### 2. **RNDIS (Remote Network Driver Interface Specification)** 切换配置 RNDIS 主要用于将移动设备模拟成网卡,从而实现网络共享等功能。它通常应用于调试环境下的 ADB 连接或者热点分享场景。 - 在 Android 上开启 RNDIS 功能的方法之一是通过开发者选项完成: - 打开「设置」-> 「关于手机」 -> 多次点击「版本号」直到解锁开发者模式; - 返回至「设置」-> 「系统」-> 「开发者选项」; - 将「网络连接类型」设为「RNDIS(以太网)」即可[^3]。 对于某些定制化固件来说,也可以直接编辑内核启动脚本: ```bash # 设置 kernel 参数以强制加载 rndis 驱动模块 androidboot.mode=rndis ``` 上述命令可通过 fastboot 工具传递给目标设备。 --- #### 3. **MTP (Media Transfer Protocol)** 切换配置 MTP 协议专为多媒体文件传输设计,广泛适用于当前主流智能手机和平板电脑产品线之中。相比起简单的磁盘映射机制,它可以更好地保护内部存储结构免受意外破坏。 - 默认情况下,当用户选择「仅充电」「文件传输」等 USB 使用目的时,实际上就是启用了 MTP 方式[^2]。 - 若要手动指定进入 MTP 模态,可尝试以下步骤: - 插入 USB 数据线后弹出提示框里选取对应项; - 若无自动询问窗口显示,则前往「通知栏」寻找相关联菜单条目进行更改。 另外值得注意的一点在于部分厂商可能会额外提供专属应用商店下载链接来辅助完成此类设定过程。 --- ### 总结说明 综上所述,针对不同需求可以选择适合自己的通信手段并加以实施部署。尽管如此还是建议优先选用官方推荐途径以免造成不必要的麻烦。 ```python def switch_mode(mode="mtp"): """Switch between different modes based on user preference.""" if mode.lower() == "ums": print("Enabling UMS Mode...") # Code to enable UMS goes here. elif mode.lower() == "rndis": print("Enabling RNDIS Mode...") # Code to enable RNDIS goes here. else: print(f"Defaulting to {mode.upper()} Mode.") # Default code block for enabling MTP. switch_mode() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值