Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/3.8.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
lumaxis committed Mar 8, 2016
2 parents be28a52 + 2f26dc7 commit 54a09a2
Show file tree
Hide file tree
Showing 196 changed files with 4,505 additions and 4,207 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj merge=union
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ profile
**/.idea/
**/.idea/**

# Infer
**/infer-out

documentation/
Products/
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode7
osx_image: xcode7.2

env:
global:
Expand All @@ -12,16 +12,14 @@ env:
- SCHEME="HockeySDK" DESTINATION="OS=8.4,name=iPhone 6" RUN_TESTS="YES"
- SCHEME="HockeySDK" DESTINATION="OS=9.0,name=iPad Air" RUN_TESTS="YES"
- SCHEME="HockeySDK" DESTINATION="OS=9.0,name=iPhone 6 Plus" RUN_TESTS="YES"
- SCHEME="HockeySDK" DESTINATION="OS=9.1,name=iPad Pro" RUN_TESTS="YES"
- SCHEME="HockeySDK" DESTINATION="OS=9.2,name=iPhone 6s" RUN_TESTS="YES"
- SCHEME="HockeySDK Framework" DESTINATION="platform=iOS Simulator,name=iPhone 6" RUN_TESTS="YES"
- SCHEME="HockeySDK Distribution" RUN_TESTS="NO"

before_install:
- xcrun simctl list
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- brew tap homebrew/versions
- brew install appledoc22
- brew link --force appledoc22

script:
- set -o pipefail
Expand Down
29 changes: 13 additions & 16 deletions Classes/BITAuthenticator.m
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,21 @@ - (void) validateWithCompletion:(void (^)(BOOL validated, NSError *))completion
return;
}

id nsurlsessionClass = NSClassFromString(@"NSURLSessionUploadTask");
BOOL isSessionSupported = (nsurlsessionClass && !bit_isRunningInAppExtension());
[self validateWithCompletion:completion sessionSupported:isSessionSupported];
}

-(void)validateWithCompletion:(void (^)(BOOL validated, NSError *))completion sessionSupported:(BOOL)isSessionSupported {
NSString *validationPath = [NSString stringWithFormat:@"api/3/apps/%@/identity/validate", self.encodedAppIdentifier];

__weak typeof (self) weakSelf = self;
if (isSessionSupported) {
if ([BITHockeyHelper isURLSessionSupported]) {
NSURLRequest *request = [self.hockeyAppClient requestWithMethod:@"GET" path:validationPath parameters:[self validationParameters]];

NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
__block NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];

NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
typeof (self) strongSelf = weakSelf;

[session finishTasksAndInvalidate];

[strongSelf handleValidationResponseWithData:data error:error completion:completion];
}];
[task resume];
Expand Down Expand Up @@ -463,27 +461,25 @@ - (void)authenticationViewController:(UIViewController *)viewController
NSParameterAssert(self.identificationType == BITAuthenticatorIdentificationTypeHockeyAppEmail || (password && password.length));
NSURLRequest* request = [self requestForAuthenticationEmail:email password:password];



id nsurlsessionClass = NSClassFromString(@"NSURLSessionUploadTask");
BOOL isURLSessionSupported = (nsurlsessionClass && !bit_isRunningInAppExtension());
[self authenticationViewController:viewController handleAuthenticationWithEmail:email request:request urlSessionSupported:isURLSessionSupported completion:completion];
[self authenticationViewController:viewController handleAuthenticationWithEmail:email request:request completion:completion];
}

- (void)authenticationViewController:(UIViewController *)viewController
handleAuthenticationWithEmail:(NSString *)email
request:(NSURLRequest *)request
urlSessionSupported:(BOOL)isURLSessionSupported
completion:(void (^)(BOOL, NSError *))completion {
__weak typeof (self) weakSelf = self;
if(isURLSessionSupported) {
if([BITHockeyHelper isURLSessionSupported]) {
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
__block NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];

NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
typeof (self) strongSelf = weakSelf;
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response;

[session finishTasksAndInvalidate];

[strongSelf handleAuthenticationWithResponse:httpResponse email:email data:data completion:completion];
}];
[task resume];
Expand Down Expand Up @@ -803,6 +799,7 @@ - (void)processFullSizeImage {
unsigned char *buffer, *source;
source = (unsigned char *)malloc((unsigned long)fs.st_size);
if (read(fd, source, (unsigned long)fs.st_size) != fs.st_size) {
close(fd);
// Couldn't read file
free(source);
return;
Expand Down
3 changes: 1 addition & 2 deletions Classes/BITAuthenticator_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@

#pragma mark - Testing
- (void) storeInstallationIdentifier:(NSString*) identifier withType:(BITAuthenticatorIdentificationType) type;
- (void)validateWithCompletion:(void (^)(BOOL validated, NSError *))completion sessionSupported:(BOOL)isSessionSupported;
- (void)validateWithCompletion:(void (^)(BOOL validated, NSError *))completion;
- (void)authenticationViewController:(UIViewController *)viewController
handleAuthenticationWithEmail:(NSString *)email
request:(NSURLRequest *)request
urlSessionSupported:(BOOL)isURLSessionSupported
completion:(void (^)(BOOL, NSError *))completion;
- (BOOL) needsValidation;
- (void) authenticate;
Expand Down
2 changes: 2 additions & 0 deletions Classes/BITCrashManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) {
*
* This allows it to get a crash report if the app got killed while being in the foreground
* because of one of the following reasons:
*
* - The main thread was blocked for too long
* - The app took too long to start up
* - The app tried to allocate too much memory. If iOS did send a memory warning before killing the app because of this reason, `didReceiveMemoryWarningInLastSession` returns `YES`.
Expand All @@ -234,6 +235,7 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) {
* - If `enableMachExceptionHandler` is not activated, crashed due to stack overflow will also be reported
*
* The following kills can _NOT_ be detected:
*
* - Terminating the app takes too long
* - Permitted background duration too long for all other cases
* - App failed to resume in time for all other cases
Expand Down
62 changes: 32 additions & 30 deletions Classes/BITCrashManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,27 @@
#define kBITCrashMetaAttachment @"BITCrashMetaAttachment"

// internal keys
NSString *const KBITAttachmentDictIndex = @"index";
NSString *const KBITAttachmentDictAttachment = @"attachment";
static NSString *const KBITAttachmentDictIndex = @"index";
static NSString *const KBITAttachmentDictAttachment = @"attachment";

NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus";
static NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus";

NSString *const kBITAppWentIntoBackgroundSafely = @"BITAppWentIntoBackgroundSafely";
NSString *const kBITAppDidReceiveLowMemoryNotification = @"BITAppDidReceiveLowMemoryNotification";
NSString *const kBITAppMarketingVersion = @"BITAppMarketingVersion";
NSString *const kBITAppVersion = @"BITAppVersion";
NSString *const kBITAppOSVersion = @"BITAppOSVersion";
NSString *const kBITAppOSBuild = @"BITAppOSBuild";
NSString *const kBITAppUUIDs = @"BITAppUUIDs";
static NSString *const kBITAppWentIntoBackgroundSafely = @"BITAppWentIntoBackgroundSafely";
static NSString *const kBITAppDidReceiveLowMemoryNotification = @"BITAppDidReceiveLowMemoryNotification";
static NSString *const kBITAppMarketingVersion = @"BITAppMarketingVersion";
static NSString *const kBITAppVersion = @"BITAppVersion";
static NSString *const kBITAppOSVersion = @"BITAppOSVersion";
static NSString *const kBITAppOSBuild = @"BITAppOSBuild";
static NSString *const kBITAppUUIDs = @"BITAppUUIDs";

NSString *const kBITFakeCrashUUID = @"BITFakeCrashUUID";
NSString *const kBITFakeCrashAppMarketingVersion = @"BITFakeCrashAppMarketingVersion";
NSString *const kBITFakeCrashAppVersion = @"BITFakeCrashAppVersion";
NSString *const kBITFakeCrashAppBundleIdentifier = @"BITFakeCrashAppBundleIdentifier";
NSString *const kBITFakeCrashOSVersion = @"BITFakeCrashOSVersion";
NSString *const kBITFakeCrashDeviceModel = @"BITFakeCrashDeviceModel";
NSString *const kBITFakeCrashAppBinaryUUID = @"BITFakeCrashAppBinaryUUID";
NSString *const kBITFakeCrashReport = @"BITFakeCrashAppString";
static NSString *const kBITFakeCrashUUID = @"BITFakeCrashUUID";
static NSString *const kBITFakeCrashAppMarketingVersion = @"BITFakeCrashAppMarketingVersion";
static NSString *const kBITFakeCrashAppVersion = @"BITFakeCrashAppVersion";
static NSString *const kBITFakeCrashAppBundleIdentifier = @"BITFakeCrashAppBundleIdentifier";
static NSString *const kBITFakeCrashOSVersion = @"BITFakeCrashOSVersion";
static NSString *const kBITFakeCrashDeviceModel = @"BITFakeCrashDeviceModel";
static NSString *const kBITFakeCrashAppBinaryUUID = @"BITFakeCrashAppBinaryUUID";
static NSString *const kBITFakeCrashReport = @"BITFakeCrashAppString";


static BITCrashManagerCallbacks bitCrashCallbacks = {
Expand Down Expand Up @@ -198,9 +198,8 @@ - (instancetype)init {

_crashManagerStatus = BITCrashManagerStatusAlwaysAsk;

NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kBITCrashManagerStatus];
if (testValue) {
_crashManagerStatus = (BITCrashManagerStatus) [[NSUserDefaults standardUserDefaults] integerForKey:kBITCrashManagerStatus];
if ([[NSUserDefaults standardUserDefaults] stringForKey:kBITCrashManagerStatus]) {
_crashManagerStatus = (BITCrashManagerStatus)[[NSUserDefaults standardUserDefaults] integerForKey:kBITCrashManagerStatus];
} else {
// migrate previous setting if available
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"BITCrashAutomaticallySendReports"]) {
Expand Down Expand Up @@ -803,7 +802,6 @@ - (BOOL)handleUserInput:(BITCrashManagerUserInput)userInput withUserProvidedMeta
case BITCrashManagerUserInputAlwaysSend:
_crashManagerStatus = BITCrashManagerStatusAutoSend;
[[NSUserDefaults standardUserDefaults] setInteger:_crashManagerStatus forKey:kBITCrashManagerStatus];
[[NSUserDefaults standardUserDefaults] synchronize];
if ([self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReportsAlways:)]) {
[self.delegate crashManagerWillSendCrashReportsAlways:self];
}
Expand Down Expand Up @@ -1377,6 +1375,7 @@ - (void)sendNextCrashReport {

// we start sending always with the oldest pending one
NSString *filename = [_crashFiles objectAtIndex:0];
NSString *attachmentFilename = filename;
NSString *cacheFilename = [filename lastPathComponent];
NSData *crashData = [NSData dataWithContentsOfFile:filename];

Expand Down Expand Up @@ -1412,6 +1411,8 @@ - (void)sendNextCrashReport {
osVersion = [fakeReportDict objectForKey:kBITFakeCrashOSVersion];

metaFilename = [cacheFilename stringByReplacingOccurrencesOfString:@".fake" withString:@".meta"];
attachmentFilename = [attachmentFilename stringByReplacingOccurrencesOfString:@".fake" withString:@""];

if ([appBundleVersion compare:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedSame) {
_crashIdenticalCurrentVersion = YES;
}
Expand Down Expand Up @@ -1465,13 +1466,13 @@ - (void)sendNextCrashReport {
options:NSPropertyListMutableContainersAndLeaves
format:&format
error:&error];
username = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", cacheFilename, kBITCrashMetaUserName]] ?: @"";
useremail = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", cacheFilename, kBITCrashMetaUserEmail]] ?: @"";
userid = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", cacheFilename, kBITCrashMetaUserID]] ?: @"";

username = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", attachmentFilename.lastPathComponent, kBITCrashMetaUserName]] ?: @"";
useremail = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", attachmentFilename.lastPathComponent, kBITCrashMetaUserEmail]] ?: @"";
userid = [self stringValueFromKeychainForKey:[NSString stringWithFormat:@"%@.%@", attachmentFilename.lastPathComponent, kBITCrashMetaUserID]] ?: @"";
applicationLog = [metaDict objectForKey:kBITCrashMetaApplicationLog] ?: @"";
description = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@.desc", [_crashesDir stringByAppendingPathComponent: cacheFilename]] encoding:NSUTF8StringEncoding error:&error];
attachment = [self attachmentForCrashReport:filename];
attachment = [self attachmentForCrashReport:attachmentFilename];
} else {
BITHockeyLog(@"ERROR: Reading crash meta data. %@", error);
}
Expand Down Expand Up @@ -1661,10 +1662,9 @@ - (void)processUploadResultWithFilename:(NSString *)filename responseData:(NSDat
- (void)sendCrashReportWithFilename:(NSString *)filename xml:(NSString*)xml attachment:(BITHockeyAttachment *)attachment {
BOOL sendingWithURLSession = NO;

id nsurlsessionClass = NSClassFromString(@"NSURLSessionUploadTask");
if (nsurlsessionClass && !bit_isRunningInAppExtension()) {
if ([BITHockeyHelper isURLSessionSupported]) {
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
__block NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];

NSURLRequest *request = [self requestWithBoundary:kBITHockeyAppClientBoundary];
NSData *data = [self postBodyWithXML:xml attachment:attachment boundary:kBITHockeyAppClientBoundary];
Expand All @@ -1676,6 +1676,8 @@ - (void)sendCrashReportWithFilename:(NSString *)filename xml:(NSString*)xml atta
completionHandler:^(NSData *responseData, NSURLResponse *response, NSError *error) {
typeof (self) strongSelf = weakSelf;

[session finishTasksAndInvalidate];

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response;
NSInteger statusCode = [httpResponse statusCode];
[strongSelf processUploadResultWithFilename:filename responseData:responseData statusCode:statusCode error:error];
Expand Down
Loading

0 comments on commit 54a09a2

Please sign in to comment.