From 12f33c355a107332214795c2cbb432d36c6bef16 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 1 Oct 2020 11:51:39 -0700 Subject: [PATCH] Adds InstalledApp.needsResign When true, app will be resigned + reinstalled next refresh rather than just refreshing provisioning profiles. --- AltStore/Managing Apps/AppManager.swift | 25 ++++++++++--------- AltStore/Operations/InstallAppOperation.swift | 3 ++- .../AltStore 8.xcdatamodel/contents | 5 ++-- AltStoreCore/Model/InstalledApp.swift | 1 + 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index ce905253..48ff4ae8 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -667,8 +667,19 @@ private extension AppManager case .refresh(let app): // Check if backup app is installed in place of real app. let uti = UTTypeCopyDeclaration(app.installedBackupAppUTI as CFString)?.takeRetainedValue() as NSDictionary? - - if app.certificateSerialNumber == group.context.certificate?.serialNumber && uti == nil + if app.certificateSerialNumber != group.context.certificate?.serialNumber || uti != nil || app.needsResign + { + // Resign app instead of just refreshing profiles because either: + // * Refreshing using different certificate + // * Backup app is still installed + // * App explicitly needs resigning + + let installProgress = self._install(app, operation: operation, group: group) { (result) in + self.finish(operation, result: result, group: group, progress: progress) + } + progress?.addChild(installProgress, withPendingUnitCount: 80) + } + else { // Refreshing with same certificate as last time, and backup app isn't still installed, // so we can just refresh provisioning profiles. @@ -678,16 +689,6 @@ private extension AppManager } progress?.addChild(refreshProgress, withPendingUnitCount: 80) } - else - { - // Refreshing using different certificate or backup app is still installed, - // so we need to resign + install. - - let installProgress = self._install(app, operation: operation, group: group) { (result) in - self.finish(operation, result: result, group: group, progress: progress) - } - progress?.addChild(installProgress, withPendingUnitCount: 80) - } case .activate(let app): let activateProgress = self._activate(app, operation: operation, group: group) { (result) in diff --git a/AltStore/Operations/InstallAppOperation.swift b/AltStore/Operations/InstallAppOperation.swift index 8db6c171..78fe9cbe 100644 --- a/AltStore/Operations/InstallAppOperation.swift +++ b/AltStore/Operations/InstallAppOperation.swift @@ -62,7 +62,8 @@ class InstallAppOperation: ResultOperation } installedApp.update(resignedApp: resignedApp, certificateSerialNumber: certificate.serialNumber) - + installedApp.needsResign = false + if let team = DatabaseManager.shared.activeTeam(in: backgroundContext) { installedApp.team = team diff --git a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 8.xcdatamodel/contents b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 8.xcdatamodel/contents index acc9846d..184adf66 100644 --- a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 8.xcdatamodel/contents +++ b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 8.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -39,6 +39,7 @@ + @@ -163,7 +164,7 @@ - + diff --git a/AltStoreCore/Model/InstalledApp.swift b/AltStoreCore/Model/InstalledApp.swift index 2b521748..6c275c29 100644 --- a/AltStoreCore/Model/InstalledApp.swift +++ b/AltStoreCore/Model/InstalledApp.swift @@ -40,6 +40,7 @@ public class InstalledApp: NSManagedObject, InstalledAppProtocol @NSManaged public var installedDate: Date @NSManaged public var isActive: Bool + @NSManaged public var needsResign: Bool @NSManaged public var certificateSerialNumber: String?