fingerprint.dart 6.3 KB

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