Home Tasker Tasker: Set USB for file transfer automatically

Tasker: Set USB for file transfer automatically

Just plug and play, I mean enjoy your USB drive access

I have been shooting more and more videos with my Pixel 3 recently which means that all these files have to go somewhere. I acquired a USB-C expansion card to my PC to speed up the transfer process (review is coming). There was one thing left to make the process quicker and less painful: using Tasker to set USB for file transfer automatically.

Set USB for file transfer automatically with Tasker

The way Android storage is accessed via PC has changed over the years. It was much easier (and less secure in the past) now, the default way is simply annoying. I appreciate the security as any other guy, but c’mon Android, you could do it better! It was time to do what I’m doing best and use Tasker to set USB for file transfer automatically.

As soon as the Nav Bar Action has been released, I knew I would use this for that purpose. Android 9.0 is perfect for the nav bar modifications as it leaves a lot of space in the right corner. With the plan in mind, it was time to shape up Tasker’s behaviour.

You will need the following plugins to make it happen:

Trigger

Since I’m going to use AutoNotification plugin anyway, I opted out for notification monitoring rather than the USB trigger as an option. This way I only going to enable, then a correct device is plugged in.

When the notification is preset, Tasker will show me an extra navbar button which will:

  • [tap once] enable file sharing
  • [tap two] close the option

It’s possible to add the third tap, but I barely use any options. If you wish you can add the task to trigger MIDI, PTP or USB tethering.

I will need two actions, one to create the navbar button, and one to restore the original navbar button.

Action: Set USB for file transfer automatically

TASKER TASK: USBFS Set File transfer
USBFS Set File Sharing
	A1: AutoNotification Actions 
		[ Configuration:Notification Title: 
		  Charging this device via USB Timeout (Seconds):20 ] 
	A2: AutoTools Secure Settings 
		[ Configuration:Set Accessibility Services: true
		  Accessibility Services: com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility 
		  Timeout (Seconds):60 ] 
	A3: AutoInput Action 
		[ Configuration:Type: Text
		  Value: File transfer
		Action : Click Timeout (Seconds):20 ] 
		//OPTIONAL WAY//
	A4: [X] Keyboard [  Input:Tab Time Between Inputs:50 ] 
	A5: [X] Keyboard [  Input:Tab Time Between Inputs:50 ] 
	A6: [X] Keyboard [  Input:Tab Time Between Inputs:50 ] 
	A7: [X] Keyboard [  Input:Enter Time Between Inputs:50 ] 
	
	A8: Navigation Bar [ Left:back[1.0] Center:home[1.0] Right: ] 
	A9: AutoTools Secure Settings 
		[ Configuration:Set Accessibility Services: true 
		  Timeout (Seconds):60 ] 
	A10: Go Home [ Page:0 ]

Initially, I wanted to use the new Keyboard action to toggle between on-screen options, but the method was much slower than AutoInput. If you don’t want to use AutoInput (I’m going to use AutoTools to enable and disable the accessibility services to avoid the lag) you can use the keyboard action. It is slow.

To access the USB preferences screen, I’m using AutoNotification Action. This way I can simply “tap” on the message in my notification drawer which will open the correct setting’s menu.

Keyboard action way
To access the correct setting, you have to perform 4 actions:

  • Tab
  • Tab
  • Tab
  • Enter

Keep the delay to min  (50). 

First, enable the AutoInput accessibility using AutoTools Secure Settings, then using AutoInput automated setup navigate to the setting screen and tap on your preferred option. Return to the notification created by the AutoInput and finish up the task.

Since the AutoInput is no longer needed, toggle it back to off with AutoTools Secure Settings and modify the navbar to default values. Lastly, for the clean effect, navigate to the home screen.

Putting it back together

Once you can set USB for file transfer automatically, add the task to the navbar action when prompted to add another, link the task responsible for resetting the navbar to the default state and you are ready to go.

Smart NavBar integration

This is a stand-alone version of the Smart NavBar actions. Once I created the standalone versions for each NavBar Task I will show you how to integrate it together. You can read the tutorial about this now!

Conclusion

I should have set this up much sooner if I’m honest. It was easier than expected with AutoNotificaiton, and thanks to the AutoTools toggles AutoInput is not running constantly. Now I can set USB for file transfer automatically. It’s not a flashy profile, but something tells me it will be one of the most useful ones for sure.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated in style with crypto-currency

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

Tasker PC control – #Tutorial 3 (Apps menu)

0
Launch apps and websites from the mobile!

Tasker PC control – #Tutorial 2 (Volume Menu)

0
If you missed the part one, I strongly recommend you to check it out. It tells you all about the framework used,...

How to control your PC like a boss – Tasker Project

0
Control PC, and other devices from a custom notification system.

Bluetooth battery monitor – monitor any Bluetooth battery with Tasker

0
Measure the battery use of Bluetooth devices

The Minimal & Elegant giveaway WINNERS

0
Picking the winners live! Livestream and making a Tasker Winners project!

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?