From 99db3dc086406c0b48d8b2f0801fd732b53f1d1e Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Fri, 26 May 2023 14:58:52 -0500 Subject: [PATCH] =?UTF-8?q?Removes=20support=20for=20=E2=80=9Cbackground?= =?UTF-8?q?=20mode=E2=80=9D=20permissions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Operations/Errors/VerificationError.swift | 2 +- AltStore/Operations/FetchSourceOperation.swift | 11 +++-------- AltStore/Operations/VerifyAppOperation.swift | 16 +--------------- AltStoreCore/Model/AppPermission.swift | 7 ------- AltStoreCore/Protocols/ALTAppPermission.swift | 12 ------------ AltStoreCore/Types/ALTAppPermissions.h | 3 --- AltStoreCore/Types/ALTAppPermissions.m | 1 - 7 files changed, 5 insertions(+), 47 deletions(-) diff --git a/AltStore/Operations/Errors/VerificationError.swift b/AltStore/Operations/Errors/VerificationError.swift index d3643dc0..ccc531ce 100644 --- a/AltStore/Operations/Errors/VerificationError.swift +++ b/AltStore/Operations/Errors/VerificationError.swift @@ -206,7 +206,7 @@ private extension VerificationError guard let permissions, !permissions.isEmpty else { return nil } let permissionsByType = Dictionary(grouping: permissions) { $0.type } - let permissionSections = [ALTAppPermissionType.entitlement, .privacy, .backgroundMode].compactMap { (type) -> String? in + let permissionSections = [ALTAppPermissionType.entitlement, .privacy].compactMap { (type) -> String? in guard let permissions = permissionsByType[type] else { return nil } // "Privacy:" diff --git a/AltStore/Operations/FetchSourceOperation.swift b/AltStore/Operations/FetchSourceOperation.swift index 20be4ac7..31d595fc 100644 --- a/AltStore/Operations/FetchSourceOperation.swift +++ b/AltStore/Operations/FetchSourceOperation.swift @@ -166,15 +166,10 @@ private extension FetchSourceOperation versions.insert(version.versionID) } - for permission in app.permissions + for permission in app.permissions where permission.type == .privacy { - switch permission.type - { - case .privacy, .backgroundMode: - guard permission.usageDescription != nil else { throw SourceError.missingPermissionUsageDescription(for: permission.permission, app: app, source: source) } - - default: break - } + // Privacy permissions MUST have a usage description. + guard permission.usageDescription != nil else { throw SourceError.missingPermissionUsageDescription(for: permission.permission, app: app, source: source) } } } diff --git a/AltStore/Operations/VerifyAppOperation.swift b/AltStore/Operations/VerifyAppOperation.swift index 4fc81f0a..12d498f4 100644 --- a/AltStore/Operations/VerifyAppOperation.swift +++ b/AltStore/Operations/VerifyAppOperation.swift @@ -293,20 +293,6 @@ private extension VerifyAppOperation allEntitlements = allEntitlements.filter { !ALTEntitlement.ignoredEntitlements.contains($0) } - // Background Modes - // App extensions can't have background modes, so don't need to worry about them. - let allBackgroundModes: Set - if let backgroundModes = app.bundle.infoDictionary?[Bundle.Info.backgroundModes] as? [String] - { - let backgroundModes = backgroundModes.lazy.map { ALTAppBackgroundMode($0) } - allBackgroundModes = Set(backgroundModes) - } - else - { - allBackgroundModes = [] - } - - // Privacy let allPrivacyPermissions: Set if #available(iOS 16, *) @@ -346,7 +332,7 @@ private extension VerifyAppOperation // Verify permissions. let sourcePermissions: Set = Set(await $storeApp.perform { $0.permissions.map { AnyHashable($0.permission) } }) - let localPermissions: [any ALTAppPermission] = Array(allEntitlements) + Array(allBackgroundModes) + Array(allPrivacyPermissions) + let localPermissions: [any ALTAppPermission] = Array(allEntitlements) + Array(allPrivacyPermissions) // To pass: EVERY permission in localPermissions must also appear in sourcePermissions. // If there is a single missing permission, throw error. diff --git a/AltStoreCore/Model/AppPermission.swift b/AltStoreCore/Model/AppPermission.swift index fa30c7c5..35ade8bb 100644 --- a/AltStoreCore/Model/AppPermission.swift +++ b/AltStoreCore/Model/AppPermission.swift @@ -84,7 +84,6 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable { case .entitlement: return ALTEntitlement(rawValue: self._permission) case .privacy: return ALTAppPrivacyPermission(rawValue: self._permission) - case .backgroundMode: return ALTAppBackgroundMode(rawValue: self._permission) default: return UnknownAppPermission(rawValue: self._permission) } } @@ -105,7 +104,6 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable { case entitlement case privacyType = "privacy" - case backgroundMode = "background" case usageDescription } @@ -132,11 +130,6 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable self._permission = privacyType self.type = .privacy } - else if let backgroundMode = try container.decodeIfPresent(String.self, forKey: .backgroundMode) - { - self._permission = backgroundMode - self.type = .backgroundMode - } else { self._permission = "" diff --git a/AltStoreCore/Protocols/ALTAppPermission.swift b/AltStoreCore/Protocols/ALTAppPermission.swift index 590707b6..b436694d 100644 --- a/AltStoreCore/Protocols/ALTAppPermission.swift +++ b/AltStoreCore/Protocols/ALTAppPermission.swift @@ -16,7 +16,6 @@ public extension ALTAppPermissionType case .unknown: return NSLocalizedString("Permission", comment: "") case .entitlement: return NSLocalizedString("Entitlement", comment: "") case .privacy: return NSLocalizedString("Privacy Permission", comment: "") - case .backgroundMode: return NSLocalizedString("Background Mode", comment: "") default: return nil } } @@ -150,14 +149,3 @@ extension ALTAppPrivacyPermission: ALTAppPermission } } } - -extension ALTAppBackgroundMode: ALTAppPermission -{ - public var type: ALTAppPermissionType { .backgroundMode } - public var symbolName: String? { nil } - - public var localizedName: String? { nil } - public var synthesizedName: String? { nil } - - public var localizedDescription: String? { nil } -} diff --git a/AltStoreCore/Types/ALTAppPermissions.h b/AltStoreCore/Types/ALTAppPermissions.h index 03039fa7..9bb04c47 100644 --- a/AltStoreCore/Types/ALTAppPermissions.h +++ b/AltStoreCore/Types/ALTAppPermissions.h @@ -12,11 +12,8 @@ typedef NSString *ALTAppPermissionType NS_TYPED_EXTENSIBLE_ENUM; extern ALTAppPermissionType const ALTAppPermissionTypeUnknown; extern ALTAppPermissionType const ALTAppPermissionTypeEntitlement; extern ALTAppPermissionType const ALTAppPermissionTypePrivacy; -extern ALTAppPermissionType const ALTAppPermissionTypeBackgroundMode; typedef NSString *ALTAppPrivacyPermission NS_TYPED_EXTENSIBLE_ENUM; -typedef NSString *ALTAppBackgroundMode NS_TYPED_EXTENSIBLE_ENUM; - extern ALTAppPrivacyPermission const ALTAppPrivacyPermissionAppleMusic; extern ALTAppPrivacyPermission const ALTAppPrivacyPermissionBluetooth; extern ALTAppPrivacyPermission const ALTAppPrivacyPermissionCalendars; diff --git a/AltStoreCore/Types/ALTAppPermissions.m b/AltStoreCore/Types/ALTAppPermissions.m index b4984b36..34de74d2 100644 --- a/AltStoreCore/Types/ALTAppPermissions.m +++ b/AltStoreCore/Types/ALTAppPermissions.m @@ -11,7 +11,6 @@ ALTAppPermissionType const ALTAppPermissionTypeUnknown = @"unknown"; ALTAppPermissionType const ALTAppPermissionTypeEntitlement = @"entitlement"; ALTAppPermissionType const ALTAppPermissionTypePrivacy = @"privacy"; -ALTAppPermissionType const ALTAppPermissionTypeBackgroundMode = @"background"; ALTAppPrivacyPermission const ALTAppPrivacyPermissionAppleMusic = @"AppleMusic"; ALTAppPrivacyPermission const ALTAppPrivacyPermissionBluetooth = @"BluetoothAlways";