1/*
2 * Copyright (c) 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
17import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility';
18import { HiLog } from '../common/HiLog';
19import Constants from '../common/constant';
20import GlobalContext from '../common/GlobalContext';
21
22const TAG = 'DialogUIExt';
23
24export default class DialogUIExtAbility extends UIExtensionAbility {
25
26  async onSessionCreate(want: Want, session: UIExtensionContentSession): Promise<void> {
27    HiLog.info(TAG, `onSessionCreate start`);
28    GlobalContext.store('dialogUIExtWant', want);
29    try {
30      session.loadContent('pages/alert');
31      session.setWindowBackgroundColor(Constants.TRANSPARENT_BACKGROUND_COLOR);
32    } catch (exception) {
33      HiLog.error(TAG, `Failed to set the background color. Cause: ${JSON.stringify(exception)}`);
34    }
35  }
36
37  onSessionDestroy(session: UIExtensionContentSession): void {
38    HiLog.info(TAG, `onSessionDestroy`);
39  }
40
41  onWindowStageDestroy(): void {
42    HiLog.info(TAG, `onWindowStageDestroy`);
43  }
44
45  onForeground(): void {
46    HiLog.info(TAG, `onForeground`);
47  }
48
49  onBackground() {
50    HiLog.info(TAG, `onBackground`);
51  }
52};
53