Bug 492302

Summary: kdeconnect Android fails to support "trusted networks"
Product: [Applications] kdeconnect Reporter: tnemeth
Component: android-applicationAssignee: Albert Vaca Cintora <albertvaka>
Status: RESOLVED FIXED    
Severity: normal CC: andrew.g.r.holmes, kdebugzilla, mace68
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Android   
OS: Android 14.x   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Networks list
Warning message

Description tnemeth 2024-08-28 06:51:06 UTC
Created attachment 173025 [details]
Networks list

SUMMARY

    Hi !
    There is a warning on my main Android kdeconnect 1.32.1 screen :

        "The network is not a trusted network : automatic discovery disabled."

    When I go the the breadcrumb menu and select "Trusted networks", There is only :
    - « Allow all »
    - « #_# »
    - at the bottom, « Add "my_wifi_network" »

   (« my_wifi_network » being my own wifi network of course).

   Whatever I do with the "#_#" network (remove or leave it), when I add my_wifi_network
   and go back to the main screen, the same warning is always displayed. And when I return
   to the trusted networks configuration, my_wifi_network has disappeared, only the #_#
   "network" remains...


STEPS TO REPRODUCE
1. open the Android kdeconnect application
2. select the breadcrumb "Trusted networks" menu
3. look at the networks (in my case there is only #_#
4. remove (or not) #_#
5. add your wifi network
6. go back to the main screen : the warning is still here
7. return to the "Trusted networks" menu : the added network isn't here anymore, but « #_# » is (even if it had been removed previously).

OBSERVED RESULT
The added network isn't accepted as a trusted network and do not appear in the "Trusted networks" list. There is always a buggy #_# network present.

EXPECTED RESULT
The added network should be accepted as a trusted network and there shouldn't be a #_# buggy network in the list.

SOFTWARE/OS VERSIONS
OS: Android 14
Comment 1 tnemeth 2024-08-28 06:51:31 UTC
Created attachment 173026 [details]
Warning message
Comment 2 Mace 2024-08-29 06:43:12 UTC
I just reported this also lol. Nice to know I'm not with this issue.
https://bugs.kde.org/show_bug.cgi?id=492351
Comment 3 Mace 2024-08-29 07:45:20 UTC
(In reply to Mace from comment #2)
> ...I'm not with this issue.
> https://bugs.kde.org/show_bug.cgi?id=492351
...I'm not *the only one* with this issue.
Comment 4 tnemeth 2024-08-29 17:14:45 UTC
(In reply to Mace from comment #3)
> (In reply to Mace from comment #2)
> > ...I'm not with this issue.
> > https://bugs.kde.org/show_bug.cgi?id=492351
> ...I'm not *the only one* with this issue.

^^
Comment 5 Axel Karjalainen 2024-08-31 12:50:47 UTC
I'm pretty sure this bug is caused by dea0bb4e[1], but I can't see any obvious issue. Did the change get tested?

[1]: https://invent.kde.org/network/kdeconnect-android/-/commit/dea0bb4e1f5a25afe202da1edd3416c39ef9a785
Comment 6 Bug Janitor Service 2024-08-31 14:41:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdeconnect-android/-/merge_requests/472
Comment 7 Philip C 2024-09-21 22:24:49 UTC
Git commit db615b82df9eb9d6a8a14f3d061868a90f4f1395 by Philip Cohn-Cort, on behalf of Marko Zajc.
Committed on 21/09/2024 at 22:24.
Pushed by philipc into branch 'master'.

Fix trusted networks

## Summary
1) Fix the code responsible for loading the trusted network list.
2) The old `#_#` delimiter has been replaced with a less likely NUL character. This requires re-adding trusted networks, so I can revert it if necessary.
3) Ignore incoming identity packets on untrusted devices if they come from an untrusted device.

## Test Plan

### Before:
1) Trusted networks were completely broken, an would show variations of `#` and `_` on the list due to a bug in the splitting code.
2) Any network with `#_#` in the SSID - although unlikely - would not be possible to use as a trusted network.
3) The device was still discoverable on an untrusted network by manually refreshing the devices list.

### After:
1) Trusted networks now load the SSID list correctly.
2) Networks with `#_#` in the SSID can be added as trusted networks.
3) The device is no longer discoverable on an untrusted network.

M  +26   -10   src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java
M  +4    -3    src/org/kde/kdeconnect/Helpers/TrustedNetworkHelper.kt

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