PDRToolSystemEx.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*
  2. *------------------------------------------------------------------
  3. * pandora/tools/PDRToolSystemEx.h.h
  4. * Description:
  5. * 获取设备信息头文件
  6. * DCloud Confidential Proprietary
  7. * Copyright (c) Department of Research and Development/Beijing/DCloud.
  8. * All Rights Reserved.
  9. *
  10. * Changelog:
  11. * number author modify date modify record
  12. * 0 xty 2013-1-10 创建文件
  13. *------------------------------------------------------------------
  14. */
  15. #import <CoreGraphics/CoreGraphics.h>
  16. #import <UIKit/UIKit.h>
  17. #import <QuartzCore/QuartzCore.h>
  18. #import <SystemConfiguration/SystemConfiguration.h>
  19. #import <CoreText/CoreText.h>
  20. #define PT_IsAtLeastiOSVersion(X) ([[[UIDevice currentDevice] systemVersion] compare:X options:NSNumericSearch] != NSOrderedAscending)
  21. #define PT_IsIPad() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad))
  22. /*
  23. **@获取系统时间
  24. */
  25. @interface PTDate : NSObject
  26. +(PTDate*)date;
  27. @property(nonatomic, readonly)NSInteger year;
  28. @property(nonatomic, readonly)SInt8 month;
  29. @property(nonatomic, readonly)SInt8 day;
  30. @property(nonatomic, readonly)SInt8 hour;
  31. @property(nonatomic, readonly)SInt8 minute;
  32. @property(nonatomic, readonly)double sencond;
  33. @property(nonatomic, readonly)double milliseconds;
  34. +(NSDate*)dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
  35. +(NSDate*)dateWithHour:(NSInteger)hour minute:(NSInteger)minute sencond:(NSInteger)sencond;
  36. @end
  37. /*
  38. **@采集网络的相关信息,域名为plus.device
  39. */
  40. typedef NS_ENUM(NSInteger, PTNetType) {
  41. PTNetTypeUnknow = 0,
  42. PTNetTypeNone, // none
  43. PTNetTypeEthernet, // none
  44. PTNetTypeWIFI, // wifi
  45. PTNetTypeCell2G, // 2G
  46. PTNetTypeCell3G, // 3G
  47. PTNetTypeCell4G, // 4G
  48. PTNetTypeWWAN // 2g/3g
  49. };
  50. typedef void (^PTNetInfoNetChangeCallback)(PTNetType newNetType, PTNetType oldNetType);
  51. @interface PTNetInfo : NSObject
  52. @property(nonatomic, readonly)PTNetType netType;
  53. + (instancetype)info;
  54. - (BOOL)startNotifierWithCallback:(SCNetworkReachabilityCallBack)reachabilityCallback;
  55. - (BOOL)startNotifierWithBlock:(PTNetInfoNetChangeCallback)reachabilityCallback;
  56. - (void)stopNotifier;
  57. + (instancetype)reachabilityForInternetConnection;
  58. @end
  59. /*
  60. **@采集手机硬件的相关信息,域名为plus.device
  61. */
  62. @interface PTDeviceInfo : NSObject
  63. //国际移动设备身份码
  64. @property(nonatomic, retain)NSString *IMEI;
  65. //国际移动用户识别码
  66. @property(nonatomic, retain)NSString *IMSI;
  67. //设备型号
  68. @property(nonatomic, retain)NSString *model;
  69. //生产厂商
  70. @property(nonatomic, retain)NSString *vendor;
  71. @property(nonatomic, retain)NSString *UUID;
  72. //移动网络国家类型,Mobile Country Code
  73. @property(nonatomic, retain)NSString *mcc;
  74. //"运营商代号,Mobile Country Code"
  75. @property(nonatomic, retain)NSString *mnc;
  76. @property(nonatomic, retain)NSString *mac;
  77. +(PTDeviceInfo*)deviceInfo;
  78. + (NSString*)openUUID;
  79. + (NSString*)uniqueAppInstanceIdentifier;
  80. @end
  81. typedef NS_ENUM(NSInteger, PTSystemVersion) {
  82. PTSystemVersion5Series = 0,
  83. PTSystemVersion6Series,
  84. PTSystemVersion7Series,
  85. PTSystemVersion8Series,
  86. PTSystemVersion9Series,
  87. PTSystemVersion10Series,
  88. PTSystemVersion11Series,
  89. PTSystemVersionUnknown
  90. };
  91. typedef NS_ENUM(NSInteger, PTDeviceType) {
  92. PTDeviceTypeiPhoneSimulator,
  93. PTDeviceTypeiPhone3G,
  94. PTDeviceTypeiPhone3GS,
  95. PTDeviceTypeiPhone4,
  96. PTDeviceTypeiPhone4s,
  97. PTDeviceTypeiPhone5,
  98. PTDeviceTypeiPhone5c,
  99. PTDeviceTypeiPhone5s,
  100. PTDeviceTypeiPhone6,
  101. PTDeviceTypeiPhone6Plus,
  102. PTDeviceTypeiPhone6s,
  103. PTDeviceTypeiPhone6sPlus,
  104. PTDeviceTypeiPhone7,
  105. PTDeviceTypeiPhone7Plus,
  106. PTDeviceTypeiPhone8,
  107. PTDeviceTypeiPhone8Plus,
  108. PTDeviceTypeiPhoneX,
  109. PTDeviceTypeiPhoneXR,
  110. PTDeviceTypeiPhoneXS,
  111. PTDeviceTypeiPhoneXSMax,
  112. PTDeviceTypeiPhoneSE,
  113. PTDeviceTypeiPod3G,
  114. PTDeviceTypeiPod4G,
  115. PTDeviceTypeiPod5G,
  116. PTDeviceTypeiPad5,
  117. PTDeviceTypeiPad6,
  118. PTDeviceTypeiPadPro,
  119. PTDeviceTypeiPadAir2,
  120. PTDeviceTypeiPadAir,
  121. PTDeviceTypeNewiPad,
  122. PTDeviceTypeiPad3,
  123. PTDeviceTypeiPad2,
  124. PTDeviceTypeiPad1,
  125. PTDeviceTypeiPadMini4,
  126. PTDeviceTypeiPadMini3,
  127. PTDeviceTypeiPadMini2,
  128. PTDeviceTypeiPadMini1,
  129. PTDeviceTypeiAppleTV,
  130. PTDeviceTypeiUnknown
  131. };
  132. /*
  133. **@采集手机操作系统的相关信息,域名为plus.os
  134. */
  135. @interface PTDeviceOSInfo : NSObject
  136. //操作系统语言
  137. @property(nonatomic, retain)NSString *language;
  138. //操作系统版本号
  139. @property(nonatomic, retain)NSString *version;
  140. //操作系统名称
  141. @property(nonatomic, retain)NSString *name;
  142. //操作系统提供商
  143. @property(nonatomic, retain)NSString *vendor;
  144. +(NSString*)deviceUtsname;
  145. + (NSString*)getPreferredLanguage;
  146. + (PTDeviceOSInfo*)osInfo;
  147. + (PTSystemVersion)systemVersion;
  148. + (PTDeviceType)deviceType;
  149. + (NSString*)deviceTypeInString;
  150. + (NSString*)cuntryCode;
  151. + (BOOL)is7Series;
  152. + (BOOL)is6Series;
  153. + (BOOL)is5Series;
  154. + (BOOL)isIpad;
  155. @end
  156. /*
  157. **@采集手机自身屏幕的相关分辨率等信息,域名为plus.screen
  158. */
  159. @interface PTDeviceScreenInfo : NSObject
  160. //屏幕高度
  161. @property(nonatomic, assign)CGFloat resolutionHeight;
  162. //屏幕宽度
  163. @property(nonatomic, assign)CGFloat resolutionWidth;
  164. //屏幕物理高度
  165. @property(nonatomic, assign)CGFloat height;
  166. //屏幕物理宽度
  167. @property(nonatomic, assign)CGFloat width;
  168. //X方向上的密度
  169. @property(nonatomic, assign)CGFloat dpiX;
  170. //Y方向上的密度
  171. @property(nonatomic, assign)CGFloat dpiY;
  172. @property(nonatomic, assign)CGFloat scale;
  173. +(PTDeviceScreenInfo*)screenInfo;
  174. @end
  175. /*
  176. **@采集手机自身屏幕的相关分辨率等信息,域名为plus.screen
  177. */
  178. @interface PTDeviceDisplayInfo : NSObject
  179. //应用可用区域
  180. @property (nonatomic, assign)CGRect displayRect;
  181. //应用可用高度
  182. @property(nonatomic, assign)CGFloat resolutionHeight;
  183. //应用可用宽度
  184. @property(nonatomic, assign)CGFloat resolutionWidth;
  185. - (CGRect)displayRect;
  186. +(PTDeviceDisplayInfo*)displayInfo;
  187. +(PTDeviceDisplayInfo*)displayInfoWith:(UIInterfaceOrientation)orientation;
  188. @end
  189. @interface PTDevice : NSObject
  190. {
  191. PTDeviceInfo *_deviceInfo;
  192. PTDeviceOSInfo *_osInfo;
  193. PTDeviceScreenInfo *_screenInfo;
  194. PTDeviceDisplayInfo *_displayInfo;
  195. PTNetInfo *_netInfo;
  196. }
  197. +(PTDevice*)sharedDevice;
  198. -(void)update;
  199. @property(nonatomic, retain)PTDeviceInfo *deviceInfo;
  200. @property(nonatomic, retain)PTDeviceOSInfo *osInfo;
  201. @property(nonatomic, retain)PTDeviceScreenInfo *screenInfo;
  202. @property(nonatomic, retain)PTDeviceDisplayInfo *displayInfo;
  203. /*@property(nonatomic, retain)PTNetInfo *netInfo;*/
  204. +(long long)getAvailableMemorySize;
  205. +(long long)getUseMemorySize;
  206. + (void)setDeviceInterfaceOrientation:(UIInterfaceOrientation)orientation;
  207. @end
  208. @interface NSString(Measure)
  209. - (BOOL)isAlphaNumeric;
  210. - (int)getMeasure:(CGFloat*)aOutValue withStaff:(CGFloat)aStaff;
  211. @end
  212. @interface UIColor(longColor)
  213. -(NSString*)CSSColor:(BOOL)hasAlpha;
  214. +(UIColor*)colorWithLong:(long)colorValue;
  215. +(UIColor*)colorWithCSS:(NSString*)cssColor;
  216. +(CGFloat)alphWithCSS:(NSString*)cssColor;
  217. @end
  218. @interface CAMediaTimingFunction(Util)
  219. +(CAMediaTimingFunction*)curveEnum2Obj:(UIViewAnimationCurve)curve;
  220. @end
  221. @interface PTGIF :NSObject
  222. @property(nonatomic, retain, readonly)NSArray *frames;
  223. @property(nonatomic, retain, readonly)NSArray *delayTimes;
  224. + (instancetype)praseGIFData:(NSData *)data;
  225. + (instancetype)createGifWithFrames:(NSArray *)f withDelayTimes:(NSArray*)delayTimes;
  226. @end
  227. @interface NSDate (DateFormater)
  228. + (NSDate*)dateFromString:(NSString*)dateStr;
  229. + (NSString*)stringFrmeDate:(NSDate*)date;
  230. //根据格式把时间转为字符串(默认使用本地所在时区)
  231. - (NSString *)stringWithFormat:(NSString*)fmt;
  232. @end
  233. typedef NS_ENUM(NSInteger, UIImageCheckImageIsPureWhiteOption) {
  234. UIImageCIWTop22 = 0,//从顶部向下偏移22px横线截屏检测渲染是否完成
  235. UIImageCIWBottom22 = 1,//-从底部向上偏移25px横线检测渲染是否完成
  236. UIImageCIWCenter = 2,//-从中间横线检测渲染是否完成
  237. UIImageCIWAuto = 3,//为全屏检测(左、中、右三条竖线)
  238. UIImageCIWFull = 4 // 为全屏检测
  239. };
  240. //导航图标旋转接口
  241. @interface UIImage(Util)
  242. - (UIImage *)adjustOrientation;
  243. - (UIImage*)adjustOrientationToup;
  244. - (UIImage*)imageRotatedByDegrees:(CGFloat)degrees
  245. supportRetina:(BOOL)support
  246. scale:(CGFloat)scale;
  247. + (UIImage*)screenshot:(UIView*)view clipRect:(CGRect)shotRect;
  248. - (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size;
  249. + (BOOL)checkImageIsPureWhite:(UIImage*)image;
  250. + (NSData*)compressImageData:(NSData*)srcData toMaxSize:(long)maxSize;
  251. + (UIImage*)dcloud_imageWithContentsOfFile:(NSString *)path;
  252. + (BOOL)checkImageIsPureWhite:(UIImage*)image option:(UIImageCheckImageIsPureWhiteOption)option;
  253. @end
  254. @interface NSString (WBRequest)
  255. - (NSString*)urlEncode;
  256. - (NSString *)URLDecodeStringEx;
  257. - (NSString *)URLEncodedStringEx;
  258. - (NSString *)URLDecodedStringWithCFStringEncodingEx:(CFStringEncoding)encoding;
  259. - (NSString *)URLEncodedStringWithCFStringEncodingEx:(CFStringEncoding)encoding;
  260. /**
  261. * 判断字符串中是否有中文,如果有则将中文转码
  262. */
  263. - (NSString *)URLChineseEncode;
  264. - (NSString *)convertToMD5;
  265. - (BOOL)isWebUrlString;
  266. @end
  267. @interface PTTool : NSObject
  268. + (BOOL)setSkipBackupAttribute:(BOOL)skip toItemAtURL:(NSURL*)URL;
  269. + (NSDictionary*)merge:(NSDictionary*)merge to:(NSDictionary*)to;
  270. @end
  271. @interface NSData (AES)
  272. - (NSData *)AESEncryptWithKey:(NSString *)key;
  273. - (NSData *)AESEncryptWithKey128:(NSString *)key;
  274. - (NSData *)AESDecryptWithKey:(NSString *)key;
  275. - (NSData *)AESDecryptWithKey128:(NSString *)key;
  276. + (NSData *)compressData:(NSData*)uncompressedData;
  277. - (NSData *)compressData:(NSData*)uncompressedData;
  278. @end
  279. typedef NS_ENUM(NSInteger, H5CoreToolDirection) {
  280. H5CoreToolDirectionDown,
  281. H5CoreToolDirectionUp,
  282. H5CoreToolDirectionLeft,
  283. H5CoreToolDirectionRight,
  284. H5CoreToolDirectionUnknown
  285. };
  286. extern NSString *kDCCoreToolFontMetaKeyName;
  287. extern NSString *kDCCoreToolFontMetaKeyTraits;
  288. @interface H5CoreTool : NSObject
  289. + (NSString*)dynamicLoadFont:(NSString*)fontFilePath;
  290. + (NSString*)dynamicLoadFontUseCache:(NSString*)newPath;
  291. + (NSDictionary*)dynamicLoadFontMeta:(NSString*)fontFilePath;
  292. + (NSDictionary*)dynamicLoadFontMetaUseCache:(NSString*)newPath;
  293. + (H5CoreToolDirection)determineDirection:(CGPoint)translation;
  294. + (void)getLocationTestAuthentication:(BOOL)testAuthentication withReslutBlock:(void(^)(NSDictionary*, NSError*))block;
  295. @end
  296. @interface H5TextCheck :NSObject
  297. + (BOOL)isTelephone:(NSString*)value;
  298. + (BOOL)isEmail:(NSString*)value;
  299. @end
  300. @interface UIFont(H5Tool)
  301. +(CGFloat)piexl2Size:(CGFloat)piexl;
  302. @end
  303. @interface NSArray(DCAdd)
  304. -(BOOL)dc_containsStringCaseInsensitive:(NSString*)testString;
  305. @end
  306. typedef NS_ENUM(NSInteger, PDRCoreAppSSLActive) {
  307. PDRCoreAppSSLActiveAllow = 0,
  308. PDRCoreAppSSLActiveWarning,
  309. PDRCoreAppSSLActiveRefuse
  310. };
  311. @interface NSObject(DCFlgs)
  312. - (void)dc_destoryFlgs;
  313. - (void)dc_mask_set:(int)flg;
  314. - (BOOL)dc_mask_test:(int)flg;
  315. - (void)dc_mask_clear:(int)flg;
  316. - (void)dc_mask2_set:(int)flg;
  317. - (BOOL)dc_mask2_test:(int)flg;
  318. - (void)dc_mask2_clear:(int)flg;
  319. + (void)dc_mask:(NSUInteger)store clear:(int)flg;
  320. + (BOOL)dc_mask:(NSUInteger)store test:(int)flg;
  321. + (void)dc_mask:(NSUInteger)store set:(int)flg;
  322. @end
  323. #ifdef __cplusplus
  324. extern "C" {
  325. #endif
  326. int PT_Parse_GetMeasurement( NSObject* aMeasure, CGFloat aStaff, CGFloat * aOutMeasureValue );
  327. CGSize DCT_CGSizeSwap(CGSize);
  328. CGRect DCT_CGRectEdgeInsets(CGRect, UIEdgeInsets);
  329. CGRect tDCT_CGRectEdgeInsets(CGRect, UIEdgeInsets,CGFloat);
  330. CGRect jDCT_CGRectEdgeInsets(CGRect, CGFloat,CGFloat);
  331. #ifdef __cplusplus
  332. }
  333. #endif