euv_core/platform/harmony/enum.rs
1use super::*;
2
3/// Unified host-declared rendering channel shared across HarmonyOS, Wearables, MiniApps, and QuickApps.
4#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum HostRenderChannel {
6 /// Direct native GPU rendering on a verified host surface (Vulkan / GLES3 / Metal).
7 GpuDirect,
8 /// GPU texture upload from a CPU software framebuffer.
9 GpuUpload,
10 /// Native CPU software pixel buffer (`OH_NativeWindow` / watch framebuffer).
11 #[default]
12 SoftwareBuffer,
13 /// Host `<canvas>` 2D context (`putImageData`).
14 Canvas2d,
15 /// Host `<canvas>` WebGL 1.0 context.
16 WebGl,
17 /// Host `<canvas>` WebGL 2.0 context.
18 WebGl2,
19}
20
21/// All 7 HarmonyOS / OpenHarmony physical device categories unified by `HarmonyPlatform`.
22#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub enum HarmonyDeviceType {
24 /// HarmonyOS smartphone (`deviceType: "phone"`).
25 #[default]
26 Phone,
27 /// HarmonyOS tablet (`deviceType: "tablet"`).
28 Tablet,
29 /// HarmonyOS PC / 2-in-1 desktop (`deviceType: "2in1"`).
30 Pc2In1,
31 /// HarmonyOS foldable phone/tablet with dynamic hinge transitions (`"foldable"`).
32 Foldable,
33 /// HarmonyOS Watch / Wearable (`deviceType: "wearable"`).
34 Watch,
35 /// HarmonyOS Smart TV / Vision (`deviceType: "tv"`).
36 Tv,
37 /// HarmonyOS Automotive / Smart Cockpit (`deviceType: "car"`).
38 Automotive,
39}
40
41/// Physical hinge posture state reported by HarmonyOS foldable devices (`display.FoldStatus`).
42#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
43pub enum HarmonyFoldState {
44 /// Device is closed to its compact cover screen.
45 Folded,
46 /// Device is partially unfolded (tent / flex laptop posture).
47 HalfFolded,
48 /// Device is fully unfolded to its tablet-class inner display.
49 #[default]
50 Expanded,
51}
52
53/// Active native rendering path bound to HarmonyOS `OHNativeWindow`.
54#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub enum HarmonyGraphicsApi {
56 /// Direct GPU rendering over Khronos Vulkan (`VK_OHOS_surface`).
57 Vulkan,
58 /// Direct GPU rendering over EGL + OpenGL ES 3.0 (`eglCreateWindowSurface`).
59 #[default]
60 OpenGlEs3,
61 /// Reference CPU software buffer upload via `OH_NativeWindow_NativeWindowRequestBuffer` / `FlushBuffer`.
62 SoftwareBuffer,
63}
64
65/// Stage-Model HarmonyOS `UIAbility` and `WindowStage` lifecycle hooks normalized into EUV `SystemEvent`s.
66#[derive(Clone, Debug, PartialEq)]
67pub enum HarmonyLifecycleHook {
68 /// `UIAbility.onCreate(want)` creating a fresh ability session.
69 OnCreate {
70 /// Optional incoming Want URI deep link.
71 want_uri: Option<String>,
72 },
73 /// `UIAbility.onWindowStageCreate(windowStage)` attaching `OHNativeWindow` / `XComponent`.
74 OnWindowStageCreate {
75 /// Raw `OHNativeWindow*` pointer (`0` when deferred).
76 native_window: usize,
77 /// Raw `OH_NativeXComponent*` pointer (`0` when deferred).
78 xcomponent: usize,
79 },
80 /// `UIAbility.onForeground()` resuming rendering and active interactive frame pumping.
81 OnForeground,
82 /// `WindowStageEventType.ACTIVE` signaling active window input focus.
83 OnWindowActive,
84 /// `WindowStageEventType.INACTIVE` signaling transient focus loss (control center, multi-window switch).
85 OnWindowInactive,
86 /// `UIAbility.onBackground()` freezing rendering, timers, and frame pumping (0% CPU/GPU).
87 OnBackground,
88 /// `UIAbility.onWindowStageDestroy()` detaching native surface handles safely.
89 OnWindowStageDestroy,
90 /// `UIAbility.onDestroy()` terminating the ability session gracefully.
91 OnDestroy,
92 /// `UIAbility.onMemoryLevel(level)` reporting OS memory pressure.
93 OnMemoryLevel(i32),
94 /// `UIAbility.onConfigurationUpdate` updating theme, locale, density, or foldable state.
95 OnConfigurationUpdate {
96 /// Updated OS appearance mode (`Light` / `Dark`).
97 theme: ThemeMode,
98 /// Updated BCP-47 locale tag.
99 locale: String,
100 /// Updated display density scale factor (`vp -> px`).
101 density: f32,
102 /// Optional updated foldable hinge posture.
103 fold_state: Option<HarmonyFoldState>,
104 },
105 /// System gesture or hardware Back button press (`onBackPress`).
106 OnBackPress,
107 /// Warm-launch `UIAbility.onNewWant(want)` delivering a new deep-link URI.
108 OnNewWant(String),
109}