mirror of
https://gitee.com/openharmony/security_privacy_center
synced 2024-11-26 17:31:16 +00:00
证书管理session冲突修复
Signed-off-by: 杨海龙2023 <yanghailong26@huawei.com>
This commit is contained in:
parent
68901e3ce0
commit
3a42813f6f
@ -40,7 +40,6 @@ export default class CertPickerUiExtAbility extends UIExtensionAbility {
|
||||
}
|
||||
let storage: LocalStorage = new LocalStorage(param);
|
||||
session.loadContent('pages/picker/CertManagerSheetFa', storage);
|
||||
GlobalContext.getContext().setSession(session, true);
|
||||
let pwdStore = new PwdStore();
|
||||
GlobalContext.getContext().setPwdStore(pwdStore);
|
||||
try {
|
||||
|
@ -47,7 +47,7 @@ export default class MainExtensionAbility extends UIExtensionAbility {
|
||||
session.loadContent('pages/certManagerFa', storage);
|
||||
}
|
||||
GlobalContext.getContext().setAbilityWant(want);
|
||||
GlobalContext.getContext().setSession(session, false);
|
||||
GlobalContext.getContext().setSession(session);
|
||||
let pwdStore = new PwdStore();
|
||||
GlobalContext.getContext().setPwdStore(pwdStore);
|
||||
GlobalContext.getContext().setFlag(true);
|
||||
|
@ -44,8 +44,6 @@ export class GlobalContext {
|
||||
private session: UIExtensionContentSession;
|
||||
private flag: Boolean;
|
||||
|
||||
private sheetSession: UIExtensionContentSession;
|
||||
|
||||
public static getContext(): GlobalContext {
|
||||
if (!GlobalContext.instance) {
|
||||
GlobalContext.instance = new GlobalContext();
|
||||
@ -65,12 +63,8 @@ export class GlobalContext {
|
||||
return this.want;
|
||||
}
|
||||
|
||||
getSession(isSheetPage: boolean): UIExtensionContentSession {
|
||||
if (isSheetPage) {
|
||||
return this.sheetSession;
|
||||
} else {
|
||||
return this.session;
|
||||
}
|
||||
getSession(): UIExtensionContentSession {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
getFlag(): Boolean {
|
||||
@ -89,12 +83,8 @@ export class GlobalContext {
|
||||
this.want = want;
|
||||
}
|
||||
|
||||
setSession(session: UIExtensionContentSession, isSheetPage: boolean): void {
|
||||
if (isSheetPage) {
|
||||
this.sheetSession = session;
|
||||
} else {
|
||||
this.session = session;
|
||||
}
|
||||
setSession(session: UIExtensionContentSession): void {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
setFlag(flag: Boolean): void {
|
||||
|
@ -50,7 +50,7 @@ export default struct HeadComponent {
|
||||
let length = Router.getLength();
|
||||
console.info(TAG + 'router length: ' + Number(length));
|
||||
if (GlobalContext.getContext().getFlag()) {
|
||||
Number(length) == 1 ? GlobalContext.getContext().getSession(this.isStartBySheet).sendData({'action': 'exit'}) : Router.back();
|
||||
Number(length) == 1 ? GlobalContext.getContext().getSession().sendData({'action': 'exit'}) : Router.back();
|
||||
} else {
|
||||
Number(length) == 1 ? GlobalContext.getContext().getCmContext().terminateSelf() : Router.back();
|
||||
}
|
||||
|
@ -31,9 +31,8 @@ export default class PreventScreenshotsModel {
|
||||
return PreventScreenshotsModel.sInstance;
|
||||
}
|
||||
|
||||
PreventScreenshots(flag: boolean, isSheetPage: boolean) {
|
||||
PreventScreenshots(flag: boolean, session: UIExtensionContentSession | undefined) {
|
||||
let isPrivacyMode: boolean = flag;
|
||||
let session: UIExtensionContentSession = GlobalContext.getContext().getSession(isSheetPage);
|
||||
if (session !== undefined) {
|
||||
session.setWindowPrivacyMode(isPrivacyMode);
|
||||
return;
|
||||
|
@ -35,7 +35,7 @@ struct CertPwdInput {
|
||||
@State mPreventScreenshotsPresenter: PreventScreenshotsPresenter = PreventScreenshotsPresenter.getInstance();
|
||||
|
||||
onPageShow() {
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(true, false);
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(true, GlobalContext.getContext().getSession());
|
||||
let uri = GlobalContext.getContext().getAbilityWant().uri;
|
||||
GlobalContext.getContext().clearAbilityWantUri();
|
||||
|
||||
@ -51,7 +51,7 @@ struct CertPwdInput {
|
||||
}
|
||||
|
||||
onPageHide() {
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(false, false);
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(false, GlobalContext.getContext().getSession());
|
||||
}
|
||||
|
||||
build() {
|
||||
|
@ -82,7 +82,9 @@ export struct CertManagerSheetFa {
|
||||
} else if (name === NavEntryKey.AUTHORIZED_APP_ENTRY) {
|
||||
AuthorizedAppManagementPage()
|
||||
} else if (name === NavEntryKey.CRED_PWD_INPUT_ENTRY) {
|
||||
CredPwdInputPage()
|
||||
CredPwdInputPage({
|
||||
sheetSession: this.session
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import { GlobalContext } from '../../common/GlobalContext';
|
||||
import CmInstallPresenter from '../../presenter/CmInstallPresenter';
|
||||
|
||||
import PreventScreenshotsPresenter from '../../model/PreventScreenshotsModel';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
|
||||
const TAG: string = 'CredPwdInputPage: ';
|
||||
|
||||
@ -47,12 +48,14 @@ export struct CredPwdInputPage {
|
||||
|
||||
@State mPreventScreenshotsPresenter: PreventScreenshotsPresenter = PreventScreenshotsPresenter.getInstance();
|
||||
|
||||
private sheetSession?: UIExtensionContentSession;
|
||||
|
||||
onPageShow(): void {
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(true, true);
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(true, this.sheetSession);
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(false, true);
|
||||
this.mPreventScreenshotsPresenter.PreventScreenshots(false, this.sheetSession);
|
||||
}
|
||||
|
||||
build() {
|
||||
|
Loading…
Reference in New Issue
Block a user