fix(core): 修复窗口管理和证书签名功能中的异常处理
- 在AppAbility中为getMainWindowSync添加try-catch异常处理 - 将CertServiceActivation中的回调函数转换为Promise链式调用 - 修改AuthorizeSignConfirmView中PIN窗口显示方式为Promise模式 - 在WindowHelper中为destroyWindow、UI上下文设置、避免区域计算添加异常捕获 - 修复全局上下文获取方式并处理可能的异常情况 - 为全屏状态和系统栏控制方法添加异常处理 - 在生物识别权限检查中添加try-catch保护 - 将签名管理器的PIN窗口方法从回调改为Promise返回值
这个提交包含在:
父节点
e684edb25a
当前提交
ee6ab8963a
@ -64,8 +64,12 @@ export class WindowHelper {
|
|||||||
*/
|
*/
|
||||||
static async close(): Promise<void> {
|
static async close(): Promise<void> {
|
||||||
if (WindowHelper.cacheWindow) {
|
if (WindowHelper.cacheWindow) {
|
||||||
await WindowHelper.cacheWindow.destroyWindow();
|
try {
|
||||||
WindowHelper.cacheWindow = null
|
await WindowHelper.cacheWindow.destroyWindow();
|
||||||
|
} catch (error) {
|
||||||
|
} finally {
|
||||||
|
WindowHelper.cacheWindow = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,16 +85,21 @@ export class WindowHelper {
|
|||||||
public static set windowClass(value: window.Window | undefined) {
|
public static set windowClass(value: window.Window | undefined) {
|
||||||
WindowHelper._windowClass = value;
|
WindowHelper._windowClass = value;
|
||||||
if (value) {
|
if (value) {
|
||||||
GlobalContext.setUiContext(value.getUIContext())
|
try {
|
||||||
}
|
const uc = value.getUIContext()
|
||||||
if (WindowHelper._windowClass) {
|
GlobalContext.setUiContext(uc)
|
||||||
let avoidArea = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
|
try {
|
||||||
WindowHelper._bottomRectHeight = px2vp(avoidArea.bottomRect.height)
|
let avoidArea = value.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
|
||||||
let avoidArea2 = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_CUTOUT);
|
WindowHelper._bottomRectHeight = uc.px2vp(avoidArea.bottomRect.height)
|
||||||
WindowHelper._topRectHeight = px2vp(avoidArea2.topRect.height)
|
let avoidArea2 = value.getWindowAvoidArea(window.AvoidAreaType.TYPE_CUTOUT);
|
||||||
let avoidArea3 = WindowHelper._windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
|
WindowHelper._topRectHeight = uc.px2vp(avoidArea2.topRect.height)
|
||||||
const a = px2vp(avoidArea3.topRect.height)
|
let avoidArea3 = value.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
|
||||||
WindowHelper._topRectHeight = a > WindowHelper._topRectHeight ? a : WindowHelper._topRectHeight
|
const a = uc.px2vp(avoidArea3.topRect.height)
|
||||||
|
WindowHelper._topRectHeight = a > WindowHelper._topRectHeight ? a : WindowHelper._topRectHeight
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,11 +128,19 @@ export class WindowHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static get windowsWidth() {
|
public static get windowsWidth() {
|
||||||
return px2vp(display.getDefaultDisplaySync().width)
|
try {
|
||||||
|
return GlobalContext.getUiContext()?.px2vp(display.getDefaultDisplaySync().width)??0
|
||||||
|
} catch (error) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static get windowsHeight() {
|
public static get windowsHeight() {
|
||||||
return px2vp(display.getDefaultDisplaySync().height)
|
try {
|
||||||
|
return GlobalContext.getUiContext()?.px2vp(display.getDefaultDisplaySync().height)??0
|
||||||
|
} catch (error) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +150,8 @@ export class WindowHelper {
|
|||||||
static setWindowLayoutFullScreen(isLayoutFullScreen: boolean) {
|
static setWindowLayoutFullScreen(isLayoutFullScreen: boolean) {
|
||||||
if (WindowHelper._windowClass) {
|
if (WindowHelper._windowClass) {
|
||||||
WindowHelper._isFullScreen = isLayoutFullScreen
|
WindowHelper._isFullScreen = isLayoutFullScreen
|
||||||
WindowHelper._windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
|
WindowHelper._windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).catch(() => {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +160,10 @@ export class WindowHelper {
|
|||||||
*/
|
*/
|
||||||
static hideStatusBar() {
|
static hideStatusBar() {
|
||||||
if (WindowHelper._windowClass) {
|
if (WindowHelper._windowClass) {
|
||||||
WindowHelper._windowClass.setSpecificSystemBarEnabled('status', false);
|
WindowHelper._windowClass.setSpecificSystemBarEnabled('status', false).catch(() => {
|
||||||
WindowHelper._windowClass.setSpecificSystemBarEnabled('navigationIndicator', false);
|
});
|
||||||
|
WindowHelper._windowClass.setSpecificSystemBarEnabled('navigationIndicator', false).catch(() => {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +172,10 @@ export class WindowHelper {
|
|||||||
*/
|
*/
|
||||||
static showStatusBar() {
|
static showStatusBar() {
|
||||||
if (WindowHelper._windowClass) {
|
if (WindowHelper._windowClass) {
|
||||||
WindowHelper._windowClass.setSpecificSystemBarEnabled('status', true);
|
WindowHelper._windowClass.setSpecificSystemBarEnabled('status', true).catch(() => {
|
||||||
WindowHelper._windowClass.setSpecificSystemBarEnabled('navigationIndicator', true);
|
});
|
||||||
|
WindowHelper._windowClass.setSpecificSystemBarEnabled('navigationIndicator', true).catch(() => {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +188,7 @@ export class WindowHelper {
|
|||||||
if (WindowHelper._windowClass) {
|
if (WindowHelper._windowClass) {
|
||||||
WindowHelper._windowClass.setWindowSystemBarProperties({
|
WindowHelper._windowClass.setWindowSystemBarProperties({
|
||||||
statusBarContentColor: color,
|
statusBarContentColor: color,
|
||||||
|
}).catch(() => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户