• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 "resource_utils.h"
17 
18 #include <sys/stat.h>
19 
20 #include "bundle_mgr_interface.h"
21 #include "if_system_ability_manager.h"
22 #include "iservice_registry.h"
23 #include "singleton.h"
24 #include "system_ability_definition.h"
25 #include "telephony_log_wrapper.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 constexpr int32_t HAP_USER_ID = 100;
30 const std::string ResourceUtils::RESOURCE_HAP_BUNDLE_NAME = "ohos.telephony.resources";
31 const std::string ResourceUtils::IS_NOTIFY_USER_RESTRICTIED_CHANGE = "is_notify_user_restrictied_change";
32 const std::string ResourceUtils::IS_CS_CAPABLE = "is_cs_capable";
33 const std::string ResourceUtils::IS_SWITCH_PHONE_REG_CHANGE = "is_switch_phone_reg_change";
34 const std::string ResourceUtils::SPN_FORMATS = "spn_formats";
35 const std::string ResourceUtils::EMERGENCY_CALLS_ONLY = "emergency_calls_only";
36 const std::string ResourceUtils::OUT_OF_SERIVCE = "out_of_serivce";
37 const std::string ResourceUtils::CMCC = "cmcc";
38 const std::string ResourceUtils::CUCC = "cucc";
39 const std::string ResourceUtils::CTCC = "ctcc";
40 const std::string ResourceUtils::CALL_FAILED_UNASSIGNED_NUMBER = "call_failed_unassigned_number";
41 const std::string ResourceUtils::CALL_FAILED_NO_ROUTE_TO_DESTINATION = "call_failed_no_route_to_destination";
42 const std::string ResourceUtils::CALL_FAILED_CHANNEL_UNACCEPTABLE = "call_failed_channel_unacceptable";
43 const std::string ResourceUtils::CALL_FAILED_OPERATOR_DETERMINED_BARRING = "call_failed_operator_determined_barring";
44 const std::string ResourceUtils::CALL_FAILED_NORMAL_CALL_CLEARING = "call_failed_normal_call_clearing";
45 const std::string ResourceUtils::CALL_FAILED_USER_BUSY = "call_failed_user_busy";
46 const std::string ResourceUtils::CALL_FAILED_NO_USER_RESPONDING = "call_failed_no_user_responding";
47 const std::string ResourceUtils::CALL_FAILED_USER_ALERTING_NO_ANSWER = "call_failed_user_no_answer";
48 const std::string ResourceUtils::CALL_FAILED_CALL_REJECTED = "call_failed_call_rejected";
49 const std::string ResourceUtils::CALL_FAILED_NUMBER_CHANGED = "call_failed_number_changed";
50 const std::string ResourceUtils::CALL_FAILED_CALL_REJECTED_DESTINATION = "call_failed_call_rejected_destination";
51 const std::string ResourceUtils::CALL_FAILED_FAILED_PRE_EMPTION = "call_failed_pre_emption";
52 const std::string ResourceUtils::CALL_FAILED_NON_SELECTED_USER_CLEARING = "call_failed_non_selected_user_clearing";
53 const std::string ResourceUtils::CALL_FAILED_DESTINATION_OUT_OF_ORDER = "call_failed_destination_out_of_order";
54 const std::string ResourceUtils::CALL_FAILED_INVALID_NUMBER_FORMAT = "call_failed_invalid_number_format";
55 const std::string ResourceUtils::CALL_FAILED_FACILITY_REJECTED = "call_failed_facility_rejected";
56 const std::string ResourceUtils::CALL_FAILED_RESPONSE_TO_STATUS_ENQUIRY = "call_failed_response_to_status_enquiry";
57 const std::string ResourceUtils::CALL_FAILED_NORMAL_UNSPECIFIED = "call_failed_normal_unspecified";
58 const std::string ResourceUtils::CALL_FAILED_NO_CIRCUIT_CHANNEL_AVAILABLE = "call_failed_no_circuit_channel_available";
59 const std::string ResourceUtils::CALL_FAILED_NETWORK_OUT_OF_ORDER = "call_failed_network_out_of_order";
60 const std::string ResourceUtils::CALL_FAILED_TEMPORARY_FAILURE = "call_failed_temporary_failure";
61 const std::string ResourceUtils::CALL_FAILED_SWITCHING_EQUIPMENT_CONGESTION =
62     "call_failed_switching_equipment_congestion";
63 const std::string ResourceUtils::CALL_FAILED_ACCESS_INFORMATION_DISCARDED = "call_failed_access_information_discarded";
64 const std::string ResourceUtils::CALL_FAILED_REQUEST_CIRCUIT_CHANNEL_NOT_AVAILABLE =
65     "call_failed_requested_circuit_or_channel_not_available";
66 const std::string ResourceUtils::CALL_FAILED_RESOURCES_UNAVAILABLE_UNSPECIFIED =
67     "call_failed_resources_unavailable_or_unspecified";
68 const std::string ResourceUtils::CALL_FAILED_QUALITY_OF_SERVICE_UNAVAILABLE =
69     "call_failed_quality_of_service_unavailable";
70 const std::string ResourceUtils::CALL_FAILED_REQUESTED_FACILITY_NOT_SUBSCRIBED =
71     "call_failed_requested_facility_not_subscribed";
72 const std::string ResourceUtils::CALL_FAILED_INCOMING_CALLS_BARRED_WITHIN_THE_CUG =
73     "call_failed_incoming_calls_barred_within_the_CUG";
74 const std::string ResourceUtils::CALL_FAILED_BEARER_CAPABILITY_NOT_AUTHORIZED =
75     "call_failed_bearer_capability_not_authorized";
76 const std::string ResourceUtils::CALL_FAILED_BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE =
77     "call_failed_bearer_capability_not_presently_unavailable";
78 const std::string ResourceUtils::CALL_FAILED_SERVICE_OR_OPTION_NOT_AVAILABLE_UNSPECIFIED =
79     "call_failed_service_or_option_not_available_or_unspecified";
80 const std::string ResourceUtils::CALL_FAILED_BEARER_SERVICE_NOT_IMPLEMENTED =
81     "call_failed_bearer_service_not_implemented";
82 const std::string ResourceUtils::CALL_FAILED_ACM_EQUALTO_OR_GREATE_THAN_ACMMAX =
83     "call_failed_acm_equal_to_or_greater_than_acmmax";
84 const std::string ResourceUtils::CALL_FAILED_REQUESTED_FACILITY_NOT_IMPLEMENTED =
85     "call_failed_requested_facility_not_implemented";
86 const std::string ResourceUtils::CALL_FAILED_ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE =
87     "call_failed_only_restricted_digital_info_bearer_capability_is_available";
88 const std::string ResourceUtils::CALL_FAILED_SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED =
89     "call_failed_service_or_option_not_implemented";
90 const std::string ResourceUtils::CALL_FAILED_INVALID_TRANSACTION_IDENTIFIER_VALUE =
91     "call_failed_invalid_transaction_identifier_value";
92 const std::string ResourceUtils::CALL_FAILED_USER_NOT_MEMBER_OF_CUG = "call_failed_user_not_member_of_CUG";
93 const std::string ResourceUtils::CALL_FAILED_INCOMPATIBLE_DESTINATION = "call_failed_incompatible_destination";
94 const std::string ResourceUtils::CALL_FAILED_INVALID_TRANSIT_NETWORK_SELECTION =
95     "call_failed_invalid_transit_network_selection";
96 const std::string ResourceUtils::CALL_FAILED_SEMANTICALLY_INCORRECT_MESSAGE =
97     "call_failed_semantically_incorrect_message";
98 const std::string ResourceUtils::CALL_FAILED_INVALID_MANDATORY_INFORMATION =
99     "call_failed_invalid_mandatory_information";
100 const std::string ResourceUtils::CALL_FAILED_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED =
101     "call_failed_message_type_non_existent_or_not_implemented";
102 const std::string ResourceUtils::CALL_FAILED_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE =
103     "call_failed_message_type_not_compatible_with_protocol_state";
104 const std::string ResourceUtils::CALL_FAILED_INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED =
105     "call_failed_information_element_non_existent_or_not_implemented";
106 const std::string ResourceUtils::CALL_FAILED_CONDITIONAL_IE_ERROR = "call_failed_conditional_IE_error";
107 const std::string ResourceUtils::CALL_FAILED_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE =
108     "call_failed_message_not_compatible_with_protocol_state";
109 const std::string ResourceUtils::CALL_FAILED_RECOVERY_ON_TIMER_EXPIRED = "call_failed_recovery_on_timer_expired";
110 const std::string ResourceUtils::CALL_FAILED_PROTOCOL_ERROR_UNSPECIFIED = "call_failed_protocol_error_unspecified";
111 const std::string ResourceUtils::CALL_FAILED_INTERWORKING_UNSPECIFIED = "call_failed_interworking_unspecified";
112 const std::string ResourceUtils::CALL_FAILED_CALL_BARRED = "call_failed_call_barred";
113 const std::string ResourceUtils::CALL_FAILED_FDN_BLOCKED = "call_failed_fdn_blocked";
114 const std::string ResourceUtils::CALL_FAILED_IMSI_UNKNOWN_IN_VLR = "call_failed_imsi_unknow";
115 const std::string ResourceUtils::CALL_FAILED_IMEI_NOT_ACCEPTED = "call_failed_imei_not_accepted";
116 const std::string ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_USSD = "call_failed_dial_modify_to_ussd";
117 const std::string ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_SS = "call_failed_dial_modify_to_ss";
118 const std::string ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_DIAL = "call_failed_dial_modify_to_dial";
119 const std::string ResourceUtils::CALL_FAILED_RADIO_OFF = "call_failed_radio_off";
120 const std::string ResourceUtils::CALL_FAILED_OUT_OF_SERVICE = "call_failed_out_of_service";
121 const std::string ResourceUtils::CALL_FAILED_NO_VALID_SIM = "call_failed_no_valid_sim";
122 const std::string ResourceUtils::CALL_FAILED_RADIO_INTERNAL_ERROR = "call_failed_radio_internal_error";
123 const std::string ResourceUtils::CALL_FAILED_NETWORK_RESP_TIMEOUT = "call_failed_network_response_timeout";
124 const std::string ResourceUtils::CALL_FAILED_NETWORK_REJECT = "call_failed_network_reject";
125 const std::string ResourceUtils::CALL_FAILED_RADIO_ACCESS_FAILURE = "call_failed_radio_access_failure";
126 const std::string ResourceUtils::CALL_FAILED_RADIO_LINK_FAILURE = "call_failed_radio_link_failure";
127 const std::string ResourceUtils::CALL_FAILED_RADIO_LINK_LOST = "call_failed_radio_link_lost";
128 const std::string ResourceUtils::CALL_FAILED_RADIO_UPLINK_FAILURE = "call_failed_radio_uplink_failure";
129 const std::string ResourceUtils::CALL_FAILED_RADIO_SETUP_FAILURE = "call_failed_radio_setup_failure";
130 const std::string ResourceUtils::CALL_FAILED_RADIO_RELEASE_NORMAL = "call_failed_radio_release_normal";
131 const std::string ResourceUtils::CALL_FAILED_RADIO_RELEASE_ABNORMAL = "call_failed_radio_release_abnormal";
132 const std::string ResourceUtils::CALL_FAILED_ACCESS_CLASS_BLOCKED = "call_failed_access_class_barring";
133 const std::string ResourceUtils::CALL_FAILED_NETWORK_DETACH = "call_failed_network_detach";
134 const std::string ResourceUtils::CALL_FAILED_INVALID_PARAMETER = "call_failed_invalid_parameter";
135 const std::string ResourceUtils::CALL_FAILED_SIM_NOT_EXIT = "call_failed_sim_not_exit";
136 const std::string ResourceUtils::CALL_FAILED_SIM_PIN_NEED = "call_failed_sim_pin_need";
137 const std::string ResourceUtils::CALL_FAILED_CALL_NOT_ALLOW = "call_failed_call_not_allow";
138 const std::string ResourceUtils::CALL_FAILED_SIM_INVALID = "call_failed_sim_invalid";
139 const std::string ResourceUtils::CALL_FAILED_UNKNOWN = "call_failed_unknow";
140 
141 const std::map<std::string, ResourceUtils::ResourceType> ResourceUtils::mapResourceNameType_ = {
142     { ResourceUtils::IS_NOTIFY_USER_RESTRICTIED_CHANGE, ResourceUtils::ResourceType::ResourceTypeBoolean },
143     { ResourceUtils::IS_CS_CAPABLE, ResourceUtils::ResourceType::ResourceTypeBoolean },
144     { ResourceUtils::IS_SWITCH_PHONE_REG_CHANGE, ResourceUtils::ResourceType::ResourceTypeBoolean },
145     { ResourceUtils::SPN_FORMATS, ResourceUtils::ResourceType::ResourceTypeArrayString },
146     { ResourceUtils::EMERGENCY_CALLS_ONLY, ResourceUtils::ResourceType::ResourceTypeString },
147     { ResourceUtils::OUT_OF_SERIVCE, ResourceUtils::ResourceType::ResourceTypeString },
148     { ResourceUtils::CMCC, ResourceUtils::ResourceType::ResourceTypeString },
149     { ResourceUtils::CUCC, ResourceUtils::ResourceType::ResourceTypeString },
150     { ResourceUtils::CTCC, ResourceUtils::ResourceType::ResourceTypeString },
151     { ResourceUtils::CALL_FAILED_UNASSIGNED_NUMBER, ResourceUtils::ResourceType::ResourceTypeString },
152     { ResourceUtils::CALL_FAILED_NO_ROUTE_TO_DESTINATION, ResourceUtils::ResourceType::ResourceTypeString },
153     { ResourceUtils::CALL_FAILED_CHANNEL_UNACCEPTABLE, ResourceUtils::ResourceType::ResourceTypeString },
154     { ResourceUtils::CALL_FAILED_OPERATOR_DETERMINED_BARRING, ResourceUtils::ResourceType::ResourceTypeString },
155     { ResourceUtils::CALL_FAILED_NORMAL_CALL_CLEARING, ResourceUtils::ResourceType::ResourceTypeString },
156     { ResourceUtils::CALL_FAILED_USER_BUSY, ResourceUtils::ResourceType::ResourceTypeString },
157     { ResourceUtils::CALL_FAILED_NO_USER_RESPONDING, ResourceUtils::ResourceType::ResourceTypeString },
158     { ResourceUtils::CALL_FAILED_USER_ALERTING_NO_ANSWER, ResourceUtils::ResourceType::ResourceTypeString },
159     { ResourceUtils::CALL_FAILED_CALL_REJECTED, ResourceUtils::ResourceType::ResourceTypeString },
160     { ResourceUtils::CALL_FAILED_NUMBER_CHANGED, ResourceUtils::ResourceType::ResourceTypeString },
161     { ResourceUtils::CALL_FAILED_CALL_REJECTED_DESTINATION, ResourceUtils::ResourceType::ResourceTypeString },
162     { ResourceUtils::CALL_FAILED_FAILED_PRE_EMPTION, ResourceUtils::ResourceType::ResourceTypeString },
163     { ResourceUtils::CALL_FAILED_NON_SELECTED_USER_CLEARING, ResourceUtils::ResourceType::ResourceTypeString },
164     { ResourceUtils::CALL_FAILED_DESTINATION_OUT_OF_ORDER, ResourceUtils::ResourceType::ResourceTypeString },
165     { ResourceUtils::CALL_FAILED_INVALID_NUMBER_FORMAT, ResourceUtils::ResourceType::ResourceTypeString },
166     { ResourceUtils::CALL_FAILED_FACILITY_REJECTED, ResourceUtils::ResourceType::ResourceTypeString },
167     { ResourceUtils::CALL_FAILED_RESPONSE_TO_STATUS_ENQUIRY, ResourceUtils::ResourceType::ResourceTypeString },
168     { ResourceUtils::CALL_FAILED_NORMAL_UNSPECIFIED, ResourceUtils::ResourceType::ResourceTypeString },
169     { ResourceUtils::CALL_FAILED_NO_CIRCUIT_CHANNEL_AVAILABLE, ResourceUtils::ResourceType::ResourceTypeString },
170     { ResourceUtils::CALL_FAILED_NETWORK_OUT_OF_ORDER, ResourceUtils::ResourceType::ResourceTypeString },
171     { ResourceUtils::CALL_FAILED_TEMPORARY_FAILURE, ResourceUtils::ResourceType::ResourceTypeString },
172     { ResourceUtils::CALL_FAILED_SWITCHING_EQUIPMENT_CONGESTION, ResourceUtils::ResourceType::ResourceTypeString },
173     { ResourceUtils::CALL_FAILED_ACCESS_INFORMATION_DISCARDED, ResourceUtils::ResourceType::ResourceTypeString },
174     { ResourceUtils::CALL_FAILED_REQUEST_CIRCUIT_CHANNEL_NOT_AVAILABLE,
175         ResourceUtils::ResourceType::ResourceTypeString },
176     { ResourceUtils::CALL_FAILED_RESOURCES_UNAVAILABLE_UNSPECIFIED, ResourceUtils::ResourceType::ResourceTypeString },
177     { ResourceUtils::CALL_FAILED_QUALITY_OF_SERVICE_UNAVAILABLE, ResourceUtils::ResourceType::ResourceTypeString },
178     { ResourceUtils::CALL_FAILED_REQUESTED_FACILITY_NOT_SUBSCRIBED, ResourceUtils::ResourceType::ResourceTypeString },
179     { ResourceUtils::CALL_FAILED_INCOMING_CALLS_BARRED_WITHIN_THE_CUG,
180         ResourceUtils::ResourceType::ResourceTypeString },
181     { ResourceUtils::CALL_FAILED_BEARER_CAPABILITY_NOT_AUTHORIZED, ResourceUtils::ResourceType::ResourceTypeString },
182     { ResourceUtils::CALL_FAILED_BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE,
183         ResourceUtils::ResourceType::ResourceTypeString },
184     { ResourceUtils::CALL_FAILED_SERVICE_OR_OPTION_NOT_AVAILABLE_UNSPECIFIED,
185         ResourceUtils::ResourceType::ResourceTypeString },
186     { ResourceUtils::CALL_FAILED_BEARER_SERVICE_NOT_IMPLEMENTED, ResourceUtils::ResourceType::ResourceTypeString },
187     { ResourceUtils::CALL_FAILED_ACM_EQUALTO_OR_GREATE_THAN_ACMMAX, ResourceUtils::ResourceType::ResourceTypeString },
188     { ResourceUtils::CALL_FAILED_REQUESTED_FACILITY_NOT_IMPLEMENTED, ResourceUtils::ResourceType::ResourceTypeString },
189     { ResourceUtils::CALL_FAILED_ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE,
190         ResourceUtils::ResourceType::ResourceTypeString },
191     { ResourceUtils::CALL_FAILED_SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED,
192         ResourceUtils::ResourceType::ResourceTypeString },
193     { ResourceUtils::CALL_FAILED_INVALID_TRANSACTION_IDENTIFIER_VALUE,
194         ResourceUtils::ResourceType::ResourceTypeString },
195     { ResourceUtils::CALL_FAILED_USER_NOT_MEMBER_OF_CUG, ResourceUtils::ResourceType::ResourceTypeString },
196     { ResourceUtils::CALL_FAILED_INCOMPATIBLE_DESTINATION, ResourceUtils::ResourceType::ResourceTypeString },
197     { ResourceUtils::CALL_FAILED_INVALID_TRANSIT_NETWORK_SELECTION, ResourceUtils::ResourceType::ResourceTypeString },
198     { ResourceUtils::CALL_FAILED_SEMANTICALLY_INCORRECT_MESSAGE, ResourceUtils::ResourceType::ResourceTypeString },
199     { ResourceUtils::CALL_FAILED_INVALID_MANDATORY_INFORMATION, ResourceUtils::ResourceType::ResourceTypeString },
200     { ResourceUtils::CALL_FAILED_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED,
201         ResourceUtils::ResourceType::ResourceTypeString },
202     { ResourceUtils::CALL_FAILED_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE,
203         ResourceUtils::ResourceType::ResourceTypeString },
204     { ResourceUtils::CALL_FAILED_INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED,
205         ResourceUtils::ResourceType::ResourceTypeString },
206     { ResourceUtils::CALL_FAILED_CONDITIONAL_IE_ERROR, ResourceUtils::ResourceType::ResourceTypeString },
207     { ResourceUtils::CALL_FAILED_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE,
208         ResourceUtils::ResourceType::ResourceTypeString },
209     { ResourceUtils::CALL_FAILED_RECOVERY_ON_TIMER_EXPIRED, ResourceUtils::ResourceType::ResourceTypeString },
210     { ResourceUtils::CALL_FAILED_PROTOCOL_ERROR_UNSPECIFIED, ResourceUtils::ResourceType::ResourceTypeString },
211     { ResourceUtils::CALL_FAILED_INTERWORKING_UNSPECIFIED, ResourceUtils::ResourceType::ResourceTypeString },
212     { ResourceUtils::CALL_FAILED_CALL_BARRED, ResourceUtils::ResourceType::ResourceTypeString },
213     { ResourceUtils::CALL_FAILED_FDN_BLOCKED, ResourceUtils::ResourceType::ResourceTypeString },
214     { ResourceUtils::CALL_FAILED_IMSI_UNKNOWN_IN_VLR, ResourceUtils::ResourceType::ResourceTypeString },
215     { ResourceUtils::CALL_FAILED_IMEI_NOT_ACCEPTED, ResourceUtils::ResourceType::ResourceTypeString },
216     { ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_USSD, ResourceUtils::ResourceType::ResourceTypeString },
217     { ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_SS, ResourceUtils::ResourceType::ResourceTypeString },
218     { ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_DIAL, ResourceUtils::ResourceType::ResourceTypeString },
219     { ResourceUtils::CALL_FAILED_RADIO_OFF, ResourceUtils::ResourceType::ResourceTypeString },
220     { ResourceUtils::CALL_FAILED_OUT_OF_SERVICE, ResourceUtils::ResourceType::ResourceTypeString },
221     { ResourceUtils::CALL_FAILED_NO_VALID_SIM, ResourceUtils::ResourceType::ResourceTypeString },
222     { ResourceUtils::CALL_FAILED_RADIO_INTERNAL_ERROR, ResourceUtils::ResourceType::ResourceTypeString },
223     { ResourceUtils::CALL_FAILED_NETWORK_RESP_TIMEOUT, ResourceUtils::ResourceType::ResourceTypeString },
224     { ResourceUtils::CALL_FAILED_NETWORK_REJECT, ResourceUtils::ResourceType::ResourceTypeString },
225     { ResourceUtils::CALL_FAILED_RADIO_ACCESS_FAILURE, ResourceUtils::ResourceType::ResourceTypeString },
226     { ResourceUtils::CALL_FAILED_RADIO_LINK_FAILURE, ResourceUtils::ResourceType::ResourceTypeString },
227     { ResourceUtils::CALL_FAILED_RADIO_LINK_LOST, ResourceUtils::ResourceType::ResourceTypeString },
228     { ResourceUtils::CALL_FAILED_RADIO_UPLINK_FAILURE, ResourceUtils::ResourceType::ResourceTypeString },
229     { ResourceUtils::CALL_FAILED_RADIO_SETUP_FAILURE, ResourceUtils::ResourceType::ResourceTypeString },
230     { ResourceUtils::CALL_FAILED_RADIO_RELEASE_NORMAL, ResourceUtils::ResourceType::ResourceTypeString },
231     { ResourceUtils::CALL_FAILED_RADIO_RELEASE_ABNORMAL, ResourceUtils::ResourceType::ResourceTypeString },
232     { ResourceUtils::CALL_FAILED_ACCESS_CLASS_BLOCKED, ResourceUtils::ResourceType::ResourceTypeString },
233     { ResourceUtils::CALL_FAILED_NETWORK_DETACH, ResourceUtils::ResourceType::ResourceTypeString },
234     { ResourceUtils::CALL_FAILED_INVALID_PARAMETER, ResourceUtils::ResourceType::ResourceTypeString },
235     { ResourceUtils::CALL_FAILED_SIM_NOT_EXIT, ResourceUtils::ResourceType::ResourceTypeString },
236     { ResourceUtils::CALL_FAILED_SIM_PIN_NEED, ResourceUtils::ResourceType::ResourceTypeString },
237     { ResourceUtils::CALL_FAILED_CALL_NOT_ALLOW, ResourceUtils::ResourceType::ResourceTypeString },
238     { ResourceUtils::CALL_FAILED_SIM_INVALID, ResourceUtils::ResourceType::ResourceTypeString },
239     { ResourceUtils::CALL_FAILED_UNKNOWN, ResourceUtils::ResourceType::ResourceTypeString },
240 };
241 
242 const std::map<DisconnectedReasons, std::string> ResourceUtils::callFailedResourceName_ = {
243     { DisconnectedReasons::UNASSIGNED_NUMBER, ResourceUtils::CALL_FAILED_UNASSIGNED_NUMBER },
244     { DisconnectedReasons::NO_ROUTE_TO_DESTINATION, ResourceUtils::CALL_FAILED_NO_ROUTE_TO_DESTINATION },
245     { DisconnectedReasons::CHANNEL_UNACCEPTABLE, ResourceUtils::CALL_FAILED_CHANNEL_UNACCEPTABLE },
246     { DisconnectedReasons::OPERATOR_DETERMINED_BARRING, ResourceUtils::CALL_FAILED_OPERATOR_DETERMINED_BARRING },
247     { DisconnectedReasons::NORMAL_CALL_CLEARING, ResourceUtils::CALL_FAILED_NORMAL_CALL_CLEARING },
248     { DisconnectedReasons::FAILED_USER_BUSY, ResourceUtils::CALL_FAILED_USER_BUSY },
249     { DisconnectedReasons::NO_USER_RESPONDING, ResourceUtils::CALL_FAILED_NO_USER_RESPONDING },
250     { DisconnectedReasons::USER_ALERTING_NO_ANSWER, ResourceUtils::CALL_FAILED_USER_ALERTING_NO_ANSWER },
251     { DisconnectedReasons::CALL_REJECTED, ResourceUtils::CALL_FAILED_CALL_REJECTED },
252     { DisconnectedReasons::NUMBER_CHANGED, ResourceUtils::CALL_FAILED_NUMBER_CHANGED },
253     { DisconnectedReasons::CALL_REJECTED_DUE_TO_FEATURE_AT_THE_DESTINATION,
254         ResourceUtils::CALL_FAILED_CALL_REJECTED_DESTINATION },
255     { DisconnectedReasons::FAILED_PRE_EMPTION, ResourceUtils::CALL_FAILED_FAILED_PRE_EMPTION },
256     { DisconnectedReasons::NON_SELECTED_USER_CLEARING, ResourceUtils::CALL_FAILED_NON_SELECTED_USER_CLEARING },
257     { DisconnectedReasons::DESTINATION_OUT_OF_ORDER, ResourceUtils::CALL_FAILED_DESTINATION_OUT_OF_ORDER },
258     { DisconnectedReasons::INVALID_NUMBER_FORMAT, ResourceUtils::CALL_FAILED_INVALID_NUMBER_FORMAT },
259     { DisconnectedReasons::FACILITY_REJECTED, ResourceUtils::CALL_FAILED_FACILITY_REJECTED },
260     { DisconnectedReasons::RESPONSE_TO_STATUS_ENQUIRY, ResourceUtils::CALL_FAILED_RESPONSE_TO_STATUS_ENQUIRY },
261     { DisconnectedReasons::NORMAL_UNSPECIFIED, ResourceUtils::CALL_FAILED_NORMAL_UNSPECIFIED },
262     { DisconnectedReasons::NO_CIRCUIT_CHANNEL_AVAILABLE, ResourceUtils::CALL_FAILED_NO_CIRCUIT_CHANNEL_AVAILABLE },
263     { DisconnectedReasons::NETWORK_OUT_OF_ORDER, ResourceUtils::CALL_FAILED_NETWORK_OUT_OF_ORDER },
264     { DisconnectedReasons::TEMPORARY_FAILURE, ResourceUtils::CALL_FAILED_TEMPORARY_FAILURE },
265     { DisconnectedReasons::SWITCHING_EQUIPMENT_CONGESTION, ResourceUtils::CALL_FAILED_SWITCHING_EQUIPMENT_CONGESTION },
266     { DisconnectedReasons::ACCESS_INFORMATION_DISCARDED, ResourceUtils::CALL_FAILED_ACCESS_INFORMATION_DISCARDED },
267     { DisconnectedReasons::REQUEST_CIRCUIT_CHANNEL_NOT_AVAILABLE,
268         ResourceUtils::CALL_FAILED_REQUEST_CIRCUIT_CHANNEL_NOT_AVAILABLE },
269     { DisconnectedReasons::RESOURCES_UNAVAILABLE_UNSPECIFIED,
270         ResourceUtils::CALL_FAILED_RESOURCES_UNAVAILABLE_UNSPECIFIED },
271     { DisconnectedReasons::QUALITY_OF_SERVICE_UNAVAILABLE, ResourceUtils::CALL_FAILED_QUALITY_OF_SERVICE_UNAVAILABLE },
272     { DisconnectedReasons::REQUESTED_FACILITY_NOT_SUBSCRIBED,
273         ResourceUtils::CALL_FAILED_REQUESTED_FACILITY_NOT_SUBSCRIBED },
274     { DisconnectedReasons::INCOMING_CALLS_BARRED_WITHIN_THE_CUG,
275         ResourceUtils::CALL_FAILED_INCOMING_CALLS_BARRED_WITHIN_THE_CUG },
276     { DisconnectedReasons::BEARER_CAPABILITY_NOT_AUTHORIZED,
277         ResourceUtils::CALL_FAILED_BEARER_CAPABILITY_NOT_AUTHORIZED },
278     { DisconnectedReasons::BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE,
279         ResourceUtils::CALL_FAILED_BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE },
280     { DisconnectedReasons::SERVICE_OR_OPTION_NOT_AVAILABLE_UNSPECIFIED,
281         ResourceUtils::CALL_FAILED_SERVICE_OR_OPTION_NOT_AVAILABLE_UNSPECIFIED },
282     { DisconnectedReasons::BEARER_SERVICE_NOT_IMPLEMENTED, ResourceUtils::CALL_FAILED_BEARER_SERVICE_NOT_IMPLEMENTED },
283     { DisconnectedReasons::ACM_EQUALTO_OR_GREATE_THAN_ACMMAX,
284         ResourceUtils::CALL_FAILED_ACM_EQUALTO_OR_GREATE_THAN_ACMMAX },
285     { DisconnectedReasons::REQUESTED_FACILITY_NOT_IMPLEMENTED,
286         ResourceUtils::CALL_FAILED_REQUESTED_FACILITY_NOT_IMPLEMENTED },
287     { DisconnectedReasons::ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE,
288         ResourceUtils::CALL_FAILED_ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE },
289     { DisconnectedReasons::SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED,
290         ResourceUtils::CALL_FAILED_SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED },
291     { DisconnectedReasons::INVALID_TRANSACTION_IDENTIFIER_VALUE,
292         ResourceUtils::CALL_FAILED_INVALID_TRANSACTION_IDENTIFIER_VALUE },
293     { DisconnectedReasons::USER_NOT_MEMBER_OF_CUG, ResourceUtils::CALL_FAILED_USER_NOT_MEMBER_OF_CUG },
294     { DisconnectedReasons::INCOMPATIBLE_DESTINATION, ResourceUtils::CALL_FAILED_INCOMPATIBLE_DESTINATION },
295     { DisconnectedReasons::INVALID_TRANSIT_NETWORK_SELECTION,
296         ResourceUtils::CALL_FAILED_INVALID_TRANSIT_NETWORK_SELECTION },
297     { DisconnectedReasons::SEMANTICALLY_INCORRECT_MESSAGE, ResourceUtils::CALL_FAILED_SEMANTICALLY_INCORRECT_MESSAGE },
298     { DisconnectedReasons::INVALID_MANDATORY_INFORMATION, ResourceUtils::CALL_FAILED_INVALID_MANDATORY_INFORMATION },
299     { DisconnectedReasons::MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED,
300         ResourceUtils::CALL_FAILED_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED },
301     { DisconnectedReasons::MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE,
302         ResourceUtils::CALL_FAILED_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE },
303     { DisconnectedReasons::INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED,
304         ResourceUtils::CALL_FAILED_INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED },
305     { DisconnectedReasons::CONDITIONAL_IE_ERROR, ResourceUtils::CALL_FAILED_CONDITIONAL_IE_ERROR },
306     { DisconnectedReasons::MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE,
307         ResourceUtils::CALL_FAILED_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE },
308     { DisconnectedReasons::RECOVERY_ON_TIMER_EXPIRED, ResourceUtils::CALL_FAILED_RECOVERY_ON_TIMER_EXPIRED },
309     { DisconnectedReasons::PROTOCOL_ERROR_UNSPECIFIED, ResourceUtils::CALL_FAILED_PROTOCOL_ERROR_UNSPECIFIED },
310     { DisconnectedReasons::INTERWORKING_UNSPECIFIED, ResourceUtils::CALL_FAILED_INTERWORKING_UNSPECIFIED },
311     { DisconnectedReasons::CALL_BARRED, ResourceUtils::CALL_FAILED_CALL_BARRED },
312     { DisconnectedReasons::FDN_BLOCKED, ResourceUtils::CALL_FAILED_FDN_BLOCKED },
313     { DisconnectedReasons::IMSI_UNKNOWN_IN_VLR, ResourceUtils::CALL_FAILED_IMSI_UNKNOWN_IN_VLR },
314     { DisconnectedReasons::IMEI_NOT_ACCEPTED, ResourceUtils::CALL_FAILED_IMEI_NOT_ACCEPTED },
315     { DisconnectedReasons::DIAL_MODIFIED_TO_USSD, ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_USSD },
316     { DisconnectedReasons::DIAL_MODIFIED_TO_SS, ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_SS },
317     { DisconnectedReasons::DIAL_MODIFIED_TO_DIAL, ResourceUtils::CALL_FAILED_DIAL_MODIFIED_TO_DIAL },
318     { DisconnectedReasons::RADIO_OFF, ResourceUtils::CALL_FAILED_RADIO_OFF },
319     { DisconnectedReasons::OUT_OF_SERVICE, ResourceUtils::CALL_FAILED_OUT_OF_SERVICE },
320     { DisconnectedReasons::NO_VALID_SIM, ResourceUtils::CALL_FAILED_NO_VALID_SIM },
321     { DisconnectedReasons::RADIO_INTERNAL_ERROR, ResourceUtils::CALL_FAILED_RADIO_INTERNAL_ERROR },
322     { DisconnectedReasons::NETWORK_RESP_TIMEOUT, ResourceUtils::CALL_FAILED_NETWORK_RESP_TIMEOUT },
323     { DisconnectedReasons::NETWORK_REJECT, ResourceUtils::CALL_FAILED_NETWORK_REJECT },
324     { DisconnectedReasons::RADIO_ACCESS_FAILURE, ResourceUtils::CALL_FAILED_RADIO_ACCESS_FAILURE },
325     { DisconnectedReasons::RADIO_LINK_FAILURE, ResourceUtils::CALL_FAILED_RADIO_LINK_FAILURE },
326     { DisconnectedReasons::RADIO_LINK_LOST, ResourceUtils::CALL_FAILED_RADIO_LINK_LOST },
327     { DisconnectedReasons::RADIO_UPLINK_FAILURE, ResourceUtils::CALL_FAILED_RADIO_UPLINK_FAILURE },
328     { DisconnectedReasons::RADIO_SETUP_FAILURE, ResourceUtils::CALL_FAILED_RADIO_SETUP_FAILURE },
329     { DisconnectedReasons::RADIO_RELEASE_NORMAL, ResourceUtils::CALL_FAILED_RADIO_RELEASE_NORMAL },
330     { DisconnectedReasons::RADIO_RELEASE_ABNORMAL, ResourceUtils::CALL_FAILED_RADIO_RELEASE_ABNORMAL },
331     { DisconnectedReasons::ACCESS_CLASS_BLOCKED, ResourceUtils::CALL_FAILED_ACCESS_CLASS_BLOCKED },
332     { DisconnectedReasons::NETWORK_DETACH, ResourceUtils::CALL_FAILED_NETWORK_DETACH },
333     { DisconnectedReasons::FAILED_INVALID_PARAMETER, ResourceUtils::CALL_FAILED_INVALID_PARAMETER },
334     { DisconnectedReasons::SIM_NOT_EXIT, ResourceUtils::CALL_FAILED_SIM_NOT_EXIT },
335     { DisconnectedReasons::SIM_PIN_NEED, ResourceUtils::CALL_FAILED_SIM_PIN_NEED },
336     { DisconnectedReasons::CALL_NOT_ALLOW, ResourceUtils::CALL_FAILED_CALL_NOT_ALLOW },
337     { DisconnectedReasons::SIM_INVALID, ResourceUtils::CALL_FAILED_SIM_INVALID },
338     { DisconnectedReasons::FAILED_UNKNOWN, ResourceUtils::CALL_FAILED_UNKNOWN },
339 };
340 
Get()341 ResourceUtils &ResourceUtils::Get()
342 {
343     static ResourceUtils utils_;
344     if (!utils_.Init()) {
345         TELEPHONY_LOGE("ResourceUtils::Get init failed.");
346     }
347     return utils_;
348 }
349 
ResourceUtils()350 ResourceUtils::ResourceUtils()
351 {
352     resourceManager_ = std::unique_ptr<Global::Resource::ResourceManager>(Global::Resource::CreateResourceManager());
353 }
354 
Init()355 bool ResourceUtils::Init()
356 {
357     std::lock_guard<std::mutex> locker(mutex_);
358     if (beSourceAdd_) {
359         return true;
360     }
361     if (resourceManager_ == nullptr) {
362         TELEPHONY_LOGE("ResourceUtils Init failed , resourceManager is null.");
363         beSourceAdd_ = false;
364         return false;
365     }
366 
367     OHOS::sptr<OHOS::ISystemAbilityManager> systemAbilityManager =
368         OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
369     if (systemAbilityManager == nullptr) {
370         TELEPHONY_LOGE("systemAbilityManager is null.");
371         return false;
372     }
373     OHOS::sptr<OHOS::IRemoteObject> remoteObject =
374         systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
375 
376     sptr<AppExecFwk::IBundleMgr> iBundleMgr = OHOS::iface_cast<AppExecFwk::IBundleMgr>(remoteObject);
377     if (iBundleMgr == nullptr) {
378         TELEPHONY_LOGE("iBundleMgr is null.");
379         return false;
380     }
381     AppExecFwk::BundleInfo bundleInfo;
382     iBundleMgr->GetBundleInfo(
383         RESOURCE_HAP_BUNDLE_NAME.c_str(), AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, HAP_USER_ID);
384     std::string hapPath;
385     std::string resPath;
386     if (!bundleInfo.hapModuleInfos.empty()) {
387         hapPath = bundleInfo.hapModuleInfos[0].hapPath;
388     }
389     if (!bundleInfo.moduleResPaths.empty()) {
390         resPath = bundleInfo.moduleResPaths[0];
391     }
392 
393     if (IsFileExist(hapPath)) {
394         beSourceAdd_ = resourceManager_->AddResource(hapPath.c_str());
395         TELEPHONY_LOGI(
396             "ResourceUtils add hap path %{public}s %{public}d", hapPath.c_str(), static_cast<int32_t>(beSourceAdd_));
397     } else if (IsFileExist(resPath)) {
398         beSourceAdd_ = resourceManager_->AddResource(resPath.c_str());
399         TELEPHONY_LOGI("ResourceUtils add resource path %{public}s %{public}d", resPath.c_str(),
400             static_cast<int32_t>(beSourceAdd_));
401     } else {
402         TELEPHONY_LOGE("moduleResPath and moduleHapPath is invalid");
403     }
404 
405     if (beSourceAdd_) {
406         SaveAllValue();
407     }
408     return beSourceAdd_;
409 }
410 
SaveAllValue()411 void ResourceUtils::SaveAllValue()
412 {
413     std::string strValue;
414     int32_t intValue = 0;
415     bool boolValue = false;
416     std::vector<std::string> strVector;
417     std::vector<int32_t> intVector;
418     for (auto iter : mapResourceNameType_) {
419         switch (iter.second) {
420             case ResourceType::ResourceTypeString:
421                 if (GetStringByName(iter.first.c_str(), strValue)) {
422                     mapResourceValues_[iter.first] = strValue;
423                     TELEPHONY_LOGE("SaveAllValue strValue %{public}s", strValue.c_str());
424                 }
425                 break;
426             case ResourceType::ResourceTypeInteger:
427                 if (GetIntegerByName(iter.first.c_str(), intValue)) {
428                     mapResourceValues_[iter.first] = intValue;
429                 }
430                 break;
431             case ResourceType::ResourceTypeBoolean:
432                 if (GetBooleanByName(iter.first.c_str(), boolValue)) {
433                     mapResourceValues_[iter.first] = boolValue;
434                 }
435                 break;
436             case ResourceType::ResourceTypeArrayString:
437                 if (GetStringArrayByName(iter.first.c_str(), strVector)) {
438                     mapResourceValues_[iter.first] = strVector;
439                 }
440                 break;
441             case ResourceType::ResourceTypeArrayInteger:
442                 if (GetIntArrayByName(iter.first.c_str(), intVector)) {
443                     mapResourceValues_[iter.first] = intVector;
444                 }
445                 break;
446             default:
447                 break;
448         }
449     }
450 }
451 
GetStringByName(std::string name,std::string & value)452 bool ResourceUtils::GetStringByName(std::string name, std::string &value)
453 {
454     Global::Resource::RState state = resourceManager_->GetStringByName(name.c_str(), value);
455     TELEPHONY_LOGE("GetStringByName name %{public}s", name.c_str());
456     if (state == Global::Resource::RState::SUCCESS) {
457         return true;
458     } else {
459         TELEPHONY_LOGE("failed to get resource by name %{public}s", name.c_str());
460         return false;
461     }
462 }
463 
GetIntegerByName(std::string name,int & value)464 bool ResourceUtils::GetIntegerByName(std::string name, int &value)
465 {
466     Global::Resource::RState state = resourceManager_->GetIntegerByName(name.c_str(), value);
467     if (state == Global::Resource::RState::SUCCESS) {
468         return true;
469     } else {
470         TELEPHONY_LOGE("failed to get resource by name %{public}s", name.c_str());
471         return false;
472     }
473 }
474 
GetBooleanByName(std::string name,bool & value)475 bool ResourceUtils::GetBooleanByName(std::string name, bool &value)
476 {
477     Global::Resource::RState state = resourceManager_->GetBooleanByName(name.c_str(), value);
478     if (state == Global::Resource::RState::SUCCESS) {
479         return true;
480     } else {
481         TELEPHONY_LOGE("failed to get resource by name %{public}s", name.c_str());
482         return false;
483     }
484 }
485 
GetStringArrayByName(std::string name,std::vector<std::string> & value)486 bool ResourceUtils::GetStringArrayByName(std::string name, std::vector<std::string> &value)
487 {
488     value.clear();
489     Global::Resource::RState state = resourceManager_->GetStringArrayByName(name.c_str(), value);
490     if (state == Global::Resource::RState::SUCCESS) {
491         return true;
492     } else {
493         TELEPHONY_LOGE("failed to get resource by name %{public}s", name.c_str());
494         return false;
495     }
496 }
497 
GetIntArrayByName(std::string name,std::vector<int32_t> & value)498 bool ResourceUtils::GetIntArrayByName(std::string name, std::vector<int32_t> &value)
499 {
500     value.clear();
501     Global::Resource::RState state = resourceManager_->GetIntArrayByName(name.c_str(), value);
502     if (state == Global::Resource::RState::SUCCESS) {
503         return true;
504     } else {
505         TELEPHONY_LOGE("failed to get resource by name %{public}s", name.c_str());
506         return false;
507     }
508 }
509 
ShowAllValue()510 void ResourceUtils::ShowAllValue()
511 {
512     for (auto iter : mapResourceNameType_) {
513         switch (iter.second) {
514             case ResourceType::ResourceTypeString:
515                 TELEPHONY_LOGI("resource[%{public}s]:\"%{public}s\"", iter.first.c_str(),
516                     std::any_cast<std::string>(mapResourceValues_[iter.first]).c_str());
517                 break;
518             case ResourceType::ResourceTypeInteger:
519                 TELEPHONY_LOGI("resource[%{public}s]:\"%{public}d\"", iter.first.c_str(),
520                     std::any_cast<int32_t>(mapResourceValues_[iter.first]));
521                 break;
522             case ResourceType::ResourceTypeBoolean:
523                 TELEPHONY_LOGI("resource[%{public}s]:\"%{public}s\"", iter.first.c_str(),
524                     std::any_cast<bool>(mapResourceValues_[iter.first]) ? "true" : "false");
525                 break;
526             case ResourceType::ResourceTypeArrayString: {
527                 std::vector<std::string> &vecString =
528                     std::any_cast<std::vector<std::string> &>(mapResourceValues_[iter.first]);
529                 for (unsigned int i = 0; i < vecString.size(); i++) {
530                     TELEPHONY_LOGI(
531                         "resource[%{public}s][%{public}d]:\"%{public}s\"", iter.first.c_str(), i, vecString[i].c_str());
532                 }
533                 break;
534             }
535             case ResourceType::ResourceTypeArrayInteger: {
536                 std::vector<int32_t> &vecInt = std::any_cast<std::vector<int32_t> &>(mapResourceValues_[iter.first]);
537                 for (unsigned int i = 0; i < vecInt.size(); i++) {
538                     TELEPHONY_LOGI("resource[%{public}s][%{public}d]:\"%{public}d\"", iter.first.c_str(), i, vecInt[i]);
539                 }
540                 break;
541             }
542             default:
543                 break;
544         }
545     }
546 }
547 
GetCallFailedMessageName(int32_t reason,std::string & name)548 bool ResourceUtils::GetCallFailedMessageName(int32_t reason, std::string &name)
549 {
550     auto itor = callFailedResourceName_.find(static_cast<DisconnectedReasons>(reason));
551     if (itor == callFailedResourceName_.end()) {
552         name = (callFailedResourceName_.find(DisconnectedReasons::FAILED_UNKNOWN))->second;
553         return true;
554     }
555     name = itor->second;
556     return true;
557 }
558 
GetStringValueByName(std::string name,std::string & value)559 bool ResourceUtils::GetStringValueByName(std::string name, std::string &value)
560 {
561     auto itor = mapResourceValues_.find(name);
562     if (itor == mapResourceValues_.end()) {
563         return false;
564     }
565     value = std::any_cast<std::string>(itor->second);
566     return true;
567 }
568 
IsFileExist(const std::string & filePath)569 bool ResourceUtils::IsFileExist(const std::string &filePath)
570 {
571     struct stat buffer;
572     return (stat(filePath.c_str(), &buffer) == 0);
573 }
574 } // namespace Telephony
575 } // namespace OHOS
576