feat: 新增安卓平台支持

This commit is contained in:
mofeng-git
2026-05-24 08:37:19 +00:00
parent dc6475776e
commit b31aae284d
105 changed files with 7900 additions and 473 deletions

View File

@@ -49,16 +49,26 @@ pub fn ensure_libcomposite_loaded() -> Result<()> {
}
pub fn find_udc() -> Option<String> {
let udc_path = Path::new("/sys/class/udc");
if !udc_path.exists() {
return None;
}
list_udcs().into_iter().next()
}
fs::read_dir(udc_path)
.ok()?
.filter_map(|e| e.ok())
.map(|e| e.file_name().to_string_lossy().to_string())
.next()
pub fn list_udcs() -> Vec<String> {
let mut devices = Vec::new();
collect_dir_names(Path::new("/sys/class/udc"), &mut devices);
devices.sort();
devices.dedup();
devices
}
fn collect_dir_names(path: &Path, devices: &mut Vec<String>) {
if let Ok(entries) = fs::read_dir(path) {
for entry in entries.flatten() {
let name = entry.file_name().to_string_lossy().trim().to_string();
if !name.is_empty() {
devices.push(name);
}
}
}
}
pub fn is_low_endpoint_udc(name: &str) -> bool {