uTag icon indicating copy to clipboard operation
uTag copied to clipboard

Grapheneos investigation

Open thelittlefireman opened this issue 1 month ago • 7 comments

After manually recompiling and digging into the installation process, I've managed to identify the issue with GrapheneOS.

TL;DR: GrapheneOS is more aggressive with ANR (Application Not Responding) and kills SmartThings more faster than stock OS, which prevents it from completing it's initial setup.

Long Version:

The issue is related to the fact that the "dexplore.find*" function takes too long to find classes/methods, causing the system to trigger a timeout and kill the app before the search ends. A quick and dirty fix is to manually replace all instances of dexplore.find with Class.forName("xxx", true, classLoader).

Perhaps a more advanced fix would be to generate, on a computer with the dexplore CLI, a matrix with SmartThings versions and obfuscated class and method names. This matrix/table could then be included as a static asset in xposed-core.

I Will try to make a PR with something like this.

Moreover, for full compatibility with Android 16+ and GrapheneOS, three things are mandatory:

  • Disable UTAG and SmartThings from battery optimization.
  • Use the latest Lapatch (with the latest LSPosed) to patch SmartThings.
  • SmartThings should be run multiple times before UTAG setup (LSPosed crashes the first time the app is launched; this is a known issue with a fix).

It's absolutely NOT needed to exclude both apps from exploit protection.

#63 #61

thelittlefireman avatar Nov 23 '25 23:11 thelittlefireman

Perhaps a more advanced fix would be to generate, on a computer with the dexplore CLI, a matrix with SmartThings versions and obfuscated class and method names. This matrix/table could then be included as a static asset in xposed-core.

This wouldn't work because the module is designed to be dynamic for rooted users. It can't target a specific version, otherwise I'd already be doing it.

Other than it being done async and then the app restarting once the patch is ready (which wouldn't work for setup because it needs to be patched before launching), I don't see a way of resolving this.

KieronQuinn avatar Nov 23 '25 23:11 KieronQuinn

After manually recompiling and digging into the installation process, I've managed to identify the issue with GrapheneOS.

Were you able to get it to run with your fixes? Perhaps a short term fork could be useful if so

wrapper avatar Nov 24 '25 08:11 wrapper

After manually recompiling and digging into the installation process, I've managed to identify the issue with GrapheneOS.

Were you able to get it to run with your fixes? Perhaps a short term fork could be useful if so

Yes i has. I Will try to find a proper final solution. Or at least make my fork more stable to push it.

thelittlefireman avatar Nov 24 '25 21:11 thelittlefireman

Update: I've managed to keep the dynamic process and make it works after tweaking dexplore. But smartthing need to be run/crash at least 8 times before setup complete.

Update2: Running the dexplore find method process in a thread, and then restart the smartthing, is working. Only running 2 times Smartthing is mandatory. uTag doesn't not handle properly this setup the first time, but if smart thing is run before utag at the setup it works. I will try to fix that.

WIP branch: https://github.com/thelittlefireman/uTag/tree/wip-grapheneos

thelittlefireman avatar Nov 24 '25 22:11 thelittlefireman

~~I tried building your fork but the uTag app still can't talk to SmartThings ("SmartThings requires extra permissions for uTag to work") despite the app patching successfully. Is this expected?~~ Never mind, after repeatedly trying without changing anything it eventually worked?

leo60228 avatar Nov 29 '25 14:11 leo60228

~~I tried building your fork but the uTag app still can't talk to SmartThings ("SmartThings requires extra permissions for uTag to work") despite the app patching successfully. Is this expected?~~ Never mind, after repeatedly trying without changing anything it eventually worked?

Yes, After about 8 times you should get it worked. I try to improve that.

thelittlefireman avatar Nov 29 '25 20:11 thelittlefireman

Update: I'm close to something satisfying. I've moved from dexplore to dexkit (JNI + multithread) https://github.com/LuckyPray/DexKit, which take about 2 launch of smartthing (counting the first crash due to a bug in LSPatch) and about 10s to find and hook all functions the first time. I.e., we still keep dynamic implementations and it's successfully running on GrapheneOS ;)

@KieronQuinn, I've made a PR, feel free to comment/edit.

#171

thelittlefireman avatar Nov 30 '25 13:11 thelittlefireman

1.0.12 now includes the fix, I did have to tweak it ever so slightly since an in-place upgrade would fail due to the change to the saved method format, but simply adding "v2" to the SharedPreferences key format and forcing a re-application after the update resolves that.

Thanks again for your help, as well as finding DexKit. It is so much faster!

KieronQuinn avatar Dec 16 '25 01:12 KieronQuinn

I upgraded uTag and Smartthings and patching the APK was fast and worked without any workarounds (with exploit protection compatibility mode).

morta5 avatar Dec 16 '25 08:12 morta5