From 594212b7f1cc58721c8aa639d83a3b84c3c84f44 Mon Sep 17 00:00:00 2001 From: bishuixiu Date: Tue, 19 Nov 2024 14:51:35 +0800 Subject: [PATCH] Signed-off-by: bishuixiu Remove redundant code. Signed-off-by: bishuixiu --- .../src/main/ets/ViewAbility/ViewAbility.ets | 24 +++++++++---------- entry/src/main/ets/common/GetAlertMessage.ets | 13 ---------- entry/src/main/ets/common/constant.ets | 1 - entry/src/main/ets/common/utils.ets | 4 ++-- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/entry/src/main/ets/ViewAbility/ViewAbility.ets b/entry/src/main/ets/ViewAbility/ViewAbility.ets index 1b60c22..902d426 100644 --- a/entry/src/main/ets/ViewAbility/ViewAbility.ets +++ b/entry/src/main/ets/ViewAbility/ViewAbility.ets @@ -116,8 +116,8 @@ export default class ViewAbility extends ServiceExtensionAbility { async terminateCall(): Promise { return new Promise((resolve, reject) => { - let sandbox2linkFile: Map = - GlobalContext.load('sandbox2linkFile') as Map; + let sandbox2linkFile: Map = + GlobalContext.load('sandbox2linkFile') as Map; HiLog.debug(TAG, `sandbox2linkFile size: ${sandbox2linkFile.size}`); if (sandbox2linkFile.size === 0) { try { @@ -183,7 +183,7 @@ export default class ViewAbility extends ServiceExtensionAbility { this.uri, [this.sandboxBundleName, this.appIndex, this.linkFileName, this.linkUri, this.distributedInfoId] ); (GlobalContext.load('token2File') as Map).set(this.tokenId, + dlpPermission.DLPFileAccess | null)[]>).set(this.tokenId, [this.dlpFile, this.sandboxBundleName, this.appIndex, this.authPerm, this.uri, null, -1]); (GlobalContext.load('linkSet') as Set).add(this.linkUri); } @@ -221,7 +221,7 @@ export default class ViewAbility extends ServiceExtensionAbility { want.moduleName = this.sandboxModuleName; want.uri = this.linkUri; want.flags = this.linkFileWriteable ? - wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION : wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION; + wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION : wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION; let dlpWant: Want = { parameters: { 'linkFileName': { @@ -245,7 +245,7 @@ export default class ViewAbility extends ServiceExtensionAbility { 'ohos.dlp.params.index': this.appIndex, 'ohos.dlp.params.moduleName': this.sandboxModuleName, 'ohos.dlp.params.securityFlag': this.authPerm === - dlpPermission.DLPFileAccess.READ_ONLY ? true : false + dlpPermission.DLPFileAccess.READ_ONLY ? true : false } }; ObjectUtil.Assign(want.parameters, dlpWant.parameters); @@ -556,7 +556,7 @@ export default class ViewAbility extends ServiceExtensionAbility { this.linkFileName = String(this.sandboxBundleName).substring(0, Constants.BUNDLE_LEN) + '_' + this.appIndex + '_' + timestamp + String(Math.random()).substring(Constants.RAND_START, Constants.RAND_END) + '.dlp.link.' + secondarySuffix; - resolve(secondarySuffix); + resolve(secondarySuffix); }); } @@ -731,16 +731,16 @@ export default class ViewAbility extends ServiceExtensionAbility { return false; } } - defalut: { - break; - } + defalut: { + break; + } } return true; } grandUriPermission() { let flag = wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION | - wantConstant.Flags.FLAG_AUTH_PERSISTABLE_URI_PERMISSION; + wantConstant.Flags.FLAG_AUTH_PERSISTABLE_URI_PERMISSION; let targetBundleName = this.sandboxBundleName; uriPermissionManager.grantUriPermission(this.uri, flag, targetBundleName, (result) => { HiLog.info(TAG, `grandUriPermission result: ${JSON.stringify(result)}`); @@ -759,7 +759,7 @@ export default class ViewAbility extends ServiceExtensionAbility { let callerAppId = want.parameters?.['ohos.aafwk.param.callerAppIdentifier'] as string; if (callerAppId !== APPID_FOR_HOPE || paramCallerBundleName !== BUNDLE_NAME_FOR_HOPE) { HiLog.error(TAG, `callerAppId or callerBundleNameis error.`); - await this.callAlertAbility({code: Constants.ERR_JS_NOT_AUTHORIZED_APPLICATION } as BusinessError); + await this.callAlertAbility({code: Constants.ERR_JS_NOT_AUTHORIZED_APPLICATION} as BusinessError); return false; } @@ -798,7 +798,7 @@ export default class ViewAbility extends ServiceExtensionAbility { } } let fileOpenHistory: Map = - GlobalContext.load('fileOpenHistory') as Map; + GlobalContext.load('fileOpenHistory') as Map; if (fileOpenHistory.has(this.uri)) { let value: (number | string)[] = fileOpenHistory.get(this.uri) as (number | string)[]; if (this.sandboxBundleName !== value[Constants.FILE_OPEN_HISTORY_ZERO] as string) { diff --git a/entry/src/main/ets/common/GetAlertMessage.ets b/entry/src/main/ets/common/GetAlertMessage.ets index d9f34a4..432301b 100644 --- a/entry/src/main/ets/common/GetAlertMessage.ets +++ b/entry/src/main/ets/common/GetAlertMessage.ets @@ -14,19 +14,12 @@ */ import { BusinessError } from '@ohos.base'; -import display from '@ohos.display' -import StartOptions from '@ohos.app.ability.StartOptions'; import common from '@ohos.app.ability.common'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import osAccount from '@ohos.account.osAccount'; -import account_osAccount from '@ohos.account.osAccount'; import Constants from './constant'; import GlobalContext from './GlobalContext'; import deviceInfo from '@ohos.deviceInfo'; import promptAction from '@ohos.promptAction'; import { HiLog } from '../common/HiLog'; -import AccountManager from '../manager/AccountManager'; -import CommonUtil from './CommonUtil'; const TAG = 'AlertMessage'; @@ -181,12 +174,6 @@ export class GetAlertMessage { } } - public static async checkAccountInfo(accountName: string): Promise { - - let domainAccount = await AccountManager.getDomainAccountByAccountName(accountName); - return !CommonUtil.isEmptyStr(domainAccount.accountName); - } - public static async requestModalUIExtension(context: common.UIAbilityContext | common.ServiceExtensionContext, error: BusinessError) { if (deviceInfo.deviceType !== '2in1') { diff --git a/entry/src/main/ets/common/constant.ets b/entry/src/main/ets/common/constant.ets index ca11074..24549ef 100644 --- a/entry/src/main/ets/common/constant.ets +++ b/entry/src/main/ets/common/constant.ets @@ -14,7 +14,6 @@ */ export default class Constants { - public static FOOTER_ROW_WIDTH = '100%'; public static FOOTER_ROW_MARGIN = 8; public static FOOTER_ROW_PAD_LEFT = 16; diff --git a/entry/src/main/ets/common/utils.ets b/entry/src/main/ets/common/utils.ets index a31bab5..46d0032 100644 --- a/entry/src/main/ets/common/utils.ets +++ b/entry/src/main/ets/common/utils.ets @@ -553,12 +553,12 @@ async function sleep(milliSeconds: number): Promise { } async function getConnectionStatus(exactly: boolean = true): Promise { - HiLog.info(TAG, `Enter getConnectionStatus, exactly mode: ${exactly}}.`); + HiLog.info(TAG, `Enter getConnectionStatus, exactly mode: ${exactly}.`); try { const startTime = getCurrentTime(); let net: connection.NetHandle = await connection.getDefaultNet(); - let capabilities: connection.NetCapabilities = await connection.getNetCapabilities(net); + let capabilities: connection.NetCapabilities = await connection.getNetCapabilities(net); HiLog.info(TAG, `Succeeded to get net capabilities, ${JSON.stringify(capabilities)}.`); let networkCap = capabilities.networkCap;