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 Want from '@ohos.app.ability.Want'; 17import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; 18import { GlobalContext, PwdStore } from '../common/GlobalContext'; 19import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; 20 21export default class CertPickerUiExtAbility extends UIExtensionAbility { 22 onCreate(): void { 23 console.info('[CertManager] CertPickerUiExtAbility onCreate'); 24 } 25 26 onDestroy(): void { 27 console.info('[CertManager] CertPickerUiExtAbility onDestroy'); 28 } 29 30 onSessionCreate(want: Want, session: UIExtensionContentSession): void { 31 console.info('[CertManager] CertPickerUiExtAbility onSessionCreate'); 32 33 if (want === null || want === undefined) { 34 console.error('[CertManager] invalid want param'); 35 return; 36 } 37 let param: Record<string, Object> = { 38 'session': session, 39 'want': want 40 } 41 let storage: LocalStorage = new LocalStorage(param); 42 session.loadContent('pages/picker/CertManagerSheetFa', storage); 43 let pwdStore = new PwdStore(); 44 GlobalContext.getContext().setPwdStore(pwdStore); 45 try { 46 session.setWindowBackgroundColor('#00000000'); 47 } catch (err) { 48 console.error('[CertManager] CertPickerUiExtAbility setWindowBackgroundColor'); 49 } 50 } 51 52 onSessionDestroy(): void { 53 // Main window is destroyed, release UI related resources 54 GlobalContext.getContext().clearSession(); 55 console.info('[CertManager] CertPickerUiExtAbility onSessionDestroy'); 56 } 57 58 onForeground(): void { 59 // Ability has brought to foreground 60 console.info('[CertManager] CertPickerUiExtAbility onForeground'); 61 } 62 63 onBackground(): void { 64 // Ability has back to background 65 console.info('[CertManager] CertPickerUiExtAbility onBackground'); 66 } 67} 68