From eeeb1328f66b10dc6e65a2f18cb018e0598a35fd Mon Sep 17 00:00:00 2001 From: epheo Date: Tue, 9 Apr 2024 15:38:26 +0200 Subject: [PATCH] Add location authorization check This works toward solving: https://github.com/gopro/OpenGoPro/issues/506 --- .../open_gopro/wifi/adapters/wireless.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/wifi/adapters/wireless.py b/demos/python/sdk_wireless_camera_control/open_gopro/wifi/adapters/wireless.py index 42902d7e..4e4453ed 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/wifi/adapters/wireless.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/wifi/adapters/wireless.py @@ -697,6 +697,18 @@ def connect(self, ssid: str, password: str, timeout: float = 15) -> bool: location_manager = CLLocationManager.alloc().init() location_manager.startUpdatingLocation() + # Get the current authorization status for Python + max_wait = 60 + for i in range(1, max_wait): + authorization_status = location_manager.authorizationStatus() + if authorization_status == 3 or authorization_status == 4: + print("Python has been authorized for location services") + break + if i == max_wait-1: + exit("Unable to obtain authorization, exiting") + time.sleep(1) + + # Load CoreWLAN framework objc.loadBundle('CoreWLAN', bundle_path='/System/Library/Frameworks/CoreWLAN.framework',