From 77c0a22e9a31b30eb444309d8108853c302091b4 Mon Sep 17 00:00:00 2001 From: burke <16201857+burke2025@user.noreply.gitee.com> Date: Tue, 14 Oct 2025 14:20:41 +0800 Subject: [PATCH] fix: fix getStringSync deprecated --- .../main/ets/model/TrustedAuthentication.ets | 18 +++++----- entry/src/main/ets/pages/MainPage.ets | 28 +++++++-------- .../main/ets/pages/PasswordSelectionPage.ets | 8 ++--- entry/src/main/ets/pages/TradingPage.ets | 34 +++++++++---------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/entry/src/main/ets/model/TrustedAuthentication.ets b/entry/src/main/ets/model/TrustedAuthentication.ets index a86dfc6..123fd8e 100644 --- a/entry/src/main/ets/model/TrustedAuthentication.ets +++ b/entry/src/main/ets/model/TrustedAuthentication.ets @@ -255,7 +255,7 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.ShieldPwVerification')) + title: context.resourceManager.getStringSync($r('app.string.ShieldPwVerification').id) } const result = await trustedAuthentication.trustedAuthentication(challenge, credentialID, label); hilog.info(DOMAIN, 'testTag', 'DigitalShield password verification success:', result.authToken.length, @@ -279,7 +279,7 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.OpenShield')) + title: context.resourceManager.getStringSync($r('app.string.OpenShield').id) } const authInfo = await trustedAuthentication.enableTrustedAuthentication(challenge, passwordInfo, label); let assetLabel = assetName + 'label'; @@ -305,7 +305,7 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.OpenShield')) + title: context.resourceManager.getStringSync($r('app.string.OpenShield').id) } const authInfo = await trustedAuthentication.enableTrustedAuthentication(challenge, passwordInfo, label); let assetLabel = assetName + 'label'; @@ -333,7 +333,7 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.ModifyShield')) + title: context.resourceManager.getStringSync($r('app.string.ModifyShield').id) } const authInfo = await trustedAuthentication.modifyTrustedAuthenticationPwd(challenge, passwordInfo, credentialID, label); @@ -359,7 +359,7 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.ModifyShield')) + title: context.resourceManager.getStringSync($r('app.string.ModifyShield').id) } const authInfo = await trustedAuthentication.modifyTrustedAuthenticationPwd(challenge, passwordInfo, credentialID, label); @@ -379,7 +379,7 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.CloseShield')) + title: context.resourceManager.getStringSync($r('app.string.CloseShield').id) } const authInfo = await trustedAuthentication.disableTrustedAuthentication(challenge, true, credentialID, label); AssetUtils.DeleteDataFromAssetStore('pin_label1'); @@ -432,7 +432,7 @@ class TrustedAuth { } const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.FaceVerification')) + title: context.resourceManager.getStringSync($r('app.string.FaceVerification').id) } const result = await trustedAuthentication.procContentAuthentication(challenge, credentialID, reqParams, label); hilog.info(DOMAIN, 'testTag', 'Face Verification Success:', result.authToken); @@ -459,7 +459,7 @@ class TrustedAuth { } const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.FingerprintVerification')) + title: context.resourceManager.getStringSync($r('app.string.FingerprintVerification').id) } const result = await trustedAuthentication.procContentAuthentication(challenge, credentialID, reqParams, label); hilog.info(DOMAIN, 'testTag', 'Fingerprint Verification Success:', result.authToken); @@ -483,7 +483,7 @@ class TrustedAuth { } const label: trustedAuthentication.TUILable = { image: buffer, - title: context.resourceManager.getStringSync($r('app.string.PINVerification')) + title: context.resourceManager.getStringSync($r('app.string.PINVerification').id) } const result = await trustedAuthentication.procContentAuthentication(challenge, credentialID, reqParams, label); hilog.info(DOMAIN, 'testTag', 'Pin Verification Success:', result.authToken); diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets index c53e05a..aa055f7 100644 --- a/entry/src/main/ets/pages/MainPage.ets +++ b/entry/src/main/ets/pages/MainPage.ets @@ -183,13 +183,13 @@ export struct MainPage { hilog.info(DOMAIN, 'testTag', 'Finish Signature Initialization'); let indata: string = 'placeholder'; await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, TUI_PIN_DISABLE, 'pin_label1'); - this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldSuccess').id); this.hasShield = false; this.fingerprintBind = false; this.faceBind = false; } catch (error) { hilog.error(DOMAIN, 'testTag', 'Close Shield Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldFail').id) + `: ${error}`; } this.promptAction.openToast({ @@ -218,13 +218,13 @@ export struct MainPage { const challenge: Uint8Array = rand?.generateRandomSync(len)?.data; const authToken = await TrustedAuth.disablePwdWithoutAuth(challenge, 'pin_label1'); hilog.info(DOMAIN, 'testTag', 'Close Shield Success:', authToken); - this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldSuccess').id); this.hasShield = false; this.fingerprintBind = false; this.faceBind = false; } catch (error) { hilog.error(DOMAIN, 'testTag', 'Close Shield Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.CloseShieldFail').id) + `: ${error}`; } this.promptAction.openToast({ @@ -287,14 +287,14 @@ export struct MainPage { await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); let inputdata = 'placeholder'; await TrustedAuth.bindFingerID(session.handle, resignAuthToken.authToken, inputdata) - this.message += this.resourceManager.getStringSync($r('app.string.BindFingerprintSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.BindFingerprintSuccess').id); this.fingerprintBind = true; } catch (error) { hilog.error(DOMAIN, 'testTag', 'Bind Fingerprint Fail:', error); if (error.message === 'Authentication template has not been enrolled.') { - this.message += this.resourceManager.getStringSync($r('app.string.BindFingerprintFailWithNotification')); + this.message += this.resourceManager.getStringSync($r('app.string.BindFingerprintFailWithNotification').id); } else { - this.message += this.resourceManager.getStringSync($r('app.string.BindFingerprintFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.BindFingerprintFail').id) + `: ${error}`; } } @@ -320,12 +320,12 @@ export struct MainPage { try { let authType = trustedAuthentication.AuthType.AUTH_TYPE_FINGERPRINT; await TrustedAuth.disableTrustedBioAuthentication('pin_label1', authType); - this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFingerprintSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFingerprintSuccess').id); this.fingerprintBind = false; } catch (error) { // 捕获错误并处理 hilog.error(DOMAIN, 'testTag', 'UnBound Fingerprint Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFingerprintFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFingerprintFail').id) + `: ${error}`; } this.promptAction.openToast({ @@ -364,14 +364,14 @@ export struct MainPage { await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); let inputdata = 'placeholder'; await TrustedAuth.bindFaceID(session.handle, resignAuthToken.authToken, inputdata) - this.message += this.resourceManager.getStringSync($r('app.string.BindFaceSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.BindFaceSuccess').id); this.faceBind = true; } catch (error) { hilog.error(DOMAIN, 'testTag', 'Bind Face Fail:', error); if (error.message === 'Authentication template has not been enrolled.') { - this.message += this.resourceManager.getStringSync($r('app.string.BindFaceFailWithNotification')) + this.message += this.resourceManager.getStringSync($r('app.string.BindFaceFailWithNotification').id) } else { - this.message += this.resourceManager.getStringSync($r('app.string.BindFaceFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.BindFaceFail').id) + ` : ${error}`; } } @@ -396,12 +396,12 @@ export struct MainPage { try { let authType = trustedAuthentication.AuthType.AUTH_TYPE_FACE; await TrustedAuth.disableTrustedBioAuthentication('pin_label1', authType); - this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFaceSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFaceSuccess').id); this.faceBind = false; } catch (error) { // 捕获错误并处理 hilog.error(DOMAIN, 'testTag', 'UnBound Face Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFaceFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.UnBoundFaceFail').id) + `: ${error}`; } this.promptAction.openToast({ diff --git a/entry/src/main/ets/pages/PasswordSelectionPage.ets b/entry/src/main/ets/pages/PasswordSelectionPage.ets index 21b9fcd..0d5b4c2 100644 --- a/entry/src/main/ets/pages/PasswordSelectionPage.ets +++ b/entry/src/main/ets/pages/PasswordSelectionPage.ets @@ -102,12 +102,12 @@ export struct PasswordSelectionPage { hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); let indata: string = 'placeholder'; await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, this.type, 'pin_label1'); - this.message += this.resourceManager.getStringSync($r('app.string.ModifyPwSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.ModifyPwSuccess').id); this.hasShield = true; } catch (error) { // catch error hilog.error(DOMAIN, 'testTag', 'Modify Pw Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.ModifyPwFail')) + `: ${error}`; + this.message += this.resourceManager.getStringSync($r('app.string.ModifyPwFail').id) + `: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -132,12 +132,12 @@ export struct PasswordSelectionPage { hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); let indata: string = 'placeholder'; await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, this.type, 'pin_label1'); - this.message += this.resourceManager.getStringSync($r('app.string.OpenShieldSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.OpenShieldSuccess').id); this.hasShield = true; } catch (error) { // catch error hilog.error(DOMAIN, 'testTag', 'OpenShield Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.OpenShieldFail')) + `: ${error}`; + this.message += this.resourceManager.getStringSync($r('app.string.OpenShieldFail').id) + `: ${error}`; } this.promptAction.openToast({ message: this.message, diff --git a/entry/src/main/ets/pages/TradingPage.ets b/entry/src/main/ets/pages/TradingPage.ets index 7e1c3b9..4b21a2e 100644 --- a/entry/src/main/ets/pages/TradingPage.ets +++ b/entry/src/main/ets/pages/TradingPage.ets @@ -57,14 +57,14 @@ export struct BindSheetTemp { let session = await TrustedAuth.SignInit(); hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); let indata: string = - this.resourceManager.getStringSync($r('app.string.Recipient')) + ':' + this.receiver + '\n' + - this.resourceManager.getStringSync($r('app.string.AccountNumber')) + ':' + this.receiveAccount + '\n' + - this.resourceManager.getStringSync($r('app.string.TradingAmount')) + ':' + this.tradingAmount; + this.resourceManager.getStringSync($r('app.string.Recipient').id) + ':' + this.receiver + '\n' + + this.resourceManager.getStringSync($r('app.string.AccountNumber').id) + ':' + this.receiveAccount + '\n' + + this.resourceManager.getStringSync($r('app.string.TradingAmount').id) + ':' + this.tradingAmount; await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, TUI_CONTENT_PWD_VERIFY, 'pin_label1'); - this.message += this.resourceManager.getStringSync($r('app.string.PINVerificationSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.PINVerificationSuccess').id); } catch (error) { hilog.error(DOMAIN, 'testTag', 'PIN Verification Fail:', error); - this.message += this.resourceManager.getStringSync($r('app.string.PINVerificationFail')) + `: ${error}`; + this.message += this.resourceManager.getStringSync($r('app.string.PINVerificationFail').id) + `: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -83,9 +83,9 @@ export struct BindSheetTemp { let session = await TrustedAuth.SignInit(); hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); let indata: string = - this.resourceManager.getStringSync($r('app.string.Recipient')) + ':' + this.receiver + '\n' + - this.resourceManager.getStringSync($r('app.string.AccountNumber')) + ':' + this.receiveAccount + '\n' + - this.resourceManager.getStringSync($r('app.string.TradingAmount')) + ':' + this.tradingAmount; + this.resourceManager.getStringSync($r('app.string.Recipient').id) + ':' + this.receiver + '\n' + + this.resourceManager.getStringSync($r('app.string.AccountNumber').id) + ':' + this.receiveAccount + '\n' + + this.resourceManager.getStringSync($r('app.string.TradingAmount').id) + ':' + this.tradingAmount; const tuiAuthToken: Uint8Array = await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(indata, session, TUI_CONTENT_FINGERPRINT_VERIFY, 'pin_label1'); let bioAuthToken: Uint8Array = @@ -94,13 +94,13 @@ export struct BindSheetTemp { let resignAuthToken = await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); await TrustedAuth.HuksSignAndVerify(indata, session, resignAuthToken.authToken) - this.message += this.resourceManager.getStringSync($r('app.string.FingerprintVerificationSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.FingerprintVerificationSuccess').id); } catch (error) { hilog.error(DOMAIN, 'testTag', 'Fingerprint Verification Fail:', error); if (error.code === 1019100019) { - this.message += this.resourceManager.getStringSync($r('app.string.FingerprintVerificationFailWithNotification')); + this.message += this.resourceManager.getStringSync($r('app.string.FingerprintVerificationFailWithNotification').id); } else { - this.message += this.resourceManager.getStringSync($r('app.string.FingerprintVerificationFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.FingerprintVerificationFail').id) + `: ${error}`; } } @@ -122,9 +122,9 @@ export struct BindSheetTemp { let session = await TrustedAuth.SignInit(); hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); let indata: string = - this.resourceManager.getStringSync($r('app.string.Recipient')) + ':' + this.receiver + '\n' + - this.resourceManager.getStringSync($r('app.string.AccountNumber')) + ':' + this.receiveAccount + '\n' + - this.resourceManager.getStringSync($r('app.string.TradingAmount')) + ':' + this.tradingAmount; + this.resourceManager.getStringSync($r('app.string.Recipient').id) + ':' + this.receiver + '\n' + + this.resourceManager.getStringSync($r('app.string.AccountNumber').id) + ':' + this.receiveAccount + '\n' + + this.resourceManager.getStringSync($r('app.string.TradingAmount').id) + ':' + this.tradingAmount; const tuiAuthToken: Uint8Array = await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(indata, session, TUI_CONTENT_FACE_VERIFY, 'pin_label1'); let bioAuthToken: Uint8Array = @@ -133,13 +133,13 @@ export struct BindSheetTemp { let resignAuthToken = await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); await TrustedAuth.HuksSignAndVerify(indata, session, resignAuthToken.authToken) - this.message += this.resourceManager.getStringSync($r('app.string.FaceVerificationSuccess')); + this.message += this.resourceManager.getStringSync($r('app.string.FaceVerificationSuccess').id); } catch (error) { hilog.error(DOMAIN, 'testTag', 'Face Verification Fail:', error); if (error.code === 1019100019) { - this.message += this.resourceManager.getStringSync($r('app.string.FaceVerificationFailWithNotification')); + this.message += this.resourceManager.getStringSync($r('app.string.FaceVerificationFailWithNotification').id); } else { - this.message += this.resourceManager.getStringSync($r('app.string.FaceVerificationFail')) + + this.message += this.resourceManager.getStringSync($r('app.string.FaceVerificationFail').id) + `: ${error}`; } } -- Gitee