Bug 458278 - Sharing copied text to KDE Connect Android app crashes SendFileActivity
Summary: Sharing copied text to KDE Connect Android app crashes SendFileActivity
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (show other bugs)
Version: unspecified
Platform: Android Unspecified
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-25 02:34 UTC by Yuchen Shi
Modified: 2023-04-05 10:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Android app logcat (showing NPE stacktrace) (3.48 KB, text/plain)
2022-08-25 02:34 UTC, Yuchen Shi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuchen Shi 2022-08-25 02:34:25 UTC
Created attachment 151569 [details]
Android app logcat (showing NPE stacktrace)

SUMMARY

When using the share button in the overlay actions (new in Android 13) to share copied text to KDE Connect Android, it crashes without sending anything.

STEPS TO REPRODUCE
1. On Android, select some text in any application (e.g. a text editor or browser)
2. Click on Copy on the selection options
3. On the bottom-left overlay of the screen (new in Android 13, only shown after copying text), click on the share icon button.
4. Select "KDE Connect Send to Device" as the target
5. Select the desktop device (previously paired) under "Share To..."

OBSERVED RESULT

The activity immediately crashes with a NullPointerException. See logcat attached.

In addition, a notification is displayed titled "Sent 0 files to <desktop device name>". There is no toast shown.

EXPECTED RESULT

Ideally, the desktop clipboard should be set to the shared text, i.e. similar behavior as if "Send Clipboard" were tapped in the persistent notification or in the app. (Since the user is sharing from a clipboard copy overlay, that is probably what the user wants.)

If that is not possible, it should behave similar to sharing selected text on Android (without copying) -- that is, Kate is opened on the desktop with a draft containing the text being shared. In either case, it should not crash and should send the text one way or the other.

SOFTWARE/OS VERSIONS
Android: 13
KDE Connect Android app: 1.19.1
Linux: 5.19.3-arch1-1
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5

ADDITIONAL INFORMATION

While I've provided my Linux and KDE versions above, this issue can likely be reproduced on other OS and KDE Connect desktop versions given the crash is in the Android app.
Comment 1 Nicolas Fella 2022-08-25 17:19:15 UTC
Is the activity actually crashing? In normal operation the activity terminates after sending. As far as I can tell the exception occurs, is caught, printed out, and the activity terminates normally. See https://invent.kde.org/network/kdeconnect-android/-/blob/master/src/org/kde/kdeconnect/Helpers/FilesHelper.java#L168

What I don't understand is why this code is triggered at all. It is only used when the intent has EXTRA_STREAM (https://invent.kde.org/network/kdeconnect-android/-/blob/master/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java#L230). In my testing this isn't the case (neither on Android 11 nor 13). Sending text is actually handled in the else branch of that if. I really wonder why you seem to have that extra and I don't
Comment 2 Yuchen Shi 2022-08-25 19:47:42 UTC
Apologies for the inaccurate description -- just as you've said, the error is caught and logged, and it is not a proper "crash". But the logic is indeed cut-short and nothing is actually shared.

Regarding sending text -- I think the Android 13 share button from the clipboard overlay is a bit different from selecting and sharing text without copying, which does work correctly. I'm not quite familiar with `EXTRA_STREAM` but I think that difference may be the cause of this issue.
Comment 3 Nicolas Fella 2022-08-25 20:07:41 UTC
oh, you are right, I was testing select-then-share. With copy-then-share I do get the EXTRA_STREAM thing
Comment 4 Bug Janitor Service 2022-08-25 20:33:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdeconnect-android/-/merge_requests/294
Comment 5 Albert Vaca Cintora 2023-04-01 15:57:18 UTC
I'm testing this on my Pixel 4a and it's not showing that stack trace. Maybe it got fixed on the Android side? I'm happy to merge the workaround otherwise.
Comment 6 Bug Janitor Service 2023-04-01 17:50:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdeconnect-android/-/merge_requests/332
Comment 7 Albert Vaca Cintora 2023-04-05 10:16:48 UTC
Git commit 711065a8e645d507ce7b955101660cd1d1ac4c9d by Albert Vaca Cintora.
Committed on 05/04/2023 at 10:16.
Pushed by albertvaka into branch 'master'.

Refactor share function to handle null URIs

M  +50   -45   src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java

https://invent.kde.org/network/kdeconnect-android/commit/711065a8e645d507ce7b955101660cd1d1ac4c9d