• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
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 Want from '@ohos.app.ability.Want';
21import GlobalContext from '../common/GlobalContext';
22
23const TAG = 'PhoneDialogUIExtAbility';
24
25export default class PhoneDialogUIExtAbility extends UIExtensionAbility {
26  async onSessionCreate(want: Want, session: UIExtensionContentSession): Promise<void> {
27    HiLog.info(TAG, 'PhoneDialogUIExtAbility onSessionCreate start');
28    AppStorage.setOrCreate('PhoneDialogUIExtWant', want);
29    AppStorage.setOrCreate('PhoneDialogUIExtSession', session);
30    try {
31      session.loadContent('pages/PhoneDialog');
32      session.setWindowBackgroundColor(Constants.TRANSPARENT_BACKGROUND_COLOR);
33    } catch (error) {
34      HiLog.wrapError(TAG, error, 'loadContent failed');
35    }
36  }
37
38  onSessionDestroy(session: UIExtensionContentSession): void {
39    AppStorage.delete('PhoneDialogUIExtWant');
40    AppStorage.delete('PhoneDialogUIExtSession');
41    HiLog.info(TAG, 'PhoneDialogUIExtAbility onSessionDestroy');
42  }
43
44  onWindowStageDestroy(): void {
45    HiLog.info(TAG, 'PhoneDialogUIExtAbility onWindowStageDestroy');
46  }
47
48  onForeground(): void {
49    HiLog.info(TAG, 'PhoneDialogUIExtAbility onForeground');
50  }
51
52  onBackground() {
53    HiLog.info(TAG, 'PhoneDialogUIExtAbility onBackground');
54  }
55};
56