1/*
2 * Copyright (c) 2023-2023 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 UIAbility from '@ohos.app.ability.UIAbility';
17import { Log } from '@ohos/common';
18import type common from '@ohos.app.ability.common';
19import { GlobalThisHelper, GlobalThisStorageKey} from '@ohos/common';
20import { printJobMgr } from '../Controller/PrintJobManager';
21import Want from '@ohos.app.ability.Want';
22import AbilityConstant from '@ohos.app.ability.AbilityConstant';
23import window from '@ohos.window';
24
25const TAG = 'JobManagerAbility';
26
27export default class JobManagerAbility extends UIAbility {
28  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
29    Log.info(TAG, 'onCreate');
30    GlobalThisHelper.createValue<common.UIAbilityContext>(this.context, GlobalThisStorageKey.KEY_JOB_MANAGER_ABILITY_CONTEXT, true);
31    printJobMgr.onStart();
32  }
33
34  onDestroy(): void {
35    Log.info(TAG, 'onDestroy');
36  }
37
38  onWindowStageCreate(windowStage: window.WindowStage): void {
39    // Main window is created, set main page for this ability
40    Log.info(TAG, 'onWindowStageCreate');
41    windowStage.loadContent('pages/JobManagerPage');
42  }
43
44  onWindowStageDestroy(): void {
45    // Main window is destroyed, release UI related resources
46    Log.info(TAG, 'onWindowStageDestroy');
47    printJobMgr.onStop();
48  }
49
50  onForeground(): void {
51    // Ability has brought to foreground
52    Log.info(TAG, 'onForeground');
53  }
54
55  onBackground(): void {
56    // Ability has back to background
57    Log.info(TAG, 'onBackground');
58  }
59};
60