199da06d0Sopenharmony_ci/** 299da06d0Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 399da06d0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 499da06d0Sopenharmony_ci * you may not use this file except in compliance with the License. 599da06d0Sopenharmony_ci * You may obtain a copy of the License at 699da06d0Sopenharmony_ci * 799da06d0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 899da06d0Sopenharmony_ci * 999da06d0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1099da06d0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1199da06d0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1299da06d0Sopenharmony_ci * See the License for the specific language governing permissions and 1399da06d0Sopenharmony_ci * limitations under the License. 1499da06d0Sopenharmony_ci */ 1599da06d0Sopenharmony_ci 1699da06d0Sopenharmony_ciimport Ability from '@ohos.app.ability.UIAbility'; 1799da06d0Sopenharmony_ciimport LogUtils from '../common/utils/LogUtils'; 1899da06d0Sopenharmony_ciimport CallManager from '../model/CallManager'; 1999da06d0Sopenharmony_ci 2099da06d0Sopenharmony_ciconst TAG = 'MainAbility'; 2199da06d0Sopenharmony_ci 2299da06d0Sopenharmony_ciexport default class MainAbility extends Ability { 2399da06d0Sopenharmony_ci onCreate(want, launchParam) { 2499da06d0Sopenharmony_ci LogUtils.i(TAG, 'onCreate'); 2599da06d0Sopenharmony_ci globalThis.abilityWant = want; 2699da06d0Sopenharmony_ci globalThis.calluiAbilityContext = this.context; 2799da06d0Sopenharmony_ci } 2899da06d0Sopenharmony_ci 2999da06d0Sopenharmony_ci onWindowStageCreate(windowStage): void { 3099da06d0Sopenharmony_ci // Main window is created, set main page for this ability 3199da06d0Sopenharmony_ci LogUtils.i(TAG, 'onWindowStageCreate'); 3299da06d0Sopenharmony_ci windowStage.setShowOnLockScreen(true); 3399da06d0Sopenharmony_ci windowStage.loadContent('pages/index', (err, data) => { 3499da06d0Sopenharmony_ci if (err.code) { 3599da06d0Sopenharmony_ci LogUtils.e(TAG, 'Failed to load the content. Cause:' + JSON.stringify(err)); 3699da06d0Sopenharmony_ci return; 3799da06d0Sopenharmony_ci } 3899da06d0Sopenharmony_ci LogUtils.e(TAG, 'Succeeded in loading the content. Data: ' + JSON.stringify(data)); 3999da06d0Sopenharmony_ci }); 4099da06d0Sopenharmony_ci } 4199da06d0Sopenharmony_ci 4299da06d0Sopenharmony_ci onWindowStageDestroy(): void { 4399da06d0Sopenharmony_ci // Main window is destroyed, release UI related resources 4499da06d0Sopenharmony_ci LogUtils.i(TAG, 'onWindowStageDestroy'); 4599da06d0Sopenharmony_ci } 4699da06d0Sopenharmony_ci 4799da06d0Sopenharmony_ci onForeground(): void { 4899da06d0Sopenharmony_ci // Ability has brought to foreground 4999da06d0Sopenharmony_ci LogUtils.i(TAG, 'onForeground'); 5099da06d0Sopenharmony_ci } 5199da06d0Sopenharmony_ci 5299da06d0Sopenharmony_ci onBackground(): void { 5399da06d0Sopenharmony_ci // Ability has back to background 5499da06d0Sopenharmony_ci LogUtils.i(TAG, 'onBackground'); 5599da06d0Sopenharmony_ci } 5699da06d0Sopenharmony_ci 5799da06d0Sopenharmony_ci onDestroy(): void { 5899da06d0Sopenharmony_ci LogUtils.i(TAG, 'onDestroy'); 5999da06d0Sopenharmony_ci CallManager.getInstance()?.clearTimer(); 6099da06d0Sopenharmony_ci } 6199da06d0Sopenharmony_ci}; 62