Can I make the USB connection default to file transfer only for my computer?


Question

Every time I plug in my phone to my computer, it defaults to only charging. I have to open the phone notification to switch to file transfer mode. Is there a way to tell it to remember to use file transfer mode when connecting to my laptop? Or to change the default when connecting to my laptop?


I know that it is possible to change the default for all connections. However, I would prefer if it only changed the default when connecting with my laptop. I'm also uncomfortable that I would need to dig inside the developer settings to change the default.


If it matters, my phone has Android 10 (Q).


Answer

Your phone can not identify which computer it is connected to, USB an MTP protocol does not include something that could identify a host computer.


There is a feature for USB-C authentication planned but I have never heard that it is already supported by a device and if I understand it correctly it should allow to identify a device type or a device class, not an individual device or computer:



USB Type-C Authentication empowers host systems to protect against
non-compliant USB chargers and to mitigate risks from malicious
firmware/hardware in USB devices attempting to exploit a USB
connection. Using this protocol, host systems can confirm the
authenticity of a USB device, USB cable or USB charger, including such
product aspects as the capabilities and certification status.



Therefore the answer is no, with pure MTP and/or USB this is impossible.


However the other Android USB protocol Android Debug Bridge (ADB) supports authentication. The host computer automatically creates a RSA key pair you is used for authentication. The whole process is similar to SSH where you can trust a computer based on it's key pair when you connect to it the first time.


Hence you should enable developer options and ADB on your device and use adb based tools instead.


Note that if you should get an update to Android 11 there is a feature that automatically removes adb authorizations after a certain time. This option can also be found in developer options. In my opinion it is recommended to disable feature.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes