Back in the middle of March, we dedicated an entire week to many awesome Tasker tips and tricks that you've likely never seen elsewhere to best enhance your smartphone's utility. Hopefully, you've learned a bit about how to work with Tasker having played with some real-world examples.

Today, I'm bringing you a new idea I've come up with that should please the many flashaholics on our forums.

If you're a user who likes to take control of your own device by flashing custom ROMs, kernels, etc then you are likely someone who downloads a lot of files off of sites like AndroidFileHost.com. You will notice that each and every file on hosting sites like this include the MD5 sum for you to compare when you finish downloading it.

Oops
Oops

It's super important that you compare the MD5 sums before flashing a critical file such as a radio or bootloader, to ensure that you aren't flashing a corrupted file. But it's a nuisance to do so on mobile, because you need to manually find the file in your file explorer app and copy/paste the MD5 sum into a text box in order to compare the sums.

I stopped and thought to myself, why not automate this with Tasker? I looked it up and was surprised to not have found this mentioned anywhere, but it's possible and actually quite easy to do!

How It's Done

How it works: You copy the md5 sum to your clipboard BEFORE downloading, then when the download finishes you are prompted whether or not you want to compare values. If you press yes, then Tasker will calculate the MD5 sum of the downloaded file and compare it to what's in your clipboard.


Prerequisites

  • Notification Listener or AutoNotification. I personally use AutoNotification but for the sake of this tutorial I set it up using Notification Listener because it's free to use.
  • Snackbar Tasker Plugin. Not required (though if you import my profile it uses it) but it beats having to create a scene with buttons. I've set up the tutorial to only use the free features of the app.

Screenshot_20160424-180854


Instructions

  • Create a new profile and name it 'Check MD5 Sums.' For the context, go to Events --> Plugins --> Notification Listener. Select "Posted" and scroll down and pick your browser app. I personally use Chrome Dev so I selected that.
  • Task --> If. Set it to If %nltext ~ Download complete. (Or whatever sub-text your notification says when your browser app tells you a download has been completed.) This is so the task will trigger when it detects that a download has been completed, as indicated by the browser notification.
  • Plugins --> Snackbar Tasker Plugin. Select "Bottom Sheet." For the title, make it something like "Check MD5 Sums?", for Items make it "Yes,No" and for commands make it "Y,N".
  • Task --> If. Set it to If %bs_command ~ Y.
  • Code --> Run Shell. For the code make itls /sdcard/DownloadSet it to store result in %files. (Change whatever is after /sdcard/ to the path of your download folder. /sdcard/Download is the default for most people)
  • Variables --> Variable Split. Split %files.
  • Variables --> Array Pop. Pop %files, position 1, and set it to %download.
  • Code --> Run Shell. For the code make itmd5sum /sdcard/Download/%downloadSet it to store result in %md5. Again, change the download directory as needed.
  • Variables --> Variable Split. Split %md5. Don't set a splitter.
  • Alert --> Flash. Text: "MD5 Sums Match!" Check If and set it to If %md51 ~ %CLIP.
  • Alert --> Flash. Text: "MD5 Sums are Mismatched!" Check If and set it to If %md51 !~ %CLIP.
  • Task --> End If.
  • Task --> End If.

Here are screenshots of the Task editor screen, to give you a better picture of the order of actions:

Interested in importing the XML yourself? Follow this link to my thread in our Tasker Tips & Tricks forum and scroll to the attachments for the file. To import it, open up Tasker, long-press on the profiles tab up top, press import, and browse to the .prf.xml file you downloaded.


Have an idea that you've always wanted to implement in Tasker but didn't know how? Let us know below and we may feature a solution to your idea in the future!