Skip to main content

aios_spec/
sanitized.rs

1//! 脱敏后事件类型 — 不含 PII,可在系统内自由传输。
2//!
3//! `SanitizedEvent` 是 `PrivacyAirGap` 的输出,是 DiPECS 数据模型的核心。
4
5use serde::{Deserialize, Serialize};
6
7use crate::event::{
8    AppTransition, ExtensionCategory, FsActivityType, InteractionType, LocationType, NetworkType,
9    RingerMode, ScreenState, SemanticHint, SourceTier, TextHint,
10};
11
12/// 脱敏后的事件。不再包含任何 PII。
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14pub struct SanitizedEvent {
15    pub event_id: String,
16    pub timestamp_ms: i64,
17    pub event_type: SanitizedEventType,
18    pub source_tier: SourceTier,
19    pub app_package: Option<String>,
20    pub uid: Option<u32>,
21}
22
23#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
24pub enum SanitizedEventType {
25    /// 应用前后台切换 (来自 UsageStatsManager)
26    AppTransition {
27        package_name: String,
28        activity_class: Option<String>,
29        transition: AppTransition,
30    },
31    /// 应用间交互 (从 Binder 事务推断)
32    InterAppInteraction {
33        source_package: Option<String>,
34        target_service: String,
35        interaction_type: InteractionType,
36    },
37    /// 通知 (脱敏后)
38    Notification {
39        source_package: String,
40        category: Option<String>,
41        channel_id: Option<String>,
42        title_hint: TextHint,
43        text_hint: TextHint,
44        semantic_hints: Vec<SemanticHint>,
45        is_ongoing: bool,
46        group_key: Option<String>,
47    },
48    /// 进程资源状态
49    ProcessResource {
50        pid: u32,
51        package_name: Option<String>,
52        vm_rss_mb: u32,
53        vm_swap_mb: u32,
54        thread_count: u32,
55        oom_score: i32,
56    },
57    /// 文件系统活动
58    FileActivity {
59        package_name: Option<String>,
60        extension_category: ExtensionCategory,
61        activity_type: FsActivityType,
62        is_hot_file: bool,
63    },
64    /// 屏幕状态
65    Screen { state: ScreenState },
66    /// 系统状态快照
67    SystemStatus {
68        battery_pct: Option<u8>,
69        is_charging: bool,
70        network: NetworkType,
71        ringer_mode: RingerMode,
72        location_type: LocationType,
73        headphone_connected: bool,
74    },
75}