HomeTaskerTasker: 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 with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

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)?