chengyanfang

fix

Showing 26 changed files with 893 additions and 0 deletions
No preview for this file type
This file is too large to display.
  1 +/*
  2 + * Licensed to the Apache Software Foundation (ASF) under one
  3 + * or more contributor license agreements. See the NOTICE file
  4 + * distributed with this work for additional information
  5 + * regarding copyright ownership. The ASF licenses this file
  6 + * to you under the Apache License, Version 2.0 (the
  7 + * "License"); you may not use this file except in compliance
  8 + * with the License. You may obtain a copy of the License at
  9 + *
  10 + * http://www.apache.org/licenses/LICENSE-2.0
  11 + *
  12 + * Unless required by applicable law or agreed to in writing,
  13 + * software distributed under the License is distributed on an
  14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15 + * KIND, either express or implied. See the License for the
  16 + * specific language governing permissions and limitations
  17 + * under the License.
  18 + */
  19 +
  20 +#import <Foundation/Foundation.h>
  21 +
  22 +static NSString *const HTTPDNS_IOS_SDK_VERSION = @"1.17.3";
  23 +
  24 +#import <Foundation/Foundation.h>
  25 +#import "HttpdnsLoggerDelegate.h"
  26 +#import "HttpdnsServiceProvider.h"
  27 +#import "HttpdnsDegradationDelegate.h"
  1 +/*
  2 + * Licensed to the Apache Software Foundation (ASF) under one
  3 + * or more contributor license agreements. See the NOTICE file
  4 + * distributed with this work for additional information
  5 + * regarding copyright ownership. The ASF licenses this file
  6 + * to you under the Apache License, Version 2.0 (the
  7 + * "License"); you may not use this file except in compliance
  8 + * with the License. You may obtain a copy of the License at
  9 + *
  10 + * http://www.apache.org/licenses/LICENSE-2.0
  11 + *
  12 + * Unless required by applicable law or agreed to in writing,
  13 + * software distributed under the License is distributed on an
  14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15 + * KIND, either express or implied. See the License for the
  16 + * specific language governing permissions and limitations
  17 + * under the License.
  18 + */
  19 +
  20 +#ifndef HttpdnsDegradationDelegate_h
  21 +#define HttpdnsDegradationDelegate_h
  22 +
  23 +@protocol HttpDNSDegradationDelegate <NSObject>
  24 +
  25 +- (BOOL)shouldDegradeHTTPDNS:(NSString *)hostName;
  26 +
  27 +@end
  28 +
  29 +#endif /* HttpdnsDegradationDelegate_h */
  1 +//
  2 +// HttpdnsLoggerProtocol.h
  3 +// AlicloudHttpDNS
  4 +//
  5 +// Created by junmo on 2018/12/19.
  6 +// Copyright © 2018年 alibaba-inc.com. All rights reserved.
  7 +//
  8 +
  9 +#ifndef HttpdnsLoggerProtocol_h
  10 +#define HttpdnsLoggerProtocol_h
  11 +
  12 +#import <Foundation/Foundation.h>
  13 +
  14 +@protocol HttpdnsLoggerProtocol <NSObject>
  15 +
  16 +- (void)log:(NSString *)logStr;
  17 +
  18 +@end
  19 +
  20 +#endif /* HttpdnsLoggerProtocol_h */
  1 +/*
  2 + * Licensed to the Apache Software Foundation (ASF) under one
  3 + * or more contributor license agreements. See the NOTICE file
  4 + * distributed with this work for additional information
  5 + * regarding copyright ownership. The ASF licenses this file
  6 + * to you under the Apache License, Version 2.0 (the
  7 + * "License"); you may not use this file except in compliance
  8 + * with the License. You may obtain a copy of the License at
  9 + *
  10 + * http://www.apache.org/licenses/LICENSE-2.0
  11 + *
  12 + * Unless required by applicable law or agreed to in writing,
  13 + * software distributed under the License is distributed on an
  14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15 + * KIND, either express or implied. See the License for the
  16 + * specific language governing permissions and limitations
  17 + * under the License.
  18 + */
  19 +
  20 +#import <Foundation/Foundation.h>
  21 +#import "HttpdnsDegradationDelegate.h"
  22 +#import "HttpdnsLoggerDelegate.h"
  23 +
  24 +#define ALICLOUD_HTTPDNS_DEPRECATED(explain) __attribute__((deprecated(explain)))
  25 +
  26 +@interface HttpDnsService: NSObject
  27 +
  28 +@property (nonatomic, assign, readonly) int accountID;
  29 +@property (nonatomic, copy, readonly) NSString *secretKey;
  30 +@property (nonatomic, weak, setter=setDelegateForDegradationFilter:) id<HttpDNSDegradationDelegate> delegate;
  31 +
  32 +@property (nonatomic, assign) NSTimeInterval timeoutInterval;
  33 +
  34 +- (instancetype)autoInit;
  35 +
  36 +- (instancetype)initWithAccountID:(int)accountID;
  37 +
  38 +/*!
  39 + * @brief 启用鉴权功能的初始化接口
  40 + * @details 初始化、开启鉴权功能,并设置 HTTPDNS 服务 Account ID,鉴权功能对应的 secretKey。
  41 + * 您可以从控制台获取您的 Account ID 、secretKey 信息。
  42 + * 此方法会初始化为单例。
  43 + * @param accountID 您的 HTTPDNS Account ID
  44 + * @param secretKey 鉴权对应的 secretKey
  45 + */
  46 +- (instancetype)initWithAccountID:(int)accountID secretKey:(NSString *)secretKey;
  47 +
  48 +/*!
  49 + * @brief 校正 App 签名时间
  50 + * @param authCurrentTime 用于校正的时间戳,正整数。
  51 + * @details 不进行该操作,将以设备时间为准,为`(NSUInteger)[[NSDate date] timeIntervalSince1970]`。进行该操作后,如果有偏差,每次网络请求都会对设备时间进行矫正。
  52 + * @attention 校正操作在 APP 的一个生命周期内生效,APP 重启后需要重新设置才能重新生效。可以重复设置。
  53 + */
  54 +- (void)setAuthCurrentTime:(NSUInteger)authCurrentTime;
  55 +
  56 ++ (instancetype)sharedInstance;
  57 +
  58 +- (void)setCachedIPEnabled:(BOOL)enable;
  59 +
  60 +- (void)setPreResolveHosts:(NSArray *)hosts;
  61 +
  62 +- (NSString *)getIpByHostAsync:(NSString *)host;
  63 +
  64 +- (NSArray *)getIpsByHostAsync:(NSString *)host;
  65 +
  66 +- (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host;
  67 +
  68 +- (void)setHTTPSRequestEnabled:(BOOL)enable;
  69 +
  70 +- (void)setExpiredIPEnabled:(BOOL)enable;
  71 +
  72 +- (void)setLogEnabled:(BOOL)enable;
  73 +
  74 +- (void)setPreResolveAfterNetworkChanged:(BOOL)enable;
  75 +
  76 +- (void)setIPRankingDatasource:(NSDictionary<NSString *, NSNumber *> *)IPRankingDatasource;
  77 +
  78 +- (void)setLogHandler:(id<HttpdnsLoggerProtocol>)logHandler;
  79 +
  80 +- (NSString *)getSessionId;
  81 +
  82 +- (void)enableIPv6:(BOOL)enable;
  83 +- (NSString *)getIPv6ByHostAsync:(NSString *)host;
  84 +
  85 +@end
  86 +
  87 +@interface HttpDnsService (HttpdnsDeprecated)
  88 +
  89 +- (void)setAccountID:(int)accountID ALICLOUD_HTTPDNS_DEPRECATED("Deprecated in v1.5.2. Use -[HttpDnsService initWithAccountID:] instead.");
  90 +
  91 +@end
  1 +framework module AlicloudHttpDNS {
  2 + umbrella header "AlicloudHttpDNS.h"
  3 +
  4 + export *
  5 + module * { export * }
  6 +}
  1 +//
  2 +// ABSBootingProtection.h
  3 +// AntilockBrakeSystem
  4 +//
  5 +// Created by 地风(ElonChan) on 16/5/16.
  6 +// Copyright © 2016年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +typedef void (^ABSBoolCompletionHandler)(BOOL succeeded, NSError *error);
  12 +typedef void (^ABSRepairBlock)(ABSBoolCompletionHandler completionHandler);
  13 +typedef void (^ABSReportBlock)(NSUInteger crashCounts);
  14 +
  15 +typedef NS_ENUM(NSInteger, ABSBootingProtectionStatus) {
  16 + ABSBootingProtectionStatusNormal, /**< APP 启动正常 */
  17 + ABSBootingProtectionStatusNormalChecking, /**< 正在检测是否会在特定时间内是否会 Crash,注意:检测状态下“连续启动崩溃计数”个数小于或等于上限值 */
  18 + ABSBootingProtectionStatusNeedFix, /**< APP 出现连续启动 Crash,需要采取修复措施 */
  19 + ABSBootingProtectionStatusFixing, /**< APP 出现连续启动 Crash,正在修复中... */
  20 +};
  21 +
  22 +/**
  23 + * 启动连续 crash 保护。
  24 + * 启动后 `_crashOnLaunchTimeIntervalThreshold` 秒内 crash,反复超过 `_continuousCrashOnLaunchNeedToReport` 次则上报日志,超过 `_continuousCrashOnLaunchNeedToFix` 则启动修复操作。
  25 + */
  26 +@interface ABSBootingProtection : NSObject
  27 +
  28 +/**
  29 + * 启动连续 crash 保护方法。
  30 + * 前置条件:在 App 启动时注册 crash 处理函数,在 crash 时调用[ABSBootingProtection addCrashCountIfNeeded]。
  31 + * 启动后一定时间内(`crashOnLaunchTimeIntervalThreshold`秒内)crash,反复超过一定次数(`continuousCrashOnLaunchNeedToReport`次)则上报日志,超过一定次数(`continuousCrashOnLaunchNeedToFix`次)则启动修复程序;在一定时间内(`crashOnLaunchTimeIntervalThreshold`秒) 秒后若没有 crash 将“连续启动崩溃计数”计数置零。
  32 + `reportBlock` 上报逻辑,
  33 + `repairtBlock` 修复逻辑,完成后执行 `[self setCrashCount:0]`
  34 +
  35 + */
  36 +- (void)launchContinuousCrashProtect;
  37 +
  38 +/*!
  39 + * 当前启动Crash的状态
  40 + */
  41 +@property (nonatomic, assign, readonly) ABSBootingProtectionStatus bootingProtectionStatus;
  42 +
  43 +/*!
  44 + * 达到需要执行上报操作的“连续启动崩溃计数”个数。
  45 + */
  46 +@property (nonatomic, assign, readonly) NSUInteger continuousCrashOnLaunchNeedToReport;
  47 +
  48 +/*!
  49 + * 达到需要执行修复操作的“连续启动崩溃计数”个数。
  50 + */
  51 +@property (nonatomic, assign, readonly) NSUInteger continuousCrashOnLaunchNeedToFix;
  52 +
  53 +/*!
  54 + * APP 启动后经过多少秒,可以将“连续启动崩溃计数”清零
  55 + */
  56 +@property (nonatomic, assign, readonly) NSTimeInterval crashOnLaunchTimeIntervalThreshold;
  57 +
  58 +/*!
  59 + * 借助 context 可以让多个模块注册事件,并且事件 block 能独立执行,互不干扰。
  60 + */
  61 +@property (nonatomic, copy, readonly) NSString *context;
  62 +
  63 +/*!
  64 + * @details 启动后kCrashOnLaunchTimeIntervalThreshold秒内crash,反复超过continuousCrashOnLaunchNeedToReport次则上报日志,超过continuousCrashOnLaunchNeedToFix则启动修复程序;当所有操作完成后,执行 completion。在 crashOnLaunchTimeIntervalThreshold 秒后若没有 crash 将 kContinuousCrashOnLaunchCounterKey 计数置零。
  65 + * @param context 借助 context 可以让多个模块注册事件,并且事件 block 能独立执行,互不干扰。
  66 + */
  67 +- (instancetype)initWithContinuousCrashOnLaunchNeedToReport:(NSUInteger)continuousCrashOnLaunchNeedToReport
  68 + continuousCrashOnLaunchNeedToFix:(NSUInteger)continuousCrashOnLaunchNeedToFix
  69 + crashOnLaunchTimeIntervalThreshold:(NSTimeInterval)crashOnLaunchTimeIntervalThreshold
  70 + context:(NSString *)context;
  71 +/*!
  72 + * 当前“连续启动崩溃“的状态
  73 + */
  74 ++ (ABSBootingProtectionStatus)bootingProtectionStatusWithContext:(NSString *)context continuousCrashOnLaunchNeedToFix:(NSUInteger)continuousCrashOnLaunchNeedToFix;
  75 +
  76 +/*!
  77 + * 设置上报逻辑,参数 crashCounts 为启动连续 crash 次数
  78 + */
  79 +- (void)setReportBlock:(ABSReportBlock)reportBlock;
  80 +
  81 +/*!
  82 + * 设置修复逻辑
  83 + */
  84 +- (void)setRepairBlock:(ABSRepairBlock)repairtBlock;
  85 +
  86 +@end
  1 +//
  2 +// ABSUncaughtExceptionHandler.h
  3 +// AntilockBrakeSystem
  4 +//
  5 +// Created by 地风(ElonChan) on 16/5/16.
  6 +// Copyright © 2016年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +typedef void (^ABSUncaughtExceptionCallback)(NSException *exception);
  11 +
  12 +@interface ABSUncaughtExceptionHandler : NSObject
  13 +
  14 ++ (void)registerExceptionHandlerWithCallback:(ABSUncaughtExceptionCallback)callback;
  15 +
  16 +@end
  1 +//
  2 +// ABSUtil.h
  3 +// AntilockBrakeSystem
  4 +//
  5 +// Created by 地风(ElonChan) on 16/5/16.
  6 +// Copyright © 2016年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface ABSUtil : NSObject
  12 +
  13 +// 设置日志逻辑
  14 ++ (void)setLogger:(void (^)(NSString *))logger;
  15 +
  16 ++ (void)Logger:(NSString *)log;
  17 +
  18 ++ (BOOL)isValidString:(id)notValidString;
  19 +
  20 ++ (BOOL)isWhiteListClass:(Class)class;
  21 +
  22 ++ (void)deleteCacheWithfilePathsToRemove:(NSArray *)filePathsToRemove;
  23 +
  24 +@end
  1 +//
  2 +// AlicloudHTTPDNSMini.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by ryan on 3/6/2016.
  6 +// Copyright © 2016 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef AlicloudHTTPDNSMini_h
  10 +#define AlicloudHTTPDNSMini_h
  11 +
  12 +#define HTTPDNSMINI_RESOLVED_NOTIFY @"HTTPDNSMiniResolvedNotify"
  13 +
  14 +@interface AlicloudHTTPDNSMini : NSObject
  15 +
  16 ++ (AlicloudHTTPDNSMini *)sharedInstance;
  17 +- (NSArray *)getIpsByHostAsync:(NSString *)host;
  18 +- (void)setPreResolveHosts:(NSArray *)hosts;
  19 +
  20 +@end
  21 +
  22 +#endif /* AlicloudHTTPDNSMini_h */
  1 +/*
  2 + * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
  3 + *
  4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  5 + *
  6 + * This file contains Original Code and/or Modifications of Original Code
  7 + * as defined in and that are subject to the Apple Public Source License
  8 + * Version 2.0 (the 'License'). You may not use this file except in
  9 + * compliance with the License. The rights granted to you under the License
  10 + * may not be used to create, or enable the creation or redistribution of,
  11 + * unlawful or unlicensed copies of an Apple operating system, or to
  12 + * circumvent, violate, or enable the circumvention or violation of, any
  13 + * terms of an Apple operating system software license agreement.
  14 + *
  15 + * Please obtain a copy of the License at
  16 + * http://www.opensource.apple.com/apsl/ and read it before using this file.
  17 + *
  18 + * The Original Code and all software distributed under the License are
  19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  23 + * Please see the License for the specific language governing rights and
  24 + * limitations under the License.
  25 + *
  26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  27 + */
  28 +/*
  29 + * Copyright (c) 1980, 1986, 1993
  30 + * The Regents of the University of California. All rights reserved.
  31 + *
  32 + * Redistribution and use in source and binary forms, with or without
  33 + * modification, are permitted provided that the following conditions
  34 + * are met:
  35 + * 1. Redistributions of source code must retain the above copyright
  36 + * notice, this list of conditions and the following disclaimer.
  37 + * 2. Redistributions in binary form must reproduce the above copyright
  38 + * notice, this list of conditions and the following disclaimer in the
  39 + * documentation and/or other materials provided with the distribution.
  40 + * 3. All advertising materials mentioning features or use of this software
  41 + * must display the following acknowledgement:
  42 + * This product includes software developed by the University of
  43 + * California, Berkeley and its contributors.
  44 + * 4. Neither the name of the University nor the names of its contributors
  45 + * may be used to endorse or promote products derived from this software
  46 + * without specific prior written permission.
  47 + *
  48 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  49 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  50 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  51 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  52 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  53 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  54 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  56 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  57 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  58 + * SUCH DAMAGE.
  59 + *
  60 + * @(#)route.h 8.3 (Berkeley) 4/19/94
  61 + * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $
  62 + */
  63 +
  64 +
  65 +#ifndef AlicloudIPv6Adapter_h
  66 +#define AlicloudIPv6Adapter_h
  67 +#import <Foundation/Foundation.h>
  68 +
  69 +@interface AlicloudIPv6Adapter : NSObject
  70 +
  71 ++ (instancetype)getInstance;
  72 +
  73 +/**
  74 + * 判断当前是否为IPv6-Only网络
  75 + */
  76 +- (BOOL)isIPv6OnlyNetwork;
  77 +
  78 +/**
  79 + * 手动刷新IPv6-Only网络的判定
  80 + */
  81 +- (BOOL)reResolveIPv6OnlyStatus;
  82 +
  83 +/**
  84 + IPv4 > IPv6地址转换\n
  85 + - 输入IPv4地址无效,返回原地址
  86 + - IPv6-Only网络,返回转换后的IPv6地址
  87 + - 非IPv6-Only网络,返回原地址
  88 +
  89 + @param addr IPv4地址
  90 + @return 转换后的v6地址 或 原地址
  91 + */
  92 +- (NSString *)handleIpv4Address:(NSString *)addr;
  93 +
  94 +/**
  95 + * 判断是否为IPv4地址
  96 + */
  97 +- (BOOL)isIPv4Address:(NSString *)addr;
  98 +
  99 +/**
  100 + * 判断是否为IPv6地址
  101 + */
  102 +- (BOOL)isIPv6Address:(NSString *)addr;
  103 +
  104 +@end
  105 +
  106 +#endif /* AlicloudIPv6Adapter_h */
  1 +//
  2 +// AlicloudReachabilityManager.h
  3 +//
  4 +// Created by 亿刀 on 14-1-9.
  5 +// Edited by junmo on 15-5-16
  6 +// Copyright (c) 2014年 Twitter. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <CoreTelephony/CTTelephonyNetworkInfo.h>
  11 +
  12 +#define ALICLOUD_NETWOEK_STATUS_NOTIFY @"AlicloudNetworkStatusChangeNotify"
  13 +
  14 +typedef enum {
  15 + AlicloudNotReachable = 0,
  16 + AlicloudReachableViaWiFi,
  17 + AlicloudReachableVia2G,
  18 + AlicloudReachableVia3G,
  19 + AlicloudReachableVia4G
  20 +} AlicloudNetworkStatus;
  21 +
  22 +@interface AlicloudReachabilityManager : NSObject
  23 +
  24 +/**
  25 + * 获取Reachability单例对象
  26 + */
  27 ++ (AlicloudReachabilityManager *)shareInstance;
  28 +
  29 +/**
  30 + * 获取Reachability单例对象,为保证全局维护一个netInfo实例,可从外部传入netInfo对象的引用
  31 + * warn: netInfo多次实例化,有一定几率crash
  32 + *
  33 + */
  34 ++ (AlicloudReachabilityManager *)shareInstanceWithNetInfo:(CTTelephonyNetworkInfo *)netInfo;
  35 +
  36 +/**
  37 + * 返回当前网络状态(同步调用,可能会阻塞调用线程)
  38 + */
  39 +- (AlicloudNetworkStatus)currentNetworkStatus;
  40 +
  41 +/**
  42 + * 返回之前网络状态
  43 + */
  44 +- (AlicloudNetworkStatus)preNetworkStatus;
  45 +
  46 +/**
  47 + * 检测网络是否连通(同步调用,阻塞调用线程)
  48 + */
  49 +- (BOOL)checkInternetConnection;
  50 +
  51 +/**
  52 + * 检测Wifi网络是否联通
  53 + */
  54 +- (BOOL)isReachableViaWifi;
  55 +
  56 +/**
  57 + * 检测蜂窝网络是否联通
  58 + */
  59 +- (BOOL)isReachableViaWWAN;
  60 +
  61 +@end
  1 +//
  2 +// AlicloudReport.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by ryan on 3/6/2016.
  6 +// Copyright © 2016 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef AlicloudReport_h
  10 +#define AlicloudReport_h
  11 +
  12 +extern const NSString *EXT_INFO_KEY_VERSION;
  13 +extern const NSString *EXT_INFO_KEY_PACKAGE;
  14 +
  15 +// SDK标识
  16 +typedef NS_ENUM(NSInteger, AMSService) {
  17 + AMSMAN = 0,
  18 + AMSHTTPDNS,
  19 + AMSMPUSH,
  20 + AMSMAC,
  21 + AMSAPI,
  22 + AMSHOTFIX,
  23 + AMSFEEDBACK,
  24 + AMSIM
  25 +};
  26 +
  27 +// 上报状态
  28 +typedef NS_ENUM(NSInteger, AMSReportStatus) {
  29 + AMS_UNREPORTED_STATUS,
  30 + AMS_REPORTED_STATUS
  31 +};
  32 +
  33 +@interface AlicloudReport : NSObject
  34 +
  35 +/**
  36 + * 异步上报活跃设备统计
  37 + *
  38 + @param tag SDK标识
  39 + */
  40 ++ (void)statAsync:(AMSService)tag;
  41 +
  42 +/**
  43 + * 异步上报活跃设备统计并携带附加信息
  44 + *
  45 + @param tag SDK标识
  46 + @param extInfo 附加上报信息 { EXT_INFO_KEY_VERSION :"x.x.x", EXT_INFO_KEY_PACKAGE: "xxx"}
  47 + */
  48 ++ (void)statAsync:(AMSService)tag extInfo:(NSDictionary *)extInfo;
  49 +
  50 +/**
  51 + * 获取指定SDK标识上报状态
  52 + *
  53 + @param tag SDK标识
  54 + @return 返回上报状态
  55 + */
  56 ++ (AMSReportStatus)getReportStatus:(AMSService)tag;
  57 +
  58 +/**
  59 + * 获取上报状态(兼容老版本接口)
  60 + *
  61 + @param tag SDK标识
  62 + @return YES:已经上报 NO:没有上报
  63 + */
  64 ++ (BOOL)isDeviceReported:(AMSService)tag;
  65 +
  66 +@end
  67 +
  68 +#endif /* AlicloudReport_h */
  1 +//
  2 +// AlicloudTracker.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 2017/6/30.
  6 +// Copyright © 2017年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef AlicloudTracker_h
  10 +#define AlicloudTracker_h
  11 +
  12 +@interface AlicloudTracker : NSObject
  13 +
  14 +@property (nonatomic, copy) NSString *sdkId;
  15 +@property (nonatomic, copy) NSString *sdkVersion;
  16 +
  17 +/**
  18 + 设置Tracker的通用打点属性,每次上报都携带该参数
  19 +
  20 + @param key 通用属性Key
  21 + @param value 通用属性Value
  22 + */
  23 +- (void)setGlobalProperty:(NSString *)key value:(NSString *)value;
  24 +
  25 +/**
  26 + 删除Tracker通用打点属性
  27 +
  28 + @param key 通用属性Key
  29 + */
  30 +- (void)removeGlobalProperty:(NSString *)key;
  31 +
  32 +/**
  33 + 自定义打点上报
  34 +
  35 + @param eventName 事件名
  36 + @param duration 时长
  37 + @param properties 额外参数
  38 + */
  39 +- (void)sendCustomHit:(NSString *)eventName
  40 + duration:(long long)duration
  41 + properties:(NSDictionary *)properties;
  42 +
  43 +@end
  44 +#endif /* AlicloudTracker_h */
  1 +//
  2 +// AlicloudTrackerManager.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 2017/7/4.
  6 +// Copyright © 2017年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef AlicloudTrackerManager_h
  10 +#define AlicloudTrackerManager_h
  11 +
  12 +#import "AlicloudTracker.h"
  13 +
  14 +@interface AlicloudTrackerManager : NSObject
  15 +
  16 +/**
  17 + 获取上报通道管理器对象,并初始化UT
  18 +
  19 + @return 管理器对象
  20 + */
  21 ++ (instancetype)getInstance;
  22 +
  23 +/**
  24 + 根据SDK标识和版本号获取上报通道
  25 +
  26 + @param sdkId SDK标识
  27 + @param version SDK版本号
  28 + @return 上报通道对象
  29 + */
  30 +- (AlicloudTracker *)getTrackerBySdkId:(NSString *)sdkId version:(NSString *)version;
  31 +
  32 +@end
  33 +
  34 +#endif /* AlicloudTrackerManager_h */
  1 +//
  2 +// AlicloudUtils.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by lingkun on 16/5/16.
  6 +// Copyright © 2016年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +#define ALICLOUDUTILS_VERSION @"1.3.6"
  12 +
  13 +// In this header, you should import all the public headers of your framework using statements like #import <AlicloudUtils/PublicHeader.h>
  14 +
  15 +#import <AlicloudUtils/AlicloudReachabilityManager.h>
  16 +#import <AlicloudUtils/EMASSecurityModeManager.h>
  17 +#import <AlicloudUtils/EMASSecurityModeCommon.h>
  18 +#import <AlicloudUtils/AlicloudTrackerManager.h>
  19 +#import <AlicloudUtils/AlicloudIPv6Adapter.h>
  20 +#import <AlicloudUtils/AlicloudHTTPDNSMini.h>
  21 +#import <AlicloudUtils/AntilockBrakeSystem.h>
  22 +#import <AlicloudUtils/EMASBeaconService.h>
  23 +#import <AlicloudUtils/AlicloudTracker.h>
  24 +#import <AlicloudUtils/AlicloudReport.h>
  25 +#import <AlicloudUtils/EMASOptions.h>
  26 +#import <AlicloudUtils/EMASTools.h>
  27 +#import <AlicloudUtils/UtilLog.h>
  1 +//
  2 +// AntilockBrakeSystem.h
  3 +// AntilockBrakeSystem
  4 +//
  5 +// Created by 地风(ElonChan) on 16/5/16.
  6 +// Copyright © 2016年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#import "ABSUncaughtExceptionHandler.h"
  10 +#import "ABSBootingProtection.h"
  11 +#import "ABSUtil.h"
  1 +//
  2 +// EMASBeaconService.h
  3 +// AlicloudBeacon
  4 +//
  5 +// Created by junmo on 2017/7/6.
  6 +// Copyright © 2017年 junmo. All rights reserved.
  7 +//
  8 +
  9 +#ifndef EMASBeaconService_h
  10 +#define EMASBeaconService_h
  11 +
  12 +@interface EMASBeaconConfiguration : NSObject
  13 +
  14 +- (instancetype)initWithData:(NSData *)data;
  15 +- (id)getConfigureItemByKey:(NSString *)key;
  16 +
  17 +@end
  18 +
  19 +typedef void (^AlicloudBeaconCallbackHandler)(BOOL res, NSError *error);
  20 +
  21 +@interface EMASBeaconService : NSObject
  22 +
  23 +- (instancetype)initWithAppKey:(NSString *)appKey
  24 + appSecret:(NSString *)appSecret
  25 + SDKVersion:(NSString *)SDKVersion
  26 + SDKID:(NSString *)SDKID;
  27 +
  28 +- (instancetype)initWithAppKey:(NSString *)appKey
  29 + appSecret:(NSString *)appSecret
  30 + SDKVersion:(NSString *)SDKVersion
  31 + SDKID:(NSString *)SDKID
  32 + extension:(NSDictionary *)extension;
  33 +
  34 +- (void)enableLog:(BOOL)enabled;
  35 +- (BOOL)isLogEnabled;
  36 +
  37 +//- (void)getBeaconConfigByKey:(NSString *)key
  38 +// completionHandler:(void(^)(EMASBeaconConfiguration *configuration, NSError *error))completionHandler;
  39 +
  40 +- (void)getBeaconConfigStringByKey:(NSString *)key
  41 + completionHandler:(void(^)(NSString *result, NSError *error))completionHandler;
  42 +
  43 +@end
  44 +
  45 +#endif /* EMASBeaconService_h */
  1 +//
  2 +// EMASOptions.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 2018/3/16.
  6 +// Copyright © 2018年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef EMASOptions_h
  10 +#define EMASOptions_h
  11 +
  12 +@interface EMASOptionSDKServiceItem : NSObject
  13 +
  14 +@property (nonatomic, copy) NSString *sdkId;
  15 +@property (nonatomic, copy) NSString *version;
  16 +@property (nonatomic, assign) NSNumber *status;
  17 +
  18 +@end
  19 +
  20 +@interface EMASOptions : NSObject
  21 +
  22 +@property (nonatomic, copy, readonly) NSString *emasAppKey;
  23 +@property (nonatomic, copy, readonly) NSString *emasAppSecret;
  24 +@property (nonatomic, copy, readonly) NSString *emasBundleId;
  25 +@property (nonatomic, copy, readonly) NSString *hotfixIdSecret;
  26 +@property (nonatomic, copy, readonly) NSString *hotfixRsaSecret;
  27 +@property (nonatomic, copy, readonly) NSString *httpdnsAccountId;
  28 +@property (nonatomic, copy, readonly) NSString *httpdnsSecretKey;
  29 +
  30 ++ (EMASOptions *)defaultOptions;
  31 +- (NSString *)optionByConfigKey:(NSString *)key;
  32 +- (EMASOptionSDKServiceItem *)sdkServiceItemForSdkId:(NSString *)sdkId;
  33 +
  34 +@end
  35 +
  36 +#endif /* EMASOptions_h */
  1 +//
  2 +// EMASSecurityModeCommon.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 2018/3/11.
  6 +// Copyright © 2018年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef EMASSecurityModeCommon_h
  10 +#define EMASSecurityModeCommon_h
  11 +
  12 +typedef void (^SDKCheckSuccessHandler)(void);
  13 +typedef void (^SDKCheckCrashHandler)(NSUInteger crashCount);
  14 +
  15 +#endif /* EMASSecurityModeCommon_h */
  1 +//
  2 +// EMASSecurityModeManager.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 2018/3/10.
  6 +// Copyright © 2018年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef EMASSecurityModeManager_h
  10 +#define EMASSecurityModeManager_h
  11 +
  12 +#import "EMASSecurityModeCommon.h"
  13 +
  14 +@interface EMASSecurityModeManager : NSObject
  15 +
  16 ++ (instancetype)sharedInstance;
  17 +
  18 +- (void)registerSDKComponentAndStartCheck:(NSString *)sdkId
  19 + sdkVersion:(NSString *)sdkVersion
  20 + appKey:(NSString *)appKey
  21 + appSecret:(NSString *)appSecret
  22 + sdkCrashThreshold:(NSUInteger)crashTimesThreshold
  23 + onSuccess:(SDKCheckSuccessHandler)successHandler
  24 + onCrash:(SDKCheckCrashHandler)crashHandler;
  25 +
  26 +@end
  27 +
  28 +#endif /* EMASSecurityModeManager_h */
  1 +//
  2 +// EMASTools.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 2018/3/14.
  6 +// Copyright © 2018年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef EMASTools_h
  10 +#define EMASTools_h
  11 +
  12 +#define EMAS_SYNC_EXECUTE_BY_KEY(key, executor)\
  13 +[EMASTools syncExecuteBlockByKey:key block:executor];\
  14 +
  15 +#define EMAS_SYNC_EXECUTE_BY_QUEUE(queue, executor)\
  16 +[EMASTools syncExecuteBlockByQueue:queue block:executor];\
  17 +
  18 +@interface EMASTools : NSObject
  19 +
  20 ++ (BOOL)isValidString:(id)obj;
  21 ++ (BOOL)isValidDictionary:(id)obj;
  22 ++ (BOOL)isValidArray:(id)obj;
  23 +
  24 ++ (NSString *)md5:(NSString *)str;
  25 ++ (NSString *)sha1:(NSString *)str;
  26 ++ (NSString *)hmacSha1:(NSString *)str key:(NSString *)key;
  27 ++ (NSString *)base64EncodedWithString:(NSString *)str;
  28 ++ (NSString *)base64DecodedWithString:(NSString *)base64Str;
  29 ++ (NSData *)aes128CBCEncrypt:(NSData *)data key:(NSData *)key iv:(char *)iv;
  30 ++ (NSString *)URLEncodedString:(NSString *)str;
  31 +
  32 ++ (NSString *)convertObjectToJsonString:(id)obj;
  33 ++ (id)convertJsonStringToObject:(NSString *)jsonStr;
  34 ++ (id)convertJsonDataToObject:(NSData *)jsonData;
  35 +
  36 ++ (NSString *)convertDateToGMT0String:(NSDate *)date;
  37 ++ (NSString *)convertDateToGMT8String:(NSDate *)date;
  38 +
  39 ++ (void)swizzleClassMethod:(Class)cls originSEL:(SEL)originSEL swizzleSEL:(SEL)swizzleSEL;
  40 ++ (void)swizzleInstanceMethod:(Class)cls originSEL:(SEL)originSEL swizzleSEL:(SEL)swizzleSEL;
  41 +
  42 ++ (BOOL)isIPv4Address:(NSString *)addr;
  43 ++ (BOOL)isIPv6Address:(NSString *)addr;
  44 +
  45 ++ (dispatch_queue_t)createQueueIfNotExists:(NSString *)key;
  46 ++ (void)syncExecuteBlockByKey:(NSString *)key block:(void(^)(void))block;
  47 ++ (void)syncExecuteBlockByQueue:(dispatch_queue_t)queue block:(void(^)(void))block;
  48 +
  49 ++ (NSString *)bundleIdForApp;
  50 ++ (NSString *)deviceBrand;
  51 ++ (NSString *)deviceModel;
  52 +
  53 ++ (void)threadWaitForSec:(double)sec;
  54 +
  55 +@end
  56 +
  57 +#endif /* EMASTools_h */
  1 +//
  2 +// UtilLog.h
  3 +// AlicloudUtils
  4 +//
  5 +// Created by junmo on 16/11/24.
  6 +// Copyright © 2016年 Ali. All rights reserved.
  7 +//
  8 +
  9 +#ifndef UtilLog_h
  10 +#define UtilLog_h
  11 +
  12 +@interface UtilLog : NSObject
  13 +
  14 ++ (void)enableLog;
  15 +
  16 ++ (BOOL)isLogEnabled;
  17 +
  18 +#define UtilLogD(tag, frmt, ...)\
  19 +if ([UtilLog isLogEnabled]) {\
  20 +NSLog(@"[%@]-[D]: %@", tag, [NSString stringWithFormat:(frmt), ##__VA_ARGS__]);\
  21 +}
  22 +
  23 +#define UtilLogI(tag, frmt, ...)\
  24 +if ([UtilLog isLogEnabled]) {\
  25 +NSLog(@"[%@]-[I]: %@", tag, [NSString stringWithFormat:(frmt), ##__VA_ARGS__]);\
  26 +}
  27 +
  28 +#define UtilLogE(tag, frmt, ...)\
  29 +if ([UtilLog isLogEnabled]) {\
  30 +NSLog(@"[%@]-[E]: %@", tag, [NSString stringWithFormat:(frmt), ##__VA_ARGS__]);\
  31 +}
  32 +@end
  33 +
  34 +#endif /* UtilLog_h */
  1 +framework module AlicloudUtils {
  2 + umbrella header "AlicloudUtils.h"
  3 +
  4 + export *
  5 + module * { export * }
  6 +}