diff --git a/pymobiledevice3/cli/profile.py b/pymobiledevice3/cli/profile.py index 6de954571..9e3b752db 100644 --- a/pymobiledevice3/cli/profile.py +++ b/pymobiledevice3/cli/profile.py @@ -145,6 +145,8 @@ def profile_install_wifi_profile(service_provider: LockdownServiceProvider, encr This will enable the device to auto-connect to given network """ + if keybag is not None: + keybag = Path(keybag) MobileConfigService(lockdown=service_provider).install_wifi_profile( encryption_type=encryption_type, ssid=ssid, password=password, keybag_file=keybag) @@ -156,6 +158,8 @@ def profile_install_wifi_profile(service_provider: LockdownServiceProvider, encr def profile_install_http_proxy(service_provider: LockdownServiceProvider, server: str, port: int, keybag: Optional[str]) -> None: """ Install HTTP Proxy profile """ + if keybag is not None: + keybag = Path(keybag) MobileConfigService(lockdown=service_provider).install_http_proxy(server, port, keybag_file=keybag) @@ -163,3 +167,15 @@ def profile_install_http_proxy(service_provider: LockdownServiceProvider, server def profile_remove_http_proxy(service_provider: LockdownServiceProvider) -> None: """ Remove HTTP Proxy profile that was previously installed using pymobiledevice3 """ MobileConfigService(lockdown=service_provider).remove_http_proxy() + + +@profile_group.command('install-restrictions-profile', cls=Command) +@click.option('--keybag', type=click.Path(file_okay=True, dir_okay=False, exists=True)) +@click.option('--enforced-software-update-delay', type=click.IntRange(0, 90), default=0) +def profile_install_restrictions_profile( + service_provider: LockdownServiceProvider, keybag: Optional[str], enforced_software_update_delay: int) -> None: + """ Install restrictions profile (can be used for delayed OTA) """ + if keybag is not None: + keybag = Path(keybag) + MobileConfigService(lockdown=service_provider).install_restrictions_profile( + enforced_software_update_delay=enforced_software_update_delay, keybag_file=Path(keybag)) diff --git a/pymobiledevice3/services/mobile_config.py b/pymobiledevice3/services/mobile_config.py index 52238b14f..b629c8a39 100755 --- a/pymobiledevice3/services/mobile_config.py +++ b/pymobiledevice3/services/mobile_config.py @@ -224,9 +224,9 @@ def supervise(self, organization: str, keybag_file: Path) -> None: ] }) - def install_managed_profile(self, display_name: str, payload_content: Mapping[str, Any], - payload_uuid: str = str(uuid4()), - keybag_file: Optional[Path] = None) -> None: + def install_managed_profile( + self, display_name: str, payload_content: Mapping[str, Any], payload_uuid: str = str(uuid4()), + keybag_file: Optional[Path] = None) -> None: profile_data = plistlib.dumps({ 'PayloadContent': [ payload_content @@ -242,3 +242,124 @@ def install_managed_profile(self, display_name: str, payload_content: Mapping[st self.install_profile_silent(keybag_file, profile_data) else: self.install_profile(profile_data) + + def install_restrictions_profile( + self, enforced_software_update_delay: int = 0, payload_uuid: str = str(uuid4()), + keybag_file: Optional[Path] = None) -> None: + self.install_managed_profile('Restrictions', { + 'PayloadDescription': 'Configures restrictions', + 'PayloadDisplayName': 'Restrictions', + 'PayloadIdentifier': f'com.apple.applicationaccess.{payload_uuid}', + 'PayloadType': 'com.apple.applicationaccess', + 'PayloadUUID': payload_uuid, + 'PayloadVersion': 1, + 'allowActivityContinuation': True, + 'allowAddingGameCenterFriends': True, + 'allowAirPlayIncomingRequests': True, + 'allowAirPrint': True, + 'allowAirPrintCredentialsStorage': True, + 'allowAirPrintiBeaconDiscovery': True, + 'allowAppCellularDataModification': True, + 'allowAppClips': True, + 'allowAppInstallation': True, + 'allowAppRemoval': True, + 'allowApplePersonalizedAdvertising': True, + 'allowAssistant': True, + 'allowAssistantWhileLocked': True, + 'allowAutoCorrection': True, + 'allowAutoUnlock': True, + 'allowAutomaticAppDownloads': True, + 'allowBluetoothModification': True, + 'allowBookstore': True, + 'allowBookstoreErotica': True, + 'allowCamera': True, + 'allowCellularPlanModification': True, + 'allowChat': True, + 'allowCloudBackup': True, + 'allowCloudDocumentSync': True, + 'allowCloudPhotoLibrary': True, + 'allowContinuousPathKeyboard': True, + 'allowDefinitionLookup': True, + 'allowDeviceNameModification': True, + 'allowDeviceSleep': True, + 'allowDictation': True, + 'allowESIMModification': True, + 'allowEnablingRestrictions': True, + 'allowEnterpriseAppTrust': True, + 'allowEnterpriseBookBackup': True, + 'allowEnterpriseBookMetadataSync': True, + 'allowEraseContentAndSettings': True, + 'allowExplicitContent': True, + 'allowFilesNetworkDriveAccess': True, + 'allowFilesUSBDriveAccess': True, + 'allowFindMyDevice': True, + 'allowFindMyFriends': True, + 'allowFingerprintForUnlock': True, + 'allowFingerprintModification': True, + 'allowGameCenter': True, + 'allowGlobalBackgroundFetchWhenRoaming': True, + 'allowInAppPurchases': True, + 'allowKeyboardShortcuts': True, + 'allowManagedAppsCloudSync': True, + 'allowMultiplayerGaming': True, + 'allowMusicService': True, + 'allowNews': True, + 'allowNotificationsModification': True, + 'allowOpenFromManagedToUnmanaged': True, + 'allowOpenFromUnmanagedToManaged': True, + 'allowPairedWatch': True, + 'allowPassbookWhileLocked': True, + 'allowPasscodeModification': True, + 'allowPasswordAutoFill': True, + 'allowPasswordProximityRequests': True, + 'allowPasswordSharing': True, + 'allowPersonalHotspotModification': True, + 'allowPhotoStream': True, + 'allowPredictiveKeyboard': True, + 'allowProximitySetupToNewDevice': True, + 'allowRadioService': True, + 'allowRemoteAppPairing': True, + 'allowRemoteScreenObservation': True, + 'allowSafari': True, + 'allowScreenShot': True, + 'allowSharedStream': True, + 'allowSpellCheck': True, + 'allowSpotlightInternetResults': True, + 'allowSystemAppRemoval': True, + 'allowUIAppInstallation': True, + 'allowUIConfigurationProfileInstallation': True, + 'allowUSBRestrictedMode': True, + 'allowUnpairedExternalBootToRecovery': False, + 'allowUntrustedTLSPrompt': True, + 'allowVPNCreation': True, + 'allowVideoConferencing': True, + 'allowVoiceDialing': True, + 'allowWallpaperModification': True, + 'allowiTunes': True, + 'enforcedSoftwareUpdateDelay': enforced_software_update_delay, + 'forceAirDropUnmanaged': False, + 'forceAirPrintTrustedTLSRequirement': False, + 'forceAssistantProfanityFilter': False, + 'forceAuthenticationBeforeAutoFill': False, + 'forceAutomaticDateAndTime': False, + 'forceClassroomAutomaticallyJoinClasses': False, + 'forceClassroomRequestPermissionToLeaveClasses': False, + 'forceClassroomUnpromptedAppAndDeviceLock': False, + 'forceClassroomUnpromptedScreenObservation': False, + 'forceDelayedSoftwareUpdates': True, + 'forceEncryptedBackup': False, + 'forceITunesStorePasswordEntry': False, + 'forceLimitAdTracking': False, + 'forceWatchWristDetection': False, + 'forceWiFiPowerOn': False, + 'forceWiFiWhitelisting': False, + 'ratingApps': 1000, + 'ratingMovies': 1000, + 'ratingRegion': 'us', + 'ratingTVShows': 1000, + 'safariAcceptCookies': 2.0, + 'safariAllowAutoFill': True, + 'safariAllowJavaScript': True, + 'safariAllowPopups': True, + 'safariForceFraudWarning': False + }, payload_uuid=payload_uuid, keybag_file=keybag_file)