• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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 logger from '../common/logger';
18import type Want from '@ohos.app.ability.Want';
19import type AbilityConstant from '@ohos.app.ability.AbilityConstant';
20import type window from '@ohos.window';
21
22const TAG = 'AutoManagerAbility';
23
24export default class AutoManagerAbility extends UIAbility {
25  private localStorage: LocalStorage = new LocalStorage();
26
27  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
28    logger.info(TAG, 'onCreate');
29    this.localStorage.setOrCreate('autoManagerAbilityWant', want);
30  }
31
32  onDestroy(): void {
33    logger.info(TAG, 'onDestroy');
34  }
35
36  onWindowStageCreate(windowStage: window.WindowStage): void {
37    // Main window is created, set main page for this ability
38    logger.info(TAG, 'onWindowStageCreate');
39    windowStage.loadContent('pages/autoManager/managerStart', this.localStorage);
40  }
41
42  onWindowStageDestroy(): void {
43    // Main window is destroyed, release UI related resources
44    logger.info(TAG, 'onWindowStageDestroy');
45  }
46
47  onForeground(): void {
48    // Ability has brought to foreground
49    logger.info(TAG, 'onForeground');
50  }
51
52  onBackground(): void {
53    // Ability has back to background
54    logger.info(TAG, 'onBackground');
55  }
56};
57