From b61b389c216591e498c37723f1502dd76d08a9f0 Mon Sep 17 00:00:00 2001 From: Jerome Morissard Date: Sat, 23 Jan 2016 22:40:06 +0100 Subject: [PATCH] Update DeviceModels and remove PowerInformations --- iAppInfos.podspec | 4 +- .../iAppInfos/iAppInfos/JMODevicePowerInfos.h | 26 -- .../iAppInfos/iAppInfos/JMODevicePowerInfos.m | 347 ------------------ .../iAppInfos/iAppInfos/UIDevice+iAppInfos.h | 73 +--- .../iAppInfos/iAppInfos/UIDevice+iAppInfos.m | 260 +++++++------ iAppInfos/iAppInfos/iAppInfos/iAppInfos.h | 1 - iAppInfos/iAppInfos/iAppInfos/iAppInfos.m | 21 +- 7 files changed, 153 insertions(+), 579 deletions(-) delete mode 100644 iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.h delete mode 100644 iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.m diff --git a/iAppInfos.podspec b/iAppInfos.podspec index d835128..01bccb8 100644 --- a/iAppInfos.podspec +++ b/iAppInfos.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'iAppInfos' - s.version = '0.2.1' + s.version = '0.3' s.requires_arc = true s.author = { 'Morissard Jérome' => 'morissardj@gmail.com' @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/leverdeterre/iAppInfos' s.source = { :git => 'https://github.com/leverdeterre/iAppInfos.git', - :tag => "0.2.1" + :tag => "0.3" } s.source_files = 'iAppInfos/iAppInfos/iAppInfos/*' s.frameworks = 'CoreTelephony', 'UIKit' diff --git a/iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.h b/iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.h deleted file mode 100644 index 65de1fc..0000000 --- a/iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// JMODevicePowerInfos.h -// iAppInfos -// -// Created by Jerome Morissard on 1/19/14. -// Copyright (c) 2014 Jerome Morissard. All rights reserved. -// - -#import - -@interface JMODevicePowerInfos : NSObject - -@property (strong, nonatomic) NSString *systemOnChip; -@property (strong, nonatomic) NSString *deviceModel; -@property (strong, nonatomic) NSString *cpu; -@property (strong, nonatomic) NSString *gpu; -@property (assign, nonatomic) NSUInteger futuremarkScore; //http://community.futuremark.com/hardware/mobile/ -@property (assign, nonatomic) NSUInteger geekbenchScore; //http://browser.primatelabs.com/ios-benchmarks -@property (assign, nonatomic) BOOL retina; -@property (assign, nonatomic, getter = hasGoodGraphicPerformance) BOOL goodPerformance; - -+ (instancetype)infosForDeviceModelNamed:(NSString *)deviceModelName; -+ (void)sortAlldevices; -- (BOOL)hasGoodGraphicPerformance; - -@end \ No newline at end of file diff --git a/iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.m b/iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.m deleted file mode 100644 index 54bc887..0000000 --- a/iAppInfos/iAppInfos/iAppInfos/JMODevicePowerInfos.m +++ /dev/null @@ -1,347 +0,0 @@ -// -// JMODevicePowerInfos.m -// iAppInfos -// -// Created by Jerome Morissard on 1/19/14. -// Copyright (c) 2014 Jerome Morissard. All rights reserved. -// - - -#define jmoiPadLimitOfBadPerformaceFuturemark 2500.0f //treshold base on realScore (futuremark) -#define jmoiPadLimitOfBadPerformaceGeekbench 400.0f //treshold base on realScore (geekBench) - -#define jmoiPhoneLimitOfBadPerformaceFuturemark 200.0f //treshold base on realScore (futuremark) -#define jmoiPhoneLimitOfBadPerformaceGeekbench 100.0f //treshold base on realScore (geekBench) - -#define jmoUndefinedScore -1 - -#import "JMODevicePowerInfos.h" -#import "UIDevice+iAppInfos.h" -#import "JMOLogMacro.h" - -@implementation JMODevicePowerInfos - -- (instancetype)init -{ - self = [super init]; - if (self) { - _futuremarkScore = jmoUndefinedScore; - _geekbenchScore = jmoUndefinedScore; - _retina = (BOOL)([UIScreen mainScreen].scale == 2.0f); - } - - return self; -} - -+ (instancetype)infosForDeviceModelNamed:(NSString *)deviceModelName -{ - JMODevicePowerInfos *infos = [[JMODevicePowerInfos alloc] init]; - infos.deviceModel = deviceModelName; - - if ([deviceModelName isEqualToString:UIDeviceModeliPodTouch1G] ) { - infos.systemOnChip = @"Samsung S5L8900"; - infos.cpu = @"ARM1176JZ(F)-S v1.0"; - infos.gpu = @"PowerVR MBX Lite"; - infos.futuremarkScore = 120; - infos.geekbenchScore = 75; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone1G] ) { - infos.systemOnChip = @"Samsung S5L8900"; - infos.cpu = @"ARM1176JZ(F)-S v1.0"; - infos.gpu = @"PowerVR MBX Lite"; - infos.futuremarkScore = 120; - infos.geekbenchScore = 75; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone3G] ) { - infos.systemOnChip = @"Samsung S5L8720"; - infos.gpu = @"PowerVR MBX Lite"; - infos.futuremarkScore = 120; //in theory iphone 3GS is 2.5% faster - infos.geekbenchScore = 75; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPodTouch2G] ) { - infos.systemOnChip = @"Samsung S5L8720"; - infos.cpu = @"ARM1176JZ(F)-S v1.0"; - infos.gpu = @"PowerVR MBX Lite"; - infos.futuremarkScore = 120; - infos.geekbenchScore = 75; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone3GS] ) { - infos.systemOnChip = @"Samsung S5PC100"; - infos.cpu = @"ARM Cortex-A8"; - infos.gpu = @"PowerVR SGX535"; - infos.futuremarkScore = 300; //in theory iphone 4 is 35% faster - infos.geekbenchScore = 149; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPodTouch3G] ) { - infos.systemOnChip = @"Samsung S5PC100"; - infos.cpu = @"ARM Cortex-A8"; - infos.gpu = @"PowerVR SGX535"; - infos.futuremarkScore = 300; - infos.geekbenchScore = 149; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPad]) { - infos.systemOnChip = @"Apple A4"; - infos.cpu = @"ARM Cortex-A8"; - infos.gpu = @"PowerVR SGX535"; - infos.futuremarkScore = 1434; //in theory ipad2/2 - infos.geekbenchScore = 200; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone4] || - [deviceModelName isEqualToString:UIDeviceModelVerizoniPhone4] ) { - infos.systemOnChip = @"Apple A4"; - infos.cpu = @"ARM Cortex-A8"; - infos.gpu = @"PowerVR SGX535"; - infos.futuremarkScore = 488; - infos.geekbenchScore = 210; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPodTouch4G] ) { - infos.systemOnChip = @"Apple A4"; - infos.cpu = @"ARM Cortex-A8"; - infos.gpu = @"PowerVR SGX535"; - infos.futuremarkScore = 488; - infos.geekbenchScore = 209; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPad2_Wifi] || - [deviceModelName isEqualToString:UIDeviceModeliPad2_GSM] || - [deviceModelName isEqualToString:UIDeviceModeliPad2_CDMA] || - [deviceModelName isEqualToString:UIDeviceModeliPad2]) { - infos.systemOnChip = @"Apple A5"; - infos.cpu = @"ARM Cortex-A9"; - infos.gpu = @"PowerVR SGX543MP2"; - infos.futuremarkScore = 2868; - infos.geekbenchScore = 490; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone4S] ) { - infos.systemOnChip = @"Apple A5"; - infos.cpu = @"ARM Cortex-A9"; - infos.gpu = @"PowerVR SGX543MP2"; - infos.futuremarkScore = 2330; - infos.geekbenchScore = 406; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPad3G_Wifi] || - [deviceModelName isEqualToString:UIDeviceModeliPad3G_4G] || - [deviceModelName isEqualToString:UIDeviceModeliPad3G_4G]) { - //http://community.futuremark.com/hardware/mobile/Apple+iPad+3/review - infos.systemOnChip = @"Apple A5"; - infos.cpu = @"Apple A5X"; - infos.gpu = @"PowerVR SGX543MP4"; - infos.futuremarkScore = 4209; - infos.geekbenchScore = 493; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone5_GSM] || - [deviceModelName isEqualToString:UIDeviceModeliPhone5_GSM_CDMA] ) { - infos.systemOnChip = @"Apple A6"; - infos.cpu = @"Swift (Apple-designed)"; - infos.gpu = @"PowerVR SGX543MP3"; - infos.futuremarkScore = 5689; - infos.geekbenchScore = 1279; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPodTouch5G] ) { - infos.systemOnChip = @"Apple A5"; - infos.cpu = @"ARM Cortex-A9"; - infos.gpu = @"PowerVR SGX543MP2"; - infos.futuremarkScore = 2316; - infos.geekbenchScore = 410; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPad4G_Wifi] || - [deviceModelName isEqualToString:UIDeviceModeliPad4G_GSM] || - [deviceModelName isEqualToString:UIDeviceModeliPad4G_GSM_CDMA]) { - infos.systemOnChip = @"Apple A6X"; - infos.cpu = @"Swift (Apple-designed)"; - infos.gpu = @"PowerVR SGX554MP4"; - infos.futuremarkScore = 9615; - infos.geekbenchScore = 1409; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPadMini1G_Wifi] || - [deviceModelName isEqualToString:UIDeviceModeliPadMini1G_GSM] || - [deviceModelName isEqualToString:UIDeviceModeliPadMini1G_GSM_CDMA]) { - infos.systemOnChip = @"Apple A5"; - infos.cpu = @"ARM Cortex-A9"; - infos.gpu = @"PowerVR SGX543MP2"; - infos.futuremarkScore = 2847; - infos.geekbenchScore = 492; - infos.retina = NO; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone5C_GSM] || - [deviceModelName isEqualToString:UIDeviceModeliPhone5C_Global] ) { - infos.systemOnChip = @"Apple A6"; - infos.cpu = @"Swift (Apple-designed)"; - infos.gpu = @"PowerVR SGX543MP3"; - infos.futuremarkScore = 5851; - infos.geekbenchScore = 1248; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPhone5S_GSM] || - [deviceModelName isEqualToString:UIDeviceModeliPhone5S_Global] ) { - infos.systemOnChip = @"Apple A7"; - infos.cpu = @"Cyclone (Apple-designed)"; - infos.gpu = @"PowerVR G6430"; - infos.futuremarkScore = 9615*2; //in theory ipad4*2 - infos.geekbenchScore = 2488; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPadMiniRetina2G_Wifi] || - [deviceModelName isEqualToString:UIDeviceModeliPadMiniRetina2G_Cellular] ) { - infos.systemOnChip = @"Apple A7"; - infos.cpu = @"Cyclone (Apple-designed)"; - infos.gpu = @"PowerVR G6430"; - infos.futuremarkScore = 9615*2; //in theory ipad4*2 - infos.geekbenchScore = 2390; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPadAir_Wifi] || - [deviceModelName isEqualToString:UIDeviceModeliPadAir_Cellular] ) { - infos.systemOnChip = @"Apple A7"; - infos.cpu = @"Cyclone (Apple-designed)"; - infos.gpu = @"PowerVR G6430"; - infos.futuremarkScore = 9615*2; //in theory ipad4*2 - infos.geekbenchScore = 2594; - infos.retina = YES; - } - - else if ([deviceModelName isEqualToString:UIDeviceModeliPadAir_4GCellular]) { - infos.systemOnChip = @"Apple A7"; - infos.cpu = @"Cyclone (Apple-designed)"; - infos.gpu = @"PowerVR G6430"; - infos.futuremarkScore = 9615*2; //in theory == UIDeviceModeliPadAir_Wifi - infos.geekbenchScore = 2594; - infos.retina = YES; - } - else if ([deviceModelName isEqualToString:UIDeviceModeliPadMiniRetina4G_Cellular] ) { - infos.systemOnChip = @"Apple A7"; - infos.cpu = @"Cyclone (Apple-designed)"; - infos.gpu = @"PowerVR G6430"; - infos.futuremarkScore = 9615*2; //in theory == UIDeviceModeliPadAir_Wifi - infos.geekbenchScore = 2390; - infos.retina = YES; - } - - return infos; -} - -- (BOOL)hasGoodGraphicPerformance -{ - //Return YES for hasGoodGraphicPerformance for unknow device (new devices are suppose to be better ...) - if (self.futuremarkScore == jmoUndefinedScore || self.geekbenchScore == jmoUndefinedScore ) { - return YES; - } - - if ([self.deviceModel rangeOfString:@"Simulator"].location != NSNotFound) { - return YES; - } - else if ([self.deviceModel rangeOfString:@"iPad"].location != NSNotFound) { - if ([self realScore] < jmoiPadLimitOfBadPerformaceGeekbench) { - return NO; - } - } - else if ([self.deviceModel rangeOfString:@"iPhone"].location != NSNotFound) { - if ([self realScore] < jmoiPadLimitOfBadPerformaceGeekbench) { - return NO; - } - } - else if ([self.deviceModel rangeOfString:@"iPod"].location != NSNotFound) { - if ([self realScore] < jmoiPadLimitOfBadPerformaceGeekbench) { - return NO; - } - } - - return YES; -} - -#pragma mark - - -- (CGFloat)realScore -{ - return [self geekbenchScoreCorrected]; -} - -- (CGFloat)futuremarkScoreCorrected -{ - CGFloat retinaCost = 2.0f; - if (self.retina) { - return ((CGFloat)self.futuremarkScore/retinaCost); - } - return (CGFloat)self.futuremarkScore; -} - -- (CGFloat)geekbenchScoreCorrected -{ - CGFloat retinaCost = 2.0f; - if (self.retina) { - return ((CGFloat)self.self.geekbenchScore/retinaCost); - } - return (CGFloat)self.self.geekbenchScore; -} - -#pragma mark - - -+ (void)sortAlldevices -{ - //IPADS - JMOLog(@"IPADS "); - - NSArray *alliPadDevices = @[UIDeviceModeliPad,UIDeviceModeliPad2_Wifi,UIDeviceModeliPad3G_Wifi,UIDeviceModeliPad4G_Wifi,UIDeviceModeliPadMini1G_Wifi,UIDeviceModeliPadMiniRetina2G_Wifi,UIDeviceModeliPadAir_Wifi]; - NSMutableArray *arrayOfDeviceInfos = [NSMutableArray new]; - for (NSString *deviceName in alliPadDevices) { - [arrayOfDeviceInfos addObject:[self.class infosForDeviceModelNamed:deviceName]]; - } - - NSArray *iPadSorted = [arrayOfDeviceInfos sortedArrayWithOptions:NSSortStable usingComparator:^NSComparisonResult(JMODevicePowerInfos *obj1, JMODevicePowerInfos *obj2) { - if ([obj1 realScore] > [obj2 realScore] ) { - return NSOrderedAscending; - } - else if ([obj2 realScore] > [obj1 realScore] ) { - return NSOrderedDescending; - } - return NSOrderedSame; - }]; - - int i = 1; - for (JMODevicePowerInfos *info in iPadSorted) { - NSLog(@"%d\t%@ %f",i, info.deviceModel, [info realScore]); - i++; - } - - //IPHONES - JMOLog(@"IPHONES "); - - NSArray *alliPhoneDevices = @[UIDeviceModeliPhone1G,UIDeviceModeliPhone3G, UIDeviceModeliPhone3GS,UIDeviceModeliPhone4,UIDeviceModeliPhone4S, UIDeviceModeliPhone5_GSM,UIDeviceModeliPhone5C_GSM,UIDeviceModeliPhone5S_GSM ]; - arrayOfDeviceInfos = [NSMutableArray new]; - for (NSString *deviceName in alliPhoneDevices) { - [arrayOfDeviceInfos addObject:[self.class infosForDeviceModelNamed:deviceName]]; - } - - NSArray *iphoneSorted = [arrayOfDeviceInfos sortedArrayWithOptions:NSSortStable usingComparator:^NSComparisonResult(JMODevicePowerInfos *obj1, JMODevicePowerInfos *obj2) { - if ([obj1 realScore] > [obj2 realScore] ) { - return NSOrderedAscending; - } - else if ([obj2 realScore] > [obj1 realScore] ) { - return NSOrderedDescending; - } - return NSOrderedSame; - }]; - - i = 1; - for (JMODevicePowerInfos *info in iphoneSorted) { - NSLog(@"%d\t%@ %f",i, info.deviceModel, [info realScore]); - i++; - } - -} - -@end diff --git a/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.h b/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.h index 0e12373..bddb3ec 100644 --- a/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.h +++ b/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.h @@ -8,61 +8,6 @@ #import -extern NSString * const UIDeviceModeliPhone1G; -extern NSString * const UIDeviceModeliPhone3G; -extern NSString * const UIDeviceModeliPhone3GS; - -extern NSString * const UIDeviceModeliPhone4; -extern NSString * const UIDeviceModelVerizoniPhone4; -extern NSString * const UIDeviceModeliPhone4S; - -extern NSString * const UIDeviceModeliPhone5_GSM; -extern NSString * const UIDeviceModeliPhone5_GSM_CDMA; -extern NSString * const UIDeviceModeliPhone5C_GSM; -extern NSString * const UIDeviceModeliPhone5C_Global; - -extern NSString * const UIDeviceModeliPhone5S_GSM; -extern NSString * const UIDeviceModeliPhone5S_Global; - -extern NSString * const UIDeviceModeliPhone6; -extern NSString * const UIDeviceModeliPhone6Plus; - -extern NSString * const UIDeviceModeliPodTouch1G; -extern NSString * const UIDeviceModeliPodTouch2G; -extern NSString * const UIDeviceModeliPodTouch3G; -extern NSString * const UIDeviceModeliPodTouch4G; -extern NSString * const UIDeviceModeliPodTouch5G; - -extern NSString * const UIDeviceModeliPad; -extern NSString * const UIDeviceModeliPad2_Wifi; -extern NSString * const UIDeviceModeliPad2_GSM; -extern NSString * const UIDeviceModeliPad2_CDMA; -extern NSString * const UIDeviceModeliPad2; -extern NSString * const UIDeviceModeliPad3G_Wifi; -extern NSString * const UIDeviceModeliPad3G_4G; -extern NSString * const UIDeviceModeliPad4G_Wifi; -extern NSString * const UIDeviceModeliPad4G_GSM; -extern NSString * const UIDeviceModeliPad4G_GSM_CDMA; - -extern NSString * const UIDeviceModeliPadMini1G_Wifi; -extern NSString * const UIDeviceModeliPadMini1G_GSM; -extern NSString * const UIDeviceModeliPadMini1G_GSM_CDMA; -extern NSString * const UIDeviceModeliPadMiniRetina2G_Wifi; -extern NSString * const UIDeviceModeliPadMiniRetina2G_Cellular; -extern NSString * const UIDeviceModeliPadAir_Wifi; -extern NSString * const UIDeviceModeliPadAir_Cellular; -extern NSString * const UIDeviceModeliPadAir_4GCellular; -extern NSString * const UIDeviceModeliPadMiniRetina4G_Cellular; - -extern NSString * const UIDeviceModeliPadAir2_Wifi; -extern NSString * const UIDeviceModeliPadAir2_Cellular; -extern NSString * const UIDeviceModeliPadMiniRetina3_Wifi; -extern NSString * const UIDeviceModeliPadMiniRetina3_Cellular; - -extern NSString * const UIDeviceModelSimulatorI386; -extern NSString * const UIDeviceModelSimulatorX86_64; -extern NSString * const UIDeviceModelSimulator; - typedef NS_ENUM(NSInteger, UIDeviceModelType) { UIDeviceModelTypeiPhone, UIDeviceModelTypeiPod, @@ -70,28 +15,28 @@ typedef NS_ENUM(NSInteger, UIDeviceModelType) { UIDeviceModelTypeSimulator }; -@class JMODevicePowerInfos; @interface UIDevice (iAppInfos) /** - * jmo_modelName give a more explicit name of the device model + * jmo_modelName give the exact mobile device model name (iPhone 4 (GSM),iPhone 4 (GSM / 2012), etc..) * - * @return NSString, a better device model name + * @return NSString, a device model name */ + (NSString *)jmo_modelName; /** - * Whether the device is an iPod, iPhone, or iPad. If it is not explicitly any of those, - * the device is assumed to be a simulator. + * jmo_familyModelName give the family model name (iPhone 4,5,6,6S) * - * @return UIDeviceModelType + * @return NSString, a family model name */ -+ (UIDeviceModelType)jmo_deviceModelType; ++ (NSString *)jmo_familyModelName; /** + * Whether the device is an iPod, iPhone, or iPad. If it is not explicitly any of those, + * the device is assumed to be a simulator. * - * @return JMODevicePowerInfos object + * @return UIDeviceModelType */ -+ (JMODevicePowerInfos *)jmo_devicePowerInfos; ++ (UIDeviceModelType)jmo_deviceModelType; @end diff --git a/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.m b/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.m index da186aa..355049d 100644 --- a/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.m +++ b/iAppInfos/iAppInfos/iAppInfos/UIDevice+iAppInfos.m @@ -7,66 +7,9 @@ // #import "UIDevice+iAppInfos.h" -#import "JMODevicePowerInfos.h" #include -NSString * const UIDeviceModeliPhone1G = @"iPhone 1G"; -NSString * const UIDeviceModeliPhone3G = @"iPhone 3G"; -NSString * const UIDeviceModeliPhone3GS = @"iPhone 3GS"; - -NSString * const UIDeviceModeliPhone4 = @"iPhone 4"; -NSString * const UIDeviceModelVerizoniPhone4 = @"Verizon iPhone 4"; -NSString * const UIDeviceModeliPhone4S = @"iPhone 4S"; - -NSString * const UIDeviceModeliPhone5_GSM = @"iPhone 5 (GSM)"; -NSString * const UIDeviceModeliPhone5_GSM_CDMA = @"iPhone 5 (GSM+CDMA)"; -NSString * const UIDeviceModeliPhone5C_GSM = @"iPhone 5C (GSM)"; -NSString * const UIDeviceModeliPhone5C_Global = @"iPhone 5C (Global)"; - -NSString * const UIDeviceModeliPhone5S_GSM = @"iPhone 5S (GSM)"; -NSString * const UIDeviceModeliPhone5S_Global = @"iPhone 5S (Global)"; - -NSString * const UIDeviceModeliPhone6 = @"iPhone 6"; -NSString * const UIDeviceModeliPhone6Plus = @"iPhone 6 Plus"; - -NSString * const UIDeviceModeliPodTouch1G = @"iPod Touch 1G"; -NSString * const UIDeviceModeliPodTouch2G = @"iPod Touch 2G"; -NSString * const UIDeviceModeliPodTouch3G = @"iPod Touch 3G"; -NSString * const UIDeviceModeliPodTouch4G = @"iPod Touch 4G"; -NSString * const UIDeviceModeliPodTouch5G = @"iPod Touch 5G"; - -NSString * const UIDeviceModeliPad = @"iPad"; -NSString * const UIDeviceModeliPad2_Wifi = @"iPad 2 (WiFi)"; -NSString * const UIDeviceModeliPad2_GSM = @"iPad 2 (GSM)"; -NSString * const UIDeviceModeliPad2_CDMA = @"iPad 2 (CDMA)"; -NSString * const UIDeviceModeliPad2 = @"iPad 2"; -NSString * const UIDeviceModeliPad3G_Wifi = @"iPad-3G (WiFi)"; -NSString * const UIDeviceModeliPad3G_4G = @"iPad-3G (4G)"; -NSString * const UIDeviceModeliPad4G_Wifi = @"iPad-4G (WiFi)"; -NSString * const UIDeviceModeliPad4G_GSM = @"iPad-4G (GSM)"; -NSString * const UIDeviceModeliPad4G_GSM_CDMA = @"iPad-4G (GSM+CDMA)"; - -NSString * const UIDeviceModeliPadMini1G_Wifi = @"iPad mini-1G (WiFi)"; -NSString * const UIDeviceModeliPadMini1G_GSM = @"iPad mini-1G (GSM)"; -NSString * const UIDeviceModeliPadMini1G_GSM_CDMA = @"iPad mini-1G (GSM+CDMA)"; -NSString * const UIDeviceModeliPadMiniRetina2G_Wifi = @"iPad mini 2G Retina (WiFi)"; -NSString * const UIDeviceModeliPadMiniRetina2G_Cellular = @"iPad mini 2G Retina (Cellular)"; -NSString * const UIDeviceModeliPadAir_Wifi = @"iPad Air (WiFi)"; -NSString * const UIDeviceModeliPadAir_Cellular = @"iPad Air (Cellular)"; -NSString * const UIDeviceModeliPadAir_4GCellular = @"iPad Air (4G)"; -NSString * const UIDeviceModeliPadMiniRetina4G_Cellular = @"iPad mini (4G)"; - -NSString * const UIDeviceModeliPadAir2_Wifi = @"iPad Air 2 (WiFi)"; -NSString * const UIDeviceModeliPadAir2_Cellular = @"iPad Air 2 (Cellular)"; -NSString * const UIDeviceModeliPadMiniRetina3_Wifi = @"iPad mini 3 Retina (Wifi)"; -NSString * const UIDeviceModeliPadMiniRetina3_Cellular = @"iPad mini 3 Retina (Cellular)"; - -NSString * const UIDeviceModelSimulatorI386 = @"iPhone Simulator (i386)"; -NSString * const UIDeviceModelSimulatorX86_64 = @"iPhone Simulator (x86_64)"; -NSString * const UIDeviceModelSimulator = @"iPhone Simulator"; - - @implementation UIDevice (iAppInfos) + (NSString *) jmo_getSysInfo @@ -86,83 +29,156 @@ + (NSString *) jmo_getSysInfo + (NSString *)jmo_modelName { NSString *systInfo = [self jmo_getSysInfo]; - if ([systInfo isEqualToString:@"iPhone1,1"]) return UIDeviceModeliPhone1G; - if ([systInfo isEqualToString:@"iPhone1,2"]) return UIDeviceModeliPhone3G; - if ([systInfo isEqualToString:@"iPhone2,1"]) return UIDeviceModeliPhone3GS; - if ([systInfo isEqualToString:@"iPhone3,1"]) return UIDeviceModeliPhone4; - if ([systInfo isEqualToString:@"iPhone3,2"]) return UIDeviceModeliPhone4; - if ([systInfo isEqualToString:@"iPhone3,3"]) return UIDeviceModelVerizoniPhone4; - if ([systInfo isEqualToString:@"iPhone4,1"]) return UIDeviceModeliPhone4S; - if ([systInfo isEqualToString:@"iPhone5,1"]) return UIDeviceModeliPhone5_GSM; - if ([systInfo isEqualToString:@"iPhone5,2"]) return UIDeviceModeliPhone5_GSM_CDMA; - if ([systInfo isEqualToString:@"iPhone5,3"]) return UIDeviceModeliPhone5C_GSM; - if ([systInfo isEqualToString:@"iPhone5,4"]) return UIDeviceModeliPhone5C_Global; - if ([systInfo isEqualToString:@"iPhone6,1"]) return UIDeviceModeliPhone5S_GSM; - if ([systInfo isEqualToString:@"iPhone6,2"]) return UIDeviceModeliPhone5S_Global; - if ([systInfo isEqualToString:@"iPhone7,1"]) return UIDeviceModeliPhone6Plus; - if ([systInfo isEqualToString:@"iPhone7,2"]) return UIDeviceModeliPhone6; - - if ([systInfo isEqualToString:@"iPod1,1"]) return UIDeviceModeliPodTouch1G; - if ([systInfo isEqualToString:@"iPod2,1"]) return UIDeviceModeliPodTouch2G; - if ([systInfo isEqualToString:@"iPod3,1"]) return UIDeviceModeliPodTouch3G; - if ([systInfo isEqualToString:@"iPod4,1"]) return UIDeviceModeliPodTouch4G; - if ([systInfo isEqualToString:@"iPod5,1"]) return UIDeviceModeliPodTouch5G; - - if ([systInfo isEqualToString:@"iPad1,1"]) return UIDeviceModeliPad; - if ([systInfo isEqualToString:@"iPad2,1"]) return UIDeviceModeliPad2_Wifi; - if ([systInfo isEqualToString:@"iPad2,2"]) return UIDeviceModeliPad2_GSM; - if ([systInfo isEqualToString:@"iPad2,3"]) return UIDeviceModeliPad2_CDMA; - if ([systInfo isEqualToString:@"iPad2,4"]) return UIDeviceModeliPad2; - if ([systInfo isEqualToString:@"iPad2,5"]) return UIDeviceModeliPadMini1G_Wifi; - if ([systInfo isEqualToString:@"iPad2,6"]) return UIDeviceModeliPadMini1G_GSM; - if ([systInfo isEqualToString:@"iPad2,7"]) return UIDeviceModeliPadMini1G_GSM_CDMA; - if ([systInfo isEqualToString:@"iPad3,1"]) return UIDeviceModeliPad3G_Wifi; - if ([systInfo isEqualToString:@"iPad3,2"]) return UIDeviceModeliPad3G_4G; - if ([systInfo isEqualToString:@"iPad3,3"]) return UIDeviceModeliPad3G_4G; - if ([systInfo isEqualToString:@"iPad3,4"]) return UIDeviceModeliPad4G_Wifi; - if ([systInfo isEqualToString:@"iPad3,5"]) return UIDeviceModeliPad4G_GSM; - if ([systInfo isEqualToString:@"iPad3,6"]) return UIDeviceModeliPad4G_GSM_CDMA; - if ([systInfo isEqualToString:@"iPad4,1"]) return UIDeviceModeliPadAir_Wifi; - if ([systInfo isEqualToString:@"iPad4,2"]) return UIDeviceModeliPadAir_Cellular; - if ([systInfo isEqualToString:@"iPad4,3"]) return UIDeviceModeliPadAir_4GCellular; - if ([systInfo isEqualToString:@"iPad4,4"]) return UIDeviceModeliPadMiniRetina2G_Wifi; - if ([systInfo isEqualToString:@"iPad4,5"]) return UIDeviceModeliPadMiniRetina2G_Cellular; - if ([systInfo isEqualToString:@"iPad4,6"]) return UIDeviceModeliPadMiniRetina4G_Cellular; - - if ([systInfo isEqualToString:@"iPad4,7"]) return UIDeviceModeliPadMiniRetina3_Wifi; - if ([systInfo isEqualToString:@"iPad4,8"]) return UIDeviceModeliPadMiniRetina3_Cellular; - if ([systInfo isEqualToString:@"iPad4,9"]) return UIDeviceModeliPadMiniRetina3_Cellular; - if ([systInfo isEqualToString:@"iPad5,3"]) return UIDeviceModeliPadAir2_Wifi; - if ([systInfo isEqualToString:@"iPad5,4"]) return UIDeviceModeliPadAir2_Cellular; - - if ([systInfo isEqualToString:@"i386"]) return UIDeviceModelSimulator; - if ([systInfo isEqualToString:@"x86_64"]) return UIDeviceModelSimulator; + + if ([systInfo isEqualToString:@"iPhone1,1"]) return @"iPhone 2G"; + if ([systInfo isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; + if ([systInfo isEqualToString:@"iPhone2,1"]) return @"iPhone 3G[S]"; + if ([systInfo isEqualToString:@"iPhone3,1"]) return @"iPhone 4 (GSM)"; + if ([systInfo isEqualToString:@"iPhone3,2"]) return @"iPhone 4 (GSM / 2012)"; + if ([systInfo isEqualToString:@"iPhone3,3"]) return @"iPhone 4 (CDMA)"; + if ([systInfo isEqualToString:@"iPhone4,1"]) return @"iPhone 4[S]"; + if ([systInfo isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)"; + if ([systInfo isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (Global)"; + if ([systInfo isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)"; + if ([systInfo isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (Global)"; + if ([systInfo isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)"; + if ([systInfo isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (Global)"; + if ([systInfo isEqualToString:@"iPhone7,1"]) return @"iPhone 6+"; + if ([systInfo isEqualToString:@"iPhone7,2"]) return @"iPhone 6"; + if ([systInfo isEqualToString:@"iPhone8,1"]) return @"iPhone 6s"; + if ([systInfo isEqualToString:@"iPhone8,2"]) return @"iPhone 6s+"; + + if ([systInfo isEqualToString:@"iPod1,1"]) return @"iPod touch 1G"; + if ([systInfo isEqualToString:@"iPod2,1"]) return @"iPod touch 2G"; + if ([systInfo isEqualToString:@"iPod3,1"]) return @"iPod touch 3"; + if ([systInfo isEqualToString:@"iPod4,1"]) return @"iPod touch 4"; + if ([systInfo isEqualToString:@"iPod5,1"]) return @"iPod touch 5"; + if ([systInfo isEqualToString:@"iPod7,1"]) return @"iPod touch 6"; + + if ([systInfo isEqualToString:@"iPad1,1"]) return @"iPad 1"; + if ([systInfo isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)"; + if ([systInfo isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)"; + if ([systInfo isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)"; + if ([systInfo isEqualToString:@"iPad2,4"]) return @"iPad 2 (Mid 2012)"; + if ([systInfo isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)"; + if ([systInfo isEqualToString:@"iPad2,6"]) return @"iPad Mini (GSM)"; + if ([systInfo isEqualToString:@"iPad2,7"]) return @"iPad Mini (Global)"; + + if ([systInfo isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)"; + if ([systInfo isEqualToString:@"iPad3,2"]) return @"iPad 3 (CDMA)"; + if ([systInfo isEqualToString:@"iPad3,3"]) return @"iPad 3 (GSM)"; + if ([systInfo isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)"; + if ([systInfo isEqualToString:@"iPad3,5"]) return @"iPad 4 (GSM)"; + if ([systInfo isEqualToString:@"iPad3,6"]) return @"iPad 4 (Global)"; + + if ([systInfo isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)"; + if ([systInfo isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)"; + if ([systInfo isEqualToString:@"iPad4,3"]) return @"iPad Air (China)"; + if ([systInfo isEqualToString:@"iPad4,4"]) return @"iPad Mini 2 (WiFi)"; + if ([systInfo isEqualToString:@"iPad4,5"]) return @"iPad Mini 2 (Cellular)"; + if ([systInfo isEqualToString:@"iPad4,6"]) return @"iPad Mini 2 (China)";; + if ([systInfo isEqualToString:@"iPad4,7"]) return @"iPad Mini 3 (WiFi)";; + if ([systInfo isEqualToString:@"iPad4,8"]) return @"iPad Mini 3 (Cellular)"; + if ([systInfo isEqualToString:@"iPad4,9"]) return @"iPad Mini 3 (China)"; + + if ([systInfo isEqualToString:@"iPad5,1"]) return @"iPad Mini 4 (WiFi)"; + if ([systInfo isEqualToString:@"iPad5,2"]) return @"iPad Mini 4 (Cellular)"; + if ([systInfo isEqualToString:@"iPad5,3"]) return @"iPad Air 2 (WiFi)"; + if ([systInfo isEqualToString:@"iPad5,4"]) return @"iPad Air 2 (Cellular)"; + + if ([systInfo isEqualToString:@"iPad6,7"]) return @"iPad Pro (WiFi)"; + if ([systInfo isEqualToString:@"iPad6,8"]) return @"iPad Pro (Cellular)"; + + if ([systInfo isEqualToString:@"i386"]) return @"iPhone Simulator"; + if ([systInfo isEqualToString:@"x86_64"]) return @"iPhone Simulator"; + + return systInfo; +} + ++ (NSString *)jmo_familyModelName +{ + NSString *systInfo = [self jmo_getSysInfo]; + + if ([systInfo isEqualToString:@"iPhone1,1"]) return @"iPhone 2G"; + if ([systInfo isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; + if ([systInfo isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS"; + if ([systInfo isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; + if ([systInfo isEqualToString:@"iPhone3,2"]) return @"iPhone 4"; + if ([systInfo isEqualToString:@"iPhone3,3"]) return @"iPhone 4"; + if ([systInfo isEqualToString:@"iPhone4,1"]) return @"iPhone 4S"; + if ([systInfo isEqualToString:@"iPhone5,1"]) return @"iPhone 5"; + if ([systInfo isEqualToString:@"iPhone5,2"]) return @"iPhone 5"; + if ([systInfo isEqualToString:@"iPhone5,3"]) return @"iPhone 5c"; + if ([systInfo isEqualToString:@"iPhone5,4"]) return @"iPhone 5c"; + if ([systInfo isEqualToString:@"iPhone6,1"]) return @"iPhone 5s"; + if ([systInfo isEqualToString:@"iPhone6,2"]) return @"iPhone 5s"; + if ([systInfo isEqualToString:@"iPhone7,1"]) return @"iPhone 6+"; + if ([systInfo isEqualToString:@"iPhone7,2"]) return @"iPhone 6"; + if ([systInfo isEqualToString:@"iPhone8,1"]) return @"iPhone 6s"; + if ([systInfo isEqualToString:@"iPhone8,2"]) return @"iPhone 6s+"; + + if ([systInfo isEqualToString:@"iPod1,1"]) return @"iPod touch 1G"; + if ([systInfo isEqualToString:@"iPod2,1"]) return @"iPod touch 2G"; + if ([systInfo isEqualToString:@"iPod3,1"]) return @"iPod touch 3"; + if ([systInfo isEqualToString:@"iPod4,1"]) return @"iPod touch 4"; + if ([systInfo isEqualToString:@"iPod5,1"]) return @"iPod touch 5"; + if ([systInfo isEqualToString:@"iPod7,1"]) return @"iPod touch 6"; + + if ([systInfo isEqualToString:@"iPad1,1"]) return @"iPad 1"; + if ([systInfo isEqualToString:@"iPad2,1"]) return @"iPad 2"; + if ([systInfo isEqualToString:@"iPad2,2"]) return @"iPad 2"; + if ([systInfo isEqualToString:@"iPad2,3"]) return @"iPad 2"; + if ([systInfo isEqualToString:@"iPad2,4"]) return @"iPad 2"; + if ([systInfo isEqualToString:@"iPad2,5"]) return @"iPad Mini"; + if ([systInfo isEqualToString:@"iPad2,6"]) return @"iPad Mini"; + if ([systInfo isEqualToString:@"iPad2,7"]) return @"iPad Mini"; + + if ([systInfo isEqualToString:@"iPad3,1"]) return @"iPad 3"; + if ([systInfo isEqualToString:@"iPad3,2"]) return @"iPad 3"; + if ([systInfo isEqualToString:@"iPad3,3"]) return @"iPad 3"; + if ([systInfo isEqualToString:@"iPad3,4"]) return @"iPad 4"; + if ([systInfo isEqualToString:@"iPad3,5"]) return @"iPad 4"; + if ([systInfo isEqualToString:@"iPad3,6"]) return @"iPad 4"; + + if ([systInfo isEqualToString:@"iPad4,1"]) return @"iPad Air"; + if ([systInfo isEqualToString:@"iPad4,2"]) return @"iPad Air"; + if ([systInfo isEqualToString:@"iPad4,3"]) return @"iPad Air"; + if ([systInfo isEqualToString:@"iPad4,4"]) return @"iPad Mini 2"; + if ([systInfo isEqualToString:@"iPad4,5"]) return @"iPad Mini 2"; + if ([systInfo isEqualToString:@"iPad4,6"]) return @"iPad Mini 2";; + if ([systInfo isEqualToString:@"iPad4,7"]) return @"iPad Mini 3"; + if ([systInfo isEqualToString:@"iPad4,8"]) return @"iPad Mini 3"; + if ([systInfo isEqualToString:@"iPad4,9"]) return @"iPad Mini 3"; + + if ([systInfo isEqualToString:@"iPad5,1"]) return @"iPad Mini 4"; + if ([systInfo isEqualToString:@"iPad5,2"]) return @"iPad Mini 4"; + if ([systInfo isEqualToString:@"iPad5,3"]) return @"iPad Air 2"; + if ([systInfo isEqualToString:@"iPad5,4"]) return @"iPad Air 2"; + + if ([systInfo isEqualToString:@"iPad6,7"]) return @"iPad Pro"; + if ([systInfo isEqualToString:@"iPad6,8"]) return @"iPad Pro"; + + if ([systInfo isEqualToString:@"i386"]) return @"iPhone Simulator"; + if ([systInfo isEqualToString:@"x86_64"]) return @"iPhone Simulator"; return systInfo; } -+ (UIDeviceModelType)jmo_deviceModelType { ++ (UIDeviceModelType)jmo_deviceModelType +{ NSString *modelName = [self jmo_modelName]; - if ([modelName isEqualToString:UIDeviceModelSimulator]) { - return UIDeviceModelTypeSimulator; - } - else if ([modelName rangeOfString:@"iPhone"].location != NSNotFound) { + if ([modelName rangeOfString:@"iPhone"].location != NSNotFound) { return UIDeviceModelTypeiPhone; - } - else if ([modelName rangeOfString:@"iPod"].location != NSNotFound) { + + } else if ([modelName rangeOfString:@"iPod"].location != NSNotFound) { return UIDeviceModelTypeiPod; - } - else if ([modelName rangeOfString:@"iPad"].location != NSNotFound) { + + } else if ([modelName rangeOfString:@"iPad"].location != NSNotFound) { return UIDeviceModelTypeiPad; } return UIDeviceModelTypeSimulator; } -+ (JMODevicePowerInfos *)jmo_devicePowerInfos -{ - return [JMODevicePowerInfos infosForDeviceModelNamed:[self jmo_modelName]]; -} - @end diff --git a/iAppInfos/iAppInfos/iAppInfos/iAppInfos.h b/iAppInfos/iAppInfos/iAppInfos/iAppInfos.h index 3e7b8c9..e8cab7b 100644 --- a/iAppInfos/iAppInfos/iAppInfos/iAppInfos.h +++ b/iAppInfos/iAppInfos/iAppInfos/iAppInfos.h @@ -43,7 +43,6 @@ @property (strong, readonly, nonatomic) NSString *operatorName; @property (strong, readonly, nonatomic) NSString *deviceModelName; @property (assign, readonly, nonatomic) UIDeviceModelType deviceModelType; -@property (strong, readonly, nonatomic) JMODevicePowerInfos *devicePowerInfo; @property (strong, readonly, nonatomic) NSString *compilationSDK; @property (strong, readonly, nonatomic) NSString *freeDiskSpace; @property (assign, readonly, nonatomic) NSInteger batteryLevel; //in pourcent diff --git a/iAppInfos/iAppInfos/iAppInfos/iAppInfos.m b/iAppInfos/iAppInfos/iAppInfos/iAppInfos.m index 25e834c..f358733 100644 --- a/iAppInfos/iAppInfos/iAppInfos/iAppInfos.m +++ b/iAppInfos/iAppInfos/iAppInfos/iAppInfos.m @@ -10,7 +10,6 @@ #import "UIApplication+iAppInfos.h" #import "NSDictionary+iAppInfos.h" -#import "JMODevicePowerInfos.h" #import "mach/mach.h" #import @@ -136,11 +135,6 @@ - (UIDeviceModelType)deviceModelType return [UIDevice jmo_deviceModelType]; } -- (JMODevicePowerInfos *)devicePowerInfo -{ - return [UIDevice jmo_devicePowerInfos]; -} - - (NSString *)compilationSDK { return [UIApplication jmo_iOSSDKVersion]; @@ -282,18 +276,11 @@ - (id)infoForKey:(NSString *)key else if ([key isEqualToString:AppVersionManagerKeyMemoryUseByApp]) { unsigned long memoryUseByApp = memoryUsedByApp(); return @(memoryUseByApp/(1024 * 1024)); - } - else if ([key isEqualToString:AppVersionManagerKeyOperator]) { + + } else if ([key isEqualToString:AppVersionManagerKeyOperator]) { return [self operatorName]; - } - else if ([key isEqualToString:AppVersionManagerKeyGraphicalPerformance]) { - JMODevicePowerInfos *graphInfo = [JMODevicePowerInfos infosForDeviceModelNamed:[UIDevice jmo_modelName]]; - if ([graphInfo hasGoodGraphicPerformance]) { - return @"YES"; - } - return @"NO"; - } - else { + + } else { id obj = [self.customValues objectForKey:key]; if (nil != obj) { return obj;