18779efd5Sopenharmony_ci/**
28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License.
58779efd5Sopenharmony_ci * You may obtain a copy of the License at
68779efd5Sopenharmony_ci *
78779efd5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88779efd5Sopenharmony_ci *
98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and
138779efd5Sopenharmony_ci * limitations under the License.
148779efd5Sopenharmony_ci */
158779efd5Sopenharmony_ciimport { HiLog } from '../../../../../../common/src/main/ets/util/HiLog';
168779efd5Sopenharmony_ciimport { StringUtil } from '../../../../../../common/src/main/ets/util/StringUtil';
178779efd5Sopenharmony_ciimport audio from '@ohos.multimedia.audio';
188779efd5Sopenharmony_ciimport router from '@ohos.router';
198779efd5Sopenharmony_ciimport observer from '@ohos.telephony.observer';
208779efd5Sopenharmony_ciimport PreferencesUtil from '../../util/PreferencesUtil';
218779efd5Sopenharmony_ciimport { PhoneNumber } from '../../../../../../feature/phonenumber/src/main/ets/PhoneNumber';
228779efd5Sopenharmony_ciimport IndexPresenter from '../IndexPresenter';
238779efd5Sopenharmony_ciimport CallRecordListDataSource from '../../model/bean/CallRecordListDataSource';
248779efd5Sopenharmony_ciconst TAG = 'DialerPresenter';
258779efd5Sopenharmony_ciconst SECRET_CODE_START: string = '*#*#';
268779efd5Sopenharmony_ciconst SECRET_CODE_END: string = '#*#*';
278779efd5Sopenharmony_ci
288779efd5Sopenharmony_ci/**
298779efd5Sopenharmony_ci * dialer presenter
308779efd5Sopenharmony_ci */
318779efd5Sopenharmony_ciexport default class DialerPresenter {
328779efd5Sopenharmony_ci  private static mPresenter: DialerPresenter;
338779efd5Sopenharmony_ci  private _isCallStateChangeObserved = false;
348779efd5Sopenharmony_ci  readonly NUM_TEXT_MAX_LENGTH = 20;
358779efd5Sopenharmony_ci  readonly NUM_TEXT_MAXSIZE_LENGTH = 14;
368779efd5Sopenharmony_ci  readonly NUM_TEXT_FONT_SIZE_MAX = 38;
378779efd5Sopenharmony_ci  private timer: any = null;
388779efd5Sopenharmony_ci  btnShow: boolean = true;
398779efd5Sopenharmony_ci  isEmergencyNum: boolean = false;
408779efd5Sopenharmony_ci  tele_number: string = '';
418779efd5Sopenharmony_ci  tele_num_size: number = this.NUM_TEXT_FONT_SIZE_MAX;
428779efd5Sopenharmony_ci  all_number: string = '';
438779efd5Sopenharmony_ci  call_p: number = 134;
448779efd5Sopenharmony_ci  call_y: number = 6;
458779efd5Sopenharmony_ci  moveY: number = 336;
468779efd5Sopenharmony_ci  dialerButtonWidth = 48;
478779efd5Sopenharmony_ci  dialerButtonHeight = 48;
488779efd5Sopenharmony_ci  dialerRadius = 24;
498779efd5Sopenharmony_ci  refreshView: boolean;
508779efd5Sopenharmony_ci  callBtnClick: boolean;
518779efd5Sopenharmony_ci  secretCode: string = '';
528779efd5Sopenharmony_ci  isPalyAudioing: boolean = false;
538779efd5Sopenharmony_ci  mAllCallRecordListDataSource: CallRecordListDataSource = new CallRecordListDataSource();
548779efd5Sopenharmony_ci  callLogSearchList: any[] = [];
558779efd5Sopenharmony_ci  static getInstance() {
568779efd5Sopenharmony_ci    if (this.mPresenter == null) {
578779efd5Sopenharmony_ci      this.mPresenter = new DialerPresenter();
588779efd5Sopenharmony_ci    }
598779efd5Sopenharmony_ci    return this.mPresenter;
608779efd5Sopenharmony_ci  }
618779efd5Sopenharmony_ci
628779efd5Sopenharmony_ci  aboutToAppear() {
638779efd5Sopenharmony_ci    if (!PreferencesUtil.isUsed() && !this._isCallStateChangeObserved) {
648779efd5Sopenharmony_ci      observer.on('callStateChange', (callback: {
658779efd5Sopenharmony_ci        state,
668779efd5Sopenharmony_ci        number,
678779efd5Sopenharmony_ci      }) => {
688779efd5Sopenharmony_ci        HiLog.i(TAG, 'callStateChange state' + callback.state);
698779efd5Sopenharmony_ci        if (callback.state === 0) {
708779efd5Sopenharmony_ci          HiLog.i(TAG, 'callback.state:' + callback.state);
718779efd5Sopenharmony_ci          this.refresh();
728779efd5Sopenharmony_ci        }
738779efd5Sopenharmony_ci      });
748779efd5Sopenharmony_ci      this._isCallStateChangeObserved = true;
758779efd5Sopenharmony_ci    }
768779efd5Sopenharmony_ci  }
778779efd5Sopenharmony_ci
788779efd5Sopenharmony_ci  refresh() {
798779efd5Sopenharmony_ci    if (!PreferencesUtil.isUsed()) {
808779efd5Sopenharmony_ci      PreferencesUtil.setIsUsed(true);
818779efd5Sopenharmony_ci      this.refreshView = !this.refreshView;
828779efd5Sopenharmony_ci    }
838779efd5Sopenharmony_ci  }
848779efd5Sopenharmony_ci
858779efd5Sopenharmony_ci  editPhoneNumber(phoneNum): void {
868779efd5Sopenharmony_ci    if (StringUtil.isEmpty(phoneNum)) {
878779efd5Sopenharmony_ci      return;
888779efd5Sopenharmony_ci    }
898779efd5Sopenharmony_ci    HiLog.i(TAG, 'editPhoneNumber');
908779efd5Sopenharmony_ci    AppStorage.SetOrCreate('tele_number', phoneNum);
918779efd5Sopenharmony_ci    this.all_number = phoneNum;
928779efd5Sopenharmony_ci    this.viewNumberTextProc();
938779efd5Sopenharmony_ci    this.deleteAddSpace();
948779efd5Sopenharmony_ci//    this.callHistorySearch()
958779efd5Sopenharmony_ci  }
968779efd5Sopenharmony_ci
978779efd5Sopenharmony_ci  onDestroy() {
988779efd5Sopenharmony_ci  }
998779efd5Sopenharmony_ci
1008779efd5Sopenharmony_ci  /*
1018779efd5Sopenharmony_ci   * Change the font size when deleting a number.
1028779efd5Sopenharmony_ci   */
1038779efd5Sopenharmony_ci  deleteTeleNum() {
1048779efd5Sopenharmony_ci//    this.callHistorySearch()
1058779efd5Sopenharmony_ci    let number: string = AppStorage.Get('tele_number');
1068779efd5Sopenharmony_ci    if (this.all_number.length < this.NUM_TEXT_MAX_LENGTH) {
1078779efd5Sopenharmony_ci      AppStorage.SetOrCreate('tele_number', this.all_number);
1088779efd5Sopenharmony_ci    } else {
1098779efd5Sopenharmony_ci      AppStorage.SetOrCreate('tele_number', this.all_number.substr(this.all_number.length - this.NUM_TEXT_MAX_LENGTH));
1108779efd5Sopenharmony_ci    }
1118779efd5Sopenharmony_ci    if (number.length > this.NUM_TEXT_MAXSIZE_LENGTH) {
1128779efd5Sopenharmony_ci      this.tele_num_size = this.NUM_TEXT_FONT_SIZE_MAX * this.NUM_TEXT_MAXSIZE_LENGTH / number.length;
1138779efd5Sopenharmony_ci    } else if (number.length <= this.NUM_TEXT_MAXSIZE_LENGTH) {
1148779efd5Sopenharmony_ci      this.tele_num_size = this.NUM_TEXT_FONT_SIZE_MAX;
1158779efd5Sopenharmony_ci    }
1168779efd5Sopenharmony_ci  }
1178779efd5Sopenharmony_ci
1188779efd5Sopenharmony_ci  /*
1198779efd5Sopenharmony_ci   * Add formatting spaces when deleting a number.
1208779efd5Sopenharmony_ci   */
1218779efd5Sopenharmony_ci  deleteAddSpace() {
1228779efd5Sopenharmony_ci    let number: string = AppStorage.Get('tele_number');
1238779efd5Sopenharmony_ci    let teleNumberNoSpace = StringUtil.removeSpace(number);
1248779efd5Sopenharmony_ci    this.all_number = StringUtil.removeSpace(this.all_number);
1258779efd5Sopenharmony_ci    if (teleNumberNoSpace.length > this.NUM_TEXT_MAXSIZE_LENGTH - 2) {
1268779efd5Sopenharmony_ci      AppStorage.SetOrCreate('tele_number', teleNumberNoSpace);
1278779efd5Sopenharmony_ci      return;
1288779efd5Sopenharmony_ci    }
1298779efd5Sopenharmony_ci    if (this.checkNeedNumberSpace(number)) {
1308779efd5Sopenharmony_ci      if (teleNumberNoSpace.length <= 3) {
1318779efd5Sopenharmony_ci        AppStorage.SetOrCreate('tele_number', teleNumberNoSpace);
1328779efd5Sopenharmony_ci        return;
1338779efd5Sopenharmony_ci      }
1348779efd5Sopenharmony_ci      if (teleNumberNoSpace.length > 3) {
1358779efd5Sopenharmony_ci        let split1 = teleNumberNoSpace.substr(0, 3);
1368779efd5Sopenharmony_ci        let split2 = teleNumberNoSpace.substr(3, teleNumberNoSpace.length - 3);
1378779efd5Sopenharmony_ci        AppStorage.SetOrCreate('tele_number', split1 + ' ' + split2);
1388779efd5Sopenharmony_ci        if (teleNumberNoSpace.length > 7) {
1398779efd5Sopenharmony_ci          split2 = teleNumberNoSpace.substr(3, 4);
1408779efd5Sopenharmony_ci          let split3 = teleNumberNoSpace.substr(7, teleNumberNoSpace.length - 7);
1418779efd5Sopenharmony_ci          AppStorage.SetOrCreate('tele_number', split1 + ' ' + split2 + ' ' + split3);
1428779efd5Sopenharmony_ci        }
1438779efd5Sopenharmony_ci      }
1448779efd5Sopenharmony_ci    } else {
1458779efd5Sopenharmony_ci      if (teleNumberNoSpace.length > 8) {
1468779efd5Sopenharmony_ci        let split4 = teleNumberNoSpace.substr(0, 8);
1478779efd5Sopenharmony_ci        let split5 = teleNumberNoSpace.substr(8, teleNumberNoSpace.length - 8);
1488779efd5Sopenharmony_ci        AppStorage.SetOrCreate('tele_number', split4 + ' ' + split5);
1498779efd5Sopenharmony_ci      }
1508779efd5Sopenharmony_ci    }
1518779efd5Sopenharmony_ci  }
1528779efd5Sopenharmony_ci
1538779efd5Sopenharmony_ci  /*
1548779efd5Sopenharmony_ci   * Check whether formatting spaces are required when entering a number.
1558779efd5Sopenharmony_ci   */
1568779efd5Sopenharmony_ci  checkNeedNumberSpace(numText) {
1578779efd5Sopenharmony_ci    let isSpace = /[\+;,#\*]/g;
1588779efd5Sopenharmony_ci    let isRule = /^\+.*/;
1598779efd5Sopenharmony_ci    if (isSpace.test(numText)) {
1608779efd5Sopenharmony_ci      // If the number string contains special characters, no space is added.
1618779efd5Sopenharmony_ci      if (isRule.test(numText)) {
1628779efd5Sopenharmony_ci        return true;
1638779efd5Sopenharmony_ci      } else {
1648779efd5Sopenharmony_ci        return false;
1658779efd5Sopenharmony_ci      }
1668779efd5Sopenharmony_ci    }
1678779efd5Sopenharmony_ci    return true;
1688779efd5Sopenharmony_ci  }
1698779efd5Sopenharmony_ci
1708779efd5Sopenharmony_ci  dialing(phoneNumber, options?: any) {
1718779efd5Sopenharmony_ci    this.editPhoneNumber('');
1728779efd5Sopenharmony_ci    PhoneNumber.fromString(phoneNumber).dial(options).then((rst) => {
1738779efd5Sopenharmony_ci      this.refresh();
1748779efd5Sopenharmony_ci    });
1758779efd5Sopenharmony_ci  }
1768779efd5Sopenharmony_ci
1778779efd5Sopenharmony_ci  /*
1788779efd5Sopenharmony_ci   * Key vibration
1798779efd5Sopenharmony_ci   */
1808779efd5Sopenharmony_ci  pressVibrate() {
1818779efd5Sopenharmony_ci  }
1828779efd5Sopenharmony_ci
1838779efd5Sopenharmony_ci  /*
1848779efd5Sopenharmony_ci   * Add a space when entering a number.
1858779efd5Sopenharmony_ci   */
1868779efd5Sopenharmony_ci  ifNeedSpace() {
1878779efd5Sopenharmony_ci    let needNumber: string = AppStorage.Get('tele_number');
1888779efd5Sopenharmony_ci    switch (needNumber.length) {
1898779efd5Sopenharmony_ci      case 3:
1908779efd5Sopenharmony_ci        if (this.checkNeedNumberSpace(needNumber)) {
1918779efd5Sopenharmony_ci          AppStorage.SetOrCreate('tele_number', needNumber + ' ');
1928779efd5Sopenharmony_ci        }
1938779efd5Sopenharmony_ci        break;
1948779efd5Sopenharmony_ci      case 8:
1958779efd5Sopenharmony_ci        AppStorage.SetOrCreate('tele_number', needNumber + ' ');
1968779efd5Sopenharmony_ci        break;
1978779efd5Sopenharmony_ci      default:
1988779efd5Sopenharmony_ci        break;
1998779efd5Sopenharmony_ci    }
2008779efd5Sopenharmony_ci  }
2018779efd5Sopenharmony_ci
2028779efd5Sopenharmony_ci  /*
2038779efd5Sopenharmony_ci   * Processing of Overlong Input Numbers
2048779efd5Sopenharmony_ci   */
2058779efd5Sopenharmony_ci  viewNumberTextProc() {
2068779efd5Sopenharmony_ci    let numStringNoSpace_all = StringUtil.removeSpace(this.all_number);
2078779efd5Sopenharmony_ci    let number: string = AppStorage.Get('tele_number');
2088779efd5Sopenharmony_ci    AppStorage.SetOrCreate('tele_number', numStringNoSpace_all.length > this.NUM_TEXT_MAX_LENGTH ?
2098779efd5Sopenharmony_ci    numStringNoSpace_all.substr(numStringNoSpace_all.length - this.NUM_TEXT_MAX_LENGTH) : number
2108779efd5Sopenharmony_ci    );
2118779efd5Sopenharmony_ci    if (number.length > this.NUM_TEXT_MAXSIZE_LENGTH) {
2128779efd5Sopenharmony_ci      AppStorage.SetOrCreate('tele_number', StringUtil.removeSpace(number));
2138779efd5Sopenharmony_ci    }
2148779efd5Sopenharmony_ci    if (number.length > this.NUM_TEXT_MAXSIZE_LENGTH) {
2158779efd5Sopenharmony_ci      this.tele_num_size = this.NUM_TEXT_FONT_SIZE_MAX * this.NUM_TEXT_MAXSIZE_LENGTH / (number.length); // 可视号码在16-25位时,适配font-size
2168779efd5Sopenharmony_ci    } else {
2178779efd5Sopenharmony_ci      this.tele_num_size = this.NUM_TEXT_FONT_SIZE_MAX;
2188779efd5Sopenharmony_ci    }
2198779efd5Sopenharmony_ci  }
2208779efd5Sopenharmony_ci
2218779efd5Sopenharmony_ci  /*
2228779efd5Sopenharmony_ci   * Play different audio resources based on key digits.
2238779efd5Sopenharmony_ci   */
2248779efd5Sopenharmony_ci  playAudio(number) {
2258779efd5Sopenharmony_ci    switch (number.toString()) {
2268779efd5Sopenharmony_ci      case '1':
2278779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_1);
2288779efd5Sopenharmony_ci        break;
2298779efd5Sopenharmony_ci      case '2':
2308779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_2);
2318779efd5Sopenharmony_ci        break;
2328779efd5Sopenharmony_ci      case '3':
2338779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_3);
2348779efd5Sopenharmony_ci        break;
2358779efd5Sopenharmony_ci      case '4':
2368779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_4);
2378779efd5Sopenharmony_ci        break;
2388779efd5Sopenharmony_ci      case '5':
2398779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_5);
2408779efd5Sopenharmony_ci        break;
2418779efd5Sopenharmony_ci      case '6':
2428779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_6);
2438779efd5Sopenharmony_ci        break;
2448779efd5Sopenharmony_ci      case '7':
2458779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_7);
2468779efd5Sopenharmony_ci        break;
2478779efd5Sopenharmony_ci      case '8':
2488779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_8);
2498779efd5Sopenharmony_ci        break;
2508779efd5Sopenharmony_ci      case '9':
2518779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_9);
2528779efd5Sopenharmony_ci        break;
2538779efd5Sopenharmony_ci      case '0':
2548779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_0);
2558779efd5Sopenharmony_ci        break;
2568779efd5Sopenharmony_ci      case '*':
2578779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_S);
2588779efd5Sopenharmony_ci        break;
2598779efd5Sopenharmony_ci      case '#':
2608779efd5Sopenharmony_ci        this.tonePlayer(audio.ToneType.TONE_TYPE_DIAL_P);
2618779efd5Sopenharmony_ci        break;
2628779efd5Sopenharmony_ci      default:
2638779efd5Sopenharmony_ci        HiLog.e(TAG, 'keytone src is error');
2648779efd5Sopenharmony_ci    }
2658779efd5Sopenharmony_ci  }
2668779efd5Sopenharmony_ci
2678779efd5Sopenharmony_ci  async tonePlayer(type) {
2688779efd5Sopenharmony_ci    HiLog.i(TAG, 'TonePlayer type: ' + type);
2698779efd5Sopenharmony_ci    let that = this;
2708779efd5Sopenharmony_ci    let tonePlayer = null;
2718779efd5Sopenharmony_ci    let audioRendererInfo = {
2728779efd5Sopenharmony_ci      content: audio.ContentType.CONTENT_TYPE_UNKNOWN,
2738779efd5Sopenharmony_ci      usage: audio.StreamUsage.STREAM_USAGE_DTMF,
2748779efd5Sopenharmony_ci      rendererFlags: 0
2758779efd5Sopenharmony_ci    };
2768779efd5Sopenharmony_ci
2778779efd5Sopenharmony_ci    if (!this.isPalyAudioing) {
2788779efd5Sopenharmony_ci      this.isPalyAudioing = true;
2798779efd5Sopenharmony_ci      tonePlayer = await audio.createTonePlayer(audioRendererInfo);
2808779efd5Sopenharmony_ci      await tonePlayer.load(type);
2818779efd5Sopenharmony_ci      await tonePlayer.start();
2828779efd5Sopenharmony_ci      setTimeout(async () => {
2838779efd5Sopenharmony_ci        that.isPalyAudioing = false;
2848779efd5Sopenharmony_ci        await tonePlayer.stop();
2858779efd5Sopenharmony_ci        await tonePlayer.release();
2868779efd5Sopenharmony_ci      }, 15)
2878779efd5Sopenharmony_ci    }
2888779efd5Sopenharmony_ci  };
2898779efd5Sopenharmony_ci
2908779efd5Sopenharmony_ci  /*
2918779efd5Sopenharmony_ci   * Jump to New Contact
2928779efd5Sopenharmony_ci   */
2938779efd5Sopenharmony_ci  jumpToAccountants() {
2948779efd5Sopenharmony_ci    router.push({
2958779efd5Sopenharmony_ci      url: 'pages/contacts/accountants/Accountants',
2968779efd5Sopenharmony_ci      params: {
2978779efd5Sopenharmony_ci        updataShow: false,
2988779efd5Sopenharmony_ci        phoneNumbers: [{
2998779efd5Sopenharmony_ci                         phoneNumber: AppStorage.Get('tele_number')
3008779efd5Sopenharmony_ci                       }]
3018779efd5Sopenharmony_ci      },
3028779efd5Sopenharmony_ci    })
3038779efd5Sopenharmony_ci  }
3048779efd5Sopenharmony_ci
3058779efd5Sopenharmony_ci  sendMessage() {
3068779efd5Sopenharmony_ci    let formatnum = PhoneNumber.fromString(this.all_number).format();
3078779efd5Sopenharmony_ci    PhoneNumber.fromString(this.all_number).sendMessage(formatnum, formatnum);
3088779efd5Sopenharmony_ci  }
3098779efd5Sopenharmony_ci
3108779efd5Sopenharmony_ci  saveCallRecordExistingContact() {
3118779efd5Sopenharmony_ci    HiLog.i(TAG, 'saveCallRecordExistingContact start.');
3128779efd5Sopenharmony_ci    router.pushUrl({
3138779efd5Sopenharmony_ci      url: 'pages/contacts/batchselectcontacts/SingleSelectContactPage',
3148779efd5Sopenharmony_ci      params: {
3158779efd5Sopenharmony_ci        phoneNumberShow: AppStorage.Get('tele_number'),
3168779efd5Sopenharmony_ci        editContact: 2,
3178779efd5Sopenharmony_ci      }
3188779efd5Sopenharmony_ci    });
3198779efd5Sopenharmony_ci  }
3208779efd5Sopenharmony_ci
3218779efd5Sopenharmony_ci  dealSecretCode(value: string) {
3228779efd5Sopenharmony_ci    let length = value.length;
3238779efd5Sopenharmony_ci    if (length > 8 && value.startsWith(SECRET_CODE_START) && value.endsWith(SECRET_CODE_END)) {
3248779efd5Sopenharmony_ci      let str = value.substring(SECRET_CODE_START.length, length - SECRET_CODE_END.length);
3258779efd5Sopenharmony_ci      this.secretCode = str;
3268779efd5Sopenharmony_ci    } else {
3278779efd5Sopenharmony_ci      this.secretCode = '';
3288779efd5Sopenharmony_ci    }
3298779efd5Sopenharmony_ci  }
3308779efd5Sopenharmony_ci
3318779efd5Sopenharmony_ci  callHistorySearch() {
3328779efd5Sopenharmony_ci    let teleNumber: string = AppStorage.Get('tele_number');
3338779efd5Sopenharmony_ci    globalThis.DataWorker.sendRequest('getQueryT9PhoneNumbers', {
3348779efd5Sopenharmony_ci      favoriteForm: JSON.stringify({favorite:{teleNumber:teleNumber.replace(/\s*/g,'')}}),
3358779efd5Sopenharmony_ci      context: globalThis.context
3368779efd5Sopenharmony_ci    }, (result) => {
3378779efd5Sopenharmony_ci      let nameArray = [];
3388779efd5Sopenharmony_ci      for (let i = 0; i < result.length; i++) {
3398779efd5Sopenharmony_ci        nameArray.push(result[i].showName);
3408779efd5Sopenharmony_ci        result[i].displayName = result[i]?.showName || result[i]?.phoneNumbers[0]?.phoneNumber || '';
3418779efd5Sopenharmony_ci        result[i].phoneNumber = result[i]?.phoneNumbers[0]?.phoneNumber || '';
3428779efd5Sopenharmony_ci      }
3438779efd5Sopenharmony_ci      const queryCall = {context: globalThis.context,mergeRule: '', actionData: {teleNumber:teleNumber.replace(/\s*/g,''), nameArray}};
3448779efd5Sopenharmony_ci      globalThis.DataWorker?.sendRequest('getCallHistorySearch', queryCall, (data) => {
3458779efd5Sopenharmony_ci        this.callLogSearchList = [];
3468779efd5Sopenharmony_ci        if(data.callLogList.length > 0 || result.length > 0){
3478779efd5Sopenharmony_ci          this.callLogSearchList = [...this.callLogSearchList,...result]
3488779efd5Sopenharmony_ci          for (let i = 0; i < data.callLogList.length; i++) {
3498779efd5Sopenharmony_ci            const displayName = data?.callLogList[i]?.displayName || data?.callLogList[i]?.phoneNumber;
3508779efd5Sopenharmony_ci            if(!nameArray.includes(displayName)){
3518779efd5Sopenharmony_ci              nameArray.push(displayName)
3528779efd5Sopenharmony_ci              this.callLogSearchList.push({...data.callLogList[i], displayName});
3538779efd5Sopenharmony_ci            }
3548779efd5Sopenharmony_ci          }
3558779efd5Sopenharmony_ci        }
3568779efd5Sopenharmony_ci        this.mAllCallRecordListDataSource.refreshAll(this.callLogSearchList.sort((a: any, b: any)=> (a.count || 0) - (b.count || 0)));
3578779efd5Sopenharmony_ci      })
3588779efd5Sopenharmony_ci    })
3598779efd5Sopenharmony_ci  }
3608779efd5Sopenharmony_ci
3618779efd5Sopenharmony_ci  jumpToContactDetail(phoneNumber) {
3628779efd5Sopenharmony_ci    router.pushUrl(
3638779efd5Sopenharmony_ci      {
3648779efd5Sopenharmony_ci        url: 'pages/contacts/details/ContactDetail',
3658779efd5Sopenharmony_ci        params: {
3668779efd5Sopenharmony_ci          sourceHasPhone: true,
3678779efd5Sopenharmony_ci          phoneNumberShow: phoneNumber
3688779efd5Sopenharmony_ci        }
3698779efd5Sopenharmony_ci      }
3708779efd5Sopenharmony_ci    )
3718779efd5Sopenharmony_ci  }
3728779efd5Sopenharmony_ci}