Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP/concept: Some highly concerning trends and maybe a "bug" related to LinkSheetCompat? #321

Open
pressRtowin opened this issue Feb 16, 2024 · 12 comments
Assignees

Comments

@pressRtowin
Copy link
Contributor

pressRtowin commented Feb 16, 2024

Hey, how's it going? Glad to see LinkSheet's still going strong (and wow it's blown up quite a bit).

I don't know if you've noticed, but a few months back, Discord stated pushing out what I consider to be a rather concerning update. All links opened from Discord now completely ignore your system "Opening Links" settings. There seems to be a list of apps directly programed to open for any of their associated domains. If you attempt to open ANY link to one of those domains, it will force it to open in its respective app, if that app is installed. This means, for example, that you can no longer have YouTube Revanced installed while also leaving the YouTube app enabled so videos in the Play Store still work. If you want YouTube links from Discord to open in Revanced, you MUST disable the stock YouTube app. Even worse is that even after disabling the stock app, you still get no control over which alternate app (that can handle YouTube links) Discord will pick. It will always pick the next one in its list (not sure how it orders them), so if the app you want it to use is 4th in its list for that domain, you'll have to disable all 3 apps above it. Again, this behavior happens regardless of the "Opening Links" settings for each of those apps.

For domains that aren't associated with an app on the list, attempting to open a link from Discord will respect your default browser setting, if you have one set. If you don't have one set, you no longer get a system dialog to pick which app you want to use. The link will always open in Chrome.

So this means that in both cases above, you'll now never see the system app picker when opening links from Discord. Furthermore, it means that as more and more domains get white listed (and associated with specific apps), even setting app picker replacements like LinkSheet as the default browser will become less and less useful.

I know that was a long and seemingly off-topic rant, but the reason I'm bringing all this up, I guess, is I'm wondering if you've run into any other apps doing this recently, and if you know any way around this. I fear that this may turn into a pattern sooner than later. Do apps like LinkSheet have any way to work around this? Or are we at the mercy of app developers not doing whatever the hell it is that Discord is doing? I even tried LinkSheetCompat, as its description (about Chrome searching for YouTube explicitly) seemed exactly like what Discord is doing, but apparently what Discord is doing is even more pervasive than Chrome, and LinkSheetCompat was never opened, even after disabling stock YouTube.

Any thoughts/ideas?

@JasonHK
Copy link

JasonHK commented Feb 16, 2024

If Discord hard-coded a list of package names to a set of URLs, the only possible way to eliminate the issue is to patch Discord directly (via Revanced Manager, for example).

@1fexd
Copy link
Collaborator

1fexd commented Feb 16, 2024

I'll have to properly dig into this, but from a quick test it appears you have already come to the correct conclusion of what's happening.
To provide some further context: When tapping a result in Chrome that leads to youtube.com, Chrome will try to find the first app that's set to handle this domain (either by having it cryptographically tied to the app like the official Youtube client, or if it has been manually set as linkhandler [e.g. ReVanced Youtube]). Since LinkSheet declares itself as a browser to hijack the "system link opening", Chrome will not recognize it as "link handler" for youtube.com (since browsers are exlcuded from this query) - that's why I made LinkSheetCompat in an attempt to circumvent this;

Sadly, this has to literally be done for every domain that exists (and has a native app) - I have played around with the idea of allowing the user to basically add the domains they want to be hijacked when clicked in Chrome, then patching an embedded barebones LinkSheetCompat APK (which is actually easily doable thanks to the ReVanced guys) which could then be installed - but this hasn't really been a priority.

As you already have stated, it looks like Discord is even more invasive, as it does the same as Chrome and also appears to directly choose an app to open itself, rather then to let the Android system decide (or at least that part that's left after Google crippled it in A12).

Possible solutions to this problem include:

  • Switching to another browser (which not everyone wants to do)
  • Patching apps like Discord (either via ReVanced, or via LSPatch [may even be better suited as you can directly hook calls to the Android system there and spoof the results of these queries Discord appears to do, I think?])
  • Implement the Compat solution I mentioned

@1fexd 1fexd changed the title Some highly concerning trends and maybe a "bug" related to LinkSheetCompat? WIP/concept: Some highly concerning trends and maybe a "bug" related to LinkSheetCompat? Feb 16, 2024
@1fexd 1fexd added wip/concept and removed bug labels Feb 16, 2024
@1fexd 1fexd pinned this issue Feb 16, 2024
@SodaWithoutSparkles
Copy link
Contributor

Actually, patched Discord mobile clients already exists in the form of Vendetta and Aliucord. Unfortunately, both are EOL now, but patches are still running fine. A viable solution would be to create a plugin to de-hardcode the activity?

There're some discussions from oSumAtrix (ReVanced project leader?) and the team to create a patched Discord just like Vendetta. Maybe worth opening an issue at https://github.com/revanced/revanced-patches and ask them to create a patch for discord instead.

Ofc using root/mount installs is also an option, but that might not be viable for most users.

@pressRtowin
Copy link
Contributor Author

pressRtowin commented Feb 16, 2024

Possible solutions to this problem include:

  • Switching to another browser (which not everyone wants to do)
  • Patching apps like Discord (either via ReVanced, or via LSPatch [may even be better suited as you can directly hook calls to the Android system there and spoof the results of these queries Discord appears to do, I think?])
  • Implement the Compat solution I mentioned

Sounds like the only solution to actually continue using apps like Discord is the second. And that has to be done on an app-by-app basis (as more apps start to do this—as I have no doubt they inevitably will). Do you think this would be possible with a single universal patch that could be applied to any offending app easily (like how Revanced universal patches work now), or is the implementation of this behavior complex enough that each app would have to have a specialized patch written from the ground up for it? I don't know too much about how android works at that level.

I still find it shocking that we're at a point where apps are just allowed to completely ignore explicit system settings set by the user. 😔

@1fexd
Copy link
Collaborator

1fexd commented Feb 16, 2024

Actually, patched Discord mobile clients already exists in the form of Vendetta and Aliucord. Unfortunately, both are EOL now, but patches are still running fine. A viable solution would be to create a plugin to de-hardcode the activity?

That might be a possible solution, yeah.

There're some discussions from oSumAtrix (ReVanced project leader?) and the team to create a patched Discord just like Vendetta. Maybe worth opening an issue at https://github.com/revanced/revanced-patches and ask them to create a patch for discord instead.

I'm not sure if ReVanced is the best option in this case.

Ofc using root/mount installs is also an option, but that might not be viable for most users.

I want to avoid anything root related if possible.

@pressRtowin
Copy link
Contributor Author

I'm not sure if ReVanced is the best option in this case.

I'm not super familiar with LSPatch, but does it offer something similar to the way universal patches work with Revanced so that any new (or obscure) apps that start doing this could be quickly dealt with without having to wait for a new patch to come out for it?

@1fexd
Copy link
Collaborator

1fexd commented Feb 16, 2024

Sounds like the only solution to actually continue using apps like Discord is the second. And that has to be done on an app-by-app basis (as more apps start to do this—as I have no doubt they inevitably will). Do you think this would be possible with a single universal patch that could be applied to any offending app easily (like how Revanced universal patches work now), or is the implementation of this behavior complex enough that each app would have to have a specialized patch written from the ground up for it? I don't know too much about how android works at that level.

Having written ReVanced patches in the past, creating a universal patch for this usecase is probably quite hard. I have also written Xposed modules before, which can be injected/patched into APKs using LSPatch. These modules approach patching differently, in the sense that they don't directly modify the app's Dalvik instructions, but rather hook method calls. This also works for system calls as far as I know, so maybe it would be possible to hook the package manager query call an app uses to determine which link handlers are installed and return the desired result (LinkSheet in this case).

@pressRtowin
Copy link
Contributor Author

pressRtowin commented Feb 16, 2024

This also works for system calls as far as I know, so maybe it would be possible to hook the package manager query call an app uses to determine which link handlers are installed and return the desired result (LinkSheet in this case).

Could that also be used to restore the system app picker, or would it have to go to a specific app? Personally, I'd kill to just have every link opened from anywhere open the system app picker but of course, customizability is always great.

In any case, it's good to know that options may exist, and we're not quite at a dead end (yet), though having to patch every app that starts doing this is still more cumbersome than I was hoping.

@1fexd
Copy link
Collaborator

1fexd commented Feb 16, 2024

Could that also be used to restore the system app picker, or would it have to go to a specific app? In my case, I'd kill to just have every link opened from anywhere open the system app picker but of course, customizability is always great.

On A12+ the old system app picker is gone, so it would have to be routed through LinkSheet - there is a Xposed module though (https://github.com/Henry-ZHR/KillDomainVerification), but that one requires Xposed to be installed on the device (=> it doesn't work with LSPatch)

@pressRtowin
Copy link
Contributor Author

On A12+ the old system app picker is gone, so it would have to be routed through LinkSheet - there is a Xposed module though (https://github.com/Henry-ZHR/KillDomainVerification), but that one requires Xposed to be installed on the device (=> it doesn't work with LSPatch)

I just meant the default dialog that still comes up when you try to open links that more than one app can handle, or the similar one that shows for generic URLs with a list of all your browsers.

@pressRtowin
Copy link
Contributor Author

You know, these ones:
Screenshot_20240216_100709_Android System
Screenshot_20240216_100755_Android System

@1fexd
Copy link
Collaborator

1fexd commented Feb 18, 2024

Yep, I've seen this one - strange stuff, would need to dig into the Android source to find out what the heck is going on here 😄

@1fexd 1fexd unpinned this issue Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants