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 16 #include "call_manager_dump_helper.h" 17 18 #include "call_manager_service.h" 19 #include "core_service_client.h" 20 21 namespace OHOS { 22 namespace Telephony { Dump(const std::vector<std::string> & args,std::string & result) const23bool CallManagerDumpHelper::Dump(const std::vector<std::string> &args, std::string &result) const 24 { 25 result.clear(); 26 ShowHelp(result); 27 ShowCallManagerInfo(result); 28 return true; 29 } 30 CallManagerDumpHelper()31CallManagerDumpHelper::CallManagerDumpHelper() 32 { 33 TELEPHONY_LOGI("CallManagerDumpHelper() entry."); 34 } 35 WhetherHasSimCard(const int32_t slotId) const36bool CallManagerDumpHelper::WhetherHasSimCard(const int32_t slotId) const 37 { 38 bool hasSimCard = false; 39 DelayedRefSingleton<CoreServiceClient>::GetInstance().HasSimCard(slotId, hasSimCard); 40 return hasSimCard; 41 } 42 ShowHelp(std::string & result) const43void CallManagerDumpHelper::ShowHelp(std::string &result) const 44 { 45 result.append("Usage:dump <command> [options]\n") 46 .append("Description:\n") 47 .append("-call_manager_info ") 48 .append("dump all call_manager information in the system\n") 49 .append("-input_simulate <event> ") 50 .append("simulate event from ohos call_manager, supported events: login/logout/token_invalid\n") 51 .append("-output_simulate <event> ") 52 .append("simulate event output\n") 53 .append("-show_log_level ") 54 .append("show call_manager SA's log level\n") 55 .append("-set_log_level <level> ") 56 .append("set call_manager SA's log level\n") 57 .append("-perf_dump ") 58 .append("dump performance statistics\n"); 59 } 60 ShowCallManagerInfo(std::string & result) const61void CallManagerDumpHelper::ShowCallManagerInfo(std::string &result) const 62 { 63 result.append("Ohos call_manager service:"); 64 result.append("\n"); 65 result.append("CurrentTime: "); 66 result.append(DelayedSingleton<CallManagerService>::GetInstance()->GetBindTime()); 67 result.append("\n"); 68 result.append("SpendTime:"); 69 result.append(DelayedSingleton<CallManagerService>::GetInstance()->GetStartServiceSpent()); 70 result.append("\n"); 71 result.append("ServiceRunningState:"); 72 result.append(std::to_string(DelayedSingleton<CallManagerService>::GetInstance()->GetServiceRunningState())); 73 result.append("\n"); 74 for (int32_t i = 0; i < SIM_SLOT_COUNT; i++) { 75 if (WhetherHasSimCard(i)) { 76 result.append("SlotId = "); 77 result.append(std::to_string(i)); 78 result.append("\n"); 79 } 80 } 81 result.append("CallState:"); 82 result.append(std::to_string(DelayedSingleton<CallManagerService>::GetInstance()->GetCallState())); 83 result.append("\n"); 84 result.append("RingingCallState:"); 85 bool enabled = false; 86 DelayedSingleton<CallManagerService>::GetInstance()->IsRinging(enabled); 87 result.append(std::to_string(enabled)); 88 result.append("\n"); 89 result.append("HasCall:"); 90 result.append(std::to_string(DelayedSingleton<CallManagerService>::GetInstance()->HasCall())); 91 result.append("\n"); 92 } 93 } // namespace Telephony 94 } // namespace OHOS