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 async onSessionCreate(want: Want, session: UIExtensionContentSession): Promise<void> { 26 HiLog.info(TAG, `onSessionCreate start`); 27 GlobalContext.store('dialogUIExtWant', want); 28 try { 29 session.loadContent('pages/alert'); 30 session.setWindowBackgroundColor(Constants.TRANSPARENT_BACKGROUND_COLOR); 31 } catch (exception) { 32 HiLog.error(TAG, `Failed to set the background color. Cause: ${JSON.stringify(exception)}`); 33 } 34 } 35 36 onSessionDestroy(session: UIExtensionContentSession): void { 37 HiLog.info(TAG, `onSessionDestroy`); 38 } 39 40 onWindowStageDestroy(): void { 41 HiLog.info(TAG, `onWindowStageDestroy`); 42 } 43 44 onForeground(): void { 45 HiLog.info(TAG, `onForeground`); 46 } 47 48 onBackground() { 49 HiLog.info(TAG, `onBackground`); 50 } 51}; 52