UPDATE: I ended up doing it like this, so this is no longer a high priority. (Though it would be nice to be able to disable Direct Share on a per-app basis.)
[NOTHINGYET] XPosed module to disable Direct Share targets on Android 10+
The idea is to implement the ReVanced patch below as an XPosed/LSPosed module.
The method for an app to publish Direct Share targets on A10+ has changed such that blocking via the intents firewall is no longer possible.
Direct Share targets can only be published via the Sharing Shortcuts API on A11+.
The patch below removes share-target elements from the resource file res/xml/shortcuts.xml. The same can presumably be done using XPosed.
The specific apps that have bugged me with Direct Share targets are WhatsApp and Outlook, for which patching the APKs directly causes problems. In Outlook, for example, the MUA client ID or whatever is changed and is no longer the same as the stock app (which may mean it's no longer an approved app by your O365 admin).
Patching in memory seems the superior way to go about this.
I've never written an Android app, a Magisk module, or an XPosed module. I don't know anything with regard to Kotlin or Java or Groovy or Dalvik or Smali or (Java?) VM (ART?) or Zygote or bytecode or DSLs or Android architecture or Android components or intents or activities or services or receivers or Android Studio or the Android SDK or the Android NDK (what does that even stand for?) or the XPosed API etc.,etc.,etc.
I just don't want these stupid Direct Share targets in my sharesheet.
-
https://github.com/ReVanced/revanced-patches/pull/3334/files
-
https://developer.android.com/training/sharing/direct-share-targets
-
https://developer.android.com/reference/androidx/core/content/pm/ShortcutManagerCompat
-
https://api.xposed.info/reference/android/content/res/XResources.html
-
https://github.com/search?q=android.content.res.XResources&type=code
-
https://github.com/search?q=android.content.res.XResources+xml&type=code
-
https://github.com/LSPosed/LSPosed/wiki/Develop-Xposed-Modules-Using-Modern-Xposed-API
-
https://xdaforums.com/t/tutorial-xposed-module-devlopment.2709324/
-
https://github.com/rovo89/xposedbridge/wiki/development-tutorial
-
https://github.com/rovo89/XposedBridge/wiki/Replacing-resources
-
https://developer.android.com/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder
-
https://github.com/android/storage-samples/tree/main/SharingShortcuts