Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d2c3c88 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: Fix the PID extract function

After https://r.android.com/3205038, the function always returns None
because the path doesn't contain any "/".

Bug: 356808668
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: Deploy to CrOS and reboot, BT can start
Flag: EXEMPT, Floss-only changes
Change-Id: I99208b1a8509336da71925fef7a05a159ed4d8ed
parent 176136b1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -286,6 +286,7 @@ fn pid_inotify_async_fd() -> AsyncFd<inotify::Inotify> {
/// Given an pid path, returns the adapter index for that pid path.
fn get_hci_index_from_pid_path(path: &str) -> Option<VirtualHciIndex> {
    path.rsplit_once('/')
        .or_else(|| Some(("", path))) // Contains no '/', so |path| is the last component.
        .and_then(|tup| tup.1.strip_prefix("bluetooth"))
        .and_then(|s| s.strip_suffix(".pid"))
        .and_then(|p| p.parse::<i32>().ok())