0xStubs

Computer science, IT, Photography

Prevent autostart of Android File Transfer on macOS

Android File Transfer (let’s call it AFT) is a handy tool to transfer files from and to an Android device when using a Mac. This software has an annoying habit though: It automatically starts when an Android device is plugged in. Since on most modern Android devices, the user has to give permission to access files after connecting it to a PC, it opens up just to confront the user with an error message.

This behavior is caused by an App called “Android File Transfer Agent.app”, which is automatically installed by AFT to launch on login and wait for connecting devices. Here is what seems to happen on every launch of AFT to install this agent:

  1. “~/Library/Application Support/Google/Android File Transfer/Android File Transfer Agent.app” is replaced by “/Applications/Android File Transfer.app/Contents/Resources/Android File Transfer Agent.app”
  2. The Agent app ist started
  3. An entry for this application is installed as a Login Item for the current user

People have come up with different hacks to sabotage this “feature”, e.g. renaming “Android File Transfer Agent.app” to something else in the /Applications folder or making the folder under ~/Library unaccessible for AFT. Unfortunately, these solutions have side effects, such as an increasing number of invalid entries in the user’s startup items. A more clean solution therefore is to replace “Android File Transfer Agent.app” by an application bundle that does nothing.

Creating a noop application

We can simply use the Automator to create an application bundle:

  1. Run Automator.app and create a new Application
  2. Since some action has to be performed, insert an empty shell script into the work flow
  3. Save the application as “Android File Transfer Agent.app” in your user’s directory

Replacing agent by noop application

  1. Stop any running “Android File Transfer Agent” using the Activity Monitor
  2. Remove app from ~/Library:
    rm -rf ~/Library/Application\ Support/Google/Android\ File\ Transfer/Android\ File\ Transfer\ Agent.app
  3. Replace the agent app under /Applications:
    sudo rm -rf /Applications/Android\ File\ Transfer.app/Contents/Resources/Android\ File\ Transfer\ Agent.app
    sudo cp -r ~/Android\ File\ Transfer\ Agent.app /Applications/Android\ File\ Transfer.app/Contents/Resources/

On the next launch of AFT, it will copy your noop app to your ~/Library folder and install it as a startup item. Since it is a valid app, this should not cause any issues. Of course, after an update of AFT you will have to replace the agent app under /Applications again, but the last update was in 2012, so I wouldn’t worry too much…

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.