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
16import Ability from '@ohos.app.ability.UIAbility';
17import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
18import { GlobalContext } from '../../../../../../common/utils/src/main/ets/default/baseUtil/GlobalContext';
19
20export default class MainAbility extends Ability {
21  tag: string = "ApplicationInfoSettings";
22  windowStage;
23
24  onCreate(want, launchParam) {
25    LogUtil.info(this.tag + ' Application onCreate');
26    GlobalContext.getContext().setObject(GlobalContext.globalKeyAbilityWant, want);
27    GlobalContext.getContext().setObject(GlobalContext.globalKeySettingsAbilityContext, this.context);
28  }
29
30  onDestroy() {
31    LogUtil.info(this.tag + 'Application onDestroy')
32  }
33
34  onWindowStageCreate(windowStage) {
35    // Main window is created, set main page for this ability
36    LogUtil.info(this.tag + "  onWindowStageCreate is called");
37    this.windowStage = windowStage;
38    windowStage.setUIContent(this.context, "pages/applicationInfo", null);
39  }
40
41  onNewWant(want): void {
42    GlobalContext.getContext().setObject(GlobalContext.globalKeyAbilityWant, want);
43    LogUtil.info(this.tag + " onNewWant is called");
44    this.windowStage?.setUIContent(this.context, "pages/applicationInfo", null);
45  }
46};
47