From ef6898fbd4031bc0e6db8731276d30a4d1521442 Mon Sep 17 00:00:00 2001 From: Hsin-chen Chuang <chharry@google.com> Date: Tue, 22 Aug 2023 17:18:42 +0800 Subject: [PATCH] Floss: btclient: Implement socket close command Bug: 262813906 Tag: #floss Test: test with the next CL Test: mmm packages/modules/Bluetooth Change-Id: I1cf1c722836e5b847021d3b0adbe34278ff0c986 --- .../rust/linux/client/src/command_handler.rs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/system/gd/rust/linux/client/src/command_handler.rs b/system/gd/rust/linux/client/src/command_handler.rs index 48c43d4a32e..17a2900b861 100644 --- a/system/gd/rust/linux/client/src/command_handler.rs +++ b/system/gd/rust/linux/client/src/command_handler.rs @@ -251,7 +251,7 @@ fn build_commands() -> HashMap<String, CommandOption> { String::from( "socket connect <address> <l2cap|rfcomm> <psm|uuid> <auth-required> <Bredr|LE>", ), - String::from("socket disconnect <socket_id>"), + String::from("socket close <socket_id>"), String::from("socket set-on-connect-schedule <send|resend|dump>"), ], description: String::from("Socket manager utilities."), @@ -1626,6 +1626,26 @@ impl CommandHandler { status, id, addr, sock_type, psm_or_uuid); } } + "close" => { + let sockid = String::from(get_arg(args, 1)?) + .parse::<u64>() + .or(Err("Failed parsing socket ID"))?; + let status = self + .context + .lock() + .unwrap() + .socket_manager_dbus + .as_mut() + .unwrap() + .close(callback_id, sockid); + if status != BtStatus::Success { + return Err(format!( + "Failed to close the listening socket, status = {:?}", + status, + ) + .into()); + } + } _ => return Err(CommandError::InvalidArgs), }; -- GitLab