Skip to content

Commit

Permalink
Merge pull request #53 from sync1211/android-12-bluetooth
Browse files Browse the repository at this point in the history
Add Bluetooth permission request for Android 12+
  • Loading branch information
NaitLee authored Feb 11, 2023
2 parents c4a5ef7 + ada5079 commit 5b28396
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

IsAndroid = (os.environ.get("P4A_BOOTSTRAP") is not None)


class DictAsObject(dict):
""" Let you use a dict like an object in JavaScript.
"""
Expand Down Expand Up @@ -341,9 +342,14 @@ def serve():
server = PrinterServer(('' if listen_all else address, port), PrinterServerHandler)
service_url = f'http://{address}:{port}/'


info(i18n('serving-at-0', service_url))
if '-s' not in sys.argv:
if '-s' not in sys.argv and not IsAndroid:
webbrowser.open(service_url)
# Request required bluetooth permissions (Android 12+)
if IsAndroid:
from android.permissions import request_permissions, Permission
request_permissions([Permission.BLUETOOTH_SCAN, Permission.BLUETOOTH_CONNECT])

try:
server.serve_forever()
Expand Down

0 comments on commit 5b28396

Please sign in to comment.