You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.0 KiB

2 years ago
//
// ABSBootingProtection.h
// AntilockBrakeSystem
//
// Created by 地风(ElonChan) on 16/5/16.
// Copyright © 2016年 Ali. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void (^ABSBoolCompletionHandler)(BOOL succeeded, NSError *error);
typedef void (^ABSRepairBlock)(ABSBoolCompletionHandler completionHandler);
typedef void (^ABSReportBlock)(NSUInteger crashCounts);
typedef NS_ENUM(NSInteger, ABSBootingProtectionStatus) {
ABSBootingProtectionStatusNormal, /**< APP 启动正常 */
ABSBootingProtectionStatusNormalChecking, /**< 正在检测是否会在特定时间内是否会 Crash,注意:检测状态下“连续启动崩溃计数”个数小于或等于上限值 */
ABSBootingProtectionStatusNeedFix, /**< APP 出现连续启动 Crash,需要采取修复措施 */
ABSBootingProtectionStatusFixing, /**< APP 出现连续启动 Crash,正在修复中... */
};
/**
* crash
* `_crashOnLaunchTimeIntervalThreshold` crash `_continuousCrashOnLaunchNeedToReport` `_continuousCrashOnLaunchNeedToFix`
*/
@interface ABSBootingProtection : NSObject
/**
* crash
* App crash crash [ABSBootingProtection addCrashCountIfNeeded]
* `crashOnLaunchTimeIntervalThreshold`crash`continuousCrashOnLaunchNeedToReport``continuousCrashOnLaunchNeedToFix``crashOnLaunchTimeIntervalThreshold` crash
`reportBlock`
`repairtBlock` `[self setCrashCount:0]`
*/
- (void)launchContinuousCrashProtect;
/*!
* Crash的状态
*/
@property (nonatomic, assign, readonly) ABSBootingProtectionStatus bootingProtectionStatus;
/*!
*
*/
@property (nonatomic, assign, readonly) NSUInteger continuousCrashOnLaunchNeedToReport;
/*!
*
*/
@property (nonatomic, assign, readonly) NSUInteger continuousCrashOnLaunchNeedToFix;
/*!
* APP
*/
@property (nonatomic, assign, readonly) NSTimeInterval crashOnLaunchTimeIntervalThreshold;
/*!
* context block
*/
@property (nonatomic, copy, readonly) NSString *context;
/*!
* @details kCrashOnLaunchTimeIntervalThreshold秒内crashcontinuousCrashOnLaunchNeedToReport次则上报日志continuousCrashOnLaunchNeedToFix则启动修复程序 completion crashOnLaunchTimeIntervalThreshold crash kContinuousCrashOnLaunchCounterKey
* @param context context block
*/
- (instancetype)initWithContinuousCrashOnLaunchNeedToReport:(NSUInteger)continuousCrashOnLaunchNeedToReport
continuousCrashOnLaunchNeedToFix:(NSUInteger)continuousCrashOnLaunchNeedToFix
crashOnLaunchTimeIntervalThreshold:(NSTimeInterval)crashOnLaunchTimeIntervalThreshold
context:(NSString *)context;
/*!
*
*/
+ (ABSBootingProtectionStatus)bootingProtectionStatusWithContext:(NSString *)context continuousCrashOnLaunchNeedToFix:(NSUInteger)continuousCrashOnLaunchNeedToFix;
/*!
* crashCounts crash
*/
- (void)setReportBlock:(ABSReportBlock)reportBlock;
/*!
*
*/
- (void)setRepairBlock:(ABSRepairBlock)repairtBlock;
@end