From fa37fdd3005293179ae9b99479800b12f44cd62f Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 28 Feb 2018 11:55:49 -0500 Subject: [PATCH] Fix legacy sounds for voip pushes This way users who were unknowingly upgraded in the night will continue to hear the ka-klunk until they've seen the splash screen announcing the feature. // FREEBIE --- Signal.xcodeproj/project.pbxproj | 8 +++++ .../migrations/OWS107LegacySounds.h | 13 ++++++++ .../migrations/OWS107LegacySounds.m | 30 +++++++++++++++++++ .../migrations/OWSDatabaseMigrationRunner.m | 2 ++ 4 files changed, 53 insertions(+) create mode 100644 SignalMessaging/environment/migrations/OWS107LegacySounds.h create mode 100644 SignalMessaging/environment/migrations/OWS107LegacySounds.m diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 2ac42a125..8e444c046 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -210,6 +210,8 @@ 34FD93701E3BD43A00109093 /* OWSAnyTouchGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 34FD936F1E3BD43A00109093 /* OWSAnyTouchGestureRecognizer.m */; }; 4503F1BE20470A5B00CEE724 /* classic-quiet.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 4503F1BB20470A5B00CEE724 /* classic-quiet.aifc */; }; 4503F1BF20470A5B00CEE724 /* classic.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 4503F1BC20470A5B00CEE724 /* classic.aifc */; }; + 4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */ = {isa = PBXBuildFile; fileRef = 4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */; }; + 4503F1C4204711D300CEE724 /* OWS107LegacySounds.h in Headers */ = {isa = PBXBuildFile; fileRef = 4503F1C2204711D200CEE724 /* OWS107LegacySounds.h */; }; 4505C2BF1E648EA300CEBF41 /* ExperienceUpgrade.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4505C2BE1E648EA300CEBF41 /* ExperienceUpgrade.swift */; }; 450998651FD8A34D00D89EB3 /* DeviceSleepManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */; }; 450998681FD8C0FF00D89EB3 /* AttachmentSharing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F83A1E8DF1700035BE1A /* AttachmentSharing.m */; }; @@ -801,6 +803,8 @@ 435EAC2E5E22D3F087EB3192 /* Pods-SignalShareExtension.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalShareExtension.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SignalShareExtension/Pods-SignalShareExtension.app store release.xcconfig"; sourceTree = ""; }; 4503F1BB20470A5B00CEE724 /* classic-quiet.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; path = "classic-quiet.aifc"; sourceTree = ""; }; 4503F1BC20470A5B00CEE724 /* classic.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; path = classic.aifc; sourceTree = ""; }; + 4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWS107LegacySounds.m; sourceTree = ""; }; + 4503F1C2204711D200CEE724 /* OWS107LegacySounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS107LegacySounds.h; sourceTree = ""; }; 4505C2BE1E648EA300CEBF41 /* ExperienceUpgrade.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExperienceUpgrade.swift; path = ExperienceUpgrades/ExperienceUpgrade.swift; sourceTree = ""; }; 4509E7991DD653700025A59F /* WebRTC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebRTC.framework; path = Carthage/Build/iOS/WebRTC.framework; sourceTree = ""; }; 450D19111F85236600970622 /* RemoteVideoView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteVideoView.h; sourceTree = ""; }; @@ -1340,6 +1344,8 @@ 346129F31FD5F31400532771 /* OWS105AttachmentFilePaths.h */, 346129EA1FD5F31300532771 /* OWS105AttachmentFilePaths.m */, 346129F11FD5F31400532771 /* OWS106EnsureProfileComplete.swift */, + 4503F1C2204711D200CEE724 /* OWS107LegacySounds.h */, + 4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */, 346129931FD1E30000532771 /* OWSDatabaseMigration.h */, 346129941FD1E30000532771 /* OWSDatabaseMigration.m */, 346129E51FD5C0C600532771 /* OWSDatabaseMigrationRunner.h */, @@ -2169,6 +2175,7 @@ 34480B551FD0A7A400BC14EF /* DebugLogger.h in Headers */, 344F248420069E9C00CFB4F4 /* CountryCodeViewController.h in Headers */, 346129CA1FD2072E00532771 /* UIImage+OWS.h in Headers */, + 4503F1C4204711D300CEE724 /* OWS107LegacySounds.h in Headers */, 346129711FD1D74C00532771 /* SignalKeyingStorage.h in Headers */, 34612A011FD5F31400532771 /* OWS104CreateRecipientIdentities.h in Headers */, 450998691FD8C10200D89EB3 /* AttachmentSharing.h in Headers */, @@ -2970,6 +2977,7 @@ 451F8A3F1FD71455005CB9DA /* OWSTableViewController.m in Sources */, 451F8A351FD710DE005CB9DA /* Searcher.swift in Sources */, 451F8A481FD715BA005CB9DA /* OWSContactAvatarBuilder.m in Sources */, + 4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */, 346129A61FD1F09100532771 /* OWSContactsManager.m in Sources */, 346129D21FD2085A00532771 /* CommonStrings.swift in Sources */, 45F59A082028E4FB00E8D2B0 /* OWSAudioSession.swift in Sources */, diff --git a/SignalMessaging/environment/migrations/OWS107LegacySounds.h b/SignalMessaging/environment/migrations/OWS107LegacySounds.h new file mode 100644 index 000000000..f6e75f382 --- /dev/null +++ b/SignalMessaging/environment/migrations/OWS107LegacySounds.h @@ -0,0 +1,13 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "OWSDatabaseMigration.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OWS107LegacySounds : OWSDatabaseMigration + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/environment/migrations/OWS107LegacySounds.m b/SignalMessaging/environment/migrations/OWS107LegacySounds.m new file mode 100644 index 000000000..2c3214edb --- /dev/null +++ b/SignalMessaging/environment/migrations/OWS107LegacySounds.m @@ -0,0 +1,30 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "OWS107LegacySounds.h" +#import "OWSSounds.h" +#import + +NS_ASSUME_NONNULL_BEGIN + +// Increment a similar constant for every future DBMigration +static NSString *const OWS107LegacySoundsMigrationId = @"107"; + +@implementation OWS107LegacySounds + ++ (NSString *)migrationId +{ + return OWS107LegacySoundsMigrationId; +} + +- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction +{ + OWSAssert(transaction); + + [OWSSounds setGlobalNotificationSound:OWSSound_ClassicNotification transaction:transaction]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m index 913bc26f7..cfec11736 100644 --- a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m +++ b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m @@ -8,6 +8,7 @@ #import "OWS103EnableVideoCalling.h" #import "OWS104CreateRecipientIdentities.h" #import "OWS105AttachmentFilePaths.h" +#import "OWS107LegacySounds.h" #import "OWSDatabaseMigration.h" #import #import @@ -39,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN [[OWS104CreateRecipientIdentities alloc] initWithStorageManager:storageManager], [[OWS105AttachmentFilePaths alloc] initWithStorageManager:storageManager], [[OWS106EnsureProfileComplete alloc] initWithStorageManager:storageManager], + [[OWS107LegacySounds alloc] initWithStorageManager:storageManager] ]; }