Skip to content

Commit

Permalink
Don't release CTTelephonyNetworkInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisliu committed Oct 29, 2014
1 parent 1ac90fe commit 5155539
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions DeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
@interface DeviceInfo ()
@end

@implementation DeviceInfo
@implementation DeviceInfo {
NSObject* networkInfo;
}

@synthesize versionName = _versionName;
@synthesize buildVersionRelease = _buildVersionRelease;
Expand All @@ -25,6 +27,7 @@ @implementation DeviceInfo




-(id) init {
self = [super init];
return self;
Expand Down Expand Up @@ -61,17 +64,16 @@ -(NSString*) phoneCarrier {
SEL subscriberCellularProvider = NSSelectorFromString(@"subscriberCellularProvider");
SEL carrierName = NSSelectorFromString(@"carrierName");
if (CTTelephonyNetworkInfo && subscriberCellularProvider && carrierName) {
NSObject *info = [[NSClassFromString(@"CTTelephonyNetworkInfo") alloc] init];
id (*imp1)(id, SEL) = (id (*)(id, SEL))[info methodForSelector:subscriberCellularProvider];
id carrier;
networkInfo = [[NSClassFromString(@"CTTelephonyNetworkInfo") alloc] init];
id carrier = nil;
id (*imp1)(id, SEL) = (id (*)(id, SEL))[networkInfo methodForSelector:subscriberCellularProvider];
if (imp1) {
carrier = imp1(info, subscriberCellularProvider);
carrier = imp1(networkInfo, subscriberCellularProvider);
}
NSString* (*imp2)(id, SEL) = (NSString* (*)(id, SEL))[carrier methodForSelector:carrierName];
if (imp2) {
_phoneCarrier = imp2(carrier, carrierName);
}
SAFE_ARC_RELEASE(info);
}
}
return _phoneCarrier;
Expand Down Expand Up @@ -125,22 +127,20 @@ + (NSString*)getAdvertiserID:(int) maxAttempts
Class ASIdentifierManager = NSClassFromString(@"ASIdentifierManager");
SEL sharedManager = NSSelectorFromString(@"sharedManager");
SEL advertisingIdentifier = NSSelectorFromString(@"advertisingIdentifier");
SEL UUIDString = NSSelectorFromString(@"UUIDString");
if (ASIdentifierManager && sharedManager && advertisingIdentifier && UUIDString) {
if (ASIdentifierManager && sharedManager && advertisingIdentifier) {
id (*imp1)(id, SEL) = (id (*)(id, SEL))[ASIdentifierManager methodForSelector:sharedManager];
id manager;
id adid;
NSString* identifier;
id manager = nil;
NSUUID *adid = nil;
NSString *identifier = nil;
if (imp1) {
manager = imp1(ASIdentifierManager, sharedManager);
}
id (*imp2)(id, SEL) = (id (*)(id, SEL))[manager methodForSelector:advertisingIdentifier];
NSUUID* (*imp2)(id, SEL) = (NSUUID* (*)(id, SEL))[manager methodForSelector:advertisingIdentifier];
if (imp2) {
adid = imp2(manager, advertisingIdentifier);
}
NSString* (*imp3)(id, SEL) = (NSString* (*)(id, SEL))[adid methodForSelector:UUIDString];
if (imp3) {
identifier = imp3(adid, UUIDString);
if (adid) {
identifier = [adid UUIDString];
}
if (identifier == nil && maxAttempts > 0) {
// Try again every 5 seconds
Expand Down Expand Up @@ -181,7 +181,7 @@ - (NSString*)generateUUID
return result;
}

+ (NSString *)getPlatformString
+ (NSString*)getPlatformString
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
Expand All @@ -192,7 +192,7 @@ + (NSString *)getPlatformString
return platform;
}

+ (NSString *)getPhoneModel{
+ (NSString*)getPhoneModel{
NSString *platform = [self getPlatformString];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
Expand Down

0 comments on commit 5155539

Please sign in to comment.