8

I often plug my Android device into the USB drive simply for charging purposes with no intention to use the filesystem (and with the screen off or with the USB settings in "charging only" mode, either of which prevent the phone from allowing a data connection to be made). When I do this, though, I often get a very large number of annoying pop-ups that look like the popup shown in the image below:

enter image description here

Ideally, there would be some way to configure the window manager to not display these pop-ups in the first place (without disabling automounting, so that I can still -- on occassion -- use the device as a filesystem without needing to mount manually, i.e. when the phone's USB setting is in "MTP" mode and the screen is unlocked). Failing that, it would be ideal if there were a simple command that I can use to kill all instances of this popup (without killing the rest of the window manager at the same time). Failing that, solutions to disable automounting of this specific device (without disabling all automounting) would be an acceptable solution.

Any suggestions on how to either prevent this popup from happening in the first place or to kill multiple instances of the popup in a single command?

For more context, I am using Ubuntu 14.04 LTS; I am not sure whether Gnome or Nemo is responsible for this error (I know that my "Home" directory shortcut icon invokes "nemo", but I am pretty sure that there are also Gnome-based apps on the system, there is a ~/.gnome and ~/.gnome2 directory, etc. so it could be Gnome).

  • Try this: Ignore the popup, then pull down the notification bar (which says it's "Connected as a media device") - if you have one, tap on "Ongoing" connection and switch from "MTP mode" to "PTP mode": – harrymc Jan 20 '17 at 18:59
  • 1
    The solution to your answer is here on the ubuntu stack exchange – Computing Corn Jan 20 '17 at 19:01
  • 1
    Try also the solution in this thread. Also try sudo apt-get install mtp-tools mtpfs. – harrymc Jan 20 '17 at 19:07
  • These solutions do not work / address a different issue. – Michael Aaron Safyan Jan 20 '17 at 21:15
  • @MichaelAaronSafyan "These solutions do not work / address a different issue". With kde when I installed mtp-tools mtpfs it solved a similar issue... I didn't understand if you have tried the Harry's suggestion and it didn't work or if you just discarded it...a feedback can be useful to other users too... – Hastur Jan 24 '17 at 17:24
6
+100

So you have this:

Unable to mount Pixel

The file manager is presenting those error messages, which come from GVfs, which is relaying information from libmtp.

Preventing File Manager Error Popups

Unfortunately, I have not yet discovered a way to suppress error popups in the GNOME/MATE/Cinnamon file manager. Maybe someday, I'll look into the source code to see where the error can be turned off or intercepted.

Since I don't have an answer for this, let's move on to your next-best acceptable option, which is…

Closing File Manager Popups by Command

Here is a script that can be used to clear the popups on GNOME, MATE, and Cinnamon:

#!/bin/bash

function list_empty_windows() {
  wmctrl -lp | awk "{if(\$5==\"\"){print\$3,\$1}}"
}

function list_wm_pids() {
  ps aux | grep cinnamon | perl -pe 's/.*\+\s+(\d+)\s+.*/\1/'
  pidof nautilus | tr ' ' '\n'
  pidof caja | tr ' ' '\n'
  pidof nemo | tr ' ' '\n'
}

function list_popup_windows() {
  local empty_window_file=$(mktemp)
  local window_manager_pid_file=$(mktemp)
  list_empty_windows > "$empty_window_file"
  list_wm_pids | sort > "$window_manager_pid_file"
  join "$empty_window_file" "$window_manager_pid_file"
}

function main() {
  list_popup_windows | cut -d ' ' -f 2 | xargs -n1 -P100 wmctrl -ic
}

main

If you want an easy command to remember, these will close all the windows in your file manager and cause your desktop to restart your file manager:

  • GNOME: killall nautilus
  • MATE: killall caja
  • Cinnamon: killall nemo

Disabling Automounting of Google Pixel

There doesn't seem to be a way to remember to ignore only Google Pixel.

I don't recommend this, and I haven't tested this myself, but to single out Google Pixel, you might have to comment out vendor 18d1 product 4ee1 (Google Pixel) and vendor 18d1 product 4ee2 (Google Pixel debug) in the udev rules and hwdb.

You can find the records with this command:

grep -ri '18d1.*4ee[12]' /lib/udev

After commenting out the udev records of Google Pixel, you may need to restart your desktop environment, reboot, and/or run some combination of the following commands:

sudo udevadm hwdb --update
sudo udevadm control --reload-rules
sudo udevadm trigger

Again, this is untested, and I don't recommend this especially because in order to mount Google Pixel again, you'd have to undo the manual udev changes.


Explanation

According to /var/log/syslog, GNOME is making the error show up because the USB device disappeared on the second attempt to initialize it:

Jan 24 01:32:41 node51 kernel: [613604.065259] usb 3-2: new SuperSpeed USB device number 96 using xhci_hcd
Jan 24 01:32:41 node51 kernel: [613604.082734] usb 3-2: New USB device found, idVendor=18d1, idProduct=4ee1
Jan 24 01:32:41 node51 kernel: [613604.082739] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 24 01:32:41 node51 kernel: [613604.082741] usb 3-2: Product: Pixel
Jan 24 01:32:41 node51 kernel: [613604.082743] usb 3-2: Manufacturer: Google
Jan 24 01:32:41 node51 kernel: [613604.082745] usb 3-2: SerialNumber: XXXXXXXXXXXX
Jan 24 01:32:41 node51 kernel: [613604.083855] usb 3-2: Enable of device-initiated U1 failed.
Jan 24 01:32:41 node51 kernel: [613604.084154] usb 3-2: Enable of device-initiated U2 failed.
Jan 24 01:32:42 node51 org.gtk.vfs.Daemon[4988]: Device 0 (VID=18d1 and PID=4ee1) is a Google Inc (for LG Electronics/Samsung) Nexus 4/5/7/10 (MTP).
Jan 24 01:32:43 node51 org.gtk.vfs.GPhoto2VolumeMonitor[4988]: (process:5256): GVFS-GPhoto2-WARNING **: device (null) has no BUSNUM property, ignoring
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: LIBMTP libusb: Attempt to reset device
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: inep: usb_get_endpoint_status(): No such device
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: outep: usb_get_endpoint_status(): No such device
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: libusb_open() failed!: No such device
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: LIBMTP PANIC: Could not init USB on second attempt
Jan 24 01:33:34 node51 org.gtk.vfs.Daemon[4988]: ** (gvfsd:5151): WARNING **: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Unable to open MTP device '[usb:003,096]'

In the sample above, GVfs through libmtp identified USB bus 003 device 096 as the Google Pixel device, but the Google Pixel device had already disconnected itself. The next time Google Pixel reconnects, Linux will have assigned a new device ID.

libmtp errors out because it's still trying to work with the device that disappeared. GVfs picks up the error and forwards it to GNOME Files or some other GNOME-based file manager.

Who's At Fault?

Based on what I've discovered, these have room for improvement:

libmtp

libmtp is probably the most responsible in causing this problem.

It should improve error handling when an MTP device is connected and suddenly disconnected. The error should only be passed if the device still exists. If the USB device doesn't exist, it's pointless to try resetting it.

Report issues to libmtp

Android

Android could improve its MTP implementation so that it doesn't disconnect immediately upon connecting to a computer.

Report issues to Android

Nautilus / Caja / Nemo

It would be nice if these software offered a preference to suppress error messages or display them in a less popup-y fashion.

Report issues to GNOME
Report issues to MATE Caja
Report issues to Linux Mint Nemo

  • This answer is very, very close (thanks for the suggestion concerning wmctrl). However, it turns out that the PID from the empty windows is one associated with none of the above but rather with the command "/usr/lib/x86_64-linux-gnu/cinnamon-settings-daemon/cinnamon-settings-daemon". However, what you gave me is enough to create a script that clears all the popup windows. – Michael Aaron Safyan Jan 25 '17 at 14:59
  • FYI, I've updated / edited your answer to replace your one-liner with a script that successfully closes the popup windows. – Michael Aaron Safyan Jan 25 '17 at 15:19
4

I have a workaround for this on Nemo:

Go to Edit > Preferences > Behavior and on Media Handling uncheck "Automatically mount removeable media when inserted and on startup".

When you finish charging your phone you can reenable the option to resume the default behavior.

  • 1
    Thanks for this. With caja (Ubuntu MATE) you can do: Edit -> Preferences -> Media -> uncheck "Browse media when inserted" – David Weldon Jan 2 at 3:47
1
sudo apt-get install mtp-tools mtpfs

Executing this command will install the necessary tools and the error won't appear. A complete reboot might be needed.

  • How is this supposed to help if the device is intentionally not in a mode that allows usage with MTP? [I'm not trying to use the device with MTP; rather, I'm trying to disable annoying notices/popups that appear whenever I simply want to plug-in the phone in order to charge] – Michael Aaron Safyan Jan 22 '17 at 5:28
  • 1
    @Logan: If you had read the comments on the post, you would have seen that this advice was already offered and did not help. To avoid such mistakes, it's a good idea to always read all existing answers and comments before answering. – harrymc Jan 22 '17 at 15:23
0

One thing you can try is to change how Android handles the USB port on the device. Starting with Marshmallow (Android 6.0) the default setting for the USB port was for charging only and to change that you'd have to tap on the notification bar and then the notification to change it for other uses.
First thing you'll have to do is to enable Developer Mode.
To do this open Settings - About Phone, then scroll down until you see Build Number, then just tap that 7 times to enable Developer Mode.
You'll see a little message saying that you are now a developer once you've completed the steps in the right order.

Now with developer mode enabled you'll see a new menu item in the settings menu called 'Developer Options', tap on that then scroll down until you see USB Configuration, then tap on that.
You'll then be presented with a window where you can specify the default behavior of the USB port when you connect a cable to it. You'll have the choices of Charge, MTP, PTP, and any other protocols that your device supports.

0

a simpler fix for this is to set your phone to present to the computer as a midi device instead of mtp , ptp or anything else.

You might need android 8 , i can do this on my oneplus3t

This then stops nautilus getting involved at all but is quickly undone when you do want the file sharing.

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.