CLAUDE.md 1.2 KB

DeviceID 模块

模块概述

DeviceID 模块提供设备唯一标识管理功能,生成和维护稳定的设备ID,支持多种ID生成策略和持久化方案。

主要功能

1. 设备ID生成

  • Android ID: 使用系统Android ID
  • UUID生成: 随机UUID作为设备标识
  • 复合ID: 结合多种方式生成稳定ID
  • 自定义策略: 支持自定义ID生成算法

2. ID持久化

  • SharedPreferences存储: 本地持久化设备ID
  • 文件备份: 多重备份确保ID稳定性
  • 恢复机制: ID丢失时的恢复策略

3. 隐私合规

  • 用户授权: 遵循隐私政策要求
  • 数据脱敏: 必要时进行数据脱敏
  • 重置功能: 支持用户重置设备ID

核心接口

interface DeviceIDService {
    fun getDeviceId(): String
    fun resetDeviceId(): String
    fun isDeviceIdValid(): Boolean
}

使用方式

// 获取设备ID
val deviceId = DeviceIDService.getDeviceId()

// 检查ID有效性
if (DeviceIDService.isDeviceIdValid()) {
    // 使用设备ID
}

// 重置设备ID(需要用户授权)
val newDeviceId = DeviceIDService.resetDeviceId()

构建配置

implementation "com.wenext.android:frame-deviceid:6.0.0"