Bug 446366 - No way to send clipboard from Android to a desktop, if the persistent indicator is disabled.
Summary: No way to send clipboard from Android to a desktop, if the persistent indicat...
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (show other bugs)
Version: 1.10
Platform: Android Android 11.x
: NOR minor
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-02 10:11 UTC by Daniel Duris
Modified: 2024-04-19 15:23 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Macro to fix KDE Connect phone→PC clipboard sync for Android 10+ (46.97 KB, image/png)
2021-12-14 17:27 UTC, Fabian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Duris 2021-12-02 10:11:54 UTC
SUMMARY
There is no way to send clipboard from Android to a desktop, if the persistent indicator is disabled. If I don't want to have the persistent indicator enabled, I am unable to copy  from Android and paste to a desktop. Once enabled, it works by pressing Send clipboard in the persistent indicator.

This option completely misses from the list of other options under a desktop device such as remote input, multimedia controls etc.

STEPS TO REPRODUCE
1. Disable persistent indicator
2. Copy something
3. Try to paste it on a desktop

OBSERVED RESULT
Unable to copy/paste / send clipboard

EXPECTED RESULT
Able to copy/paste / send clipboard from the app itself

SOFTWARE/OS VERSIONS
Android 11

ADDITIONAL INFORMATION
Comment 1 Fabian 2021-12-14 16:39:21 UTC
There is a restriction in Android 10+ that does not allow apps to access the clipboard, unless it is the currently active and opened keyboard. HOWEVER, I was of course not the first to notice that this is a pretty stupid restriction, so there is a Magisk mod that fixes this: https://github.com/Kr328/Riru-ClipboardWhitelist
But even with that module, KDE Connect STILL doesn't send the clipboard. I assume it probably just checks for the Android version and if that is ≥10, it doesn't even attempt to read the clipboard while it's in the background. So this is still a valid KDE Connect bug.
Comment 2 Fabian 2021-12-14 16:40:10 UTC
I actually wonder how KDE Connect is able to send the clipboard when you press the notification button. Maybe the restriction wasn't explained to me correctly.
Comment 3 Fabian 2021-12-14 16:45:02 UTC
MacroDroid has a "clipboard change" feature and summarises its Android 10+ behaviour "ADB hack". I guess someone could talk to the developer of that app and ask how he did it.
Comment 4 Fabian 2021-12-14 17:27:18 UTC
Created attachment 144546 [details]
Macro to fix KDE Connect phone→PC clipboard sync for Android 10+

Alright, I found the most stupid possible workaround (but also the only one that I could come up with). This macro responds to all clipboard changes (except by KDE Connect for some reason, which is fine), shortly sets KDE Connect as the default keyboard, empties the clipboard, fills it again and switches back to GBoard. Also, it needs a 5ms pause apparently. This macro also works when copying something from a browser, with no keyboard opened.
Comment 5 Daniel Duris 2021-12-14 17:47:30 UTC
(In reply to Fabian from comment #4)
> Created attachment 144546 [details]
> Macro to fix KDE Connect phone→PC clipboard sync for Android 10+
> 
> Alright, I found the most stupid possible workaround (but also the only one
> that I could come up with). This macro responds to all clipboard changes
> (except by KDE Connect for some reason, which is fine), shortly sets KDE
> Connect as the default keyboard, empties the clipboard, fills it again and
> switches back to GBoard. Also, it needs a 5ms pause apparently. This macro
> also works when copying something from a browser, with no keyboard opened.

That's nice workaround, but I think you missed my point. I commented on the lack of UI option in the app itself. Basically, I just require same functionality that is already available through the persistent indicator. So, the KDE Connect would be on the foreground when used anyway.

Even if your workaround works, it would still be nice to have this option under commands listed.
Comment 6 Fabian 2021-12-14 17:52:48 UTC
OK, now it still didn't react to clipboard changes by KDE Connect, but instead to its own clipboard changes, making it basically a fork bomb. :D A "Macro not invoked in the last 1 second" condition fixes that.
Comment 7 Fabian 2021-12-14 17:53:42 UTC
(In reply to Dan Duris from comment #5)
> That's nice workaround, but I think you missed my point. I commented on the
> lack of UI option in the app itself. Basically, I just require same
> functionality that is already available through the persistent indicator.
> So, the KDE Connect would be on the foreground when used anyway.
> 
> Even if your workaround works, it would still be nice to have this option
> under commands listed.

Ah, OK. But if it always synchronised instantly, as it did in Android 9 and before, you wouldn't need such a button.
Comment 8 Fabian 2021-12-18 21:09:48 UTC
(In reply to Fabian from comment #1)
> […] a Magisk mod that fixes this:
> https://github.com/Kr328/Riru-ClipboardWhitelist
> But even with that module, KDE Connect STILL doesn't send the clipboard. […]
Well, nevermind, I just didn't notice that that module has a UI in which you need to select which apps get that permission. Selecting KDE Connect in it fixes the issue.
Comment 9 Neon 2023-03-12 23:48:29 UTC
(In reply to Fabian from comment #8)
> Well, nevermind, I just didn't notice that that module has a UI in which you
> need to select which apps get that permission. Selecting KDE Connect in it
> fixes the issue.

I'm using that same Magisk Module but KDE Connect still doesn't sync my clipboard, I'm on Android 13 so I wonder if something changed in this version.
Comment 10 Fabian 2023-03-13 00:07:04 UTC
(In reply to Neon from comment #9)
> (In reply to Fabian from comment #8)
> > Well, nevermind, I just didn't notice that that module has a UI in which you
> > need to select which apps get that permission. Selecting KDE Connect in it
> > fixes the issue.
> 
> I'm using that same Magisk Module but KDE Connect still doesn't sync my
> clipboard, I'm on Android 13 so I wonder if something changed in this
> version.

Android 13 is pretty new, any component might not be fully done yet. You should report it as a bug. I won't see it any time soon, I usually stay on at most the last release of LineageOS before a version jump, currently I'm even on the preinstalled Android 10.
Comment 11 John Veness 2024-04-19 13:14:09 UTC
I think the original bug report is now fixed, as there is now a "Send clipboard" button in the main UI, which works even if the persistent notification is hidden. Automatic clipboard sending for Android >= 10 should probably be discussed elsewhere.
Comment 12 Daniel Duris 2024-04-19 15:23:37 UTC
(In reply to John Veness from comment #11)
> I think the original bug report is now fixed, as there is now a "Send
> clipboard" button in the main UI, which works even if the persistent
> notification is hidden. Automatic clipboard sending for Android >= 10 should
> probably be discussed elsewhere.

I can confirm this workaround works well.

It would be even better if clipboard would be automatically sent without the need for user input, but this could be opened under a different bug.