1048147e0Sopenharmony_ci/** 2048147e0Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3048147e0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4048147e0Sopenharmony_ci * you may not use this file except in compliance with the License. 5048147e0Sopenharmony_ci * You may obtain a copy of the License at 6048147e0Sopenharmony_ci * 7048147e0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8048147e0Sopenharmony_ci * 9048147e0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10048147e0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11048147e0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12048147e0Sopenharmony_ci * See the License for the specific language governing permissions and 13048147e0Sopenharmony_ci * limitations under the License. 14048147e0Sopenharmony_ci */ 15048147e0Sopenharmony_ci 16048147e0Sopenharmony_ciimport call from '@ohos.telephony.call'; 17048147e0Sopenharmony_ciimport HiLog from '../utils/HiLog'; 18048147e0Sopenharmony_ciimport common from '../data/commonData'; 19048147e0Sopenharmony_ciimport LooseObject from '../data/LooseObject' 20048147e0Sopenharmony_ci 21048147e0Sopenharmony_ciconst TAG = 'CallService'; 22048147e0Sopenharmony_ci 23048147e0Sopenharmony_ciexport default { 24048147e0Sopenharmony_ci 25048147e0Sopenharmony_ci /** 26048147e0Sopenharmony_ci * Calling 27048147e0Sopenharmony_ci * 28048147e0Sopenharmony_ci * @param telephone 29048147e0Sopenharmony_ci * @callback callback 30048147e0Sopenharmony_ci */ 31048147e0Sopenharmony_ci call(telephone, callback) { 32048147e0Sopenharmony_ci if (telephone == null || telephone == common.string.EMPTY_STR) { 33048147e0Sopenharmony_ci HiLog.i(TAG, 'telephone is null'); 34048147e0Sopenharmony_ci return; 35048147e0Sopenharmony_ci } 36048147e0Sopenharmony_ci let result: LooseObject = {}; 37048147e0Sopenharmony_ci call.dial(telephone).then((value) => { 38048147e0Sopenharmony_ci result.code = common.int.SUCCESS; 39048147e0Sopenharmony_ci result.value = value; 40048147e0Sopenharmony_ci callback(result); 41048147e0Sopenharmony_ci }).catch((err) => { 42048147e0Sopenharmony_ci HiLog.e(TAG, 'dial error: ' + err.message); 43048147e0Sopenharmony_ci result.code = common.int.FAILURE; 44048147e0Sopenharmony_ci callback(result); 45048147e0Sopenharmony_ci }); 46048147e0Sopenharmony_ci } 47048147e0Sopenharmony_ci}