Skip to content

Commit

Permalink
location: bugfix: ios support
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Feb 21, 2022
1 parent e510329 commit fdc2f4b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
33 changes: 10 additions & 23 deletions src/ents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,23 @@
<true/>
<key>com.apple.wifi.manager-access</key>
<true/>
<key>task_for_pid-allow</key>
<true/>
<key>com.apple.private.tcc.allow</key>
<array>
<string>kTCCServiceMicrophone</string>
<string>kTCCServiceCamera</string>
</array>
<key>com.apple.security.device.audio-input</key>
<key>com.apple.locationd.preauthorized</key>
<true/>
<key>com.apple.security.device.microphone</key>
<key>com.apple.locationd.authorizeapplications</key>
<true/>
<key>com.apple.security.device.camera</key>
<key>com.apple.locationd.defaults_access</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<key>com.apple.locationd.effective_bundle</key>
<true/>
<key>com.apple.security.personal-information.addressbook</key>
<key>com.apple.locationd.status</key>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.SystemConfiguration.SCDynamicStore-write-access</key>
<key>task_for_pid-allow</key>
<true/>
<key>com.apple.SystemConfiguration.SCPreferences-write-access</key>
<key>com.apple.private.tcc.allow</key>
<array>
<string>com.apple.AutoWake.xml</string>
<string>preferences.plist</string>
<string>com.apple.radios.plist</string>
<string>kTCCServiceMicrophone</string>
<string>kTCCServiceCamera</string>
<string>kTCCServiceLocation</string>
</array>
</dict>
</plist>
30 changes: 25 additions & 5 deletions src/rpcclient/rpcclient/darwin/location.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from enum import Enum
from typing import Mapping
from typing import Mapping, Optional

from rpcclient.exceptions import MissingLibraryError, PermissionDeniedError
from rpcclient.structs.consts import RTLD_NOW


class CLAuthorizationStatus(Enum):
Expand All @@ -28,17 +29,36 @@ class Location:
def __init__(self, client):
self._client = client

if not self._client.dlopen('/System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation', 2):
raise MissingLibraryError('failed to load CoreLocation')
self._load_location_library()
self._CLLocationManager = self._client.symbols.objc_getClass('CLLocationManager')
self._location_manager = self._CLLocationManager.objc_call('sharedManager')

self._location_manager = self._client.symbols.objc_getClass('CLLocationManager').objc_call('sharedManager')
def _load_location_library(self):
options = [
# macOS
'/System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation',
# iOS
'/System/Library/Frameworks/CoreLocation.framework/CoreLocation'
]
for option in options:
if self._client.dlopen(option, RTLD_NOW):
return
raise MissingLibraryError('CoreLocation library isn\'t available')

@property
def location_services_enabled(self) -> bool:
return bool(self._location_manager.objc_call('locationServicesEnabled'))

@location_services_enabled.setter
def location_services_enabled(self, value: bool):
self._CLLocationManager.objc_call('setLocationServicesEnabled:', value)

@property
def authorization_status(self) -> CLAuthorizationStatus:
return CLAuthorizationStatus.from_value(self._location_manager.objc_call('authorizationStatus'))

@property
def last_sample(self) -> Mapping:
def last_sample(self) -> Optional[Mapping]:
return self._location_manager.objc_call('location').objc_call('jsonObject').py

def start_updating_location(self):
Expand Down

0 comments on commit fdc2f4b

Please sign in to comment.