From d7fcac8a5a96645b7aaf3712100ff17e51f96aca Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 17:59:09 -0500 Subject: [PATCH 01/18] In-App notifications don't pause background audio // FREEBIE --- .../ConversationViewController.m | 2 +- .../attachments/OWSVideoPlayer.swift | 2 +- .../environment/OWSAudioSession.swift | 28 +++++++++++-------- SignalMessaging/environment/OWSSounds.m | 2 +- SignalMessaging/utils/OWSAudioPlayer.h | 3 ++ SignalMessaging/utils/OWSAudioPlayer.m | 10 ++++++- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 95361da33..3206a1854 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3203,7 +3203,7 @@ typedef enum : NSUInteger { NSURL *fileURL = [NSURL fileURLWithPath:filepath]; // Setup audio session - BOOL configuredAudio = [OWSAudioSession.shared setRecordCategoryWithAudioActivity:self.voiceNoteAudioActivity]; + BOOL configuredAudio = [OWSAudioSession.shared startRecordingAudioActivity:self.voiceNoteAudioActivity]; if (!configuredAudio) { OWSFail(@"%@ Couldn't configure audio session", self.logTag); [self cancelVoiceMemo]; diff --git a/SignalMessaging/attachments/OWSVideoPlayer.swift b/SignalMessaging/attachments/OWSVideoPlayer.swift index f5405e64b..c5b86db31 100644 --- a/SignalMessaging/attachments/OWSVideoPlayer.swift +++ b/SignalMessaging/attachments/OWSVideoPlayer.swift @@ -38,7 +38,7 @@ public class OWSVideoPlayer: NSObject { } public func play() { - OWSAudioSession.shared.setPlaybackCategory(audioActivity: self.audioActivity) + OWSAudioSession.shared.startPlaybackAudioActivity(self.audioActivity) guard let item = avPlayer.currentItem else { owsFail("\(logTag) video player item was unexpectedly nil") diff --git a/SignalMessaging/environment/OWSAudioSession.swift b/SignalMessaging/environment/OWSAudioSession.swift index e892975ff..62a5baa62 100644 --- a/SignalMessaging/environment/OWSAudioSession.swift +++ b/SignalMessaging/environment/OWSAudioSession.swift @@ -33,14 +33,24 @@ public class OWSAudioSession: NSObject { private var currentActivities: [Weak] = [] + // Respects hardware mute switch, plays through external speaker, mixes with backround audio + // appropriate for foreground sound effects. + public func startAmbientAudioActivity(_ audioActivity: AudioActivity) { + Logger.debug("\(logTag) in \(#function)") + + startAudioActivity(audioActivity) + + do { + try avAudioSession.setCategory(AVAudioSessionCategoryAmbient) + } catch { + owsFail("\(logTag) in \(#function) failed with error: \(error)") + } + } + // Ignores hardware mute switch, plays through external speaker - public func setPlaybackCategory(audioActivity: AudioActivity) { + public func startPlaybackAudioActivity(_ audioActivity: AudioActivity) { Logger.debug("\(logTag) in \(#function)") - // In general, we should have put the audio session back to it's default - // category when we were done with whatever activity required it to be modified - assert(avAudioSession.category == AVAudioSessionCategorySoloAmbient) - startAudioActivity(audioActivity) do { @@ -50,13 +60,9 @@ public class OWSAudioSession: NSObject { } } - public func setRecordCategory(audioActivity: AudioActivity) -> Bool { + public func startRecordingAudioActivity(_ audioActivity: AudioActivity) -> Bool { Logger.debug("\(logTag) in \(#function)") - // In general, we should have put the audio session back to it's default - // category when we were done with whatever activity required it to be modified - assert(avAudioSession.category == AVAudioSessionCategorySoloAmbient) - assert(avAudioSession.recordPermission() == .granted) startAudioActivity(audioActivity) @@ -104,8 +110,6 @@ public class OWSAudioSession: NSObject { } do { - try avAudioSession.setCategory(AVAudioSessionCategorySoloAmbient) - // When playing audio in Signal, other apps audio (e.g. Music) is paused. // By notifying when we deactivate, the other app can resume playback. try avAudioSession.setActive(false, with: [.notifyOthersOnDeactivation]) diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 86f4afa44..a9247f583 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -224,7 +224,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob [self.audioPlayer stop]; self.audioPlayer = [OWSSounds audioPlayerForSound:sound quiet:quiet]; if (shouldRespectSilentSwitch) { - [self.audioPlayer playWithCurrentAudioCategory]; + [self.audioPlayer playWithAmbientAudioCategory]; } else { [self.audioPlayer playWithPlaybackAudioCategory]; } diff --git a/SignalMessaging/utils/OWSAudioPlayer.h b/SignalMessaging/utils/OWSAudioPlayer.h index 98a9a2f13..f8aee4045 100644 --- a/SignalMessaging/utils/OWSAudioPlayer.h +++ b/SignalMessaging/utils/OWSAudioPlayer.h @@ -38,6 +38,9 @@ typedef NS_ENUM(NSInteger, AudioPlaybackState) { // respects silent switch - (void)playWithCurrentAudioCategory; +// respects silent switch, mixes with others +- (void)playWithAmbientAudioCategory; + // will ensure sound is audible, even if silent switch is enabled - (void)playWithPlaybackAudioCategory; diff --git a/SignalMessaging/utils/OWSAudioPlayer.m b/SignalMessaging/utils/OWSAudioPlayer.m index e01efcaab..5f935d507 100644 --- a/SignalMessaging/utils/OWSAudioPlayer.m +++ b/SignalMessaging/utils/OWSAudioPlayer.m @@ -99,7 +99,15 @@ NS_ASSUME_NONNULL_BEGIN - (void)playWithPlaybackAudioCategory { OWSAssertIsOnMainThread(); - [OWSAudioSession.shared setPlaybackCategoryWithAudioActivity:self.audioActivity]; + [OWSAudioSession.shared startPlaybackAudioActivity:self.audioActivity]; + + [self play]; +} + +- (void)playWithAmbientAudioCategory +{ + OWSAssertIsOnMainThread(); + [OWSAudioSession.shared startAmbientAudioActivity:self.audioActivity]; [self play]; } From d3be2b4a3b2d661a3908c374273af9de25e4c082 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 18:47:35 -0500 Subject: [PATCH 02/18] Vibrate when playing sound as alert // FREEBIE --- Signal/src/environment/NotificationsManager.m | 8 ++++--- SignalMessaging/environment/OWSSounds.h | 3 --- SignalMessaging/environment/OWSSounds.m | 23 ------------------- SignalMessaging/utils/OWSAudioPlayer.h | 2 +- SignalMessaging/utils/OWSAudioPlayer.m | 3 ++- 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/Signal/src/environment/NotificationsManager.m b/Signal/src/environment/NotificationsManager.m index 3b65fac5b..7c2503dcf 100644 --- a/Signal/src/environment/NotificationsManager.m +++ b/Signal/src/environment/NotificationsManager.m @@ -25,6 +25,7 @@ @property (nonatomic, readonly) NotificationType notificationPreviewType; @property (nonatomic, readonly) NSMutableArray *notificationHistory; +@property (nonatomic, nullable) OWSAudioPlayer *audioPlayer; @end @@ -238,7 +239,8 @@ } else { if (shouldPlaySound && [Environment.preferences soundInForeground]) { OWSSound sound = [OWSSounds notificationSoundForThread:thread]; - [OWSSounds playSound:sound quiet:YES shouldRespectSilentSwitch:YES]; + self.audioPlayer = [OWSSounds audioPlayerForSound:sound]; + [self.audioPlayer playAsForegroundAlert]; } } }); @@ -343,8 +345,8 @@ } else { if (shouldPlaySound && [Environment.preferences soundInForeground]) { OWSSound sound = [OWSSounds notificationSoundForThread:thread]; - // We play the "quiet" variation of sounds if possible for notifications in the foreground. - [OWSSounds playSound:sound quiet:YES shouldRespectSilentSwitch:YES]; + self.audioPlayer = [OWSSounds audioPlayerForSound:sound]; + [self.audioPlayer playAsForegroundAlert]; } } }); diff --git a/SignalMessaging/environment/OWSSounds.h b/SignalMessaging/environment/OWSSounds.h index 223ef11b1..99d40ccfc 100644 --- a/SignalMessaging/environment/OWSSounds.h +++ b/SignalMessaging/environment/OWSSounds.h @@ -48,9 +48,6 @@ typedef NS_ENUM(NSUInteger, OWSSound) { + (nullable NSString *)filenameForSound:(OWSSound)sound; -+ (void)playSound:(OWSSound)sound shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch; -+ (void)playSound:(OWSSound)sound quiet:(BOOL)quiet shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch; - #pragma mark - Notifications + (NSArray *)allNotificationSounds; diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index a9247f583..6d9d89f1d 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -17,8 +17,6 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob @property (nonatomic, readonly) YapDatabaseConnection *dbConnection; -@property (nonatomic, nullable) OWSAudioPlayer *audioPlayer; - @end #pragma mark - @@ -209,27 +207,6 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob return url; } -+ (void)playSound:(OWSSound)sound shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch -{ - [self.sharedManager playSound:sound quiet:NO shouldRespectSilentSwitch:shouldRespectSilentSwitch]; -} - -+ (void)playSound:(OWSSound)sound quiet:(BOOL)quiet shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch -{ - [self.sharedManager playSound:sound quiet:quiet shouldRespectSilentSwitch:shouldRespectSilentSwitch]; -} - -- (void)playSound:(OWSSound)sound quiet:(BOOL)quiet shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch -{ - [self.audioPlayer stop]; - self.audioPlayer = [OWSSounds audioPlayerForSound:sound quiet:quiet]; - if (shouldRespectSilentSwitch) { - [self.audioPlayer playWithAmbientAudioCategory]; - } else { - [self.audioPlayer playWithPlaybackAudioCategory]; - } -} - #pragma mark - Notifications + (OWSSound)defaultNotificationSound diff --git a/SignalMessaging/utils/OWSAudioPlayer.h b/SignalMessaging/utils/OWSAudioPlayer.h index f8aee4045..10a5acfaa 100644 --- a/SignalMessaging/utils/OWSAudioPlayer.h +++ b/SignalMessaging/utils/OWSAudioPlayer.h @@ -39,7 +39,7 @@ typedef NS_ENUM(NSInteger, AudioPlaybackState) { - (void)playWithCurrentAudioCategory; // respects silent switch, mixes with others -- (void)playWithAmbientAudioCategory; +- (void)playAsForegroundAlert; // will ensure sound is audible, even if silent switch is enabled - (void)playWithPlaybackAudioCategory; diff --git a/SignalMessaging/utils/OWSAudioPlayer.m b/SignalMessaging/utils/OWSAudioPlayer.m index 5f935d507..4586aea1f 100644 --- a/SignalMessaging/utils/OWSAudioPlayer.m +++ b/SignalMessaging/utils/OWSAudioPlayer.m @@ -104,11 +104,12 @@ NS_ASSUME_NONNULL_BEGIN [self play]; } -- (void)playWithAmbientAudioCategory +- (void)playAsForegroundAlert { OWSAssertIsOnMainThread(); [OWSAudioSession.shared startAmbientAudioActivity:self.audioActivity]; + AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); [self play]; } From 788316726553c4b1d6b2236c21896e5a2a2e2e43 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 18:48:37 -0500 Subject: [PATCH 03/18] Fix "None" audio for fallback notifications. // FREEBIE --- SignalMessaging/environment/OWSSounds.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 6d9d89f1d..0634304cd 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -259,11 +259,18 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob DDLogDebug(@"%@ writing new default sound to %@", self.logTag, defaultSoundPath); NSURL *_Nullable soundURL = [OWSSounds soundURLForSound:sound quiet:NO]; - OWSAssert(soundURL); + + NSData *soundData = ^{ + if (soundURL) { + return [NSData dataWithContentsOfURL:soundURL]; + } else { + OWSAssert(sound == OWSSound_None); + return [NSData new]; + } + }(); // Quick way to achieve an atomic "copy" operation that allows overwriting if the user has previously specified // a default notification sound. - NSData *soundData = [NSData dataWithContentsOfURL:soundURL]; BOOL success = [soundData writeToFile:defaultSoundPath atomically:YES]; // The globally configured sound the user has configured is unprotected, so that we can still play the sound if the From 830e9f1bfd4b75c7a685b9932b4ece69829800b4 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 19:00:18 -0500 Subject: [PATCH 04/18] Make "Signal Classic" audio stand out more // FREEBIE --- SignalMessaging/environment/OWSSounds.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 0634304cd..60acb3871 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -68,7 +68,6 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob @(OWSSound_Bamboo), @(OWSSound_Chord), @(OWSSound_Circles), - @(OWSSound_ClassicNotification), @(OWSSound_Complete), @(OWSSound_Hello), @(OWSSound_Input), @@ -76,6 +75,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob @(OWSSound_Popcorn), @(OWSSound_Pulse), @(OWSSound_Synth), + @(OWSSound_ClassicNotification), ]; } @@ -113,7 +113,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob case OWSSound_Synth: return @"Synth"; case OWSSound_ClassicNotification: - return @"Classic"; + return @"Signal Classic"; // Call Audio case OWSSound_Opening: From c2501d8d1ee09f27b0252eec5c03643a9ac6268a Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 19:00:48 -0500 Subject: [PATCH 05/18] Don't migrate legacy users to use new audio tones // FREEBIE --- .../ExperienceUpgradesPageViewController.swift | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index b5dc87592..8d8b2bc63 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -9,13 +9,6 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: var buttonAction: ((UIButton) -> Void)? - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - - // Opt users in to the new default sound ("note") after they've seen the splash screen. - OWSSounds.setGlobalNotificationSound(.note) - } - override func loadView() { self.view = UIView.container() From 4e64b09ad6fd0c2d1a908a638d81552ed0c3bbc5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 20:45:23 -0500 Subject: [PATCH 06/18] Don't set audio to ambient while other audioActivity exists // FREEBIE --- SignalMessaging/environment/OWSAudioSession.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SignalMessaging/environment/OWSAudioSession.swift b/SignalMessaging/environment/OWSAudioSession.swift index 62a5baa62..d6d60d2d6 100644 --- a/SignalMessaging/environment/OWSAudioSession.swift +++ b/SignalMessaging/environment/OWSAudioSession.swift @@ -40,6 +40,12 @@ public class OWSAudioSession: NSObject { startAudioActivity(audioActivity) + guard currentActivities.count == 0 else { + // We don't want to clobber the audio capabilities configured by (e.g.) media playback or an in-progress call + Logger.info("\(logTag) in \(#function) not touching audio session since another currentActivity exists.") + return + } + do { try avAudioSession.setCategory(AVAudioSessionCategoryAmbient) } catch { From 79ee5ed216d80be8b1163c76fa1beddb7981187c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 21:32:35 -0500 Subject: [PATCH 07/18] Be more conservative about logging legacy users into "Recents" // FREEBIE --- Signal.xcodeproj/project.pbxproj | 8 ++ .../migrations/OWS108CallLoggingPreference.h | 13 +++ .../migrations/OWS108CallLoggingPreference.m | 31 +++++++ SignalMessaging/utils/OWSPreferences.h | 2 + SignalMessaging/utils/OWSPreferences.m | 82 +++++++++++++------ 5 files changed, 113 insertions(+), 23 deletions(-) create mode 100644 SignalMessaging/environment/migrations/OWS108CallLoggingPreference.h create mode 100644 SignalMessaging/environment/migrations/OWS108CallLoggingPreference.m diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 34b462877..99e04856b 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -303,6 +303,8 @@ 458E38371D668EBF0094BD24 /* OWSDeviceProvisioningURLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 458E38361D668EBF0094BD24 /* OWSDeviceProvisioningURLParser.m */; }; 458E383A1D6699FA0094BD24 /* OWSDeviceProvisioningURLParserTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 458E38391D6699FA0094BD24 /* OWSDeviceProvisioningURLParserTest.m */; }; 459311FC1D75C948008DD4F0 /* OWSDeviceTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 459311FB1D75C948008DD4F0 /* OWSDeviceTableViewCell.m */; }; + 4598198E204E2F28009414F2 /* OWS108CallLoggingPreference.h in Headers */ = {isa = PBXBuildFile; fileRef = 4598198C204E2F28009414F2 /* OWS108CallLoggingPreference.h */; }; + 4598198F204E2F28009414F2 /* OWS108CallLoggingPreference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4598198D204E2F28009414F2 /* OWS108CallLoggingPreference.m */; }; 45A2F005204473A3002E978A /* NewMessage.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 45A2F004204473A3002E978A /* NewMessage.aifc */; }; 45A663C51F92EC760027B59E /* GroupTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A663C41F92EC760027B59E /* GroupTableViewCell.swift */; }; 45A6DAD61EBBF85500893231 /* ReminderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A6DAD51EBBF85500893231 /* ReminderView.swift */; }; @@ -878,6 +880,8 @@ 459311FB1D75C948008DD4F0 /* OWSDeviceTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSDeviceTableViewCell.m; sourceTree = ""; }; 4597E94E1D8313C100040CDE /* sq */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sq; path = translations/sq.lproj/Localizable.strings; sourceTree = ""; }; 4597E94F1D8313CB00040CDE /* bg */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bg; path = translations/bg.lproj/Localizable.strings; sourceTree = ""; }; + 4598198C204E2F28009414F2 /* OWS108CallLoggingPreference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OWS108CallLoggingPreference.h; sourceTree = ""; }; + 4598198D204E2F28009414F2 /* OWS108CallLoggingPreference.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OWS108CallLoggingPreference.m; sourceTree = ""; }; 45A2F004204473A3002E978A /* NewMessage.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; name = NewMessage.aifc; path = Signal/AudioFiles/NewMessage.aifc; sourceTree = SOURCE_ROOT; }; 45A663C41F92EC760027B59E /* GroupTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupTableViewCell.swift; sourceTree = ""; }; 45A6DAD51EBBF85500893231 /* ReminderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReminderView.swift; sourceTree = ""; }; @@ -1346,6 +1350,8 @@ 346129F11FD5F31400532771 /* OWS106EnsureProfileComplete.swift */, 4503F1C2204711D200CEE724 /* OWS107LegacySounds.h */, 4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */, + 4598198C204E2F28009414F2 /* OWS108CallLoggingPreference.h */, + 4598198D204E2F28009414F2 /* OWS108CallLoggingPreference.m */, 346129931FD1E30000532771 /* OWSDatabaseMigration.h */, 346129941FD1E30000532771 /* OWSDatabaseMigration.m */, 346129E51FD5C0C600532771 /* OWSDatabaseMigrationRunner.h */, @@ -2196,6 +2202,7 @@ 34480B611FD0A98800BC14EF /* UIColor+OWS.h in Headers */, 453518961FC63DBF00210559 /* SignalMessaging.h in Headers */, 3461295A1FD1D74C00532771 /* Environment.h in Headers */, + 4598198E204E2F28009414F2 /* OWS108CallLoggingPreference.h in Headers */, 34480B631FD0A98800BC14EF /* UIView+OWS.h in Headers */, 451F8A4B1FD715E1005CB9DA /* OWSGroupAvatarBuilder.h in Headers */, 347850721FDAEB17007B8332 /* OWSUserProfile.h in Headers */, @@ -2979,6 +2986,7 @@ 451F8A481FD715BA005CB9DA /* OWSContactAvatarBuilder.m in Sources */, 4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */, 346129A61FD1F09100532771 /* OWSContactsManager.m in Sources */, + 4598198F204E2F28009414F2 /* OWS108CallLoggingPreference.m in Sources */, 346129D21FD2085A00532771 /* CommonStrings.swift in Sources */, 45F59A082028E4FB00E8D2B0 /* OWSAudioSession.swift in Sources */, 34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */, diff --git a/SignalMessaging/environment/migrations/OWS108CallLoggingPreference.h b/SignalMessaging/environment/migrations/OWS108CallLoggingPreference.h new file mode 100644 index 000000000..dce3b59e7 --- /dev/null +++ b/SignalMessaging/environment/migrations/OWS108CallLoggingPreference.h @@ -0,0 +1,13 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "OWSDatabaseMigration.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OWS108CallLoggingPreference : OWSDatabaseMigration + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/environment/migrations/OWS108CallLoggingPreference.m b/SignalMessaging/environment/migrations/OWS108CallLoggingPreference.m new file mode 100644 index 000000000..04552234f --- /dev/null +++ b/SignalMessaging/environment/migrations/OWS108CallLoggingPreference.m @@ -0,0 +1,31 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "OWS108CallLoggingPreference.h" +#import "Environment.h" +#import "OWSPreferences.h" +#import + +NS_ASSUME_NONNULL_BEGIN + +// Increment a similar constant for every future DBMigration +static NSString *const OWS108CallLoggingPreferenceId = @"108"; + +@implementation OWS108CallLoggingPreference + ++ (NSString *)migrationId +{ + return OWS108CallLoggingPreferenceId; +} + +- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction +{ + OWSAssert(transaction); + + [[Environment preferences] applyCallLoggingSettingsForLegacyUsersWithTransaction:transaction]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/utils/OWSPreferences.h b/SignalMessaging/utils/OWSPreferences.h index f68aeb28e..0f9369769 100644 --- a/SignalMessaging/utils/OWSPreferences.h +++ b/SignalMessaging/utils/OWSPreferences.h @@ -64,6 +64,8 @@ extern NSString *const OWSPreferencesKeyEnableDebugLog; #pragma mark - Legacy CallKit settings +- (void)applyCallLoggingSettingsForLegacyUsersWithTransaction:(YapDatabaseReadWriteTransaction *)transaction; + - (BOOL)isCallKitEnabled; - (void)setIsCallKitEnabled:(BOOL)flag; diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m index afdda8394..312e033fd 100644 --- a/SignalMessaging/utils/OWSPreferences.m +++ b/SignalMessaging/utils/OWSPreferences.m @@ -7,6 +7,7 @@ #import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -52,16 +53,35 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste - (nullable id)tryGetValueForKey:(NSString *)key { OWSAssert(key != nil); - return [TSStorageManager.dbReadConnection objectForKey:key inCollection:OWSPreferencesSignalDatabaseCollection]; + + __block id result; + [TSStorageManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) { + result = [self tryGetValueForKey:key transaction:transaction]; + }]; + return result; +} + +- (nullable id)tryGetValueForKey:(NSString *)key transaction:(YapDatabaseReadTransaction *)transaction +{ + OWSAssert(key != nil); + return [transaction objectForKey:key inCollection:OWSPreferencesSignalDatabaseCollection]; } - (void)setValueForKey:(NSString *)key toValue:(nullable id)value +{ + [TSStorageManager.dbReadWriteConnection + readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + [self setValueForKey:key toValue:value transaction:transaction]; + }]; +} + +- (void)setValueForKey:(NSString *)key + toValue:(nullable id)value + transaction:(YapDatabaseReadWriteTransaction *)transaction { OWSAssert(key != nil); - [TSStorageManager.dbReadWriteConnection setObject:value - forKey:key - inCollection:OWSPreferencesSignalDatabaseCollection]; + [transaction setObject:value forKey:key inCollection:OWSPreferencesSignalDatabaseCollection]; } #pragma mark - Specific Preferences @@ -184,21 +204,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste } NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeySystemCallLogEnabled]; - - if (preference) { - return preference.boolValue; - } else { - // For legacy users, who may have previously intentionally disabled CallKit because they - // didn't want their calls showing up in the call log, we want to disable call logging - NSNumber *callKitPreference = [self tryGetValueForKey:OWSPreferencesKeyCallKitEnabled]; - if (callKitPreference && !callKitPreference.boolValue) { - // user explicitly opted out of callKit, so disable system call logging. - return NO; - } - } - - // For everyone else, including new users, enable by default. - return YES; + return preference ? preference.boolValue : YES; } - (void)setIsSystemCallLogEnabled:(BOOL)flag @@ -224,11 +230,41 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste // Therefore in versions of iOS after 11, we have no need of call privacy. #pragma mark Legacy CallKit +// Be a little conservative with system call logging with legacy users, even though it's +// not synced to iCloud, users could be concerned to suddenly see caller names in their +// recent calls list. +- (void)applyCallLoggingSettingsForLegacyUsersWithTransaction:(YapDatabaseReadWriteTransaction *)transaction +{ + NSNumber *_Nullable callKitPreference = + [self tryGetValueForKey:OWSPreferencesKeyCallKitEnabled transaction:transaction]; + BOOL wasUsingCallKit = callKitPreference ? [callKitPreference boolValue] : YES; + + NSNumber *_Nullable callKitPrivacyPreference = + [self tryGetValueForKey:OWSPreferencesKeyCallKitPrivacyEnabled transaction:transaction]; + BOOL wasUsingCallKitPrivacy = callKitPrivacyPreference ? callKitPrivacyPreference.boolValue : YES; + + BOOL shouldLogCallsInRecents = ^{ + if (wasUsingCallKit && !wasUsingCallKitPrivacy) { + // User was using CallKit and explicitly opted in to showing names/numbers, + // so it's OK to continue to show names/numbers in the system recents list. + return YES; + } else { + // User was not previously showing names/numbers in the system + // recents list, so don't opt them in. + return NO; + } + }(); + + [self setValueForKey:OWSPreferencesKeySystemCallLogEnabled + toValue:@(shouldLogCallsInRecents) + transaction:transaction]; +} + - (BOOL)isCallKitEnabled { if (@available(iOS 11, *)) { - OWSFail(@"%@ CallKit privacy is irrelevant for iOS11+", self.logTag); - return NO; + OWSFail(@"%@ CallKit is always enabled for iOS11+", self.logTag); + return YES; } NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyCallKitEnabled]; @@ -238,7 +274,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste - (void)setIsCallKitEnabled:(BOOL)flag { if (@available(iOS 11, *)) { - OWSFail(@"%@ CallKit privacy is irrelevant for iOS11+", self.logTag); + OWSFail(@"%@ CallKit is always enabled for iOS11+", self.logTag); return; } @@ -249,7 +285,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste - (BOOL)isCallKitEnabledSet { if (@available(iOS 11, *)) { - OWSFail(@"%@ CallKit privacy is irrelevant for iOS11+", self.logTag); + OWSFail(@"%@ CallKit is always enabled for iOS11+", self.logTag); return NO; } From 126a4cb7ca0a86b9ae1d281201131928f4c3f5ad Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 21:43:50 -0500 Subject: [PATCH 08/18] Fix build break // FREEBIE --- SignalMessaging/utils/OWSPreferences.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SignalMessaging/utils/OWSPreferences.h b/SignalMessaging/utils/OWSPreferences.h index 0f9369769..fe3a9a333 100644 --- a/SignalMessaging/utils/OWSPreferences.h +++ b/SignalMessaging/utils/OWSPreferences.h @@ -17,6 +17,8 @@ typedef NS_ENUM(NSUInteger, NotificationType) { extern NSString *const OWSPreferencesSignalDatabaseCollection; extern NSString *const OWSPreferencesKeyEnableDebugLog; +@class YapDatabaseReadWriteTransaction; + @interface OWSPreferences : NSObject #pragma mark - Helpers From cae40d40879a031d6c91215e7c393102ae0c1af6 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 21:44:33 -0500 Subject: [PATCH 09/18] "Bump build to 2.21.0.6." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 27856a446..4d6aba4f0 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 2.21.0.5 + 2.21.0.6 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index e27813fbd..34727b059 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.21.0 CFBundleVersion - 2.21.0.5 + 2.21.0.6 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 1ddf3bb4e12f1e57c94267cf0dac2f3f794e6ddf Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 10:12:55 -0500 Subject: [PATCH 10/18] Fix "use ambient" for notifications // FREEBIE --- SignalMessaging/environment/OWSAudioSession.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SignalMessaging/environment/OWSAudioSession.swift b/SignalMessaging/environment/OWSAudioSession.swift index d6d60d2d6..abcf9596b 100644 --- a/SignalMessaging/environment/OWSAudioSession.swift +++ b/SignalMessaging/environment/OWSAudioSession.swift @@ -37,22 +37,22 @@ public class OWSAudioSession: NSObject { // appropriate for foreground sound effects. public func startAmbientAudioActivity(_ audioActivity: AudioActivity) { Logger.debug("\(logTag) in \(#function)") - + startAudioActivity(audioActivity) - - guard currentActivities.count == 0 else { + + guard currentActivities.count == 1 else { // We don't want to clobber the audio capabilities configured by (e.g.) media playback or an in-progress call Logger.info("\(logTag) in \(#function) not touching audio session since another currentActivity exists.") return } - + do { try avAudioSession.setCategory(AVAudioSessionCategoryAmbient) } catch { owsFail("\(logTag) in \(#function) failed with error: \(error)") } } - + // Ignores hardware mute switch, plays through external speaker public func startPlaybackAudioActivity(_ audioActivity: AudioActivity) { Logger.debug("\(logTag) in \(#function)") From d12a6ae5748846c16985498c40f08d70da3bbdb2 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 10:19:52 -0500 Subject: [PATCH 11/18] "Bump build to 2.21.0.7." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 4d6aba4f0..3bfe732a8 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 2.21.0.6 + 2.21.0.7 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index 34727b059..c2b008e1e 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.21.0 CFBundleVersion - 2.21.0.6 + 2.21.0.7 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 55a4b66ca31d210dce156abfc8e2ee4168d06d3e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 13:16:34 -0500 Subject: [PATCH 12/18] Run call settings migration // FREEBIE --- .../environment/migrations/OWSDatabaseMigrationRunner.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m index 8ae0f01eb..f872b27c0 100644 --- a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m +++ b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m @@ -9,6 +9,7 @@ #import "OWS104CreateRecipientIdentities.h" #import "OWS105AttachmentFilePaths.h" #import "OWS107LegacySounds.h" +#import "OWS108CallLoggingPreference.h" #import "OWSDatabaseMigration.h" #import #import @@ -40,7 +41,8 @@ NS_ASSUME_NONNULL_BEGIN [[OWS104CreateRecipientIdentities alloc] initWithStorageManager:storageManager], [[OWS105AttachmentFilePaths alloc] initWithStorageManager:storageManager], [[OWS106EnsureProfileComplete alloc] initWithStorageManager:storageManager], - [[OWS107LegacySounds alloc] initWithStorageManager:storageManager] + [[OWS107LegacySounds alloc] initWithStorageManager:storageManager], + [[OWS108CallLoggingPreference alloc] initWithStorageManager:storageManager] ]; } From 5739f074ae85d7cb99d1e4e1bc49453ee6bca27e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 12:27:04 -0500 Subject: [PATCH 13/18] Show migration screen at first launch. sort sounds alphabetically (other than Default/None) // FREEBIE --- ...ExperienceUpgradesPageViewController.swift | 4 +-- .../src/ViewControllers/HomeViewController.m | 29 ++++++++++--------- SignalMessaging/environment/OWSSounds.m | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index 8d8b2bc63..e84bd7733 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -44,8 +44,8 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: let button = addButton(title: buttonTitle) { _ in // dismiss the modally presented view controller, then proceed. self.experienceUpgradesPageViewController.dismiss(animated: true) { - guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else { - owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))") + guard let fromViewController = UIApplication.shared.frontmostViewController else { + owsFail("frontmostViewController was unexectedly nil") return } diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index fd6148776..a760a5b71 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -287,6 +287,22 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; [self updateBarButtonItems]; } +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + // Keep in mind viewDidAppear is called while the app is in the background if the app was + // launched by a voip notification. This is fine - it will remain visible to the user + // when they eventually launch the app, but we shouldn't make any changes assuming + // the user has *seen* the upgrade experience at this point. + if (!self.hasShownAnyUnseenUpgradeExperiences) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self displayAnyUnseenUpgradeExperience]; + self.hasShownAnyUnseenUpgradeExperiences = YES; + }); + } +} + - (void)updateBarButtonItems { const CGFloat kBarButtonSize = 44; @@ -510,19 +526,6 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; }); }]; } - - // We want to show the user the upgrade experience as soon as the app is visible to them. - // It cannot go in viewDidAppear, which is called while the app is in the background if - // we were launched from a voip notification. - if (!self.hasShownAnyUnseenUpgradeExperiences) { - dispatch_async(dispatch_get_main_queue(), ^{ - if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) { - return; - } - [self displayAnyUnseenUpgradeExperience]; - self.hasShownAnyUnseenUpgradeExperiences = YES; - }); - } } #pragma mark - startup diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 60acb3871..a29b16c77 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -74,8 +74,8 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob @(OWSSound_Keys), @(OWSSound_Popcorn), @(OWSSound_Pulse), - @(OWSSound_Synth), @(OWSSound_ClassicNotification), + @(OWSSound_Synth), ]; } From 51ae9365557e34b38ac3c77922bd77da8ed1eada Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 13:53:25 -0500 Subject: [PATCH 14/18] Ensure the user sees the experience upgrade Don't mark it as seen until it is dismissed. // FREEBIE --- ...ExperienceUpgradesPageViewController.swift | 20 +++++++++---- .../src/ViewControllers/HomeViewController.m | 29 ++----------------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index e84bd7733..184c159f7 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -490,12 +490,15 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl let pageViewController: UIPageViewController + let editingDBConnection: YapDatabaseConnection + // MARK: - Initializers required init(experienceUpgrades: [ExperienceUpgrade]) { self.experienceUpgrades = experienceUpgrades setPageControlAppearance() + self.editingDBConnection = TSStorageManager.shared().newDatabaseConnection() self.pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) super.init(nibName: nil, bundle: nil) self.pageViewController.dataSource = self @@ -505,12 +508,7 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl @available(*, unavailable, message:"unavailable, use initWithExperienceUpgrade instead") required init?(coder aDecoder: NSCoder) { - assert(false) - // This should never happen, but so as not to explode we give some bogus data - self.experienceUpgrades = [ExperienceUpgrade()] - self.pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - super.init(coder: aDecoder) - self.pageViewController.dataSource = self + fatalError("unimplemented") } // MARK: - View lifecycle @@ -679,6 +677,16 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl allViewControllers.append(viewController) } + override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) { + // Blocking write before dismiss, to be sure they're marked as complete + // before HomeView.didAppear is re-fired. + self.editingDBConnection.readWrite { transaction in + Logger.info("\(self.logTag) marking all upgrades as seen.") + ExperienceUpgradeFinder.shared.markAllAsSeen(transaction: transaction) + } + super.dismiss(animated: flag, completion: completion) + } + func didTapDismissButton(sender: UIButton) { Logger.debug("\(TAG) in \(#function)") self.dismiss(animated: true) diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index a760a5b71..329c73a1e 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -47,7 +47,6 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; @property (nonatomic) UISegmentedControl *segmentedControl; @property (nonatomic) id previewingContext; @property (nonatomic) NSSet *blockedPhoneNumberSet; -@property (nonatomic) BOOL hasShownAnyUnseenUpgradeExperiences; @property (nonatomic) BOOL isViewVisible; @property (nonatomic) BOOL isAppInBackground; @@ -291,16 +290,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; { [super viewDidAppear:animated]; - // Keep in mind viewDidAppear is called while the app is in the background if the app was - // launched by a voip notification. This is fine - it will remain visible to the user - // when they eventually launch the app, but we shouldn't make any changes assuming - // the user has *seen* the upgrade experience at this point. - if (!self.hasShownAnyUnseenUpgradeExperiences) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self displayAnyUnseenUpgradeExperience]; - self.hasShownAnyUnseenUpgradeExperiences = YES; - }); - } + [self displayAnyUnseenUpgradeExperience]; } - (void)updateBarButtonItems @@ -535,21 +525,12 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; OWSAssertIsOnMainThread(); __block NSArray *unseenUpgrades; - [self.editingDbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { + [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { unseenUpgrades = [ExperienceUpgradeFinder.sharedManager allUnseenWithTransaction:transaction]; }]; return unseenUpgrades; } -- (void)markAllUpgradeExperiencesAsSeen -{ - OWSAssertIsOnMainThread(); - - [self.editingDbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - [ExperienceUpgradeFinder.sharedManager markAllAsSeenWithTransaction:transaction]; - }]; -} - - (void)displayAnyUnseenUpgradeExperience { OWSAssertIsOnMainThread(); @@ -559,11 +540,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; if (unseenUpgrades.count > 0) { ExperienceUpgradesPageViewController *experienceUpgradeViewController = [[ExperienceUpgradesPageViewController alloc] initWithExperienceUpgrades:unseenUpgrades]; - [self presentViewController:experienceUpgradeViewController - animated:YES - completion:^{ - [self markAllUpgradeExperiencesAsSeen]; - }]; + [self presentViewController:experienceUpgradeViewController animated:YES completion:nil]; } else if (!self.hasBeenPresented && [ProfileViewController shouldDisplayProfileViewOnLaunch]) { [ProfileViewController presentForUpgradeOrNag:self]; } else { From f459c9ce6d350ca4173867da6d4b4ce5c2d02308 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 13:57:59 -0500 Subject: [PATCH 15/18] CR: rename SignalClassic constant // FREEBIE --- SignalMessaging/environment/OWSSounds.h | 2 +- SignalMessaging/environment/OWSSounds.m | 6 +++--- SignalMessaging/environment/migrations/OWS107LegacySounds.m | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SignalMessaging/environment/OWSSounds.h b/SignalMessaging/environment/OWSSounds.h index 99d40ccfc..506560d13 100644 --- a/SignalMessaging/environment/OWSSounds.h +++ b/SignalMessaging/environment/OWSSounds.h @@ -20,7 +20,7 @@ typedef NS_ENUM(NSUInteger, OWSSound) { OWSSound_Popcorn, OWSSound_Pulse, OWSSound_Synth, - OWSSound_ClassicNotification, + OWSSound_SignalClassic, // Ringtone Sounds OWSSound_Opening, diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index a29b16c77..0c7e29ba4 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -74,7 +74,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob @(OWSSound_Keys), @(OWSSound_Popcorn), @(OWSSound_Pulse), - @(OWSSound_ClassicNotification), + @(OWSSound_SignalClassic), @(OWSSound_Synth), ]; } @@ -112,7 +112,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob return @"Pulse"; case OWSSound_Synth: return @"Synth"; - case OWSSound_ClassicNotification: + case OWSSound_SignalClassic: return @"Signal Classic"; // Call Audio @@ -172,7 +172,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob return (quiet ? @"pulse-quiet.aifc" : @"pulse.aifc"); case OWSSound_Synth: return (quiet ? @"synth-quiet.aifc" : @"synth.aifc"); - case OWSSound_ClassicNotification: + case OWSSound_SignalClassic: return (quiet ? @"classic-quiet.aifc" : @"classic.aifc"); // Ringtone Sounds diff --git a/SignalMessaging/environment/migrations/OWS107LegacySounds.m b/SignalMessaging/environment/migrations/OWS107LegacySounds.m index 2c3214edb..20cb6c48a 100644 --- a/SignalMessaging/environment/migrations/OWS107LegacySounds.m +++ b/SignalMessaging/environment/migrations/OWS107LegacySounds.m @@ -22,7 +22,7 @@ static NSString *const OWS107LegacySoundsMigrationId = @"107"; { OWSAssert(transaction); - [OWSSounds setGlobalNotificationSound:OWSSound_ClassicNotification transaction:transaction]; + [OWSSounds setGlobalNotificationSound:OWSSound_SignalClassic transaction:transaction]; } @end From 913cdad74a153bc895a1d76a9482e80d3d4848f6 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 14:48:13 -0500 Subject: [PATCH 16/18] "Bump build to 2.21.0.8." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 3bfe732a8..67d1e1642 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 2.21.0.7 + 2.21.0.8 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index c2b008e1e..1b3c88317 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.21.0 CFBundleVersion - 2.21.0.7 + 2.21.0.8 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 39b87b702b12c84d446d981a45ff69d5b0aedf2c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 15:28:25 -0500 Subject: [PATCH 17/18] Fix debuglogs.org integration // FREEBIE --- Scripts/debug_log_upload.py | 29 ++++++++++++++++-------- Signal/src/util/Pastelog.m | 8 +++++-- SignalMessaging/utils/OWSPreferences.m | 1 + SignalServiceKit/src/Util/MIMETypeUtil.h | 3 ++- SignalServiceKit/src/Util/MIMETypeUtil.m | 5 ++-- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Scripts/debug_log_upload.py b/Scripts/debug_log_upload.py index 0c26aafb4..dd6a3239c 100755 --- a/Scripts/debug_log_upload.py +++ b/Scripts/debug_log_upload.py @@ -28,10 +28,13 @@ def execute_command(command): print e.output sys.exit(1) - +def add_field(curl_command, form_key, form_value): + curl_command.append('-F') + curl_command.append("%s=%s" % (form_key, form_value)) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Precommit cleanup script.') - parser.add_argument('--file', help='used for starting a new version.') + parser.add_argument('--file', required=True, help='used for starting a new version.') args = parser.parse_args() @@ -41,24 +44,30 @@ if __name__ == '__main__': upload_url = params['url'] upload_fields = params['fields'] - upload_key = upload_fields['key'] + + upload_key = upload_fields.pop('key') upload_key = upload_key + os.path.splitext(args.file)[1] - upload_fields['key'] = upload_key download_url = 'https://debuglogs.org/' + upload_key print 'download_url:', download_url curl_command = ['curl', '-v', '-i', '-X', 'POST'] + + # key must appear before other fields + add_field(curl_command, 'key', upload_key) for field_name in upload_fields: - field_value = upload_fields[field_name] - curl_command.append('-F') - curl_command.append("'%s=%s'" % (field_name, field_value, )) + add_field(curl_command, field_name, upload_fields[field_name]) + + add_field(curl_command, "content-type", "application/octet-stream") + curl_command.append('-F') - curl_command.append("'file=@%s'" % (args.file,)) + curl_command.append("file=@%s" % (args.file,)) curl_command.append(upload_url) - # execute_command(curl_command) print ' '.join(curl_command) + print 'Running...' + execute_command(curl_command) + print 'download_url:', download_url - \ No newline at end of file + diff --git a/Signal/src/util/Pastelog.m b/Signal/src/util/Pastelog.m index 17dda81a0..758953d92 100644 --- a/Signal/src/util/Pastelog.m +++ b/Signal/src/util/Pastelog.m @@ -12,6 +12,7 @@ #import #import #import +#import #import #import #import @@ -150,6 +151,9 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error NSString *fieldValue = fields[fieldName]; [formData appendPartWithFormData:[fieldValue dataUsingEncoding:NSUTF8StringEncoding] name:fieldName]; } + [formData appendPartWithFormData:[weakSelf.mimeType dataUsingEncoding:NSUTF8StringEncoding] + name:@"content-type"]; + NSError *error; BOOL success = [formData appendPartWithFileURL:weakSelf.fileUrl name:@"file" @@ -168,7 +172,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error [self succeedWithUrl:[NSURL URLWithString:urlString]]; } failure:^(NSURLSessionDataTask *_Nullable task, NSError *error) { - DDLogError(@"%@ failed: %@", weakSelf.logTag, uploadUrl); + DDLogError(@"%@ upload: %@ failed with error: %@", weakSelf.logTag, uploadUrl, error); [weakSelf failWithError:error]; }]; } @@ -427,7 +431,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error __weak Pastelog *weakSelf = self; self.currentUploader = [DebugLogUploader new]; [self.currentUploader uploadFileWithURL:[NSURL fileURLWithPath:zipFilePath] - mimeType:@"application/zip" + mimeType:OWSMimeTypeApplicationZip success:^(DebugLogUploader *uploader, NSURL *url) { if (uploader != weakSelf.currentUploader) { // Ignore events from obsolete uploaders. diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m index 312e033fd..708cf35b0 100644 --- a/SignalMessaging/utils/OWSPreferences.m +++ b/SignalMessaging/utils/OWSPreferences.m @@ -255,6 +255,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste } }(); + DDLogInfo(@"%@ Migrating setting - System Call Log Enabled: %d", self.logTag, shouldLogCallsInRecents); [self setValueForKey:OWSPreferencesKeySystemCallLogEnabled toValue:@(shouldLogCallsInRecents) transaction:transaction]; diff --git a/SignalServiceKit/src/Util/MIMETypeUtil.h b/SignalServiceKit/src/Util/MIMETypeUtil.h index 4ecc7dfa7..f83a273b4 100644 --- a/SignalServiceKit/src/Util/MIMETypeUtil.h +++ b/SignalServiceKit/src/Util/MIMETypeUtil.h @@ -1,10 +1,11 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // NS_ASSUME_NONNULL_BEGIN extern NSString *const OWSMimeTypeApplicationOctetStream; +extern NSString *const OWSMimeTypeApplicationZip; extern NSString *const OWSMimeTypeImagePng; extern NSString *const OWSMimeTypeOversizeTextMessage; extern NSString *const OWSMimeTypeUnknownForTests; diff --git a/SignalServiceKit/src/Util/MIMETypeUtil.m b/SignalServiceKit/src/Util/MIMETypeUtil.m index cf26dd21f..786731ef1 100644 --- a/SignalServiceKit/src/Util/MIMETypeUtil.m +++ b/SignalServiceKit/src/Util/MIMETypeUtil.m @@ -19,6 +19,7 @@ NSString *const OWSMimeTypeApplicationOctetStream = @"application/octet-stream"; NSString *const OWSMimeTypeImagePng = @"image/png"; NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain"; NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype"; +NSString *const OWSMimeTypeApplicationZip = @"application/zip"; NSString *const kOversizeTextAttachmentUTI = @"org.whispersystems.oversize-text-attachment"; NSString *const kOversizeTextAttachmentFileExtension = @"txt"; @@ -1250,7 +1251,7 @@ NSString *const kSyncMessageFileExtension = @"bin"; @"application/yang" : @"yang", @"application/yin+xml" : @"yin", @"application/ynd.ms-pkipko" : @"pko", - @"application/zip" : @"zip", + OWSMimeTypeApplicationZip : @"zip", @"audio/aac" : @"aac", @"audio/adpcm" : @"adp", @"audio/aiff" : @"aiff", @@ -2557,7 +2558,7 @@ NSString *const kSyncMessageFileExtension = @"bin"; @"z7" : @"application/x-zmachine", @"z8" : @"application/x-zmachine", @"zaz" : @"application/vnd.zzazz.deck+xml", - @"zip" : @"application/zip", + @"zip" : OWSMimeTypeApplicationZip, @"zir" : @"application/vnd.zul", @"zirz" : @"application/vnd.zul", @"zmm" : @"application/vnd.handheld-entertainment+xml", From bd48576075f4ace01f2cb9758859318f2bd70b2b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Mar 2018 16:09:21 -0500 Subject: [PATCH 18/18] "Bump build to 2.21.0.9." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 67d1e1642..dd2b63c1f 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 2.21.0.8 + 2.21.0.9 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index 1b3c88317..5fda82284 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.21.0 CFBundleVersion - 2.21.0.8 + 2.21.0.9 ITSAppUsesNonExemptEncryption NSAppTransportSecurity