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

Commit 7a194cf6 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Floss: Implement no-op Suspend/Resume API

To prepare for powerd integration:
* Enable object manager for adapter objects so that btmanagerd can
  properly detect adapter readiness of Suspend API
* Implement no-op Suspend/Resume so that powerd integration will not
  crash.

Bug: 224606285
Tag: #floss
Test: Manual - build.py

Change-Id: If99a05bdc9e9fa1733033ccc4f0849297d1c7b1f
parent 20ec5d69
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,11 @@ fn main() -> Result<(), Box<dyn Error>> {
            }),
            }),
        )));
        )));


        // Announce the exported adapter objects so that clients can properly detect the readiness
        // of the adapter APIs.
        cr.set_object_manager_support(Some(conn.clone()));
        cr.insert("/", &[cr.object_manager()], {});

        // Run the stack main dispatch loop.
        // Run the stack main dispatch loop.
        topstack::get_runtime().spawn(Stack::dispatch(
        topstack::get_runtime().spawn(Stack::dispatch(
            rx,
            rx,
+20 −2
Original line number Original line Diff line number Diff line
@@ -82,6 +82,12 @@ impl Suspend {
            None => false,
            None => false,
        }
        }
    }
    }

    fn for_all_callbacks<F: Fn(&Box<dyn ISuspendCallback + Send>)>(&self, f: F) {
        for (_, callback) in self.callbacks.iter() {
            f(&callback);
        }
    }
}
}


impl ISuspend for Suspend {
impl ISuspend for Suspend {
@@ -109,10 +115,22 @@ impl ISuspend for Suspend {
    }
    }


    fn suspend(&self, _suspend_type: SuspendType) -> u32 {
    fn suspend(&self, _suspend_type: SuspendType) -> u32 {
        todo!()
        // Temporary no-op.
        // TODO(b/224606285): Implement suspend logic.
        let suspend_id = 1;
        self.for_all_callbacks(|callback| {
            callback.on_suspend_ready(suspend_id);
        });
        return 1;
    }
    }


    fn resume(&self) -> bool {
    fn resume(&self) -> bool {
        todo!()
        // Temporary no-op.
        // TODO(b/224606285): Implement resume logic.
        let suspend_id = 1;
        self.for_all_callbacks(|callback| {
            callback.on_resumed(suspend_id);
        });
        return true;
    }
    }
}
}