2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-23 02:17:20 +00:00

8 Commits

Author SHA1 Message Date
Albert Vaca Cintora
3986883bc7 Use NEARBY_WIFI_DEVICES instead of ACCESS_FINE_LOCATION
In Android 13+, this permission is enough

EDIT: DO NOT MERGE, the new permission doesn't allow wifiInfo.getSSID()
2023-03-04 15:39:37 +01:00
Jing Xia
3bf3cb1629 Automatically reconnect to trusted networks in the background on API 29+
## Problem

On Android 10 (API 29) or later, when a trusted network has been configured, if the mobile device rejoins the network while KDE Connect is running in the background, it doesn't reconnect to any paired devices in the trusted network. It only reconnects when the user brings the app to the foreground.

## Cause

Android 10 introduced [a separate permission for background location access](https://developer.android.com/about/versions/10/privacy/changes#app-access-device-location). 

When KDE Connect is running in the background with API 29+, [`TrustedNetworkHelper.currentSSID` fails to get the SSID](d22967f475/src/org/kde/kdeconnect/Helpers/TrustedNetworkHelper.java (L77)) because it doesn't have the required permission. This prevents KDE Connect from verifying whether a network is trusted.

## Solution

Make KDE Connect request for background location access permission.

To request for background location access, an app must [declare it in the manifest](https://developer.android.com/training/location/permissions#background), or else the option to to enable background location access won't appear in settings.

As a side note, the permission request dialog in `TrustedNetworksActivity` doesn't require changes because after Android 11, the option to allow background location no longer shows up in a dialog. [It has to be manually enabled in settings.](https://developer.android.com/training/location/permissions#background-dialog-target-sdk-version)

## Test Plan

### Before:
On Android 10 or later, configure a trusted network and pair with a device in it. Let KDE Connect run in the background. Disconnect from the trusted network and then rejoin. KDE Connect won't automatically reconnect to the paired device.

### After:
Do the same steps as above, except after configuring the trust network, go into settings and allow KDE Connect to access location all the time. After KDE Connect rejoins the trusted network, it should automatically reconnect to the paired device.

![kdeconnect_location_permission_settings](/uploads/c7d03de9f1fb1502d7036f45ccb811a0/kdeconnect_location_permission_settings.png)
2022-03-01 22:08:54 +00:00
Isira Seneviratne
d22967f475 Use ArrayUtils.contains(). 2020-07-26 21:50:10 +00:00
Isira Seneviratne
52aafe6b8c Use ContextCompat.getSystemService() to retrieve system services without casting. 2020-07-07 16:47:39 +05:30
Albert Vaca
1a247eacc9 Fix trusted networks on Android 10 2020-04-21 20:47:35 +02:00
Albert Vaca Cintora
235e49c80f Fixes as per code review 2020-01-05 17:27:16 +01:00
Albert Vaca Cintora
1448814ed7 Ask for permission, add to settings and notify in main activity 2019-10-27 23:37:40 +01:00
Juan David Vega
7f8f1bee30 T8539 - Create a new flow to manage trusted networks
Summary: I have created a new activity that allows you to trust all networks or add networks one by one to a list when you are connected to that network

Test Plan:
Test Cases:
1. By default everything should works like it works before, If you uncheck the "Allow all" option in trusted network menu and there isn't any ssid in the trusted
network list the app doesn't send the first udp package and log "Current WiFi isn't a Trusted Network"
2. With the "Allow all" uncheck, use "Add: YOUR_SSID_NAME" button to add your current ssid to the trusted networks list, once you added, go back and the app should
works as always

{F6152314}

1 -> https://youtu.be/ZpCEFTstbJI

2 -> https://youtu.be/cVB1LXlFVyk

Reviewers: #kde_connect, jdvr

Subscribers: sredman, albertvaka, nicolasfella, apol, kdeconnect

Tags: #kde_connect

Maniphest Tasks: T8539

Differential Revision: https://phabricator.kde.org/D13505
2019-10-27 22:16:12 +01:00