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 */ 15import { commonEventManager } from '@kit.BasicServicesKit'; 16import { hilog } from '@kit.PerformanceAnalysisKit'; 17 18let storage = LocalStorage.getShared() 19const LOG_TAG: string = 'Second' 20 21@Entry(storage) 22@Component 23struct Extension { 24 @State message: string = 'EmbeddedUIExtensionAbility Index'; 25 private want: Want = { 26 bundleName: 'com.example.act_embeddeduiextension', 27 abilityName: 'EmbeddedUIExtAbility', 28 parameters: {} 29 } 30 31 build() { 32 Column() { 33 Text(this.message) 34 .fontSize(20) 35 .fontWeight(FontWeight.Bold) 36 EmbeddedComponent(this.want, EmbeddedType.EMBEDDED_UI_EXTENSION) 37 .width('100%') 38 .height('90%') 39 .onError((error) => { 40 let commonEventPublishData: commonEventManager.CommonEventPublishData = { 41 parameters: { 42 data: error.code 43 } 44 } 45 commonEventManager.publish('EmbeddedUIExtension_Pull', commonEventPublishData, async (error) => { 46 hilog.info(0x0000, 'testTag1', '%{public}s', `pulling_up_fail: ${JSON.stringify(error)}`); 47 }) 48 hilog.info(0x0000, LOG_TAG, 'embeddedUIExt onError: %{public}s', JSON.stringify(error)); 49 }) 50 .onTerminated((info) => { 51 hilog.info(0x0000, LOG_TAG, 'embeddedUIExt onTerminated: %{public}s', JSON.stringify(info)); 52 }) 53 }.width('100%').height('100%') 54 } 55}