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 16// @ts-nocheck 17import UIAbility from '@ohos.app.ability.UIAbility'; 18import { Log } from '@ohos/common'; 19import type common from '@ohos.app.ability.common'; 20import { GlobalThisHelper, GlobalThisStorageKey} from '@ohos/common'; 21import { Constants } from '@ohos/common'; 22 23const TAG = 'JobManagerAbility'; 24 25export default class JobManagerAbility extends UIAbility { 26 onCreate(want, launchParam): void { 27 Log.info(TAG, 'onCreate'); 28 GlobalThisHelper.createValue<common.UIAbilityContext>(this.context, GlobalThisStorageKey.KEY_JOB_MANAGER_ABILITY_CONTEXT, true); 29 let jobId = want.parameters[Constants.WANT_JOB_ID_KEY]; 30 this.context.eventHub.on(Constants.EVENT_GET_ABILITY_DATA, (data) => { 31 data.wantJobId = jobId; 32 }); 33 } 34 35 onDestroy(): void { 36 Log.info(TAG, 'onDestroy'); 37 } 38 39 onWindowStageCreate(windowStage): void { 40 // Main window is created, set main page for this ability 41 Log.info(TAG, 'onWindowStageCreate'); 42 // windowStage.getMainWindow().then((window) => { 43 // window.resetSize(vp2px(Constants.MAIN_WINDOW_WIDTH), vp2px(Constants.MAIN_WINDOW_HEIGHT)); 44 // }).catch((err) => { 45 // Log.error(TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); 46 // }); 47 48 windowStage.setUIContent(this.context, 'pages/JobManagerPage', null); 49 } 50 51 onWindowStageDestroy(): void { 52 // Main window is destroyed, release UI related resources 53 Log.info(TAG, 'onWindowStageDestroy'); 54 let adapter = GlobalThisHelper.getValue<PrintAdapter>(GlobalThisStorageKey.KEY_PRINT_ADAPTER); 55 adapter.destroy(); 56 } 57 58 onForeground(): void { 59 // Ability has brought to foreground 60 Log.info(TAG, 'onForeground'); 61 } 62 63 onBackground(): void { 64 // Ability has back to background 65 Log.info(TAG, 'onBackground'); 66 } 67}; 68