diff --git a/entry/src/main/ets/ViewAbility/ViewAbility.ts b/entry/src/main/ets/ViewAbility/ViewAbility.ts index 5341dfd..9371e7c 100644 --- a/entry/src/main/ets/ViewAbility/ViewAbility.ts +++ b/entry/src/main/ets/ViewAbility/ViewAbility.ts @@ -146,6 +146,11 @@ export default class ViewAbility extends ServiceExtensionAbility { return } hiTraceMeter.finishTrace("DlpGetOsAccountJs", startId); + if (accountInfo.distributedInfo.name == "ohosAnonymousName" && accountInfo.distributedInfo.id == "ohosAnonymousUid") { + startAlertAbility(Constants.APP_ERROR, Constants.APP_NO_ACCOUNT_ERROR) + hiTraceMeter.finishTrace("DlpOpenFileJs", startId); + return + } hiTraceMeter.startTrace("DlpOpenDlpFileJs", startId); try { this.dlpFile = await dlpPermission.openDlpFile(srcFd) diff --git a/entry/src/main/ets/common/constant.ets b/entry/src/main/ets/common/constant.ets index 2625eee..db4533c 100644 --- a/entry/src/main/ets/common/constant.ets +++ b/entry/src/main/ets/common/constant.ets @@ -154,6 +154,7 @@ export default class Constants { static RECOVER_DLP_ERROR = '删除文档权限失败,请重试。'; static APP_INSIDE_ERROR = '应用内部错误,请重试。'; static APP_GET_ACCOUNT_ERROR = '获取帐号信息失败,请重试。'; + static APP_NO_ACCOUNT_ERROR = '帐号未登录,请登录账号后重试。'; static APP_OPEN_DLP_ERROR= '打开加密文件失败,请重试。'; static APP_PERMISSION_ERROR= '权限拒绝,请重试。'; static APP_VISIT_FILE_ERROR= '无法访问此文件'; diff --git a/entry/src/main/ets/pages/index.ets b/entry/src/main/ets/pages/index.ets index 068fe63..aa7b6b2 100644 --- a/entry/src/main/ets/pages/index.ets +++ b/entry/src/main/ets/pages/index.ets @@ -79,6 +79,10 @@ struct DlpDialog { console.info(TAG + "aboutToAppear") try { globalThis.accountInfo = await getOsAccountInfo() + if (globalThis.accountInfo.distributedInfo.name == "ohosAnonymousName" && globalThis.accountInfo.distributedInfo.id == "ohosAnonymousUid") { + this.showDlpAlertDialog(Constants.APP_ERROR, Constants.APP_NO_ACCOUNT_ERROR) + return + } } catch (err) { console.info(TAG + "getOsAccountInfo error: " + JSON.stringify(err)) terminateSelfWithResult(100, "get account info failed")