• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2022-2024 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 type Want from '@ohos.app.ability.Want';
18import type Window from '@ohos.window';
19import { GlobalContext, PwdStore } from '../common/GlobalContext';
20
21export default class MainAbility extends Ability {
22  onCreate(want: Want, launchParam): void {
23    console.info('[CertManager] MainAbility onCreate');
24
25    if (want === null || want === undefined) {
26      console.error('[CertManager] invalid want param');
27      return;
28    }
29    let pwdStore = new PwdStore();
30    GlobalContext.getContext().setCmContext(this.context);
31    GlobalContext.getContext().setPwdStore(pwdStore);
32    GlobalContext.getContext().setAbilityWant(want);
33    GlobalContext.getContext().setFlag(false);
34  }
35
36  onDestroy(): void {
37    console.info('[CertManager] MainAbility onDestroy');
38  }
39
40  onWindowStageCreate(windowStage: Window.WindowStage): void {
41    // Main window is created, set main page for this ability
42    console.info('[CertManager] MainAbility onWindowStageCreate');
43    windowStage.loadContent('pages/certManagerFa', (err, data) => {
44      if (err.code) {
45        console.error('onWindowStageCreate failed, cause:' + JSON.stringify(err));
46        return;
47      }
48    });
49  }
50
51  onWindowStageDestroy(): void {
52    // Main window is destroyed, release UI related resources
53    console.info('[CertManager] MainAbility onWindowStageDestroy');
54  }
55
56  onForeground(): void {
57    // Ability has brought to foreground
58    console.info('[CertManager] MainAbility onForeground');
59  }
60
61  onBackground(): void {
62    // Ability has back to background
63    console.info('[CertManager] MainAbility onBackground');
64  }
65
66  onNewWant(want: Want): void {
67    console.info('[CertManager] MainAbility onNewWant');
68
69    if (want === null || want === undefined) {
70      console.error('[CertManager] invalid want param');
71      return;
72    }
73    GlobalContext.getContext().setAbilityWant(want);
74  }
75};
76