Fix Android sandbox onboarding and surface insets; checkpoint application cache
android-ci / android-arm64 (push) Successful in 18m47s

This commit is contained in:
bit9992 committed 2026-11-12 13:25:41 +03:00
1 parent 52d2c22ec0
commit fd41389d63
9 files changed
+365 -33

No files matched your search

+15 -2
View File
@@ -428,6 +428,13 @@ impl ConfinedSource {
}
#[cfg(unix)]
fn open_unix_absolute(path: &Path) -> Result<File> {
// Android grants search, not directory-read access, above the app sandbox.
#[cfg(target_os = "android")]
let root = {
use std::os::unix::fs::OpenOptionsExt;
OpenOptions::new().read(true).custom_flags(libc::O_PATH | libc::O_DIRECTORY | libc::O_NOFOLLOW | libc::O_CLOEXEC).open("/")?
};
#[cfg(not(target_os = "android"))]
let root = File::open("/")?;
open_unix_relative(&root, path.strip_prefix("/").map_err(|_| err("invalid_profile_path", "Invalid absolute path"))?)
}
@@ -445,10 +452,16 @@ fn open_unix_relative(root: &File, path: &Path) -> Result<File> {
#[cfg(any(target_os = "macos", target_os = "ios"))] const NONBLOCK: i32 = 4;
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] const NONBLOCK: i32 = 0x800;
let mut file = root.try_clone()?;
for component in path.components() {
let mut components = path.components().peekable();
while let Some(component) = components.next() {
let Component::Normal(name) = component else { return Err(err("invalid_profile_path", "Invalid path component")) };
let name = CString::new(name.as_bytes()).map_err(|_| err("invalid_profile_path", "Invalid path byte"))?;
let fd = unsafe { openat(file.as_raw_fd(), name.as_ptr(), NOFOLLOW | CLOEXEC | NONBLOCK) }; // nonblocking prevents FIFO hangs; regular files unaffected
let flags = NOFOLLOW | CLOEXEC | NONBLOCK;
// Pin ancestors without requesting read/list permission. The final entry
// still needs normal read access; O_DIRECTORY + NOFOLLOW reject links.
#[cfg(target_os = "android")]
let flags = if components.peek().is_some() { flags | libc::O_PATH | libc::O_DIRECTORY } else { flags };
let fd = unsafe { openat(file.as_raw_fd(), name.as_ptr(), flags) }; // nonblocking prevents FIFO hangs; regular files unaffected
if fd < 0 { return Err(std::io::Error::last_os_error().into()); }
file = unsafe { File::from_raw_fd(fd) };
deny_link(&file.metadata()?)?;
@@ -204,6 +204,27 @@ fn descriptor_relative_opens_reject_directory_and_file_links() {
assert!(open_unix_relative(&root, Path::new("file-link")).is_err());
}
#[cfg(target_os = "android")]
#[test]
fn onboarding_traverses_search_only_ancestors_without_following_links() {
use std::os::unix::fs::{PermissionsExt, symlink};
let fixture = Fixture::new();
let ancestor = fixture.0.join("search-only");
let container = ancestor.join("files");
fs::create_dir_all(&container).unwrap();
let destination = container.join("profile-v1");
symlink(&container, ancestor.join("linked-files")).unwrap();
fs::set_permissions(&ancestor, fs::Permissions::from_mode(0o100)).unwrap();
let created = initialize_native_root(&destination);
let inspected = inspect_native_root(&destination);
let escaped = open_unix_absolute(&ancestor.join("linked-files/profile-v1"));
// Restore directory access before assertions so Fixture always cleans up.
fs::set_permissions(&ancestor, fs::Permissions::from_mode(0o700)).unwrap();
created.unwrap();
assert_eq!(inspected.unwrap(), ProfileRootState::Native);
assert!(escaped.is_err());
}
#[test]
fn legacy_discovery_returns_all_real_candidates_without_opening_keys() {
let fixture = Fixture::new();
+3 -1
View File
@@ -16,7 +16,7 @@ export component AppWindow inherits Window {
preferred-width: 1280px;
preferred-height: 800px;
min-width: 320px;
min-height: 360px;
min-height: Theme.android ? 0px : 360px;
default-font-family: Theme.font-family;
default-font-size: Theme.font-size;
background: Theme.shaded;
@@ -32,6 +32,8 @@ export component AppWindow inherits Window {
}
measure := Text { visible: false; accessible-role: none; }
keyboard := FocusScope {
// Android reports only the overlap remaining inside the rendering surface.
// Bars and IME overlap at the bottom: reserve their maximum, not their sum.
x: Theme.safe-left; y: Theme.safe-top;
width: max(0px, parent.width - Theme.safe-left - Theme.safe-right);
height: max(0px, parent.height - Theme.safe-top - max(Theme.safe-bottom, Theme.ime-inset));
+4 -6
View File
@@ -32,9 +32,12 @@ component AndroidOnboarding inherits Rectangle {
background: Theme.shaded;
accessible-role: form;
accessible-label: DialogBridge.title;
property <bool> typing: Theme.ime-inset > 0px;
// A resized Android surface can exclude the IME entirely, leaving a zero overlap inset.
property <bool> typing: Theme.ime-inset > 0px || root.height < 480px;
VerticalLayout {
padding: root.typing ? 12px : 24px;
padding-top: root.typing ? 16px : 28px;
padding-bottom: 8px;
spacing: root.typing ? 6px : 16px;
Text { text: DialogBridge.title; color: Theme.fg; font-size: Theme.font-size * (root.typing ? 1.25 : 1.8); font-weight: 700; wrap: word-wrap; }
if !root.typing: Text { text: DialogBridge.description; color: Theme.fg; font-size: Theme.font-size; wrap: word-wrap; }
@@ -60,11 +63,6 @@ component AndroidOnboarding inherits Rectangle {
if DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
if DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.fg; }
Rectangle { vertical-stretch: 1; min-height: 0px; }
if !root.typing: VerticalLayout {
spacing: 4px;
vertical-stretch: 0;
for action in DialogBridge.actions: ActionButton { text: action.label; enabled: action.enabled && !DialogBridge.busy; destructive: action.destructive; clicked => { ShellBridge.invoke(action.id); } }
}
ActionButton { height: Theme.touch-target; vertical-stretch: 0; text: DialogBridge.submit-label; primary: true; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
ActionButton { height: Theme.touch-target; vertical-stretch: 0; text: DialogBridge.cancel-label; enabled: !DialogBridge.busy; clicked => { DialogBridge.cancel(); } }
}