• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-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 type Want from '@ohos.app.ability.Want';
17import type UIAbilityContext from 'application/UIAbilityContext';
18import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
19
20export class PwdStore {
21  private certPwd: string = '';
22
23  setCertPwd(pwd: string): void {
24    this.certPwd = pwd;
25  }
26
27  getCertPwd(): string {
28    return this.certPwd;
29  }
30
31  clearCertPwd(): void {
32    this.certPwd = '';
33  }
34}
35
36export class GlobalContext {
37  private constructor() {
38  };
39
40  private static instance: GlobalContext;
41  private context: UIAbilityContext;
42  private want: Want;
43  private pwdStore: PwdStore;
44  private session: UIExtensionContentSession;
45  private flag: Boolean;
46
47  public static getContext(): GlobalContext {
48    if (!GlobalContext.instance) {
49      GlobalContext.instance = new GlobalContext();
50    }
51    return GlobalContext.instance;
52  }
53
54  getCmContext(): UIAbilityContext {
55    return this.context;
56  }
57
58  getPwdStore(): PwdStore {
59    return this.pwdStore;
60  }
61
62  getAbilityWant(): Want {
63    return this.want;
64  }
65
66  getSession(): UIExtensionContentSession {
67    return this.session;
68  }
69
70  getFlag(): Boolean {
71    return this.flag;
72  }
73
74  setCmContext(context: UIAbilityContext): void {
75    this.context = context;
76  }
77
78  setPwdStore(pwdStore: PwdStore): void {
79    this.pwdStore = pwdStore;
80  }
81
82  setAbilityWant(want: Want): void {
83    this.want = want;
84  }
85
86  setSession(session: UIExtensionContentSession): void {
87    this.session = session;
88  }
89
90  setFlag(flag: Boolean): void {
91    this.flag = flag;
92  }
93
94  clearAbilityWantUri(): void {
95    this.want.uri = '';
96  }
97
98  clearSession(): void {
99    this.session = undefined;
100  }
101
102  clearAbilityWantParamsUri(): void {
103    this.want.parameters.uri = '';
104  }
105}