From eb995cb389056be8c4d865ae0cfd8d61b9d0f0e5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 14 Nov 2016 12:47:23 -0500 Subject: [PATCH] revert to tracking longform build We use this to determine which legacy migrations to run. Also, soften the "your device is too old" behavior to just exit, rather than blow away the users installation. Ouch! * bump version // FREEBIE --- Signal/Signal-Info.plist | 2 +- Signal/src/environment/VersionMigrations.m | 50 ++++++++++++++++------ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index ca766dfda..550129bd7 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 3 + 2.6.5.4 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/Signal/src/environment/VersionMigrations.m b/Signal/src/environment/VersionMigrations.m index 74ef40701..ba106122d 100644 --- a/Signal/src/environment/VersionMigrations.m +++ b/Signal/src/environment/VersionMigrations.m @@ -36,6 +36,12 @@ + (void)performUpdateCheck { NSString *previousVersion = Environment.preferences.lastRanVersion; + NSString *currentVersion = + [NSString stringWithFormat:@"%@", NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]]; + + DDLogInfo( + @"%@ Checking migrations. currentVersion: %@, lastRanVersion: %@", self.tag, currentVersion, previousVersion); + if (!previousVersion) { DDLogInfo(@"No previous version found. Probably first launch since install - nothing to migrate."); OWSDatabaseMigrationRunner *runner = @@ -45,19 +51,25 @@ return; } - if (([self isVersion:previousVersion atLeast:@"1.0.2" andLessThan:@"2.0"])) { - // We don't migrate from RedPhone anymore, too painful to maintain. - DDLogError(@"Migrating from RedPhone no longer supported. Resetting app data and quitting."); - [Environment resetAppData]; - exit(0); - } - - BOOL VOIPRegistration = - [[PushManager sharedManager] supportsVOIPPush] && ![Environment.preferences hasRegisteredVOIPPush]; - - // VOIP Push might need to be enabled because 1) user ran old version 2) Update to compatible iOS version - if (VOIPRegistration && [TSAccountManager isRegistered]) { - [self nonBlockingPushRegistration]; + if ([self isVersion:previousVersion atLeast:@"1.0.2" andLessThan:@"2.0"]) { + DDLogError(@"Migrating from RedPhone no longer supported. Quitting."); + // Not translating these as so few are affected. + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:@"You must reinstall Signal" + message: + @"Sorry, your installation is too old for us to update. You'll have to start fresh." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *quitAction = [UIAlertAction actionWithTitle:@"Quit" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *_Nonnull action) { + exit(0); + }]; + [alertController addAction:quitAction]; + + [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController + animated:YES + completion:nil]; } if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] && [TSAccountManager isRegistered]) { @@ -197,4 +209,16 @@ } } +#pragma mark - Logging + ++ (NSString *)tag +{ + return [NSString stringWithFormat:@"[%@]", self.class]; +} + +- (NSString *)tag +{ + return self.class.tag; +} + @end