Fixed bluetooth permissions on API levels < 30

This commit is contained in:
Mark Qvist 2022-11-23 20:42:56 +01:00
parent 1f1cb5ca17
commit 5739b33f06
4 changed files with 14 additions and 5 deletions

View File

@ -377,7 +377,12 @@ class SidebandApp(MDApp):
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
Context = autoclass('android.content.Context') Context = autoclass('android.content.Context')
if check_permission("android.permission.BLUETOOTH_CONNECT"): if android_api_version > 30:
bt_permission_name = "android.permission.BLUETOOTH_CONNECT"
else:
bt_permission_name = "android.permission.BLUETOOTH"
if check_permission(bt_permission_name):
RNS.log("Have bluetooth connect permissions", RNS.LOG_DEBUG) RNS.log("Have bluetooth connect permissions", RNS.LOG_DEBUG)
self.sideband.setpersistent("permissions.bluetooth", True) self.sideband.setpersistent("permissions.bluetooth", True)
else: else:

View File

@ -27,6 +27,9 @@
<!-- Allow writing to external storage --> <!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
{% for perm in args.permissions %} {% for perm in args.permissions %}
{% if '.' in perm %} {% if '.' in perm %}
<uses-permission android:name="{{ perm }}" /> <uses-permission android:name="{{ perm }}" />

View File

@ -1,4 +1,4 @@
__debug_build__ = False __debug_build__ = True
import time import time
import RNS import RNS

View File

@ -1551,6 +1551,8 @@ class SidebandCore():
else: else:
target_port = None target_port = None
bt_device_name = None
rnode_allow_bluetooth = False
if self.getpersistent("permissions.bluetooth"): if self.getpersistent("permissions.bluetooth"):
if self.config["hw_rnode_bluetooth"]: if self.config["hw_rnode_bluetooth"]:
# TODO: Remove # TODO: Remove
@ -1558,8 +1560,7 @@ class SidebandCore():
rnode_allow_bluetooth = True rnode_allow_bluetooth = True
if self.config["hw_rnode_bt_device"] != None: if self.config["hw_rnode_bt_device"] != None:
bt_device_name = self.config["hw_rnode_bt_device"] bt_device_name = self.config["hw_rnode_bt_device"]
else:
bt_device_name = None
else: else:
# TODO: Remove # TODO: Remove
RNS.log("Disallowing RNode bluetooth since config is disabled") RNS.log("Disallowing RNode bluetooth since config is disabled")
@ -1567,7 +1568,7 @@ class SidebandCore():
else: else:
# TODO: Remove # TODO: Remove
RNS.log("Disallowing RNode bluetooth due to missing permission") RNS.log("Disallowing RNode bluetooth due to missing permission")
rnode_allow_bluetooth = True rnode_allow_bluetooth = False