fix:参考金值,研听,研值工程通用通用工程公共能力,重点对比网络请求、登录认证、状态管理、本地存储、WebView、推送、版本更新、一键登录、主题/UI 等模块,确定后续统一整改方案
This commit is contained in:
1 parent
6997a65c96
commit
d364c6d908
46 files changed
+2060
-395
No files matched your search
@@ -5,13 +5,14 @@ import 'package:android_oaid/android_oaid.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb;
|
||||
import 'package:flutter_paid/flutter_paid.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:platform_metadata/platform_metadata.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../storage/storage_keys.dart';
|
||||
import '../storage/storage_service.dart';
|
||||
import '../storage/preferences_storage.dart';
|
||||
import '../storage/secure_identity_storage.dart';
|
||||
import '../privacy/privacy_gate.dart';
|
||||
|
||||
/// 请求公共 + 平台身份 header 来源(完全对齐研值契约)。
|
||||
@@ -26,8 +27,6 @@ import '../privacy/privacy_gate.dart';
|
||||
class DeviceHeaderService {
|
||||
DeviceHeaderService._();
|
||||
static final DeviceHeaderService to = DeviceHeaderService._();
|
||||
static const _storage = FlutterSecureStorage();
|
||||
static const _kDeviceIdKey = 'device_id';
|
||||
// static const _platformMetadataChannel = MethodChannel('platform_metadata');
|
||||
|
||||
// 渠道:优先编译期 --dart-define=UMENG_CHANNEL=xxx;Android 其次读 manifest,
|
||||
@@ -48,6 +47,9 @@ class DeviceHeaderService {
|
||||
Future<void>? _baseInitialization;
|
||||
Future<void>? _identityInitialization;
|
||||
|
||||
SecureIdentityStorage get _identityStorage =>
|
||||
SecureIdentityStorage(PreferencesStorage(StorageService.to.preferences));
|
||||
|
||||
Future<void> ensureInitialized() async {
|
||||
_baseInitialization ??= _initializeBase();
|
||||
await _baseInitialization;
|
||||
@@ -89,14 +91,14 @@ class DeviceHeaderService {
|
||||
/// X-Device-Id:iOS 优先 IDFV(per-vendor 稳定),否则 UUIDv4;
|
||||
/// 首次生成后写入 secure_storage,后续复用。
|
||||
Future<String> _resolveDeviceId() async {
|
||||
final stored = await _storage.read(key: _kDeviceIdKey);
|
||||
final stored = await _identityStorage.readDeviceId();
|
||||
if (stored != null && stored.isNotEmpty) return stored;
|
||||
var id = '';
|
||||
if (!kIsWeb && Platform.isIOS) {
|
||||
id = await _resolveIdfv();
|
||||
}
|
||||
if (id.isEmpty) id = const Uuid().v4();
|
||||
await _storage.write(key: _kDeviceIdKey, value: id);
|
||||
await _identityStorage.saveDeviceId(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user