1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use std::path::Path;
use crate::error::PlatformError;
pub trait UpdateService: Send + Sync + 'static {
/// Show download progress UI
fn show_download_progress(&self) -> Result<(), PlatformError> {
Ok(())
}
/// Update download progress (0-100)
fn update_download_progress(&self, _progress: i32) -> Result<(), PlatformError> {
Ok(())
}
/// Dismiss download progress UI
fn dismiss_download_progress(&self) -> Result<(), PlatformError> {
Ok(())
}
/// Show update confirmation prompt and invoke callback with the result.
///
/// # Arguments
/// * `callback_id` - Callback ID for result
/// * `update_info_json` - Optional JSON string with update details:
/// {"version":"1.2.0","size":15728640,"releaseNotes":["..."],"isForceUpdate":true}
///
/// # Callback behavior
/// - Confirm: callback success with payload (e.g. {"confirm":true})
/// - Cancel: callback error code 2000
fn show_update_prompt(
&self,
_callback_id: u64,
_update_info_json: Option<&str>,
) -> Result<(), PlatformError> {
Err(PlatformError::NotSupported(
"show_update_prompt not implemented for this platform".to_string(),
))
}
/// Requests installation of an application update from a local package file.
///
/// This starts the platform-specific apply flow and returns once the request
/// is handed off to the updater helper.
///
/// # Arguments
/// * `package_path` - Local, readable update package path (e.g. .apk on Android)
///
/// # Platform Support / Notes
/// - Android: Launches the system installer; requires user confirmation.
/// Requires `REQUEST_INSTALL_PACKAGES` and a `FileProvider` for APK sharing.
/// - macOS: Applies a prepared `.zip` or `.app` update and relaunches the app.
/// - iOS: Not supported (App Store only).
/// - HarmonyOS: Not implemented (returns error).
fn install_update(&self, package_path: &Path) -> Result<(), PlatformError> {
let _ = package_path;
Err(PlatformError::NotSupported(
"install_update not implemented for this platform".to_string(),
))
}
}