Skip to main content

euv_core/platform/harmony/
const.rs

1/// Canonical HarmonyOS `module.json5` deviceType string for smartphones.
2pub const HARMONY_DEVICE_PHONE: &str = "phone";
3
4/// Canonical HarmonyOS `module.json5` deviceType string for tablets.
5pub const HARMONY_DEVICE_TABLET: &str = "tablet";
6
7/// Canonical HarmonyOS `module.json5` deviceType string for PCs / 2-in-1 laptops.
8pub const HARMONY_DEVICE_PC_2IN1: &str = "2in1";
9
10/// Canonical HarmonyOS device identifier for foldable displays.
11pub const HARMONY_DEVICE_FOLDABLE: &str = "foldable";
12
13/// Canonical HarmonyOS `module.json5` deviceType string for smartwatches/wearables.
14pub const HARMONY_DEVICE_WATCH: &str = "wearable";
15
16/// Canonical HarmonyOS `module.json5` deviceType string for Smart TV / Vision displays.
17pub const HARMONY_DEVICE_TV: &str = "tv";
18
19/// Canonical HarmonyOS `module.json5` deviceType string for Automotive / Cockpit displays.
20pub const HARMONY_DEVICE_AUTOMOTIVE: &str = "car";
21
22/// HarmonyOS ArkUI NDK shared library name exporting `OH_NativeXComponent_*` symbols.
23pub const HARMONY_LIB_ACE_NDK: &str = "libace_ndk.z.so";
24
25/// OpenHarmony native window shared library name exporting `OH_NativeWindow_*` symbols.
26pub const HARMONY_LIB_NATIVE_WINDOW: &str = "libnative_window.so";
27
28/// OpenHarmony NAPI runtime library name exporting `napi_*` symbols.
29pub const HARMONY_LIB_ACE_NAPI: &str = "libace_napi.z.so";
30
31/// OpenHarmony native VSync shared library name exporting `OH_NativeVSync_*` symbols.
32pub const HARMONY_LIB_NATIVE_VSYNC: &str = "libnative_vsync.so";
33
34/// OpenHarmony `OH_NativeXComponent` touch down type constant (`OH_NATIVEXCOMPONENT_DOWN`).
35pub const HARMONY_TOUCH_DOWN: i32 = 0;
36
37/// OpenHarmony `OH_NativeXComponent` touch up type constant (`OH_NATIVEXCOMPONENT_UP`).
38pub const HARMONY_TOUCH_UP: i32 = 1;
39
40/// OpenHarmony `OH_NativeXComponent` touch move type constant (`OH_NATIVEXCOMPONENT_MOVE`).
41pub const HARMONY_TOUCH_MOVE: i32 = 2;
42
43/// OpenHarmony `OH_NativeXComponent` touch cancel type constant (`OH_NATIVEXCOMPONENT_CANCEL`).
44pub const HARMONY_TOUCH_CANCEL: i32 = 3;
45
46/// OpenHarmony `OHNativeWindow` `SET_BUFFER_GEOMETRY` handle option code.
47pub const HARMONY_NW_OPT_SET_BUFFER_GEOMETRY: i32 = 0;
48
49/// OpenHarmony `OHNativeWindow` `GET_BUFFER_GEOMETRY` handle option code.
50pub const HARMONY_NW_OPT_GET_BUFFER_GEOMETRY: i32 = 1;
51
52/// OpenHarmony `OHNativeWindow` `SET_FORMAT` handle option code (`PIXEL_FMT_RGBA_8888 = 12`).
53pub const HARMONY_NW_OPT_SET_FORMAT: i32 = 3;
54
55/// OpenHarmony `PIXEL_FMT_RGBA_8888` native buffer pixel format code.
56pub const HARMONY_PIXEL_FMT_RGBA_8888: i32 = 12;
57
58/// OpenHarmony `OH_NativeXComponent` key code for system Back (`KEYCODE_BACK`).
59pub const HARMONY_KEYCODE_BACK: i32 = 2;
60
61/// OpenHarmony `OH_NativeXComponent` key code for D-pad Up (`KEYCODE_DPAD_UP`).
62pub const HARMONY_KEYCODE_DPAD_UP: i32 = 2012;
63
64/// OpenHarmony `OH_NativeXComponent` key code for D-pad Down (`KEYCODE_DPAD_DOWN`).
65pub const HARMONY_KEYCODE_DPAD_DOWN: i32 = 2013;
66
67/// OpenHarmony `OH_NativeXComponent` key code for D-pad Left (`KEYCODE_DPAD_LEFT`).
68pub const HARMONY_KEYCODE_DPAD_LEFT: i32 = 2014;
69
70/// OpenHarmony `OH_NativeXComponent` key code for D-pad Right (`KEYCODE_DPAD_RIGHT`).
71pub const HARMONY_KEYCODE_DPAD_RIGHT: i32 = 2015;
72
73/// OpenHarmony `OH_NativeXComponent` key code for D-pad Center / OK (`KEYCODE_DPAD_CENTER`).
74pub const HARMONY_KEYCODE_DPAD_CENTER: i32 = 2016;
75
76/// OpenHarmony `OH_NativeXComponent` key code for Tab (`KEYCODE_TAB`).
77pub const HARMONY_KEYCODE_TAB: i32 = 2049;
78
79/// OpenHarmony `OH_NativeXComponent` key code for Space (`KEYCODE_SPACE`).
80pub const HARMONY_KEYCODE_SPACE: i32 = 2050;
81
82/// OpenHarmony `OH_NativeXComponent` key code for Enter (`KEYCODE_ENTER`).
83pub const HARMONY_KEYCODE_ENTER: i32 = 2054;
84
85/// OpenHarmony `OH_NativeXComponent` key code for Backspace (`KEYCODE_DEL`).
86pub const HARMONY_KEYCODE_DEL: i32 = 2055;
87
88/// OpenHarmony `OH_NativeXComponent` key code for Forward Delete (`KEYCODE_FORWARD_DEL`).
89pub const HARMONY_KEYCODE_FORWARD_DEL: i32 = 2071;
90
91/// OpenHarmony `OH_NativeXComponent` key code for Escape (`KEYCODE_ESCAPE`).
92pub const HARMONY_KEYCODE_ESCAPE: i32 = 2070;
93
94/// OpenHarmony `AbilityConstant.MemoryLevel.MEMORY_LEVEL_MODERATE`.
95pub const HARMONY_MEMORY_MODERATE: i32 = 0;
96
97/// OpenHarmony `AbilityConstant.MemoryLevel.MEMORY_LEVEL_LOW`.
98pub const HARMONY_MEMORY_LOW: i32 = 1;
99
100/// OpenHarmony `AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL`.
101pub const HARMONY_MEMORY_CRITICAL: i32 = 2;
102
103/// Default HarmonyOS phone top status bar inset in logical vp.
104pub(crate) const HARMONY_PHONE_SAFE_TOP_VP: f32 = 38.0;
105
106/// Default HarmonyOS phone bottom navigation indicator inset in logical vp.
107pub(crate) const HARMONY_PHONE_SAFE_BOTTOM_VP: f32 = 28.0;
108
109/// Default HarmonyOS TV overscan safe margin in logical vp.
110pub(crate) const HARMONY_TV_OVERSCAN_VP: f32 = 24.0;
111
112/// Default HarmonyOS automotive status/dock safe inset in logical vp.
113pub(crate) const HARMONY_CAR_DOCK_VP: f32 = 44.0;
114
115/// Default initial route path for HarmonyOS UIAbility sessions.
116pub(crate) const HARMONY_DEFAULT_ROUTE: &str = "/";
117
118/// Default HarmonyOS XComponent surface identifier.
119pub(crate) const HARMONY_DEFAULT_XCOMPONENT_ID: &str = "euv_xcomponent";
120
121/// Minimum valid VSync frame interval in nanoseconds (`1 ms` / `1000 Hz`).
122pub(crate) const HARMONY_VSYNC_MIN_PERIOD_NS: i64 = 1_000_000;
123
124/// Maximum valid VSync frame interval in nanoseconds (`100 ms` / `10 Hz`).
125pub(crate) const HARMONY_VSYNC_MAX_PERIOD_NS: i64 = 100_000_000;
126
127/// Error message when `OHNativeWindow` surface buffer request or flush fails.
128#[cfg(target_env = "ohos")]
129pub(crate) const ERR_HARMONY_SURFACE_POST: &str = "harmony OHNativeWindow buffer post failed";
130
131/// Registered `OH_NativeVSync` channel identifier string.
132#[cfg(target_env = "ohos")]
133pub(crate) const HARMONY_VSYNC_NAME: &str = "euv_harmony_vsync";
134
135/// Sync fence `poll(2)` wait timeout in milliseconds before falling back to write.
136#[cfg(target_env = "ohos")]
137pub(crate) const HARMONY_FENCE_POLL_TIMEOUT_MS: i32 = 16;
138
139/// POSIX `POLLIN` flag for waiting on an acquire sync fence FD.
140#[cfg(target_env = "ohos")]
141pub(crate) const HARMONY_POLLIN: i16 = 0x0001;
142
143/// POSIX `PROT_READ | PROT_WRITE` mapping flags for `OhBufferHandle::fd`.
144#[cfg(target_env = "ohos")]
145pub(crate) const HARMONY_PROT_READ_WRITE: i32 = 0x3;
146
147/// POSIX `MAP_SHARED` mapping flag for `OhBufferHandle::fd`.
148#[cfg(target_env = "ohos")]
149pub(crate) const HARMONY_MAP_SHARED: i32 = 0x1;
150
151/// Sentinel `MAP_FAILED` address (`(void*)-1`) returned by `mmap(2)`.
152#[cfg(target_env = "ohos")]
153pub(crate) const HARMONY_MAP_FAILED: usize = usize::MAX;