提交
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// CamRisk.h
|
||||
// CamRisk
|
||||
//
|
||||
// Created by 徐森圣 on 2020/12/1.
|
||||
// Copyright © 2020 Tencent Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TuringShieldCamRisk/TuringCamRiskTask.h>
|
||||
#import <TuringShieldCamRisk/TuringCamRiskService.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
!!!: 一、服务概览
|
||||
本服务旨在对摄像头风险进行识别。由于识别引擎和预测模型均在云端,因此大多数服务均为异步接口。
|
||||
|
||||
!!!: 二、主要接口介绍
|
||||
|
||||
TuringCamRiskService
|
||||
|
|
||||
| 创建检测任务
|
||||
|
|
||||
v
|
||||
TuringCamRiskTask
|
||||
|
|
||||
| 产生请求数据
|
||||
v
|
||||
NSData
|
||||
|
||||
更多的信息请参阅 TuringCamRiskService.h 和 TuringCamRiskTask.h中的注释
|
||||
|
||||
!!!: 三、一般使用范例
|
||||
```objective-c
|
||||
// 为服务配置上下文(可用的key有多个,这里只简单例举一个,参见TuringCamRiskContextKey中的枚举字符串)
|
||||
[[TuringCamRiskService sharedService] setupContext:@{ TuringCamRiskContextAppIDKey: @"F.R.D." }];
|
||||
|
||||
// 创建一个检测任务
|
||||
TuringCamRiskTask *task = [[TuringCamRiskService sharedService] taskForSceneID:nil];
|
||||
// 为任务指定监控的视图,检测群控风险(此动作可选)
|
||||
[task monitorView:[UIApplication sharedApplication].keyWindow];
|
||||
// 为任务指定监控的摄像头设备,检测劫持风险(注意请提供正在使用的设备;此动作可选)
|
||||
[task monitorCameraWithDevice:cameraDevice session:captureSession previewView:previewLayer];
|
||||
// 获取用于请求的数据
|
||||
[task queryPostDataWithCompletionHandler:^(NSData * _Nullable data, NSError * _Nullable error) {
|
||||
// 如果成功,data非空,error为空;如果失败,data为空,error非空
|
||||
// data可用于http post直接请求图灵盾服务
|
||||
NSLog(@"data = %@, error = %@", error);
|
||||
}];
|
||||
```
|
||||
*/
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// TuringCamRiskService.h
|
||||
// TuringShieldCamRisk
|
||||
//
|
||||
// Created by 徐森圣 on 2020/12/2.
|
||||
// Copyright © 2020 Tencent Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TuringShieldCamRisk/TuringServiceDefine.h>
|
||||
#import <TuringShieldCamRisk/TuringServiceSettings.h>
|
||||
#import <TuringShieldCamRisk/TuringCamRiskTask.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// 这些常量值用于设置或获取context中的字典数据中的key。
|
||||
typedef NSString * TuringCamRiskContextKey NS_EXTENSIBLE_STRING_ENUM;
|
||||
|
||||
/// 用于设置请求序列编号的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextRequestSequenceKey;
|
||||
|
||||
/// 用于设置meta data的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextMetaDataKey;
|
||||
|
||||
/// 用于设置接入渠道号的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextChannelKey;
|
||||
|
||||
/// 用于设置接入构建号的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSNumber *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextBuildNoKey;
|
||||
|
||||
/// 用于设置接入版本号的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextVersionKey;
|
||||
|
||||
/// 用于设置接入版本LC的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextLCKey;
|
||||
|
||||
/// 用于设置其它额外信息的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextExtraInfoKey;
|
||||
|
||||
/// 用于设置接入App ID的key,参见 `TuringCamRiskContextKey`。该key对应的值应为 NSString *。
|
||||
extern TuringCamRiskContextKey const _Nonnull TuringCamRiskContextAppIDKey;
|
||||
|
||||
|
||||
@interface TuringCamRiskConfiguration : NSObject
|
||||
|
||||
/// 禁止直接生成实例
|
||||
- (nonnull instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@property (assign) int32_t channelID TS_AVAILABLE_IF(TS_ENABLES_CUSTOM_CHANNEL_ID);
|
||||
@property (nullable, nonatomic, copy) NSString *URLForTarsServer TS_AVAILABLE_IF(TS_NETWORKING_TMF_SHARK_SUPPORTS);
|
||||
@property (nullable, nonatomic, copy) NSString *valificationFilePath TS_AVAILABLE_IF(TS_USING_SIGN_VALIFICATION);
|
||||
|
||||
@end
|
||||
|
||||
@interface TuringCamRiskService : NSObject
|
||||
|
||||
+ (nullable NSError *)setupWithConfiguration:(nullable void(^)(TuringCamRiskConfiguration *_Nonnull config))configurationHandler;
|
||||
|
||||
+ (void)setupTarsServerWithURL:(nonnull NSString *)URLString withChannelID:(int32_t)ChannelID TS_AVAILABLE_IF(TS_NETWORKING_TMF_SHARK_SUPPORTS)
|
||||
TS_MSG_DEPRECATED("Use `-setupTarsServerWithURL:withChannelID:withLicense:` instead");
|
||||
|
||||
/// 禁止直接生成实例
|
||||
- (nonnull instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/// 所有服务均以此单例提供
|
||||
+ (nonnull instancetype)sharedService;
|
||||
|
||||
/// 预连接服务器网络,以便加速后续请求的回应速度
|
||||
+ (void)touchNetworking;
|
||||
|
||||
/// 设置全局回调,用于控制HTTP请求的发送
|
||||
/// @param callback 该回调会回传HTTP请求所使用的request对象,修改对象属性可改变请求的行为。回调返回NO时将取消请求,否则正常执行请求。
|
||||
/// @discussion 图灵盾完成一个操作可能会执行多个HTTP请求,中途改变请求的http目标后,无法确保原子操作,需要业务自行控制。建议在调用图灵盾任何操作前调用,并且只调用一次。
|
||||
+ (void)setupTarsHTTPPostCallback:(nullable BOOL(^)(NSMutableURLRequest *_Nonnull request))callback TS_AVAILABLE_IF(TS_ALLOWS_HTTP_POST_HANDLING);
|
||||
|
||||
/// 设置调用相关的上下文。这些上下文由业务设置,同时回传业务的后端,用于数据稽核。
|
||||
/// @param context 上下文的内容。字典中用到的key,请参考`TuringCamRiskContextKey`及其常量定义。
|
||||
- (void)setupContext:(nonnull NSDictionary<TuringCamRiskContextKey, id> *)context;
|
||||
|
||||
/// 生成一个摄像头检测任务并接受TuringCamRiskService的管理。如果相同sceneID的任务已经生成,则会
|
||||
/// 返回同一个任务实例,直到该实例被`- detatchTask:`释放。
|
||||
/// @param sceneID 摄像头检测任务的场景ID
|
||||
/// @discussion 如果sceneID为空,则该任务不会被TuringCamRiskService管理,也不需要调用
|
||||
/// `- detatchTask:`释放
|
||||
- (nonnull TuringCamRiskTask *)taskForSceneID:(nullable NSString *)sceneID;
|
||||
|
||||
/// 释放一个摄像头检测任务
|
||||
/// @param task 要释放的任务实例
|
||||
- (void)detatchTask:(nonnull TuringCamRiskTask *)task;
|
||||
|
||||
+ (nonnull NSDictionary *)SDKInfo;
|
||||
|
||||
@end
|
||||
|
||||
@interface TuringCamRiskService (Validation)
|
||||
|
||||
+ (nullable NSError *)verifySDKUsingLisence:(nullable NSString *)licenseFilePath TS_AVAILABLE_IF(TS_USING_SIGN_VALIFICATION);
|
||||
|
||||
@end
|
||||
|
||||
/// 设备实时风险标签
|
||||
@interface TuringCamRiskService (RiskToken)
|
||||
|
||||
/// 获取实时风险标签
|
||||
/// @param usingCache 是否使用缓存。YES表示由图灵盾SDK根据缓存策略,决定是否更新缓存;NO表示总是联网获取实时结果。
|
||||
/// @param completion 获取结果的回调
|
||||
/// @discussion 一般我们建议usingCache设置为YES。仅当在对风险检测要求特别高的场景下,才设置为NO。图灵盾SDK能有效管理缓存并确保缓存的检测安全效果,同时节省请求流量和服务计算成本。同时,由于您可能不够理解何时可以使用缓存而何时需要更新缓存,因此我们不建议客户端自行缓存我们的结果。
|
||||
- (void)fetchRiskTokenUsingCache:(BOOL)usingCache WithCompletionHandler:(nonnull void(^)(NSString *_Nullable message, NSError *_Nullable error))completion TS_AVAILABLE_IF(TS_ENABLES_RISK_DETECT_FEATURE);
|
||||
|
||||
@end
|
||||
|
||||
@interface TuringCamRiskService (Debugging)
|
||||
|
||||
/// 设置是否使用测试服务器
|
||||
/// @discussion 注意只能在未使用任何 TuringCamRiskService 的服务之前设置,否则某些正在进行中的
|
||||
/// 服务可能会出现错误
|
||||
@property (class, nonatomic) BOOL usesDebugServer TS_AVAILABLE_IF(__TS_OR(TS_NETWORKING_WUP_SUPPORTS, TS_NETWORKING_SHARK_SUPPORTS));
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// TuringCamRiskTask.h
|
||||
// TuringShieldCamRisk
|
||||
//
|
||||
// Created by 徐森圣 on 2020/12/2.
|
||||
// Copyright © 2020 Tencent Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
/// 摄像头检测任务
|
||||
/// @example
|
||||
/// ```
|
||||
/// [task queryPostDataWithCompletionHandler:^(NSData * _Nullable data, NSError * _Nullable error) {
|
||||
/// // error为空时可以用于发送到图灵盾服务器
|
||||
/// }];
|
||||
/// ```
|
||||
@interface TuringCamRiskTask : NSObject
|
||||
|
||||
/// 禁止直接创建摄像头检测任务
|
||||
- (nonnull instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/// 为任务指定要监控的摄像头设备及其相关信息,需要调用`-postWithCompletionHandler:`或者
|
||||
/// `-queryPostDataWithCompletionHandler`之前调用。
|
||||
/// @param cameraDevice 受监控的摄像头设备
|
||||
/// @param session 受监控的摄像会话
|
||||
/// @param previewLayer 受监控的预览图层
|
||||
/// @discussion 调用该方法是可选的,但会提升检测的准确性
|
||||
- (void)monitorCameraWithDevice:(nullable AVCaptureDevice *)cameraDevice session:(nullable AVCaptureSession *)session previewView:(nullable AVCaptureVideoPreviewLayer *)previewLayer;
|
||||
|
||||
/// 为任务指定要监控的用户界面,通常是一个用户可操作的视图,例如viewController.view,或者一个按钮
|
||||
/// @param view 受监控的用户界面
|
||||
/// @discussion 调用该方法是可选的,但会提升检测的准确性
|
||||
- (void)monitorView:(nonnull UIView *)view;
|
||||
|
||||
/// 请求检测
|
||||
/// @param completionHandler 请求完成的回调函数。如果正确返回,则result非空,否则error非空
|
||||
/// @discussion 数据将会直接发送到图灵盾服务器,只是为了便于测试连通性而提供该接口。
|
||||
- (void)postWithCompletionHandler:(nullable void(^)(NSDictionary<NSString *, id> *_Nullable result, NSError *_Nullable error))completionHandler;
|
||||
|
||||
/// 生成用于请求的数据包
|
||||
/// @param completionHandler 请求完成的回调函数。如果正确返回,则data非空,否则error非空
|
||||
- (void)queryPostDataWithCompletionHandler:(nonnull void(^)(NSData *_Nullable data, NSError *_Nullable error))completionHandler;
|
||||
|
||||
/// 任务的场景ID
|
||||
@property (nonatomic, copy, readonly, nonnull) NSString *scene;
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
//
|
||||
// TuringServiceDefine.h
|
||||
// TuringShield
|
||||
//
|
||||
// Created by 徐森圣 on 2018/3/13.
|
||||
// Copyright © 2018年 Tecent Inc. All rights reserved.
|
||||
//
|
||||
// $$api_level=TS_TURING_SHIELD_OPEN_API_LEVEL$$
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __TURING_SERVICE_DEFINE_H__
|
||||
#define __TURING_SERVICE_DEFINE_H__
|
||||
|
||||
#import "TuringServiceSettings.h"
|
||||
|
||||
#define TS_OBJECT_CLASS(name) TS_CLASS_##name
|
||||
|
||||
#define TS_OBJECT_IMPL(name) TS_REAL_##name
|
||||
|
||||
#define TS_OBJECT_DECL(name) \
|
||||
@protocol TS_OBJECT_CLASS(name) <NSObject> \
|
||||
@end \
|
||||
typedef NSObject<TS_OBJECT_CLASS(name)> *name##_t
|
||||
|
||||
#define TS_OBJECT_DECL_SUBCLASS(name, super) \
|
||||
@protocol TS_OBJECT_CLASS(name) <TS_OBJECT_CLASS(super)> \
|
||||
@end \
|
||||
typedef NSObject<TS_OBJECT_CLASS(name)> *name##_t
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define TS_BEGIN_DECLS extern "C" {
|
||||
#define TS_END_DECLS }
|
||||
#else
|
||||
#define TS_BEGIN_DECLS
|
||||
#define TS_END_DECLS
|
||||
#endif
|
||||
|
||||
TS_OBJECT_DECL(ts_object);
|
||||
|
||||
|
||||
/**
|
||||
将浮点类型的秒数转换为长整数类型的毫秒数
|
||||
|
||||
@param sec 秒数,需要为double类型
|
||||
@return 毫秒数,long long类型
|
||||
*/
|
||||
#define SEC_TO_MSEC(sec) (int64_t)( (sec) * 1000ll )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
如果condition的定义为0或未定义,则声明函数不可用
|
||||
|
||||
@param condition 一个可展开的宏定义
|
||||
*/
|
||||
#define TS_AVAILABLE_IF(condition) \
|
||||
__TS_IF_ELSE(condition) \
|
||||
/*Case True*/ (__TS_EMPTY()) \
|
||||
/*Case False*/(UNAVAILABLE_ATTRIBUTE)
|
||||
|
||||
|
||||
/**
|
||||
如果c1或c2中任意一个的定义为0或未定义,则声明函数不可用
|
||||
|
||||
@param c1 条件1,一个可展开的宏定义
|
||||
@param c2 条件2,一个可展开的宏定义
|
||||
*/
|
||||
#define TS_AVAILABLE_IFS(c1, c2) \
|
||||
__TS_IF_ELSE(c1) \
|
||||
/*Case True*/ (TS_AVAILABLE_IF(c2)) \
|
||||
/*Case False*/(UNAVAILABLE_ATTRIBUTE)
|
||||
|
||||
|
||||
/**
|
||||
如果当前线程是主线程,直接执行包含的短语句;如果当前不在主线
|
||||
程,将包含的短语句调度到主线程执行,并阻塞当前线程。
|
||||
|
||||
@param ... 一个需要调度到主线程执行的短语句
|
||||
*/
|
||||
#define TSMainThreadProtectCall(...) do { \
|
||||
if ([NSThread isMainThread] == NO) { \
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{ \
|
||||
__VA_ARGS__; \
|
||||
}); \
|
||||
} \
|
||||
else { \
|
||||
__VA_ARGS__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
如果当前线程是主线程,直接执行包含的短语句;如果当前不在主线
|
||||
程,将包含的短语句调度到主线程执行,并阻塞当前线程。然后返回
|
||||
短语句执行的结果。注意,如果返回值是Objective C对象,目前
|
||||
不支持MRC。
|
||||
|
||||
@param ... 一个需要调度到主线程执行的短语句
|
||||
@return 短语句的返回值
|
||||
*/
|
||||
#define TSMainThreadProtectGet(...) ({ \
|
||||
typeof(__VA_ARGS__) val; \
|
||||
if ([NSThread isMainThread] == NO) { \
|
||||
__block typeof(val) bval; \
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{ \
|
||||
bval = __VA_ARGS__; \
|
||||
}); \
|
||||
val = bval; \
|
||||
} \
|
||||
else { \
|
||||
val = __VA_ARGS__; \
|
||||
} \
|
||||
val; \
|
||||
})
|
||||
|
||||
|
||||
#define __1second (1.0f)
|
||||
#define __10seconds (__1second * 10)
|
||||
#define __20seconds (__1second * 20)
|
||||
#define __1minute (__1second * 60)
|
||||
#define __10minutes (__1minute * 10)
|
||||
#define __30minutes (__1minute * 30)
|
||||
#define __1hour (__1minute * 60)
|
||||
#define __1day (__1hour * 24)
|
||||
#define __1week (__1day * 7)
|
||||
|
||||
#define ts_shutup(v) (void)(v)
|
||||
|
||||
|
||||
///
|
||||
/// there's a stupid bug in @available:
|
||||
/// If we build TuringShield in Xcode 11 and use @available in TuringShield, Xcode 11 is ALSO required
|
||||
/// on building the An app that integrating TuringShield. The main reason is, the implementation of
|
||||
/// @available in Xcode 11 is different to the one in Xcode 10.
|
||||
/// So let's disable @available for time being.
|
||||
///
|
||||
#if 0
|
||||
#define ts_ios_version_is_at_least(major, minor, patch) @available(iOS major##.##minor##.##patch, *)
|
||||
#else
|
||||
#define ts_ios_version_is_at_least(major, minor, patch) \
|
||||
({ \
|
||||
NSOperatingSystemVersion v = \
|
||||
NSProcessInfo.processInfo.operatingSystemVersion; \
|
||||
v.majorVersion == major ? \
|
||||
( v.minorVersion == minor ? \
|
||||
( v.patchVersion >= patch ) : \
|
||||
( v.minorVersion > minor ) ) : \
|
||||
( v.majorVersion > major ); \
|
||||
})
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TS_SDK_CHANNEL_ID) && TS_USES_CLASS_ALIAS
|
||||
#define tsclassname(name) __TS_CAT(name, TS_ALIAS_SURFIX)
|
||||
#define tsmethodname(name) __TS_CAT(TS_ALIAS_SURFIX, name)
|
||||
#define tsclass(className) class tsclassname(className); @compatibility_alias className tsclassname(className)
|
||||
#else
|
||||
#define tsclassname(name) name
|
||||
#define tsmethodname(name) name
|
||||
#define tsclass(className) class className
|
||||
#endif
|
||||
|
||||
#define ts_channel_alias(name) __TS_CAT(name, __TS_CAT(_, TS_SDK_CHANNEL_ID))
|
||||
|
||||
#define TS_DEPRECATED __attribute__((deprecated))
|
||||
#define TS_MSG_DEPRECATED(msg) __attribute((deprecated((msg))))
|
||||
|
||||
#pragma mark - Inner Macro, do NOT use
|
||||
|
||||
|
||||
#define __TS_ARG_0_(n, ...) n
|
||||
#define __TS_ARG_1_(x0, n, ...) n
|
||||
#define __TS_ARG_2_(x0, x1, n, ...) n
|
||||
#define __TS_ARG_3_(x0, x1, x2, n, ...) n
|
||||
#define __TS_ARG_4_(x0, x1, x2, x3, n, ...) n
|
||||
#define __TS_ARG_5_(x0, x1, x2, x3, x4, n, ...) n
|
||||
#define __TS_ARG_6_(x0, x1, x2, x3, x4, x5, n, ...) n
|
||||
#define __TS_ARG_7_(x0, x1, x2, x3, x4, x5, x6, n, ...) n
|
||||
#define __TS_ARG_8_(x0, x1, x2, x3, x4, x5, x6, x7, n, ...) n
|
||||
#define __TS_ARG_9_(x0, x1, x2, x3, x4, x5, x6, x7, x8, n, ...) n
|
||||
|
||||
#define __TS_EVAL(...) __TS_EVAL1(__TS_EVAL1(__TS_EVAL1(__VA_ARGS__)))
|
||||
#define __TS_EVAL1(...) __TS_EVAL2(__TS_EVAL2(__TS_EVAL2(__VA_ARGS__)))
|
||||
#define __TS_EVAL2(...) __TS_EVAL3(__TS_EVAL3(__TS_EVAL3(__VA_ARGS__)))
|
||||
#define __TS_EVAL3(...) __TS_EVAL4(__TS_EVAL4(__TS_EVAL4(__VA_ARGS__)))
|
||||
#define __TS_EVAL4(...) __TS_EVAL5(__TS_EVAL5(__TS_EVAL5(__VA_ARGS__)))
|
||||
#define __TS_EVAL5(...) __VA_ARGS__
|
||||
|
||||
#define __TS_TO_CSTRING_(str) #str
|
||||
#define __TS_TO_CSTRING(...) __TS_TO_CSTRING_(__VA_ARGS__)
|
||||
|
||||
#define __TS_TO_NSSTRING_(str) @#str
|
||||
#define __TS_TO_NSSTRING(...) __TS_TO_NSSTRING_(__VA_ARGS__)
|
||||
|
||||
#define __TS_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
|
||||
#define __TS_CAT(a, ...) __TS_PRIMITIVE_CAT(a, __VA_ARGS__)
|
||||
|
||||
#define __TS_ARG_0(n, ...) n
|
||||
#define __TS_ARG_1(x0, n, ...) n
|
||||
#define __TS_IS_PROBE(...) __TS_ARG_1(__VA_ARGS__, 0)
|
||||
#define __TS_PROBE() ~, 1
|
||||
#define __TS_NOT(x) __TS_IS_PROBE(__TS_CAT(__TS_NOT_, x))
|
||||
#define __TS_NOT_0 __TS_PROBE()
|
||||
#define __TS_BOOL(x) __TS_NOT(__TS_NOT(x))
|
||||
|
||||
#define __TS_AND(x1, x2) __TS_IF_ELSE(x1)(__TS_IF_ELSE(x2)(1)(0))(0)
|
||||
#define __TS_AND_3(x1, x2, x3) __TS_AND(x1, __TS_AND(x2, x3))
|
||||
#define __TS_AND_4(x1, x2, x3, x4) __TS_AND(__TS_AND(x1, x2), __TS_AND(x3, x4))
|
||||
|
||||
#define __TS_OR(x1, x2) __TS_IF_ELSE(x1)(1)(__TS_IF_ELSE(x2)(1)(0))
|
||||
#define __TS_OR_3(x1, x2, x3) __TS_OR(x1, __TS_OR(x2, x3))
|
||||
|
||||
#define __TS_IIF(c) __TS_PRIMITIVE_CAT(__TS_IIF_, c)
|
||||
#define __TS_IIF_0(...)
|
||||
#define __TS_IIF_1(...) __VA_ARGS__
|
||||
|
||||
#define __TS_IELSE(c) __TS_PRIMITIVE_CAT(__TS_IELSE_, c)
|
||||
#define __TS_IELSE_0(...) __VA_ARGS__
|
||||
#define __TS_IELSE_1(...)
|
||||
|
||||
#define __TS_IIF_ELSE(c) __TS_PRIMITIVE_CAT(__TS_IIF_ELSE_, c)
|
||||
#define __TS_IIF_ELSE_0(...) __TS_IELSE_0
|
||||
#define __TS_IIF_ELSE_1(...) __VA_ARGS__ __TS_IELSE_1
|
||||
|
||||
#define __TS_IF(c) __TS_IIF(__TS_BOOL(c))
|
||||
#define __TS_IF_ELSE(c) __TS_IIF_ELSE(__TS_BOOL(c))
|
||||
|
||||
#define __TS_EMPTY()
|
||||
#define __TS_DEFER(id) id __TS_EMPTY()
|
||||
#define __TS_OBSTRUCT(...) __VA_ARGS__ __TS_DEFER(__TS_EMPTY)()
|
||||
|
||||
|
||||
#pragma mark - API Levels
|
||||
|
||||
#define TS_ALWAYS_VISIBLE __attribute__ ((visibility ("default")))
|
||||
#define TS_ALWAYS_HIDDEN __attribute__ ((visibility ("hidden")))
|
||||
|
||||
|
||||
#define TS_TURING_HIGHER_WRAPPER_LEVEL 1
|
||||
#define TS_TURING_SHIELD_OPEN_API_LEVEL 2
|
||||
#define TS_FRIENDLY_API_LEVEL 3
|
||||
#define TS_PRIVATE_LEVEL 4
|
||||
|
||||
|
||||
#if TS_API_LEVEL >= TS_TURING_HIGHER_WRAPPER_LEVEL && !!TS_TURING_ID_WRAPPER_APIS
|
||||
# define TS_TURING_ID_API 1
|
||||
#else
|
||||
# define TS_TURING_ID_API 0
|
||||
#endif
|
||||
|
||||
#if TS_API_LEVEL >= TS_TURING_HIGHER_WRAPPER_LEVEL && !!TS_TURING_AGE_WRAPPER_APIS
|
||||
# define TS_TURING_AGE_API 1
|
||||
#else
|
||||
# define TS_TURING_AGE_API 0
|
||||
#endif
|
||||
|
||||
#if TS_API_LEVEL >= TS_TURING_SHIELD_OPEN_API_LEVEL
|
||||
# define TS_TURING_SHIELD_OPEN_API 1
|
||||
#else
|
||||
# define TS_TURING_SHIELD_OPEN_API 0
|
||||
#endif
|
||||
|
||||
#if TS_API_LEVEL >= TS_FRIENDLY_API_LEVEL
|
||||
# define TS_FRIENDLY_API 1
|
||||
#else
|
||||
# define TS_FRIENDLY_API 0
|
||||
#endif
|
||||
|
||||
#if TS_API_LEVEL >= TS_PRIVATE_LEVEL
|
||||
# define TS_PRIVATE 1
|
||||
#else
|
||||
# define TS_PRIVATE 0
|
||||
#endif
|
||||
|
||||
#define TS_VISIBLE_LEVEL(APIKind) \
|
||||
__TS_IF_ELSE(APIKind) \
|
||||
/*CASE TRUE*/ (TS_ALWAYS_VISIBLE) \
|
||||
/*CASE FALSE*/ (TS_ALWAYS_HIDDEN)
|
||||
|
||||
|
||||
|
||||
#endif /* __TURING_SERVICE_DEFINE_H__ */
|
||||
@@ -0,0 +1,258 @@
|
||||
//
|
||||
// TuringServiceSettings.h
|
||||
// TuringShield
|
||||
//
|
||||
// Created by 徐森圣 on 2018/3/19.
|
||||
// Copyright © 2018年 Tecent Inc. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#ifndef TuringServiceSettings_h
|
||||
#define TuringServiceSettings_h
|
||||
|
||||
|
||||
/**
|
||||
编译目标,用于检查变量是否正确
|
||||
格式为TS_BUILD_TARGET_xxx
|
||||
|
||||
@discussion
|
||||
受Build Settings中环境变量TS_BUILD_TARGET影响并自动更新
|
||||
*/
|
||||
#define TS_BUILD_TARGET_YOUTU
|
||||
|
||||
/**
|
||||
定义为1,使用主人识别模型
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_OWNER_PROJECT 0
|
||||
|
||||
|
||||
/**
|
||||
定义为1,使用青少年识别模型
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_AGE_PROJECT 0
|
||||
|
||||
/**
|
||||
定义为1,使用人机识别模型
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_HUMAN_PROJECT 0
|
||||
|
||||
/**
|
||||
渠道号,用于决定用哪个模型
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_SDK_CHANNEL_ID 108138
|
||||
#define TS_SDK_CHANNEL_STRING __TS_TO_NSSTRING(TS_SDK_CHANNEL_ID)
|
||||
|
||||
/**
|
||||
SDK是否自带数据请求和回复逻辑
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_DATA_SENDING 1
|
||||
|
||||
/**
|
||||
SDK是否自带数据处理逻辑
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_PREDICTION_PROCEEDING 1
|
||||
|
||||
|
||||
/**
|
||||
SDK是否带请求签名逻辑,云端请求需要WAF服务配合,SDK需要打开
|
||||
TS_ENABLES_DATA_SENDING和TS_HUMAN_PROJECT
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_HTTP_REQUEST_SIGN 0
|
||||
|
||||
/**
|
||||
如果设置为非0,则同一个场景(scene)和事件(action)最多保留指定数量的数据
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_LIMITED_RECORDS_PER_SCENE_ACTION 20
|
||||
|
||||
/**
|
||||
实验室模式,某些逻辑在工程化前后可能有变化,服务器接口的调用方式也可能不一致
|
||||
目前人机部分默认值为0,主人识别部分默认值为1
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_LAB_LOGIC 0
|
||||
|
||||
/**
|
||||
打开日志打印
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENALBLES_LOG_PRINT 0
|
||||
|
||||
/**
|
||||
使用模型预测之前不检查数据非空
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_DONT_CHECK_DATA_SIZE 0
|
||||
|
||||
/**
|
||||
不记录(当然也不上报)触摸事件中的位置信息
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_DONT_RECORD_TOUCH_POSITION 0
|
||||
|
||||
|
||||
/**
|
||||
不加密打包的数据
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_DONT_ENCRYPT_PACKING_DATA 0
|
||||
|
||||
/**
|
||||
不压缩打包的数据
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_DONT_COMPRESS_PACKING_DATA 0
|
||||
|
||||
/**
|
||||
使用设备指纹特性
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_FINGERPRINT_FEATURE 1
|
||||
|
||||
/**
|
||||
支持的打包方式:WUP协议
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_NETWORKING_WUP_SUPPORTS 1
|
||||
|
||||
/**
|
||||
支持的打包方式:Shark协议
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_NETWORKING_SHARK_SUPPORTS 1
|
||||
|
||||
/**
|
||||
支持的打包方式:TMF Shark协议
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_NETWORKING_TMF_SHARK_SUPPORTS 0
|
||||
|
||||
|
||||
/**
|
||||
是否支持云控设备指纹配置;目前私有化部署不支持该选项
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_FINGERPRINT_CONFIG_CONTROL 1
|
||||
|
||||
|
||||
/**
|
||||
是否支持关键API篡改检测
|
||||
|
||||
@discussion
|
||||
受Build Settings中同名环境变量影响并自动更新
|
||||
*/
|
||||
#define TS_ENABLES_KEYED_API_CHECKING 1
|
||||
|
||||
|
||||
/**
|
||||
绑定的App bundle ID
|
||||
|
||||
@discussion
|
||||
设置后SDK将只能运行在指定的App上
|
||||
*/
|
||||
#define TS_BOUND_BUNDLE_IDENTIFIER nil
|
||||
#define TS_BOUND_BUNDLE_TOKEN { 0x00 }
|
||||
|
||||
|
||||
/**
|
||||
是否允许多渠道复用SDK
|
||||
|
||||
@discussion
|
||||
若打开,并且初始渠道号为0,则必须设置渠道号后才可以开始调用相关功能
|
||||
*/
|
||||
#define TS_ENABLES_CUSTOM_CHANNEL_ID 0
|
||||
|
||||
|
||||
|
||||
#define TS_DOMAIN_PREFIX_TOKEN com.tencent.TuringShield.
|
||||
#define TS_DOMAIN_PREFIX_CSTRING __TS_TO_CSTRING(TS_DOMAIN_PREFIX_TOKEN)
|
||||
#define TS_DOMAIN_PREFIX_STRING __TS_TO_NSSTRING(TS_DOMAIN_PREFIX_TOKEN)
|
||||
#define TS_DOMAIN_FOR_REACHABLITTY_TEST 8.8.8.8
|
||||
#define TS_DOMAIN_FOR_REACHABLITTY_TEST_CSTRING __TS_TO_CSTRING(TS_DOMAIN_FOR_REACHABLITTY_TEST)
|
||||
#define TS_DOMAIN_FOR_REACHABLITTY_TEST_STRING __TS_TO_NSSTRING(TS_DOMAIN_FOR_REACHABLITTY_TEST)
|
||||
|
||||
/**
|
||||
一些临时用的开关
|
||||
*/
|
||||
#define TS_ENABLES_SENSOR_RECORDING 0
|
||||
#define TS_ENABLES_SENSOR_REPLAYING 0
|
||||
#define TS_USES_OLD_MOTION_TRACKER_IF_NEEDED 1
|
||||
#define TS_ENABLES_CUSTOM_CLIENT_VERSION 0
|
||||
#define TS_ENABLES_CUSTOM_CHANNEL_ID 0
|
||||
#define TS_USES_CLASS_ALIAS 2
|
||||
#define TS_ACT_AS_TAID_ADVERTISER 0
|
||||
#define TS_ACT_AS_TAID_PROVIDER 1
|
||||
#define TS_ENABLES_FINGERPRINT_CONFIG_TEST 0
|
||||
#define TS_API_LEVEL TS_FRIENDLY_API_LEVEL
|
||||
#define TS_AVOID_USING_IDFA 1
|
||||
#define TS_FEATURE_DELEGATION 0
|
||||
#define TS_ENABLES_DEVICE_INFO_ACCESS 0
|
||||
|
||||
#define TS_TURING_ID_WRAPPER_APIS 0
|
||||
#define TS_TURING_AGE_WRAPPER_APIS 0
|
||||
#define TS_ANTIBOT_SDK 0
|
||||
#define TS_RISK_TOKEN_SDK 0
|
||||
#define TS_ENABLES_UAID_FETCHING 0
|
||||
#define TS_ENABLES_PHONE_MASK_FETCHING 0
|
||||
#define TS_ENABLES_RISK_DETECT_FEATURE 1
|
||||
#define TS_USES_RANDOM_NAMING 1
|
||||
#define TS_USES_GMSSL_AS_ENCRYPTION_ALGORITHM 0
|
||||
#define TS_ALLOWS_HTTP_POST_HANDLING 1
|
||||
#define TS_SKIP_GATHERER_AUTO_HANDLING 0
|
||||
#define TS_SIGNING_TOKEN_FEATURE 0
|
||||
#define TS_USING_SIGN_VALIFICATION 0
|
||||
#define TS_ENABLES_UNIVERSAL_TOKEN 0
|
||||
#define TS_USES_IDFV_LOCK 0
|
||||
#define TS_CAFISBRAIN_SDK 0
|
||||
|
||||
#define TS_SDK_VERSION 20074
|
||||
#define TS_SDK_LC_CODE QINN2D9KC5XY90F0
|
||||
#define TS_SDK_LC __TS_TO_NSSTRING(TS_SDK_LC_CODE)
|
||||
#define TS_SDK_BUILD_DATE 2024-08-15 19:28:34
|
||||
#define TS_ALIAS_SURFIX _YOUTU108138v20074
|
||||
|
||||
#endif /* TuringServiceSettings_h */
|
||||
Binary file not shown.
Reference in New Issue
Block a user