1

For privacy and security reasons I'd like to disable MTP and PTP on my phone. I recently plugged my phone into an inflight entertainment system to charge it, and was surprised to see that the status bar showed that the phone was connected as a camera (via PTP). This could happen with basically any USB hub, and you won't know until you connect to it.

Running Android 5.0.2 on a Samsung Galaxy A3 (SM-A300FU).


I have tried the following:

  1. Enabled USB debugging
  2. Plugged in the USB cable
  3. Rooted my phone (and verified that it's actually rooted)
  4. adb shell su -c 'setprop persist.sys.usb.config adb' (thanks @Firelord)
  5. Verified in Terminal Emulator:

    $ su sh -c 'cat /data/property/persist.sys.usb.config'
    adb
    
  6. Unplugged the USB cable
  7. Rebooted
  8. Disabled USB debugging
  9. Plugged in the USB cable

At this point the device is automatically "Connected as a media device", and the setting is back to the default:

$ su sh -c 'cat /data/property/persist.sys.usb.config'
mtp

If I leave the USB debugging enabled the value is mtp,adb after rebooting.


After reporting this as a bug, it turns out it's actually been fixed, and charge-only mode has been reintroduced in Android 6.


This is different from Disabling MTP/PTP/all USB stuff except charging because that question is about CyanogenMod, not stock Android, and the accepted answer is not applicable to Android 5.

  • Only the tags usb-connection-mode and 5.0-lollipop are enough IMO. – Firelord Feb 7 '16 at 15:34
  • You incorrectly followed the procedure. The command is adb shell su -c 'setprop persist.sys.usb.config adb'. This command runs with root privileges and makes the changes persistent. Yours doesn't make it persistent. The file /data/property/persist.sys.usb.config store the changes. – Firelord Feb 7 '16 at 15:37
  • I see. Can you list and give us the contents of that file after reboot is performed? Which device is it? – Firelord Feb 7 '16 at 15:50
  • Can you try with USB debugging already disabled and editing the file using a file explorer or text editor? Replace mtp with none. – Firelord Feb 7 '16 at 16:10
  • 1
    Possible duplicate of Disabling MTP/PTP/all USB stuff except charging – Firelord Feb 8 '16 at 23:35
2

Thanks to @Firelord, this is the procedure to follow:

  1. Root your phone
  2. Install Terminal Emulator
  3. In Terminal Emulator, run su sh -c 'echo -n none > /data/property/persist.sys.usb.config'
  4. Restart the phone

Bonus: Now you can get rid of all those horrible vendor apps. Bye Samsung and Three!

Caveat 1: USB debugging no longer works after doing this, regardless of whether you left it enabled while following the instructions or disabled and re-enabled it. All you need to do (I just verified it) is to set the value back to adb to make it work again, but then of course you have the original problem. If there’s a magic string to make USB debugging work and simultaneously disable both MTP and PTP, I don’t know what it is (I tried with none,adb).

Caveat 2: You can’t update Android anymore without completely resetting your device. Not even de-rooting and a factory reset work - bloody Android still says I’ve made an “unauthorized modification.” Let’s recap: “Freedom 0: The freedom to run the program as you wish, for any purpose.” I had to boot into Windows and use Samsung Smart Switch for PC to upgrade.

  • If you one day find the magic string, don't forget to update your answer. I just ended up the same: needing ADB, I had to leave it on "mtp,adb". – Izzy May 18 '16 at 1:04
  • 1
    You can also just set adb mode alone. Instead of none, just use adb. That won't show MTP/PTP – Gokul NC May 18 '16 at 8:24
  • I agree with @GokulNC. Setting adb alone works well in CM and stock Android. – Firelord May 18 '16 at 8:46
  • @GokulNC @Firelord As I said above setting it to simply adb doesn't work - it's overridden to mtp,adb. – l0b0 May 18 '16 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.