From c1c4a288c8df44ee4f9ebe04dacfe3da5ae5ae3e Mon Sep 17 00:00:00 2001 From: chris pan Date: Wed, 16 Mar 2016 13:53:08 -0700 Subject: [PATCH] Facebook iOS SDK 4.10.1 --- FBSDKCoreKit.podspec | 4 +- FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit.h | 2 +- .../AppEvents/FBSDKAppEventsDeviceInfo.m | 284 ++++++++++-------- FBSDKLoginKit.podspec | 4 +- FBSDKShareKit.podspec | 4 +- FBSDKTVOSKit.podspec | 6 +- 6 files changed, 162 insertions(+), 142 deletions(-) diff --git a/FBSDKCoreKit.podspec b/FBSDKCoreKit.podspec index 48aaa9063..0b1fefadc 100644 --- a/FBSDKCoreKit.podspec +++ b/FBSDKCoreKit.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = "FBSDKCoreKit" - s.version = "4.10.0" + s.version = "4.10.1" s.summary = "Official Facebook SDK for iOS to access Facebook Platform's core features" s.description = <<-DESC @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git", - :tag => "sdk-version-4.10.0" + :tag => "sdk-version-4.10.1" } s.ios.weak_frameworks = 'Accounts', 'CoreLocation', 'Social', 'Security', 'QuartzCore', 'CoreGraphics', 'UIKit', 'Foundation', 'AudioToolbox' diff --git a/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit.h b/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit.h index 991dff6ba..9239fb811 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit.h +++ b/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit.h @@ -41,5 +41,5 @@ #import #endif -#define FBSDK_VERSION_STRING @"4.10.0" +#define FBSDK_VERSION_STRING @"4.10.1" #define FBSDK_TARGET_PLATFORM_VERSION @"v2.5" diff --git a/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsDeviceInfo.m b/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsDeviceInfo.m index adf1771a5..7b8b066ae 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsDeviceInfo.m +++ b/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsDeviceInfo.m @@ -41,206 +41,226 @@ static const u_int FB_GROUP1_RECHECK_DURATION = 30 * 60; // seconds static const u_int FB_GIGABYTE = 1024 * 1024 * 1024; // bytes @implementation FBSDKAppEventsDeviceInfo +{ + // Ephemeral data, may change during the lifetime of an app. We collect them in different + // 'group' frequencies - group1 may gets collected once every 30 minutes. -// Ephemeral data, may change during the lifetime of an app. We collect them in different -// 'group' frequencies - group1 may gets collected once every 30 minutes. + // group1 + NSString *_carrierName; + NSString *_timeZoneAbbrev; + unsigned long long _remainingDiskSpaceGB; + NSString *_timeZoneName; -// group1 -NSString *_carrierName; -NSString *_timeZoneAbbrev; -unsigned long long _remainingDiskSpaceGB; + // Persistent data, but we maintain it to make rebuilding the device info as fast as possible. + NSString *_bundleIdentifier; + NSString *_longVersion; + NSString *_shortVersion; + NSString *_sysVersion; + NSString *_machine; + NSString *_language; + unsigned long long _totalDiskSpaceGB; + unsigned long long _coreCount; + CGFloat _width; + CGFloat _height; + CGFloat _density; -// Persistent data, but we maintain it to make rebuilding the device info as fast as possible. -NSString *_bundleIdentifier; -NSString *_longVersion; -NSString *_shortVersion; -NSString *_sysVersion; -NSString *_machine; -NSString *_language; -unsigned long long _totalDiskSpaceGB; -unsigned long long _coreCount; -CGFloat _width; -CGFloat _height; -CGFloat _density; - -// Other state -long _lastGroup1CheckTime; -BOOL _isEncodingDirty = YES; -NSString *_encodedDeviceInfo; -static FBSDKAppEventsDeviceInfo *g_singleton; + // Other state + long _lastGroup1CheckTime; + BOOL _isEncodingDirty; + NSString *_encodedDeviceInfo; +} #pragma mark - Public Methods + (void)extendDictionaryWithDeviceInfo:(NSMutableDictionary *)dictionary { - dictionary[@"extinfo"] = [g_singleton encodedDeviceInfo]; + dictionary[@"extinfo"] = [[self sharedDeviceInfo] encodedDeviceInfo]; } #pragma mark - Internal Methods + (void)initialize { - if (self == [FBSDKAppEventsDeviceInfo class]) { - g_singleton = [[FBSDKAppEventsDeviceInfo alloc] init]; - [g_singleton _collectPersistentData]; - } + if (self == [FBSDKAppEventsDeviceInfo class]) { + [[self sharedDeviceInfo] _collectPersistentData]; + } +} + ++ (instancetype)sharedDeviceInfo +{ + static FBSDKAppEventsDeviceInfo *_sharedDeviceInfo = nil; + if (_sharedDeviceInfo == nil) { + _sharedDeviceInfo = [[FBSDKAppEventsDeviceInfo alloc] init]; + } + return _sharedDeviceInfo; +} + +- (instancetype)init +{ + if ((self = [super init])) { + _isEncodingDirty = YES; + } + return self; } - (NSString *)encodedDeviceInfo { - @synchronized (self) { + @synchronized (self) { - BOOL isGroup1Expired = [self _isGroup1Expired]; - BOOL isEncodingExpired = isGroup1Expired; // Can || other groups in if we add them + BOOL isGroup1Expired = [self _isGroup1Expired]; + BOOL isEncodingExpired = isGroup1Expired; // Can || other groups in if we add them - // As long as group1 hasn't expired, we can just return the last generated value - if (_encodedDeviceInfo && !isEncodingExpired) { - return _encodedDeviceInfo; - } - - if (isGroup1Expired) { - [self _collectGroup1Data]; - } - - if (_isEncodingDirty) { - self.encodedDeviceInfo = [self _generateEncoding]; - _isEncodingDirty = NO; - } - - return _encodedDeviceInfo; + // As long as group1 hasn't expired, we can just return the last generated value + if (_encodedDeviceInfo && !isEncodingExpired) { + return _encodedDeviceInfo; } + + if (isGroup1Expired) { + [self _collectGroup1Data]; + } + + if (_isEncodingDirty) { + self.encodedDeviceInfo = [self _generateEncoding]; + _isEncodingDirty = NO; + } + + return _encodedDeviceInfo; + } } - (void)setEncodedDeviceInfo:(NSString *)encodedDeviceInfo { - @synchronized (self) { - if (![_encodedDeviceInfo isEqualToString:encodedDeviceInfo]) { - _encodedDeviceInfo = [encodedDeviceInfo copy]; - } + @synchronized (self) { + if (![_encodedDeviceInfo isEqualToString:encodedDeviceInfo]) { + _encodedDeviceInfo = [encodedDeviceInfo copy]; } + } } // This data need only be collected once. - (void)_collectPersistentData { - // Bundle stuff - NSBundle *mainBundle = [NSBundle mainBundle]; - _bundleIdentifier = mainBundle.bundleIdentifier; - _longVersion = [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; - _shortVersion = [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; + // Bundle stuff + NSBundle *mainBundle = [NSBundle mainBundle]; + _bundleIdentifier = mainBundle.bundleIdentifier; + _longVersion = [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; + _shortVersion = [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; - // Locale stuff - _language = [[NSLocale currentLocale] localeIdentifier]; + // Locale stuff + _language = [[NSLocale currentLocale] localeIdentifier]; - // Device stuff - UIDevice *device = [UIDevice currentDevice]; - _sysVersion = device.systemVersion; - _coreCount = [FBSDKAppEventsDeviceInfo _coreCount]; + // Device stuff + UIDevice *device = [UIDevice currentDevice]; + _sysVersion = device.systemVersion; + _coreCount = [FBSDKAppEventsDeviceInfo _coreCount]; - UIScreen *sc = [UIScreen mainScreen]; - CGRect sr = sc.bounds; - _width = sr.size.width; - _height = sr.size.height; - _density = sc.scale; + UIScreen *sc = [UIScreen mainScreen]; + CGRect sr = sc.bounds; + _width = sr.size.width; + _height = sr.size.height; + _density = sc.scale; - struct utsname systemInfo; - uname(&systemInfo); - _machine = @(systemInfo.machine); + struct utsname systemInfo; + uname(&systemInfo); + _machine = @(systemInfo.machine); - // Disk space stuff - float totalDiskSpace = [[FBSDKAppEventsDeviceInfo _getTotalDiskSpace] floatValue]; - _totalDiskSpaceGB = (unsigned long long)round(totalDiskSpace / FB_GIGABYTE); + // Disk space stuff + float totalDiskSpace = [[FBSDKAppEventsDeviceInfo _getTotalDiskSpace] floatValue]; + _totalDiskSpaceGB = (unsigned long long)round(totalDiskSpace / FB_GIGABYTE); } - (BOOL)_isGroup1Expired { - return ([FBSDKAppEventsUtility unixTimeNow] - _lastGroup1CheckTime) > FB_GROUP1_RECHECK_DURATION; + return ([FBSDKAppEventsUtility unixTimeNow] - _lastGroup1CheckTime) > FB_GROUP1_RECHECK_DURATION; } // This data is collected only once every GROUP1_RECHECK_DURATION. - (void)_collectGroup1Data { - // Carrier - NSString *newCarrierName = [FBSDKAppEventsDeviceInfo _getCarrier]; - if (![newCarrierName isEqualToString:_carrierName]) { - _carrierName = newCarrierName; - _isEncodingDirty = YES; - } + // Carrier + NSString *newCarrierName = [FBSDKAppEventsDeviceInfo _getCarrier]; + if (![newCarrierName isEqualToString:_carrierName]) { + _carrierName = newCarrierName; + _isEncodingDirty = YES; + } - // Time zone - NSString *newTimeZoneAbbrev = [[NSTimeZone systemTimeZone] abbreviation]; - if (![newTimeZoneAbbrev isEqualToString:_timeZoneAbbrev]) { - _timeZoneAbbrev = newTimeZoneAbbrev; - _isEncodingDirty = YES; - } + // Time zone + NSTimeZone *timeZone = [NSTimeZone systemTimeZone]; + NSString *timeZoneName = timeZone.name; + if (![timeZoneName isEqualToString:_timeZoneName]) { + _timeZoneName = timeZoneName; + _timeZoneAbbrev = timeZone.abbreviation; + _isEncodingDirty = YES; + } - // Remaining disk space - float remainingDiskSpace = [[FBSDKAppEventsDeviceInfo _getRemainingDiskSpace] floatValue]; - unsigned long long newRemainingDiskSpaceGB = (unsigned long long)round(remainingDiskSpace / FB_GIGABYTE); - if (_remainingDiskSpaceGB != newRemainingDiskSpaceGB) { - _remainingDiskSpaceGB = newRemainingDiskSpaceGB; - _isEncodingDirty = YES; - } + // Remaining disk space + float remainingDiskSpace = [[FBSDKAppEventsDeviceInfo _getRemainingDiskSpace] floatValue]; + unsigned long long newRemainingDiskSpaceGB = (unsigned long long)round(remainingDiskSpace / FB_GIGABYTE); + if (_remainingDiskSpaceGB != newRemainingDiskSpaceGB) { + _remainingDiskSpaceGB = newRemainingDiskSpaceGB; + _isEncodingDirty = YES; + } - _lastGroup1CheckTime = [FBSDKAppEventsUtility unixTimeNow]; + _lastGroup1CheckTime = [FBSDKAppEventsUtility unixTimeNow]; } - (NSString *)_generateEncoding { - // Keep a bit of precision on density as it's the most likely to become non-integer. - NSString *densityString = _density ? [NSString stringWithFormat:@"%.02f", _density] : @""; + // Keep a bit of precision on density as it's the most likely to become non-integer. + NSString *densityString = _density ? [NSString stringWithFormat:@"%.02f", _density] : @""; - NSArray *arr = @[ - @"i2", // version - starts with 'i' for iOS, we'll use 'a' for Android - _bundleIdentifier ?: @"", - _longVersion ?: @"", - _shortVersion ?: @"", - _sysVersion ?: @"", - _machine ?: @"", - _language ?: @"", - _timeZoneAbbrev ?: @"", - _carrierName ?: @"", - _width ? @((unsigned long)_width) : @"", - _height ? @((unsigned long)_height) : @"", - densityString, - @(_coreCount) ?: @"", - @(_totalDiskSpaceGB) ?: @"", - @(_remainingDiskSpaceGB) ?: @"", - ]; + NSArray *arr = @[ + @"i2", // version - starts with 'i' for iOS, we'll use 'a' for Android + _bundleIdentifier ?: @"", + _longVersion ?: @"", + _shortVersion ?: @"", + _sysVersion ?: @"", + _machine ?: @"", + _language ?: @"", + _timeZoneAbbrev ?: @"", + _carrierName ?: @"", + _width ? @((unsigned long)_width) : @"", + _height ? @((unsigned long)_height) : @"", + densityString, + @(_coreCount) ?: @"", + @(_totalDiskSpaceGB) ?: @"", + @(_remainingDiskSpaceGB) ?: @"", + _timeZoneName ?: @"" + ]; - return [FBSDKInternalUtility JSONStringForObject:arr error:NULL invalidObjectHandler:NULL]; + return [FBSDKInternalUtility JSONStringForObject:arr error:NULL invalidObjectHandler:NULL]; } #pragma mark - Helper Methods + (NSNumber *)_getTotalDiskSpace { - NSDictionary *attrs = [[[NSFileManager alloc] init] attributesOfFileSystemForPath:NSHomeDirectory() - error:nil]; - return [attrs objectForKey:NSFileSystemSize]; + NSDictionary *attrs = [[[NSFileManager alloc] init] attributesOfFileSystemForPath:NSHomeDirectory() + error:nil]; + return [attrs objectForKey:NSFileSystemSize]; } + (NSNumber *)_getRemainingDiskSpace { - NSDictionary *attrs = [[[NSFileManager alloc] init] attributesOfFileSystemForPath:NSHomeDirectory() - error:nil]; - return [attrs objectForKey:NSFileSystemFreeSize]; + NSDictionary *attrs = [[[NSFileManager alloc] init] attributesOfFileSystemForPath:NSHomeDirectory() + error:nil]; + return [attrs objectForKey:NSFileSystemFreeSize]; } + (uint)_coreCount { - return [FBSDKAppEventsDeviceInfo _readSysCtlUInt:CTL_HW type:HW_AVAILCPU]; + return [FBSDKAppEventsDeviceInfo _readSysCtlUInt:CTL_HW type:HW_AVAILCPU]; } + (uint)_readSysCtlUInt:(int)ctl type:(int)type { - int mib[2] = {ctl, type}; - uint value; - size_t size = sizeof value; - if (0 != sysctl(mib, FB_ARRAY_COUNT(mib), &value, &size, NULL, 0)) { - return 0; - } - return value; + int mib[2] = {ctl, type}; + uint value; + size_t size = sizeof value; + if (0 != sysctl(mib, FB_ARRAY_COUNT(mib), &value, &size, NULL, 0)) { + return 0; + } + return value; } + (NSString *)_getCarrier @@ -248,10 +268,10 @@ static FBSDKAppEventsDeviceInfo *g_singleton; #if TARGET_OS_TV return @"NoCarrier"; #else - // Dynamically load class for this so calling app doesn't need to link framework in. - CTTelephonyNetworkInfo *networkInfo = [[fbsdkdfl_CTTelephonyNetworkInfoClass() alloc] init]; - CTCarrier *carrier = [networkInfo subscriberCellularProvider]; - return [carrier carrierName] ?: @"NoCarrier"; + // Dynamically load class for this so calling app doesn't need to link framework in. + CTTelephonyNetworkInfo *networkInfo = [[fbsdkdfl_CTTelephonyNetworkInfoClass() alloc] init]; + CTCarrier *carrier = [networkInfo subscriberCellularProvider]; + return [carrier carrierName] ?: @"NoCarrier"; #endif } diff --git a/FBSDKLoginKit.podspec b/FBSDKLoginKit.podspec index 01343ec27..2e8bc49e3 100644 --- a/FBSDKLoginKit.podspec +++ b/FBSDKLoginKit.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = "FBSDKLoginKit" - s.version = "4.10.0" + s.version = "4.10.1" s.summary = "Official Facebook SDK for iOS to access Facebook Platform with features like Login, Share and Message Dialog, App Links, and Graph API" s.description = <<-DESC @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = "7.0" s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git", - :tag => "sdk-version-4.10.0" + :tag => "sdk-version-4.10.1" } s.weak_frameworks = "Accounts", "CoreLocation", "Social", "Security", "QuartzCore", "CoreGraphics", "UIKit", "Foundation", "AudioToolbox" diff --git a/FBSDKShareKit.podspec b/FBSDKShareKit.podspec index c303a8f44..4f58d7ad6 100644 --- a/FBSDKShareKit.podspec +++ b/FBSDKShareKit.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = "FBSDKShareKit" - s.version = "4.10.0" + s.version = "4.10.1" s.summary = "Official Facebook SDK for iOS to access Facebook Platform's Sharing Features" s.description = <<-DESC @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git", - :tag => "sdk-version-4.10.0" + :tag => "sdk-version-4.10.1" } s.ios.weak_frameworks = 'Accounts', 'AudioToolbox', 'CoreGraphics', 'CoreLocation', 'Foundation', 'QuartzCore', 'Security', 'Social', 'UIKit' diff --git a/FBSDKTVOSKit.podspec b/FBSDKTVOSKit.podspec index 89642ffa2..fa81f4ff7 100644 --- a/FBSDKTVOSKit.podspec +++ b/FBSDKTVOSKit.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = 'FBSDKTVOSKit' - s.version = '4.10.0' + s.version = '4.10.1' s.summary = 'Official Facebook SDK for tvOS to access Facebook Platform with features like Login and Graph API.' s.description = <<-DESC @@ -20,11 +20,11 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.source = { :git => 'https://github.com/facebook/facebook-ios-sdk.git', - :tag => 'sdk-version-4.10.0' } + :tag => 'sdk-version-4.10.1' } s.source_files = 'FBSDKTVOSKit/FBSDKTVOSKit/**/*.{h,m}' s.public_header_files = 'FBSDKTVOSKit/FBSDKTVOSKit/*.h' s.header_dir = 'FBSDKTVOSKit' - s.dependency 'FBSDKCoreKit', '~> 4.10' + s.dependency 'FBSDKCoreKit', '~> 4.10.1' end