• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 "telephony_state_registry_dump_helper.h"
17 
18 namespace OHOS {
19 namespace Telephony {
Dump(const std::vector<std::string> & args,std::vector<TelephonyStateRegistryRecord> & stateRecords,std::string & result) const20 bool TelephonyStateRegistryDumpHelper::Dump(const std::vector<std::string> &args,
21     std::vector<TelephonyStateRegistryRecord> &stateRecords, std::string &result) const
22 {
23     result.clear();
24     return ShowTelephonyStateRegistryInfo(stateRecords, result);
25 }
26 
TelephonyStateRegistryDumpHelper()27 TelephonyStateRegistryDumpHelper::TelephonyStateRegistryDumpHelper() {}
28 
ShowTelephonyStateRegistryInfo(std::vector<TelephonyStateRegistryRecord> & stateRecords,std::string & result) const29 bool TelephonyStateRegistryDumpHelper::ShowTelephonyStateRegistryInfo(
30     std::vector<TelephonyStateRegistryRecord> &stateRecords, std::string &result) const
31 {
32     result.append("registrations: count= ").append(std::to_string(stateRecords.size())).append("\n");
33     if (!stateRecords.empty()) {
34         for (const auto &item: stateRecords) {
35             if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_DATA_CONNECTION_STATE)) {
36                 result.append("CellularDataConnectState Register: ");
37             } else if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_DATA_FLOW)) {
38                 result.append("CellularDataFlow Register: ");
39             } else if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_CALL_STATE)) {
40                 result.append("CallState Register: ");
41             } else if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_SIM_STATE)) {
42                 result.append("SimState Register: ");
43             } else if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_SIGNAL_STRENGTHS)) {
44                 result.append("SignalInfo Register: ");
45             } else if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_CELL_INFO)) {
46                 result.append("CellInfo Register: ");
47             } else if (item.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_NETWORK_STATE)) {
48                 result.append("NetworkState Register: ");
49             } else {
50                 result.append("Unknown Subscriber: ");
51             }
52             result.append("\n").append("    { ");
53             result.append("package: ").append(item.bundleName_);
54             result.append(" pid: ").append(std::to_string(item.pid_));
55             result.append(" mask: ").append(std::to_string(item.mask_));
56             result.append(" slotId: ").append(std::to_string(item.slotId_));
57             result.append(" }");
58             result.append("\n");
59         }
60     }
61     result.append("BindStartTime: ");
62     result.append(
63         DelayedSingleton<TelephonyStateRegistryService>::GetInstance()->GetBindStartTime());
64     result.append("\n");
65     result.append("BindEndTime: ");
66     result.append(
67         DelayedSingleton<TelephonyStateRegistryService>::GetInstance()->GetBindEndTime());
68     result.append("\n");
69     result.append("BindSpendTime: ");
70     result.append(
71         DelayedSingleton<TelephonyStateRegistryService>::GetInstance()->GetBindSpendTime());
72     result.append("\n");
73     return true;
74 }
75 } // namespace Telephony
76 } // namespace OHOS