提交 093f698e 编写于 作者: L liwuli

ArkTs整改

Signed-off-by: Nliwuli <liwuli@huawei.com>
上级 65ada243
...@@ -154,21 +154,18 @@ let wantTemp: Want = { ...@@ -154,21 +154,18 @@ let wantTemp: Want = {
let certFileArray: Uint8Array = new Uint8Array(); let certFileArray: Uint8Array = new Uint8Array();
// The variable context needs to be initialized in MainAbility's onCreate callback function // The variable context needs to be initialized in MainAbility's onCreate callback function
// test.cer needs to be placed in the rawfile directory // test.cer needs to be placed in the rawfile directory
await getContext().resourceManager.getRawFileContent("test.cer") getContext().resourceManager.getRawFileContent("test.cer").then((value) => {
.then((value) => { certFileArray = value;
certFileArray = value deviceSettings.installUserCertificate(wantTemp, { inData: certFileArray, alias: "cert_alias_xts" }, (err, result) => {
}) if (err) {
.catch((error: BusinessError) => { console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to get row file content. message: ${error.message}`); } else {
return console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`);
}
}); });
}).catch((error: BusinessError) => {
deviceSettings.installUserCertificate(wantTemp, { inData: certFileArray, alias: "cert_alias_xts" }, (err, result) => { console.error(`Failed to get row file content. message: ${error.message}`);
if (err) { return
console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`);
} else {
console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`);
}
}); });
``` ```
...@@ -219,21 +216,18 @@ let wantTemp: Want = { ...@@ -219,21 +216,18 @@ let wantTemp: Want = {
let certFileArray: Uint8Array = new Uint8Array(); let certFileArray: Uint8Array = new Uint8Array();
// The variable context needs to be initialized in MainAbility's onCreate callback function // The variable context needs to be initialized in MainAbility's onCreate callback function
// test.cer needs to be placed in the rawfile directory // test.cer needs to be placed in the rawfile directory
await getContext().resourceManager.getRawFileContent("test.cer") getContext().resourceManager.getRawFileContent("test.cer").then((value) => {
.then((value) => { certFileArray = value
certFileArray = value deviceSettings.installUserCertificate(wantTemp, { inData: certFileArray, alias: "cert_alias_xts" })
.then((result) => {
console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`);
}).catch((err: BusinessError) => {
console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`);
}) })
.catch((error: BusinessError) => { }).catch((error: BusinessError) => {
console.error(`Failed to get row file content. message: ${error.message}`); console.error(`Failed to get row file content. message: ${error.message}`);
return return
}); });
await deviceSettings.installUserCertificate(wantTemp, { inData: certFileArray, alias: "cert_alias_xts" })
.then((result) => {
console.info(`Succeeded in installing user certificate, result : ${JSON.stringify(result)}`);
}).catch((err: BusinessError) => {
console.error(`Failed to install user certificate. Code: ${err.code}, message: ${err.message}`);
})
``` ```
## CertBlob ## CertBlob
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册