Skip to content

Commit a1de99f

Browse files
committed
Merge tag '2.21.0.9'
2 parents 2a297ca + bd48576 commit a1de99f

23 files changed

+233
-137
lines changed

Scripts/debug_log_upload.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ def execute_command(command):
2828
print e.output
2929
sys.exit(1)
3030

31-
31+
def add_field(curl_command, form_key, form_value):
32+
curl_command.append('-F')
33+
curl_command.append("%s=%s" % (form_key, form_value))
34+
3235
if __name__ == '__main__':
3336
parser = argparse.ArgumentParser(description='Precommit cleanup script.')
34-
parser.add_argument('--file', help='used for starting a new version.')
37+
parser.add_argument('--file', required=True, help='used for starting a new version.')
3538

3639
args = parser.parse_args()
3740

@@ -41,24 +44,30 @@ def execute_command(command):
4144

4245
upload_url = params['url']
4346
upload_fields = params['fields']
44-
upload_key = upload_fields['key']
47+
48+
upload_key = upload_fields.pop('key')
4549
upload_key = upload_key + os.path.splitext(args.file)[1]
46-
upload_fields['key'] = upload_key
4750

4851
download_url = 'https://debuglogs.org/' + upload_key
4952
print 'download_url:', download_url
5053

5154
curl_command = ['curl', '-v', '-i', '-X', 'POST']
55+
56+
# key must appear before other fields
57+
add_field(curl_command, 'key', upload_key)
5258
for field_name in upload_fields:
53-
field_value = upload_fields[field_name]
54-
curl_command.append('-F')
55-
curl_command.append("'%s=%s'" % (field_name, field_value, ))
59+
add_field(curl_command, field_name, upload_fields[field_name])
60+
61+
add_field(curl_command, "content-type", "application/octet-stream")
62+
5663
curl_command.append('-F')
57-
curl_command.append("'file=@%s'" % (args.file,))
64+
curl_command.append("file=@%s" % (args.file,))
5865
curl_command.append(upload_url)
5966

60-
# execute_command(curl_command)
6167
print ' '.join(curl_command)
6268

69+
print 'Running...'
70+
execute_command(curl_command)
71+
6372
print 'download_url:', download_url
64-
73+

Signal.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@
305305
458E38371D668EBF0094BD24 /* OWSDeviceProvisioningURLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 458E38361D668EBF0094BD24 /* OWSDeviceProvisioningURLParser.m */; };
306306
458E383A1D6699FA0094BD24 /* OWSDeviceProvisioningURLParserTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 458E38391D6699FA0094BD24 /* OWSDeviceProvisioningURLParserTest.m */; };
307307
459311FC1D75C948008DD4F0 /* OWSDeviceTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 459311FB1D75C948008DD4F0 /* OWSDeviceTableViewCell.m */; };
308+
4598198E204E2F28009414F2 /* OWS108CallLoggingPreference.h in Headers */ = {isa = PBXBuildFile; fileRef = 4598198C204E2F28009414F2 /* OWS108CallLoggingPreference.h */; };
309+
4598198F204E2F28009414F2 /* OWS108CallLoggingPreference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4598198D204E2F28009414F2 /* OWS108CallLoggingPreference.m */; };
308310
45A2F005204473A3002E978A /* NewMessage.aifc in Resources */ = {isa = PBXBuildFile; fileRef = 45A2F004204473A3002E978A /* NewMessage.aifc */; };
309311
45A663C51F92EC760027B59E /* GroupTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A663C41F92EC760027B59E /* GroupTableViewCell.swift */; };
310312
45A6DAD61EBBF85500893231 /* ReminderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A6DAD51EBBF85500893231 /* ReminderView.swift */; };
@@ -886,6 +888,8 @@
886888
459311FB1D75C948008DD4F0 /* OWSDeviceTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSDeviceTableViewCell.m; sourceTree = "<group>"; };
887889
4597E94E1D8313C100040CDE /* sq */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sq; path = translations/sq.lproj/Localizable.strings; sourceTree = "<group>"; };
888890
4597E94F1D8313CB00040CDE /* bg */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bg; path = translations/bg.lproj/Localizable.strings; sourceTree = "<group>"; };
891+
4598198C204E2F28009414F2 /* OWS108CallLoggingPreference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OWS108CallLoggingPreference.h; sourceTree = "<group>"; };
892+
4598198D204E2F28009414F2 /* OWS108CallLoggingPreference.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OWS108CallLoggingPreference.m; sourceTree = "<group>"; };
889893
45A2F004204473A3002E978A /* NewMessage.aifc */ = {isa = PBXFileReference; lastKnownFileType = file; name = NewMessage.aifc; path = Signal/AudioFiles/NewMessage.aifc; sourceTree = SOURCE_ROOT; };
890894
45A663C41F92EC760027B59E /* GroupTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupTableViewCell.swift; sourceTree = "<group>"; };
891895
45A6DAD51EBBF85500893231 /* ReminderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReminderView.swift; sourceTree = "<group>"; };
@@ -1357,6 +1361,8 @@
13571361
346129F11FD5F31400532771 /* OWS106EnsureProfileComplete.swift */,
13581362
4503F1C2204711D200CEE724 /* OWS107LegacySounds.h */,
13591363
4503F1C1204711D200CEE724 /* OWS107LegacySounds.m */,
1364+
4598198C204E2F28009414F2 /* OWS108CallLoggingPreference.h */,
1365+
4598198D204E2F28009414F2 /* OWS108CallLoggingPreference.m */,
13601366
346129931FD1E30000532771 /* OWSDatabaseMigration.h */,
13611367
346129941FD1E30000532771 /* OWSDatabaseMigration.m */,
13621368
346129E51FD5C0C600532771 /* OWSDatabaseMigrationRunner.h */,
@@ -2214,6 +2220,7 @@
22142220
34480B611FD0A98800BC14EF /* UIColor+OWS.h in Headers */,
22152221
453518961FC63DBF00210559 /* SignalMessaging.h in Headers */,
22162222
3461295A1FD1D74C00532771 /* Environment.h in Headers */,
2223+
4598198E204E2F28009414F2 /* OWS108CallLoggingPreference.h in Headers */,
22172224
34480B631FD0A98800BC14EF /* UIView+OWS.h in Headers */,
22182225
451F8A4B1FD715E1005CB9DA /* OWSGroupAvatarBuilder.h in Headers */,
22192226
347850721FDAEB17007B8332 /* OWSUserProfile.h in Headers */,
@@ -2997,6 +3004,7 @@
29973004
451F8A481FD715BA005CB9DA /* OWSContactAvatarBuilder.m in Sources */,
29983005
4503F1C3204711D300CEE724 /* OWS107LegacySounds.m in Sources */,
29993006
346129A61FD1F09100532771 /* OWSContactsManager.m in Sources */,
3007+
4598198F204E2F28009414F2 /* OWS108CallLoggingPreference.m in Sources */,
30003008
346129D21FD2085A00532771 /* CommonStrings.swift in Sources */,
30013009
45F59A082028E4FB00E8D2B0 /* OWSAudioSession.swift in Sources */,
30023010
34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */,

Signal/Signal-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</dict>
3939
</array>
4040
<key>CFBundleVersion</key>
41-
<string>2.21.0.5</string>
41+
<string>2.21.0.9</string>
4242
<key>ITSAppUsesNonExemptEncryption</key>
4343
<false/>
4444
<key>LOGS_EMAIL</key>

Signal/src/ViewControllers/ConversationView/ConversationViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3203,7 +3203,7 @@ - (void)startRecordingVoiceMemo
32033203
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
32043204

32053205
// Setup audio session
3206-
BOOL configuredAudio = [OWSAudioSession.shared setRecordCategoryWithAudioActivity:self.voiceNoteAudioActivity];
3206+
BOOL configuredAudio = [OWSAudioSession.shared startRecordingAudioActivity:self.voiceNoteAudioActivity];
32073207
if (!configuredAudio) {
32083208
OWSFail(@"%@ Couldn't configure audio session", self.logTag);
32093209
[self cancelVoiceMemo];

Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
99

1010
var buttonAction: ((UIButton) -> Void)?
1111

12-
override func viewDidAppear(_ animated: Bool) {
13-
super.viewDidAppear(animated)
14-
15-
// Opt users in to the new default sound ("note") after they've seen the splash screen.
16-
OWSSounds.setGlobalNotificationSound(.note)
17-
}
18-
1912
override func loadView() {
2013
self.view = UIView.container()
2114

@@ -51,8 +44,8 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
5144
let button = addButton(title: buttonTitle) { _ in
5245
// dismiss the modally presented view controller, then proceed.
5346
self.experienceUpgradesPageViewController.dismiss(animated: true) {
54-
guard let fromViewController = UIApplication.shared.frontmostViewController as? HomeViewController else {
55-
owsFail("unexpected frontmostViewController: \(String(describing: UIApplication.shared.frontmostViewController))")
47+
guard let fromViewController = UIApplication.shared.frontmostViewController else {
48+
owsFail("frontmostViewController was unexectedly nil")
5649
return
5750
}
5851

@@ -497,12 +490,15 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
497490

498491
let pageViewController: UIPageViewController
499492

493+
let editingDBConnection: YapDatabaseConnection
494+
500495
// MARK: - Initializers
501496

502497
required init(experienceUpgrades: [ExperienceUpgrade]) {
503498
self.experienceUpgrades = experienceUpgrades
504499

505500
setPageControlAppearance()
501+
self.editingDBConnection = OWSPrimaryStorage.shared().newDatabaseConnection()
506502
self.pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
507503
super.init(nibName: nil, bundle: nil)
508504
self.pageViewController.dataSource = self
@@ -512,12 +508,7 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
512508

513509
@available(*, unavailable, message:"unavailable, use initWithExperienceUpgrade instead")
514510
required init?(coder aDecoder: NSCoder) {
515-
assert(false)
516-
// This should never happen, but so as not to explode we give some bogus data
517-
self.experienceUpgrades = [ExperienceUpgrade()]
518-
self.pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
519-
super.init(coder: aDecoder)
520-
self.pageViewController.dataSource = self
511+
fatalError("unimplemented")
521512
}
522513

523514
// MARK: - View lifecycle
@@ -686,6 +677,16 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
686677
allViewControllers.append(viewController)
687678
}
688679

680+
override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
681+
// Blocking write before dismiss, to be sure they're marked as complete
682+
// before HomeView.didAppear is re-fired.
683+
self.editingDBConnection.readWrite { transaction in
684+
Logger.info("\(self.logTag) marking all upgrades as seen.")
685+
ExperienceUpgradeFinder.shared.markAllAsSeen(transaction: transaction)
686+
}
687+
super.dismiss(animated: flag, completion: completion)
688+
}
689+
689690
func didTapDismissButton(sender: UIButton) {
690691
Logger.debug("\(TAG) in \(#function)")
691692
self.dismiss(animated: true)

Signal/src/ViewControllers/HomeViewController.m

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ @interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, UI
4747
@property (nonatomic) UISegmentedControl *segmentedControl;
4848
@property (nonatomic) id previewingContext;
4949
@property (nonatomic) NSSet<NSString *> *blockedPhoneNumberSet;
50-
@property (nonatomic) BOOL hasShownAnyUnseenUpgradeExperiences;
5150

5251
@property (nonatomic) BOOL isViewVisible;
5352
@property (nonatomic) BOOL isAppInBackground;
@@ -287,6 +286,13 @@ - (void)viewDidLoad
287286
[self updateBarButtonItems];
288287
}
289288

289+
- (void)viewDidAppear:(BOOL)animated
290+
{
291+
[super viewDidAppear:animated];
292+
293+
[self displayAnyUnseenUpgradeExperience];
294+
}
295+
290296
- (void)updateBarButtonItems
291297
{
292298
const CGFloat kBarButtonSize = 44;
@@ -510,19 +516,6 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
510516
});
511517
}];
512518
}
513-
514-
// We want to show the user the upgrade experience as soon as the app is visible to them.
515-
// It cannot go in viewDidAppear, which is called while the app is in the background if
516-
// we were launched from a voip notification.
517-
if (!self.hasShownAnyUnseenUpgradeExperiences) {
518-
dispatch_async(dispatch_get_main_queue(), ^{
519-
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) {
520-
return;
521-
}
522-
[self displayAnyUnseenUpgradeExperience];
523-
self.hasShownAnyUnseenUpgradeExperiences = YES;
524-
});
525-
}
526519
}
527520

528521
#pragma mark - startup
@@ -532,21 +525,12 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
532525
OWSAssertIsOnMainThread();
533526

534527
__block NSArray<ExperienceUpgrade *> *unseenUpgrades;
535-
[self.editingDbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
528+
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
536529
unseenUpgrades = [ExperienceUpgradeFinder.sharedManager allUnseenWithTransaction:transaction];
537530
}];
538531
return unseenUpgrades;
539532
}
540533

541-
- (void)markAllUpgradeExperiencesAsSeen
542-
{
543-
OWSAssertIsOnMainThread();
544-
545-
[self.editingDbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
546-
[ExperienceUpgradeFinder.sharedManager markAllAsSeenWithTransaction:transaction];
547-
}];
548-
}
549-
550534
- (void)displayAnyUnseenUpgradeExperience
551535
{
552536
OWSAssertIsOnMainThread();
@@ -556,11 +540,7 @@ - (void)displayAnyUnseenUpgradeExperience
556540
if (unseenUpgrades.count > 0) {
557541
ExperienceUpgradesPageViewController *experienceUpgradeViewController =
558542
[[ExperienceUpgradesPageViewController alloc] initWithExperienceUpgrades:unseenUpgrades];
559-
[self presentViewController:experienceUpgradeViewController
560-
animated:YES
561-
completion:^{
562-
[self markAllUpgradeExperiencesAsSeen];
563-
}];
543+
[self presentViewController:experienceUpgradeViewController animated:YES completion:nil];
564544
} else if (!self.hasBeenPresented && [ProfileViewController shouldDisplayProfileViewOnLaunch]) {
565545
[ProfileViewController presentForUpgradeOrNag:self];
566546
} else {

Signal/src/environment/NotificationsManager.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ @interface NotificationsManager ()
2525
@property (nonatomic, readonly) NotificationType notificationPreviewType;
2626

2727
@property (nonatomic, readonly) NSMutableArray<NSDate *> *notificationHistory;
28+
@property (nonatomic, nullable) OWSAudioPlayer *audioPlayer;
2829

2930
@end
3031

@@ -238,7 +239,8 @@ - (void)notifyUserForErrorMessage:(TSErrorMessage *)message inThread:(TSThread *
238239
} else {
239240
if (shouldPlaySound && [Environment.preferences soundInForeground]) {
240241
OWSSound sound = [OWSSounds notificationSoundForThread:thread];
241-
[OWSSounds playSound:sound quiet:YES shouldRespectSilentSwitch:YES];
242+
self.audioPlayer = [OWSSounds audioPlayerForSound:sound];
243+
[self.audioPlayer playAsForegroundAlert];
242244
}
243245
}
244246
});
@@ -343,8 +345,8 @@ - (void)notifyUserForIncomingMessage:(TSIncomingMessage *)message
343345
} else {
344346
if (shouldPlaySound && [Environment.preferences soundInForeground]) {
345347
OWSSound sound = [OWSSounds notificationSoundForThread:thread];
346-
// We play the "quiet" variation of sounds if possible for notifications in the foreground.
347-
[OWSSounds playSound:sound quiet:YES shouldRespectSilentSwitch:YES];
348+
self.audioPlayer = [OWSSounds audioPlayerForSound:sound];
349+
[self.audioPlayer playAsForegroundAlert];
348350
}
349351
}
350352
});

Signal/src/util/Pastelog.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import <SignalMessaging/DebugLogger.h>
1313
#import <SignalMessaging/Environment.h>
1414
#import <SignalServiceKit/AppContext.h>
15+
#import <SignalServiceKit/MimeTypeUtil.h>
1516
#import <SignalServiceKit/OWSPrimaryStorage.h>
1617
#import <SignalServiceKit/TSAccountManager.h>
1718
#import <SignalServiceKit/TSContactThread.h>
@@ -150,6 +151,9 @@ - (void)uploadFileWithUploadUrl:(NSString *)uploadUrl fields:(NSDictionary *)fie
150151
NSString *fieldValue = fields[fieldName];
151152
[formData appendPartWithFormData:[fieldValue dataUsingEncoding:NSUTF8StringEncoding] name:fieldName];
152153
}
154+
[formData appendPartWithFormData:[weakSelf.mimeType dataUsingEncoding:NSUTF8StringEncoding]
155+
name:@"content-type"];
156+
153157
NSError *error;
154158
BOOL success = [formData appendPartWithFileURL:weakSelf.fileUrl
155159
name:@"file"
@@ -168,7 +172,7 @@ - (void)uploadFileWithUploadUrl:(NSString *)uploadUrl fields:(NSDictionary *)fie
168172
[self succeedWithUrl:[NSURL URLWithString:urlString]];
169173
}
170174
failure:^(NSURLSessionDataTask *_Nullable task, NSError *error) {
171-
DDLogError(@"%@ failed: %@", weakSelf.logTag, uploadUrl);
175+
DDLogError(@"%@ upload: %@ failed with error: %@", weakSelf.logTag, uploadUrl, error);
172176
[weakSelf failWithError:error];
173177
}];
174178
}
@@ -427,7 +431,7 @@ - (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)successParam fail
427431
__weak Pastelog *weakSelf = self;
428432
self.currentUploader = [DebugLogUploader new];
429433
[self.currentUploader uploadFileWithURL:[NSURL fileURLWithPath:zipFilePath]
430-
mimeType:@"application/zip"
434+
mimeType:OWSMimeTypeApplicationZip
431435
success:^(DebugLogUploader *uploader, NSURL *url) {
432436
if (uploader != weakSelf.currentUploader) {
433437
// Ignore events from obsolete uploaders.

SignalMessaging/attachments/OWSVideoPlayer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class OWSVideoPlayer: NSObject {
3838
}
3939

4040
public func play() {
41-
OWSAudioSession.shared.setPlaybackCategory(audioActivity: self.audioActivity)
41+
OWSAudioSession.shared.startPlaybackAudioActivity(self.audioActivity)
4242

4343
guard let item = avPlayer.currentItem else {
4444
owsFail("\(logTag) video player item was unexpectedly nil")

SignalMessaging/environment/OWSAudioSession.swift

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,29 @@ public class OWSAudioSession: NSObject {
3333

3434
private var currentActivities: [Weak<AudioActivity>] = []
3535

36-
// Ignores hardware mute switch, plays through external speaker
37-
public func setPlaybackCategory(audioActivity: AudioActivity) {
36+
// Respects hardware mute switch, plays through external speaker, mixes with backround audio
37+
// appropriate for foreground sound effects.
38+
public func startAmbientAudioActivity(_ audioActivity: AudioActivity) {
3839
Logger.debug("\(logTag) in \(#function)")
3940

40-
// In general, we should have put the audio session back to it's default
41-
// category when we were done with whatever activity required it to be modified
42-
assert(avAudioSession.category == AVAudioSessionCategorySoloAmbient)
41+
startAudioActivity(audioActivity)
42+
43+
guard currentActivities.count == 1 else {
44+
// We don't want to clobber the audio capabilities configured by (e.g.) media playback or an in-progress call
45+
Logger.info("\(logTag) in \(#function) not touching audio session since another currentActivity exists.")
46+
return
47+
}
48+
49+
do {
50+
try avAudioSession.setCategory(AVAudioSessionCategoryAmbient)
51+
} catch {
52+
owsFail("\(logTag) in \(#function) failed with error: \(error)")
53+
}
54+
}
55+
56+
// Ignores hardware mute switch, plays through external speaker
57+
public func startPlaybackAudioActivity(_ audioActivity: AudioActivity) {
58+
Logger.debug("\(logTag) in \(#function)")
4359

4460
startAudioActivity(audioActivity)
4561

@@ -50,13 +66,9 @@ public class OWSAudioSession: NSObject {
5066
}
5167
}
5268

53-
public func setRecordCategory(audioActivity: AudioActivity) -> Bool {
69+
public func startRecordingAudioActivity(_ audioActivity: AudioActivity) -> Bool {
5470
Logger.debug("\(logTag) in \(#function)")
5571

56-
// In general, we should have put the audio session back to it's default
57-
// category when we were done with whatever activity required it to be modified
58-
assert(avAudioSession.category == AVAudioSessionCategorySoloAmbient)
59-
6072
assert(avAudioSession.recordPermission() == .granted)
6173

6274
startAudioActivity(audioActivity)
@@ -104,8 +116,6 @@ public class OWSAudioSession: NSObject {
104116
}
105117

106118
do {
107-
try avAudioSession.setCategory(AVAudioSessionCategorySoloAmbient)
108-
109119
// When playing audio in Signal, other apps audio (e.g. Music) is paused.
110120
// By notifying when we deactivate, the other app can resume playback.
111121
try avAudioSession.setActive(false, with: [.notifyOthersOnDeactivation])

0 commit comments

Comments
 (0)