1c36cf2e9Sopenharmony_ci/*
2c36cf2e9Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3c36cf2e9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c36cf2e9Sopenharmony_ci * you may not use this file except in compliance with the License.
5c36cf2e9Sopenharmony_ci * You may obtain a copy of the License at
6c36cf2e9Sopenharmony_ci *
7c36cf2e9Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c36cf2e9Sopenharmony_ci *
9c36cf2e9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c36cf2e9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c36cf2e9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c36cf2e9Sopenharmony_ci * See the License for the specific language governing permissions and
13c36cf2e9Sopenharmony_ci * limitations under the License.
14c36cf2e9Sopenharmony_ci */
15c36cf2e9Sopenharmony_ci
16c36cf2e9Sopenharmony_ciimport UIAbility from '@ohos.app.ability.UIAbility';
17c36cf2e9Sopenharmony_ciimport { Log } from '@ohos/common';
18c36cf2e9Sopenharmony_ciimport type common from '@ohos.app.ability.common';
19c36cf2e9Sopenharmony_ciimport { GlobalThisHelper, GlobalThisStorageKey} from '@ohos/common';
20c36cf2e9Sopenharmony_ciimport { printJobMgr } from '../Controller/PrintJobManager';
21c36cf2e9Sopenharmony_ciimport Want from '@ohos.app.ability.Want';
22c36cf2e9Sopenharmony_ciimport AbilityConstant from '@ohos.app.ability.AbilityConstant';
23c36cf2e9Sopenharmony_ciimport window from '@ohos.window';
24c36cf2e9Sopenharmony_ci
25c36cf2e9Sopenharmony_ciconst TAG = 'JobManagerAbility';
26c36cf2e9Sopenharmony_ci
27c36cf2e9Sopenharmony_ciexport default class JobManagerAbility extends UIAbility {
28c36cf2e9Sopenharmony_ci  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
29c36cf2e9Sopenharmony_ci    Log.info(TAG, 'onCreate');
30c36cf2e9Sopenharmony_ci    GlobalThisHelper.createValue<common.UIAbilityContext>(this.context, GlobalThisStorageKey.KEY_JOB_MANAGER_ABILITY_CONTEXT, true);
31c36cf2e9Sopenharmony_ci    printJobMgr.onStart();
32c36cf2e9Sopenharmony_ci  }
33c36cf2e9Sopenharmony_ci
34c36cf2e9Sopenharmony_ci  onDestroy(): void {
35c36cf2e9Sopenharmony_ci    Log.info(TAG, 'onDestroy');
36c36cf2e9Sopenharmony_ci  }
37c36cf2e9Sopenharmony_ci
38c36cf2e9Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
39c36cf2e9Sopenharmony_ci    // Main window is created, set main page for this ability
40c36cf2e9Sopenharmony_ci    Log.info(TAG, 'onWindowStageCreate');
41c36cf2e9Sopenharmony_ci    windowStage.loadContent('pages/JobManagerPage');
42c36cf2e9Sopenharmony_ci  }
43c36cf2e9Sopenharmony_ci
44c36cf2e9Sopenharmony_ci  onWindowStageDestroy(): void {
45c36cf2e9Sopenharmony_ci    // Main window is destroyed, release UI related resources
46c36cf2e9Sopenharmony_ci    Log.info(TAG, 'onWindowStageDestroy');
47c36cf2e9Sopenharmony_ci    printJobMgr.onStop();
48c36cf2e9Sopenharmony_ci  }
49c36cf2e9Sopenharmony_ci
50c36cf2e9Sopenharmony_ci  onForeground(): void {
51c36cf2e9Sopenharmony_ci    // Ability has brought to foreground
52c36cf2e9Sopenharmony_ci    Log.info(TAG, 'onForeground');
53c36cf2e9Sopenharmony_ci  }
54c36cf2e9Sopenharmony_ci
55c36cf2e9Sopenharmony_ci  onBackground(): void {
56c36cf2e9Sopenharmony_ci    // Ability has back to background
57c36cf2e9Sopenharmony_ci    Log.info(TAG, 'onBackground');
58c36cf2e9Sopenharmony_ci  }
59c36cf2e9Sopenharmony_ci};
60