trebleshot / android

An open-source app that allows you to transfer files one to one securely or using a browser, all without the internet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permission changed for API startLocalOnlyHotspot but is neither declared nor checked

DSOTM-pf opened this issue · comments

Hi, there, I've found an issue in version 1.4.2, which is downloaded from F-Droid.

Describe the bug

I found the usage of startLocalOnlyHotspot may cause compatibility bugs. It is related to the call chain:

com.genonbeta.TrebleShot.service.CommunicationService.onStartCommand(android.content.Intent,int,int)int
 com.genonbeta.TrebleShot.service.CommunicationService.setupHotspot()void
  com.genonbeta.TrebleShot.util.HotspotUtils$OreoAPI.enableConfigured(java.lang.String,java.lang.String)boolean
   com.genonbeta.TrebleShot.util.HotspotUtils$OreoAPI.enable()boolean
    android.net.wifi.WifiManager.startLocalOnlyHotspot(android.net.wifi.WifiManager$LocalOnlyHotspotCallback,android.os.Handler)void

This API needs ACCESS_COARSE_LOCATION permission at API-level 28 and below, but is changed to ACCESS_FINE_LOCATION in 29. The app only uses coarse location in the manifest.


In API 28
b826421f9cf4aa117ab6f3b57e3c4b9


In API 29
ac6da51ea53516c62567df6afd85d6b


It can be fixed by adding fine location to the manifest, and request for the fine location at somewhere in the program (maybe before calling that API, and also check SDK_INT>28).

I found only the coarse location permission is there when I start a hotspot (through ADB).
image

Can you help me review this issue? @velitasali
Thanks !!!

Thanks for the thorough description.

The changes you are suggesting are already there in the latest revision.

<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" />

if (ActivityCompat.checkSelfPermission(context, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {

permissionsResultLauncher.launch(arrayOf(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION))

Thanks for the thorough description.

The changes you are suggesting are already there in the latest revision.

<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" />

if (ActivityCompat.checkSelfPermission(context, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {

permissionsResultLauncher.launch(arrayOf(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION))

Awesome! Very thanks!