[Feature Request] feat: Allow 3rd party app to trigger patch process via intent

[Feature Request] feat: Allow 3rd party app to trigger patch process via intent

This request will facilitate anyone who wants to patch via morhpe with much control from other apps such as Tasker, Macrodroid, or vFlow (FOSS) locally.

Examples.

  1. Patch when connected to home wifi at 21.00
  2. When patch is done, share to other devices and install automatically.
  3. Trigger patching remotely when device is not within reach.

While morphe-cli exist, it's much simpler to use those apps.

  1. They have visual editor.
  2. Easily shareable, anyone can share their setup to their community.

I'm aware of this request #227 but the proposal is pretty limited compared to what those apps capable to do.

More details in the link.

github.com
u/aasswwddd — 15 hours ago
▲ 22 r/tasker

r/tasker now supports images and videos, Show your scene or any interface you make with Tasker!

As title suggested, show the community the scene you make with Tasker. Can be anything, old scene, widget, scene V2 or even Java code!

Let us know the context behind them too!

I start first myself.

Here's one project that I have been working on recently. A gesture project with Java, the UI lemme configure the configuration required. Video in the comments. since Joao hasn't activated embed videos yet in the body post. He confirmed he'd do so sooner here.

Gesture sheet

Context

I created this since Poco (Xiaomi) won't let its user use native gesture if 3rd party launcher is used. The app I use to replace it has some mildly infuriating bugs so I'd like to have one with Tasker instead.

At first this was just a text based one with configuration file. As I added more logic and gestures, it became harder to manage them. That was when I realized I need a front end for this. It's still WIP and honestly a lot more harder then configuring the core engine.

reddit.com
u/aasswwddd — 4 days ago

Recognize Text via OCR and return their location as well

MacroDroid Template

Utilize ML kit library available in Macrodroid via Java code. Please use the action block and configure the input variables. Return array of dictionaries.

Java Code User

For anyone who wants to use the Java code alone, it's available here.

https://gist.githubusercontent.com/mqwec43as/a44859d7df11aab102b8219eb089915e/raw/OCR.bsh

The methods in library are obfuscated, so I have to normalize them first. And I couldn't tell which one returns the score, lines etc so this doesn't have that.

https://developers.google.com/ml-kit/vision/text-recognition/v2

Example code

addClassPath("Directory where the script is stored");
importCommands(".");

ocr = OCR();
ocr.setLanguage("jp");
ocr.recognize("/storage/emulated/0/DCIM/jp.png");
List result = ocr.toList();

// Accessing the first boundingbox
Rect box = result.get(0).boundingBox;
reddit.com
u/aasswwddd — 7 days ago
▲ 14 r/tasker

[TIPS] Use Java code to run shell command by prioritizing elevated privileges. Root > Shizuku > ADBWifi > Default

The latest beta introduce methods to run shell command with root, shizuku, adbwifi and default one.

Now with this we can create one function for all run shell action!

import com.joaomgcd.taskerm.shell.CommandResult;
import com.joaomgcd.taskerm.action.java.JavacommandException;

public CommandResult runShell(String command, int timeout) {
	int NONE = 0;
	int ROOT = 1;
	int SHIZUKU = 2;
	int ADBW = 3;
	boolean hasRoot = tasker.isRootAvailable();
	boolean hasShizuku = tasker.isShizukuAvailable();
	boolean hasAdbWifi = tasker.isAdbWifiAvailable();
	int[] order = { ROOT, SHIZUKU, ADBW, NONE };

	for (int method: order) {

		if (method == NONE) {
			return tasker.runShell(command, timeout);
		}

		else if (method == ROOT && hasRoot) {
			return tasker.runShellRoot(command, timeout);
		}

		else if (method == SHIZUKU && hasShizuku) {
			return tasker.runShellShizuku(command, timeout);
		}

		else if (method == ADBW && hasAdbWifi) {
			return tasker.runShellAdbWifi(command, timeout);
		}
	}
}

public CommandResult runShell(String command) {
	return runShell(command, 30);
}

To make this easier, you can store the script into global variable or create a task. Or store this to a file even with this approach.

https://www.reddit.com/r/tasker/comments/1r49vbf/how_to_store_java_code_as_a_file_and_use_them_in/

Implementation examples

#1 We can shorten the name to shell() and make it output JSON instead.

Copy this and run via Java code action to import.

source(new URL("https://gist.githubusercontent.com/mqwec43as/b6c911c0546b7830e59b93e4ace9beb2/raw/shell%2520script.txt"));

// Edit this to store to global variable you like
tasker.setVariable("Shell", script);

The link store the script variable and then will be stored to %Shell

Then we can execute it like this.

%Shell

// output to %shell
shell("echo 'hello'", 10);

// output to %custom_var
shell("custom_var", "echo 'hello'", 10);

This will output %shell local variable and the data can be accessed with %shell.exitCode, %shell.output, and %shell.error

#2 We can integrate this with other Java code project seamlessly.

I have gesture project, and with this I can kill foreground app with am force-stop packageName directly after I draw a circle. No additional task or Shizuku is needed!

Demo video https://files.catbox.moe/wyp9ru.mp4

reddit.com
u/aasswwddd — 11 days ago

Text-Based UI Automation With Java (Beta)

Template Link

Requires 5.65.2

Source code https://github.com/mqwec43as/AccessibilityAction The codes in this project were generated with the assistance of AI Tools.

This macro lets us declares UI automation as text, as oppose to using action instead. Similar to AutoHotkey (Windows) or AutoInput Action V2.

All the syntax and functions can be read here. (Supported: main, actions, and gestures) https://github.com/mqwec43as/AccessibilityAction/blob/main/readme/Documentation.md

Demo video, add variable set action when displayed on virtual display. https://i.imgur.com/g1jXOnJ.mp4

Total downloaded size is around 180kb (600kb unzipped) and stored on chosen folder on internal storage.

How it works

The macro sets a global java variable called a11Y and exposes every method through set() method.

You can use it in any Java code action and all the methods will be available.

a11Y = globals.get("a11Y");
a11Y.set();

// or
globals.get("a11Y").set();

openApp("Youtube");
click("Subscription");
click("Today");

Read more about the a11Y here.

https://github.com/mqwec43as/AccessibilityAction/blob/main/readme/What%20is%20a11Y.md#a11y

What's ported

  • Text-Based UI Automation.
  • Debug highligher.

What's ported

  • Assist features and other UIs. Unable to use com.google.material components due to missing compatible theme (Theme.Material3) with the library.
  • Shizuku gestures. Unable to use Shizuku in Java code.
  • Callback for gestures (tap, swipe) and takeScreenshot. Unable to use related abstract class.
  • Event declaration. Unable to intercept events in Java code.

Notes

Finally I can port my tasker project here!

I left the remaining codes there for now just so I can pick them up later, if one day Macrodroid supports Material You or using abstract classes.

Also if you see context and tasker, those are wrapper objects to match tasker syntax set by lib/macrodroidHelper.bsh. Just so I don't have much to change later.

Feel free to fork, edit, reuse or do anything about this project.

Mostly the core syntax is the same as Tasker, so you can definitely lurk on my previous posts in r/tasker to see relevant updates & discussion.

My profile is private, Click this reddit search url to find them.

Lemme know if there is any error outside what's not supported. Cheers!

reddit.com
u/aasswwddd — 18 days ago
▲ 14 r/tasker

[Project Share] Accessibility Action v3.3, Target virtual display, filter search nodes, use multiple identifiers and take node screenshot.

Taskernet

The codes inside this project were generated with the assistance of AI Tools.

This project will ask to download files from this repo. Then executes a11Y.java via Initiate a11Y variable task.

If you previously download this project, please re-import again. Reminder that this will delete only used folder inside the target folder.

 

What is this project?

Syntax based automation like AutoInput Action V2 or AutoHotkey. More info and examples can be read on the repo page. https://github.com/mqwec43as/AccessibilityAction

  1. Syntax based UI automation actions.
  2. Debug highlighter & UI inspector.
  3. Minimal script builder.

Older posts containing past discussion and examples can be found here.

 

New

  1. Target secondary/virtual display with setDisplay.
  2. Most Assist and debugging features works with secondary/virtual display.
  3. Filter nodes by their properties with sheet menu.
  4. Search nodes through list dialogs.
  5. New identifier key "flags" to match against node's properties.
  6. Use multiple keys and their counter match.
  7. Take screenshot of node, window, and display.
  8. Get pixel color.
  9. Control accessibility service.

Taskernet features

  1. Add support to run via http request on local network.
  2. Add support to run via intent. Both requires keyv to be passed, needs to be set up via project variable.

 

Support secondary/virtual display

Demo Video: Interacting with scrcpy's virtual display

We can set the target display by using setDisplay().

Target display id 20.

a11Y.set();

setDisplay(20);
openApp("Youtube");
click("Subscription");
click("Today");

Target the first scrcpy display.

a11Y.set();

setDisplay("scrcpy");
browseUrl("www.youtube.com", "Youtube");

 

Search and filter nodes

Demo video: Filter clickable and see them in list dialog

We can filter nodes now based on their flags. E.g clickable and has text. Making it easier to select nodes that are overlapped.

Noted: Some nodes that has text are not always clickable. However their parent is, and this project will try to click the parent instead.

 

Multiple keys filter and counter keys

Demo video: Highlight different nodes with one reference text

Now it's possible to filter mutiple data and invert keys too.

Require at least text or id.

aa.text = "string";
aa.notext = "me";
aa.flags = NodeInfo.PASSWORD | NodeInfo.ENABLED;
click(aa);

or

a() {
    text = "string";
    noregex = "[A-Z]";
    // Use clazz instead of class because class it's reserverd
    clazz = "android.view.Button";
    return this;
}
click(a());

 

Take screenshot of target node, window or display and get pixel color

Demo video: Sharing reddit post card

Joao added a new flag to take screenshot to Tasker accessibility service. The project now supports taking screenshot with it and checking pixel color as well.

// Screenshot of diplay 0
takeScreenshot("/storage/emulated/0/ss.png"); 

// screenshot of the first node that matches "Tasker";
takeScreenshot(getNode("Tasker"), "/storage/emulated/0/ss.png");

//  Target diplay id 3
takeScreenshot(3,"/storage/emulated/0/ss.png" )

//  Target window id 3, auto adjust the target display.
String path = takeScreenshot(3, 0, "/storage/emulated/0/ss.png" )

// Get pixel color
int color = getPixelColor(100,100); 

 

Control accessibility service

Useful when we don't always one the service to be enabled. Requires WRITE_SECURE_SETTINGS permission.

a11Y.set();

// Enable first
a11Y.enableService();
// wait(100); Wait might be needed.

openApp("Youtube");

click("Subscription");

// Disable after.
a11Y.disableService();

 

Final Notes

Assist feature limitation

The action picker can only be displayed on the main screen since tasker.doWithActivity(Consumer) can't target specific display id. The same goes when the screen is locked, we have to unlock first to see the dialog.

App Factory & v6.6

The picker and setting also won't work if com.google.android.material is not found. E.g kid app or any version before v6.7.

Joao updated the App factory last weekend, so it should probably works since it supports SceneV2 (uses material lib). Not tested though.

Transparent overlay && draw over system settings

If you dislike having a transparent overlay for normal overlay, you could disable this by running the following adb command.

adb shell settings put global maximum_obscuring_opacity_for_touch 1

Can be done via Tasker too.

Draw over settings can be accessed via Developer Options.

Dev Options > Debugging > Allow screen overlay on settings
u/aasswwddd — 29 days ago

I fixed my heat problem by toggling these two settings in dev options.

Edit: Toggling These two on and off periodically.

See possible reasons below.

Dev options > Apps > Disable Child Press

Dev Options > Apps > Auto fillI

I always have the first one toggled on for so long, forgot to turn it off when I used to play with Termux lol.

But for some strange reason, the heat comes back for a while even I have them turned off. so I decided to toggle both on & off with Automate when the screen is on and off. Edit: Read below for possible reason.

Equivalent of adb command.

adb shell settings put global autofill_logging_level 0 and adb shell settings put settings_enable_monitor_phantom_procs true

Any apps that can change system settings will do the job, one that requires WRITE_SECURE_SETTINGS or Shizuku permission, e.g Tasker, Macrodroid. I toggled both to 2 and true when screen is off and on, wait 1s and revert to the value above.

Warm heat now is gone and logd consumed a lot less power from 400-500 mah down to 200, reported by BBS Reloaded. In comparison, System consumes around 500mah for a full cycle.

I also toggled these two as well, so I could tell which apps crash or went ANR.

https://preview.redd.it/kphcoju7685h1.png?width=359&format=png&auto=webp&s=b39f8bf6e405f24a017b2a8ff5f82f591070be98

I can still feel a bit of heat for casual use, but not as bad as the entire two years I have this phone with me. What's important is the phone has less lag as well.

Considering I hit 900 charge cycle after charging like a pig and now it has 83% battery health (based on max charge). This isn't bad at all.

My phone is Poco X6, HyperOS3, debloated with Canta. I don't game at all.

Edit:

Possible Reason

https://issuetracker.google.com/issues/205156966 After reading the issue and ask AI to look at the source code of AOSP reponsibles for handling phantom (child) process, what I think might happen is.

By toggling them frequently, we kind of like refreshing and trimming the child process list down to 32.

This is hypothetical, but OEM such as Poco/playstore might still alter the value which leads to more child process running in background.

This is probably why I feel that my phone gets cooler and snappier when I toggled them frequently :).

I could be wrong though so don't quote on me, but this should be debugable by following the issue troubleshooting approach.

reddit.com
u/aasswwddd — 1 month ago
▲ 5 r/tasker

[Help] I learned to load my own jar file in Java code. But how I do use external library instead?

SOLVED:

https://www.reddit.com/r/tasker/comments/1tvljle/comment/ophq4e3

The library has to be converted to dex bytecode. I'm using d8 here https://developer.android.com/tools/d8

OP
Someone at r/macrodroid posted a macro that uses jar file to show a trackpad https://www.reddit.com/r/macrodroid/comments/1trb047/just_finished_my_trackpad_shortcuts_menu_macro/

He used DexClassLoader after saving the file in cache directory and make it read only. I managed to replicate the method in tasker and used my own class successfully.

Now I'd like to do more, like using Zxing to read qr code for example. Or any other library really.

Ask this here just in case anyone familiar with this here, not sure where to look. Read through Beanshell's repo and doc, addClassPath(String) seems to be used to add the file but that was a bust.

More like I don't really understand the jargon lol. I'm just a vibe coder after all.

Anyone know how to do this properly? Thankyou!

Anyway, this is the script to load jar file gist.githubusercontent.com

u/aasswwddd — 1 month ago
▲ 8 r/tasker

[Profile share] Pass variables from Java to Tasker or vice versa easily

https://taskernet.com/shares/?user=AS35m8mzep6ZT53%2BqNrzeLiaw4Tx1L4o%2BrgzYDR5Rg4cuz25FIQvQrdsluWlrxmTqBfm&id=Profile%3AJava+%26+Tasker+Variables+Transfer

The code used in this profile is generated with AI.

Simple concept like JSlet action where all our variables are transferred automatically. It should respect tasker array syntax too.

  1. From Tasker to Java, array will be converted to List.
  2. From Java to Tasker, array will be convert to %arr#.
  3. Transfer only variable with name matches local variable syntax.

The usage is pretty simple. We just need to use the global java variable that the profile sets.

In Java code action, write it like this.

// From Java to tasker
myHelper.toTasker();

// From Tasker to Java;
myHelper.toJava();

// With regex
myHelper.toJava("you");
myHelper.toTasker("me"):

I attach an example to in the project. You could take a look at how it works there.

Possibility

Similar concept can be used as well to log them.

Tasker stored the variables and their values as a bundle. Can be retrieved withtasker.getTaskVariables();

And for Java, the variables can be retrieved from this.variables as String[] or Variable[] this.namespace.getDeclaredVariables() and the values can be retrieved from this.namespace.getVariable(String);

For example, we can store tasker local variables to a database, view and call them on demand like this. https://files.catbox.moe/w2v1l0.mp4

reddit.com
u/aasswwddd — 1 month ago
▲ 5 r/tasker

Has anyone tried starting a virtual display with Tasker or Shizuku?

Recently I had been playing around with scrcpy 4.0. I'm at the stage where I can already target the display as seen in this post. Now I'd like to take it further by creating my own virtual display.

My only sources has been https://github.com/kangrio/SimpleVirtualDisplay and scrcpy repo. but all I had done so far is just lousy reading the repos, download the files I thought relevant, reference how to use Shizuku and ask Copilot via VS code to convert it.

I saw an app at r/fossdroid that uses scrcpy to record phone call. But it requires scrcpy so I'm not too sure if it's possible or not.

Has anyone done this?

I thought that if I could do this, I could start an app on the virtual display and do some automation while the screen is locked. At least with scrcpy I could do so, though only limited to apps that I don't lock.

This is what I had so far https://gist.githubusercontent.com/mqwec43as/0e70cc3bb6587853f48b756d413f06c7/raw/d414a33e73e35f97844108a660fa046fdf2d009a/VirtualDisplay.bsh

u/aasswwddd — 2 months ago
▲ 6 r/tasker

[How to] Attempt to run UI automation on secondary/virtual displays.

Recently, scrcpy 4.0 introduced flex-display. I've been dying to cast some of my apps and control it from my phone, just for the bigger screen. Now I got something working with my project here.

So far I tested it with scrcpy and it worked pretty well on HyperOS3 (Android 16). Check out the video below.

https://files.catbox.moe/5tyhqh.mp4

I didn't have any device with multiple displays so I couldn't verify on them.

Setup

The code in the project used below was generated with the assistance of AI tools.

  1. Install Tasker v6.6, preferably latest beta v6.7.
  2. Import this project. Follow the step.
  3. Open Task "Silent update with a11Y".
  4. Run Java code that includes pre release, then restart Tasker.

The code in the project can be found in this repo. https://github.com/mqwec43as/AccessibilityAction

How to

First, make sure that any additional displays are available. If we don't have any, we could use scrcpy.

e.g open Sync via scrcpy.

scrcpy --keep-active --tcpip=192.168.1.13:5555 --new-display=1080x1920 --start-app=com.laurencedawson.reddit_sync --flex-display --max-size=1920 --always-on-top

Identify the display we want to test by running the task called "Show Display Information".

It should pop temporary overlays on every displays, note down the name or the id of the screen we want to test.

Last, Create a new task, and add new Java code action.

Test the following code there, for example.

a11Y.set();
setDisplayId(4); // or the display name setDisplayId("scrcpy");

click("text");

If we want to visualize the automation.

a11Y.debug();
a11Y.set();

setDisplayIdByPackageName("com.laurencedawson.reddit_sync"); // where the package resides

click("joaomgcd");
click("developer");

a11Y.clear();

For now, only AccessibilityNodeInfo actions, gestures (tap/swipe) and shizuku inputs supports this.

How it works

AccessibilityNodeInfo actions

We need to get the root from the focused window on target display. All window can be retrieved from AccessibilityService.getWindowsOnAllDisplays()

Gesture and Shizuku

We need the display context and target the display with setDisplayId for GestureDescription and MotionEvent

reddit.com
u/aasswwddd — 2 months ago

Simple way to execute V2 script by sending http request to my pc on local network?

I have existing setup with EventGhost and AutoRemote plugin, but that is hardly instant even if its on local network, like 1s delay.

I was wondering if there is a setup that allows me easily replicate this setup? I want to send simple key press such down next etc from android app called Tasker.

My goal in the end is to mirror an app (not the entire screen) on my android app with scrcpy's flex display and remote control the navigation from my phone.

reddit.com
u/aasswwddd — 2 months ago
▲ 6 r/tasker

[Share] Examples to get clipboard with java code, via temporary overlay and Shizuku

Temporary overlay

data = source(new URL("https://gist.githubusercontent.com/mqwec43as/b2d64f379fc4c6dc3509aeeedb638d39/raw/getClipboardWithOverlay.bsh"));
tasker.showToast(data);

Shizuku

data = source(new URL("https://gist.githubusercontent.com/mqwec43as/dd195fce8c5f6d69802e93c0bf6830fc/raw/getClipboard.bsh"));
if (data != null) tasker.showToast(data);

Run the codes above to test, then copy it from the link to Java code action if it works

Caveats

  1. Both won't work if the screen is locked.
  2. The overlay one won't work if an app that prevents any overlay is on focus, like Bank Apps or System Setting. Since the overlay has to take focus first as said by Automate dev here.
    1. I haven't tested with Accessibility Overlay, probably it'd work.
reddit.com
u/aasswwddd — 2 months ago
▲ 6 r/tasker

[Task share] Trigger Circle to Search with java code

https://taskernet.com/shares/?user=AS35m8mzep6ZT53%2BqNrzeLiaw4Tx1L4o%2BrgzYDR5Rg4cuz25FIQvQrdsluWlrxmTqBfm&id=Task%3ATrigger+Circle+To+Search+With+Java

May not work on most OS, I assume this works on Android 16 but I can't guarantee.

Converted from MainActivity.kt in MiCTS's source code.

https://github.com/parallelcc/MiCTS/blob/2ead158104bdb8605cbb5eae39a30d44db71bab6/app/src/main/java/com/parallelc/micts/ui/activity/MainActivity.kt#L34

Working on:

  1. HyperOS3 (Android 16), tested by me.
  2. PixelOS (Android 16) reported here.
  3. OxygenOS (Android 16) reported here.
  4. OneUI (Android 16) reported here.

Not working on:

  1. XOS (Android 15) tested by me.
  2. CrDroid (Android 15) tested by me.

For anyone who is interested to make it work, you can read the documentation by MiCTS dev here.

https://deepwiki.com/parallelcc/MiCTS/1.2-system-requirements-and-compatibility#system-service-characteristics

reddit.com
u/aasswwddd — 2 months ago