1/* 2 * Copyright (c) 2025 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 */ 15import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; 16import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; 17import Want from '@ohos.app.ability.Want'; 18import { logger } from '../utils/Logger'; 19 20const TAG: string = '[MechExtAbility]'; 21 22export default class MechExtAbility extends UIExtensionAbility { 23 onCreate() { 24 logger.info(`${TAG} UIExtAbility onCreate`); 25 } 26 27 onForeground() { 28 logger.info(`${TAG} UIExtAbility onForeground`); 29 } 30 31 onBackground() { 32 logger.info(`${TAG} UIExtAbility onBackground`); 33 } 34 35 onDestroy() { 36 logger.info(`${TAG} UIExtAbility onDestroy`); 37 } 38 39 onSessionCreate(want: Want, session: UIExtensionContentSession) { 40 logger.info(`${TAG} UIExtAbility onSessionCreate.`); 41 let param: Record<string, UIExtensionContentSession> = { 42 'session': session 43 }; 44 let storage: LocalStorage = new LocalStorage(param); 45 session.loadContent('pages/MechControl', storage); 46 session.setWindowBackgroundColor('#00000000'); 47 logger.info(`${TAG} onSessionCreate end.`); 48 } 49 50 onSessionDestroy(session: UIExtensionContentSession) { 51 logger.info(`${TAG} UIExtAbility onSessionDestroy`); 52 } 53}