• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 //! shell
16 
17 #[allow(unused_imports)]
18 use super::daemon_app;
19 use super::shell;
20 #[allow(unused_imports)]
21 use hdc::common::forward;
22 #[allow(unused_imports)]
23 use hdc::common::hdcfile;
24 use hdc::config::ConnectType;
25 use hdc::transfer::buffer;
26 use hdc::transfer::TcpMap;
27 use hdc::transfer::UsbMap;
28 
free_session(connect_type: ConnectType, session_id: u32)29 pub async fn free_session(connect_type: ConnectType, session_id: u32) {
30     match connect_type {
31         ConnectType::Bt => {}
32         ConnectType::Tcp => {
33             TcpMap::end(session_id).await;
34         }
35         ConnectType::Uart => {}
36         ConnectType::Usb(_) => {
37             UsbMap::end(session_id).await;
38         }
39 
40         ConnectType::HostUsb(_) => {
41             // add to avoid warning
42         }
43 
44         ConnectType::Bridge => {}
45     }
46     stop_task(session_id).await;
47 }
48 
stop_task(session_id: u32)49 pub async fn stop_task(session_id: u32) {
50     hdcfile::stop_task(session_id).await;
51     shell::stop_task(session_id).await;
52     daemon_app::stop_task(session_id).await;
53     forward::stop_task(session_id).await;
54 }
55 
dump_running_task_info() -> String56 pub async fn dump_running_task_info() -> String {
57     let mut result = "\n".to_string();
58     result.push_str(&format!("{:#}", buffer::dump_session().await));
59     result.push_str(&format!("{:#}", hdcfile::dump_task().await));
60     result.push_str(&format!("{:#}", shell::dump_task().await));
61     result.push_str(&format!("{:#}", daemon_app::dump_task().await));
62     result.push_str(&format!("{:#}", forward::dump_task().await));
63     result.push_str("# ");
64     result.to_string()
65 }
66