fingerprint.dart 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. import '../../constants/configs.dart';
  2. import 'disconnect_domain.dart';
  3. /// 设备指纹信息
  4. ///
  5. /// 描述用户软件、硬件设备相关信息
  6. class Fingerprint {
  7. /// 软件产品名称
  8. String productCode;
  9. /// 硬件平台标识符
  10. String platform;
  11. /// 渠道标识符
  12. String channel;
  13. /// 设备硬件ID
  14. String deviceId;
  15. /// 版本值
  16. int appVersionCode;
  17. /// 版本名称
  18. String appVersionName;
  19. /// 设备语言
  20. String lang;
  21. /// 设备型号
  22. String deviceModel;
  23. /// 设备系统类型
  24. String deviceOs;
  25. /// 设备品牌
  26. String deviceBrand;
  27. /// 设备宽度
  28. int deviceWidth;
  29. /// 设备高度
  30. int deviceHeight;
  31. /// ios 钥匙串
  32. String keychain;
  33. /// Google Services Framework ID
  34. String gsfId;
  35. /// Google Advertising ID
  36. String googleId;
  37. /// Android ID
  38. String androidId;
  39. /// iOS IDFA
  40. String idfa;
  41. /// 设备时区
  42. int timezoneOffset;
  43. /// installReferrer
  44. String refer;
  45. String country;
  46. /// 是否是新安装
  47. bool isNewInstall;
  48. /// 用户UUID
  49. String userUuid;
  50. /// 是否有SIM卡
  51. bool simReady;
  52. /// 运营商
  53. String carrierName;
  54. /// 运营商MCC
  55. String mcc;
  56. /// 运营商MNC
  57. String mnc;
  58. /// 国家ISO
  59. String countryIso;
  60. String networkCarrierName;
  61. String networkMcc;
  62. String networkMnc;
  63. String networkCountryIso;
  64. // 手机国家码
  65. String phoneCountryIso;
  66. /// 是否VPN
  67. bool isVpn;
  68. /// 是否连接自己的VPN
  69. bool isConnectedVpn;
  70. /// 是否是开发者模式
  71. int adb;
  72. /// 连接不上网络的域名
  73. List<DisconnectDomain> disconnectDomainList;
  74. /// 扩展数据
  75. dynamic exData;
  76. /// 默认构造函数
  77. Fingerprint({
  78. required this.productCode,
  79. required this.platform,
  80. required this.channel,
  81. required this.deviceId,
  82. required this.appVersionCode,
  83. required this.appVersionName,
  84. required this.lang,
  85. required this.deviceModel,
  86. required this.deviceOs,
  87. required this.deviceBrand,
  88. required this.deviceWidth,
  89. required this.deviceHeight,
  90. this.keychain = '',
  91. this.gsfId = '',
  92. this.googleId = '',
  93. this.androidId = '',
  94. this.idfa = '',
  95. this.refer = '',
  96. required this.timezoneOffset,
  97. required this.country,
  98. this.isNewInstall = false,
  99. this.userUuid = '',
  100. this.simReady = false,
  101. this.carrierName = '',
  102. this.mcc = '',
  103. this.mnc = '',
  104. this.countryIso = '',
  105. this.networkCarrierName = '',
  106. this.networkMcc = '',
  107. this.networkMnc = '',
  108. this.networkCountryIso = '',
  109. this.phoneCountryIso = '',
  110. this.isVpn = false,
  111. this.isConnectedVpn = false,
  112. this.adb = 2,
  113. this.disconnectDomainList = const [],
  114. this.exData,
  115. });
  116. /// 空对象构造函数
  117. factory Fingerprint.empty() {
  118. return Fingerprint(
  119. productCode: Configs.productCode,
  120. platform: 'unknown',
  121. channel: 'unknown',
  122. deviceId: '',
  123. appVersionCode: 0,
  124. appVersionName: '',
  125. lang: 'en',
  126. deviceModel: 'unknown',
  127. deviceOs: 'unknown',
  128. deviceBrand: 'unknown',
  129. deviceWidth: 0,
  130. deviceHeight: 0,
  131. timezoneOffset: DateTime.now().timeZoneOffset.inSeconds,
  132. country: '',
  133. isNewInstall: false,
  134. userUuid: '',
  135. simReady: false,
  136. carrierName: '',
  137. mcc: '',
  138. mnc: '',
  139. countryIso: '',
  140. networkCarrierName: '',
  141. networkMcc: '',
  142. networkMnc: '',
  143. networkCountryIso: '',
  144. phoneCountryIso: '',
  145. isVpn: false,
  146. isConnectedVpn: false,
  147. adb: 2,
  148. disconnectDomainList: const [],
  149. exData: null,
  150. );
  151. }
  152. /// 从JSON创建对象
  153. factory Fingerprint.fromJson(Map<String, dynamic> json) {
  154. return Fingerprint(
  155. productCode: json['productCode'] ?? Configs.productCode,
  156. platform: json['platform'] ?? 'unknown',
  157. channel: json['channel'] ?? 'unknown',
  158. deviceId: json['deviceId'] ?? '',
  159. appVersionCode: json['appVersionCode'] ?? 0,
  160. appVersionName: json['appVersionName'] ?? '',
  161. lang: json['lang'] ?? 'en',
  162. deviceModel: json['deviceModel'] ?? 'unknown',
  163. deviceOs: json['deviceOs'] ?? 'unknown',
  164. deviceBrand: json['deviceBrand'] ?? 'unknown',
  165. deviceWidth: json['deviceWidth'] ?? 0,
  166. deviceHeight: json['deviceHeight'] ?? 0,
  167. keychain: json['keychain'] ?? '',
  168. gsfId: json['gsfId'] ?? '',
  169. googleId: json['googleId'] ?? '',
  170. androidId: json['androidId'] ?? '',
  171. idfa: json['idfa'] ?? '',
  172. refer: json['refer'] ?? '',
  173. timezoneOffset:
  174. json['timezoneOffset'] ?? DateTime.now().timeZoneOffset.inSeconds,
  175. country: json['country'] ?? '',
  176. isNewInstall: json['isNewInstall'] ?? false,
  177. userUuid: json['userUuid'] ?? '',
  178. simReady: json['simReady'] ?? false,
  179. carrierName: json['carrierName'] ?? '',
  180. mcc: json['mcc'] ?? '',
  181. mnc: json['mnc'] ?? '',
  182. countryIso: json['countryIso'] ?? '',
  183. networkCarrierName: json['networkCarrierName'] ?? '',
  184. networkMcc: json['networkMcc'] ?? '',
  185. networkMnc: json['networkMnc'] ?? '',
  186. networkCountryIso: json['networkCountryIso'] ?? '',
  187. phoneCountryIso: json['phoneCountryIso'] ?? '',
  188. isVpn: json['isVpn'] ?? false,
  189. isConnectedVpn: json['isConnectedVpn'] ?? false,
  190. adb: json['adb'] ?? 2,
  191. disconnectDomainList: json['disconnectDomainList'] ?? const [],
  192. exData: json['exData'],
  193. );
  194. }
  195. /// 转换为Map
  196. Map<String, dynamic> toJson() {
  197. return {
  198. 'productCode': productCode,
  199. 'platform': platform,
  200. 'channel': channel,
  201. 'deviceId': deviceId,
  202. 'appVersionCode': appVersionCode,
  203. 'appVersionName': appVersionName,
  204. 'lang': lang,
  205. 'deviceModel': deviceModel,
  206. 'deviceOs': deviceOs,
  207. 'deviceBrand': deviceBrand,
  208. 'deviceWidth': deviceWidth,
  209. 'deviceHeight': deviceHeight,
  210. 'keychain': keychain,
  211. 'gsfId': gsfId,
  212. 'googleId': googleId,
  213. 'androidId': androidId,
  214. 'idfa': idfa,
  215. 'refer': refer,
  216. 'timezoneOffset': timezoneOffset,
  217. 'country': country,
  218. 'isNewInstall': isNewInstall,
  219. 'userUuid': userUuid,
  220. 'simReady': simReady,
  221. 'carrierName': carrierName,
  222. 'mcc': mcc,
  223. 'mnc': mnc,
  224. 'countryIso': countryIso,
  225. 'networkCarrierName': networkCarrierName,
  226. 'networkMcc': networkMcc,
  227. 'networkMnc': networkMnc,
  228. 'networkCountryIso': networkCountryIso,
  229. 'phoneCountryIso': phoneCountryIso,
  230. 'isVpn': isVpn,
  231. 'isConnectedVpn': isConnectedVpn,
  232. 'adb': adb,
  233. 'disconnectDomainList': disconnectDomainList,
  234. 'exData': exData,
  235. };
  236. }
  237. @override
  238. String toString() {
  239. return toJson().toString();
  240. }
  241. }