1df226684Sopenharmony_ci/* 2df226684Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3df226684Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4df226684Sopenharmony_ci * you may not use this file except in compliance with the License. 5df226684Sopenharmony_ci * You may obtain a copy of the License at 6df226684Sopenharmony_ci * 7df226684Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8df226684Sopenharmony_ci * 9df226684Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10df226684Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11df226684Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12df226684Sopenharmony_ci * See the License for the specific language governing permissions and 13df226684Sopenharmony_ci * limitations under the License. 14df226684Sopenharmony_ci */ 15df226684Sopenharmony_ci 16df226684Sopenharmony_ciimport UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; 17df226684Sopenharmony_ciimport UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; 18df226684Sopenharmony_ciimport { HiLog } from '../common/HiLog'; 19df226684Sopenharmony_ciimport Constants from '../common/constant'; 20df226684Sopenharmony_ciimport GlobalContext from '../common/GlobalContext'; 21df226684Sopenharmony_ci 22df226684Sopenharmony_ciconst TAG = 'DialogUIExt'; 23df226684Sopenharmony_ci 24df226684Sopenharmony_ciexport default class DialogUIExtAbility extends UIExtensionAbility { 25df226684Sopenharmony_ci 26df226684Sopenharmony_ci async onSessionCreate(want: Want, session: UIExtensionContentSession): Promise<void> { 27df226684Sopenharmony_ci HiLog.info(TAG, `onSessionCreate start`); 28df226684Sopenharmony_ci GlobalContext.store('dialogUIExtWant', want); 29df226684Sopenharmony_ci try { 30df226684Sopenharmony_ci session.loadContent('pages/alert'); 31df226684Sopenharmony_ci session.setWindowBackgroundColor(Constants.TRANSPARENT_BACKGROUND_COLOR); 32df226684Sopenharmony_ci } catch (exception) { 33df226684Sopenharmony_ci HiLog.error(TAG, `Failed to set the background color. Cause: ${JSON.stringify(exception)}`); 34df226684Sopenharmony_ci } 35df226684Sopenharmony_ci } 36df226684Sopenharmony_ci 37df226684Sopenharmony_ci onSessionDestroy(session: UIExtensionContentSession): void { 38df226684Sopenharmony_ci HiLog.info(TAG, `onSessionDestroy`); 39df226684Sopenharmony_ci } 40df226684Sopenharmony_ci 41df226684Sopenharmony_ci onWindowStageDestroy(): void { 42df226684Sopenharmony_ci HiLog.info(TAG, `onWindowStageDestroy`); 43df226684Sopenharmony_ci } 44df226684Sopenharmony_ci 45df226684Sopenharmony_ci onForeground(): void { 46df226684Sopenharmony_ci HiLog.info(TAG, `onForeground`); 47df226684Sopenharmony_ci } 48df226684Sopenharmony_ci 49df226684Sopenharmony_ci onBackground() { 50df226684Sopenharmony_ci HiLog.info(TAG, `onBackground`); 51df226684Sopenharmony_ci } 52df226684Sopenharmony_ci}; 53