未验证 提交 f61f256e 编写于 作者: O openharmony_ci 提交者: Gitee

!22670 Rectify the arkts syntax

Merge pull request !22670 from 189******51/master
...@@ -59,13 +59,16 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAb ...@@ -59,13 +59,16 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAb
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
{ {
deviceId: '1', deviceId: '1',
bundleName: 'com.example.application', bundleName: 'com.example.application',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
}, (err, data) => { }, (err: BusinessError, data: distributedBundle.RemoteAbilityInfo) => {
if (err) { if (err) {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
} else { } else {
...@@ -115,15 +118,18 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>; ...@@ -115,15 +118,18 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>;
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
{ {
deviceId: '1', deviceId: '1',
bundleName: 'com.example.application', bundleName: 'com.example.application',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
}).then(data => { }).then((data: distributedBundle.RemoteAbilityInfo) => {
console.info('Operation succeed:' + JSON.stringify(data)); console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
...@@ -164,6 +170,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\ ...@@ -164,6 +170,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
[ [
...@@ -177,7 +186,7 @@ try { ...@@ -177,7 +186,7 @@ try {
bundleName: 'com.example.application2', bundleName: 'com.example.application2',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
} }
], (err, data) => { ], (err: BusinessError, data: distributedBundle.RemoteAbilityInfo[]) => {
if (err) { if (err) {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
} else { } else {
...@@ -227,6 +236,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA ...@@ -227,6 +236,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
[ [
...@@ -240,9 +252,9 @@ try { ...@@ -240,9 +252,9 @@ try {
bundleName: 'com.example.application2', bundleName: 'com.example.application2',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
} }
]).then(data => { ]).then((data: distributedBundle.RemoteAbilityInfo[]) => {
console.info('Operation succeed:' + JSON.stringify(data)); console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
...@@ -284,13 +296,16 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa ...@@ -284,13 +296,16 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
{ {
deviceId: '1', deviceId: '1',
bundleName: 'com.example.application', bundleName: 'com.example.application',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
}, 'zh-Hans-CN', (err, data) => { }, 'zh-Hans-CN', (err: BusinessError, data: distributedBundle.RemoteAbilityInfo) => {
if (err) { if (err) {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
} else { } else {
...@@ -341,15 +356,18 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA ...@@ -341,15 +356,18 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
{ {
deviceId: '1', deviceId: '1',
bundleName: 'com.example.application', bundleName: 'com.example.application',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
}, 'zh-Hans-CN').then(data => { }, 'zh-Hans-CN').then((data: distributedBundle.RemoteAbilityInfo) => {
console.info('Operation succeed:' + JSON.stringify(data)); console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
...@@ -391,6 +409,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback ...@@ -391,6 +409,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
[ [
...@@ -404,7 +425,7 @@ try { ...@@ -404,7 +425,7 @@ try {
bundleName: 'com.example.application2', bundleName: 'com.example.application2',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
} }
], 'zh-Hans-CN', (err, data) => { ], 'zh-Hans-CN', (err: BusinessError, data: distributedBundle.RemoteAbilityInfo[]) => {
if (err) { if (err) {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
} else { } else {
...@@ -455,6 +476,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise ...@@ -455,6 +476,9 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise
**示例:** **示例:**
```ts ```ts
import distributedBundle from '@ohos.bundle.distributedBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
distributedBundle.getRemoteAbilityInfo( distributedBundle.getRemoteAbilityInfo(
[ [
...@@ -468,9 +492,9 @@ try { ...@@ -468,9 +492,9 @@ try {
bundleName: 'com.example.application2', bundleName: 'com.example.application2',
abilityName: 'EntryAbility' abilityName: 'EntryAbility'
} }
], 'zh-Hans-CN').then(data => { ], 'zh-Hans-CN').then((data: distributedBundle.RemoteAbilityInfo[]) => {
console.info('Operation succeed:' + JSON.stringify(data)); console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => { }).catch((err: BusinessError) => {
console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`); console.log(`Operation failed: error code is ${err.code} and error message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
......
...@@ -46,9 +46,10 @@ getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void; ...@@ -46,9 +46,10 @@ getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void;
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
try { try {
installer.getBundleInstaller((err, data) => { installer.getBundleInstaller((err: BusinessError, data: installer.BundleInstaller) => {
if (err) { if (err) {
console.error('getBundleInstaller failed:' + err.message); console.error('getBundleInstaller failed:' + err.message);
} else { } else {
...@@ -79,11 +80,12 @@ getBundleInstaller(): Promise\<BundleInstaller>; ...@@ -79,11 +80,12 @@ getBundleInstaller(): Promise\<BundleInstaller>;
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
try { try {
installer.getBundleInstaller().then((data) => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
console.info('getBundleInstaller successfully.'); console.info('getBundleInstaller successfully.');
}).catch((error) => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -176,23 +178,25 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback: ...@@ -176,23 +178,25 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1, installFlag: 1,
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.install(hapFilePaths, installParam, err => { data.install(hapFilePaths, installParam, (err: BusinessError) => {
if (err) { if (err) {
console.error('install failed:' + err.message); console.error('install failed:' + err.message);
} else { } else {
console.info('install successfully.'); console.info('install successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -254,18 +258,20 @@ install(hapFilePaths: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): ...@@ -254,18 +258,20 @@ install(hapFilePaths: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;):
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.install(hapFilePaths, err => { data.install(hapFilePaths, (err: BusinessError) => {
if (err) { if (err) {
console.error('install failed:' + err.message); console.error('install failed:' + err.message);
} else { } else {
console.info('install successfully.'); console.info('install successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -336,22 +342,24 @@ install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<v ...@@ -336,22 +342,24 @@ install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<v
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1, installFlag: 1,
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.install(hapFilePaths, installParam) data.install(hapFilePaths, installParam)
.then((data) => { .then((data: void) => {
console.info('install successfully: ' + JSON.stringify(data)); console.info('install successfully: ' + JSON.stringify(data));
}).catch((error) => { }).catch((error: BusinessError) => {
console.error('install failed:' + error.message); console.error('install failed:' + error.message);
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -395,23 +403,25 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac ...@@ -395,23 +403,25 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.ohos.demo'; let bundleName = 'com.ohos.demo';
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1 installFlag: 1
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.uninstall(bundleName, installParam, err => { data.uninstall(bundleName, installParam, (err: BusinessError) => {
if (err) { if (err) {
console.error('uninstall failed:' + err.message); console.error('uninstall failed:' + err.message);
} else { } else {
console.info('uninstall successfully.'); console.info('uninstall successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -453,18 +463,20 @@ uninstall(bundleName: string, callback: AsyncCallback&lt;void&gt;): void; ...@@ -453,18 +463,20 @@ uninstall(bundleName: string, callback: AsyncCallback&lt;void&gt;): void;
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.ohos.demo'; let bundleName = 'com.ohos.demo';
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.uninstall(bundleName, err => { data.uninstall(bundleName, (err: BusinessError) => {
if (err) { if (err) {
console.error('uninstall failed:' + err.message); console.error('uninstall failed:' + err.message);
} else { } else {
console.info('uninstall successfully.'); console.info('uninstall successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -511,22 +523,24 @@ uninstall(bundleName: string, installParam?: InstallParam) : Promise\<void\>; ...@@ -511,22 +523,24 @@ uninstall(bundleName: string, installParam?: InstallParam) : Promise\<void\>;
**示例:** **示例:**
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.ohos.demo'; let bundleName = 'com.ohos.demo';
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1, installFlag: 1,
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.uninstall(bundleName, installParam) data.uninstall(bundleName, installParam)
.then((data) => { .then((data: void) => {
console.info('uninstall successfully: ' + JSON.stringify(data)); console.info('uninstall successfully: ' + JSON.stringify(data));
}).catch((error) => { }).catch((error: BusinessError) => {
console.error('uninstall failed:' + error.message); console.error('uninstall failed:' + error.message);
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -567,23 +581,25 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback& ...@@ -567,23 +581,25 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.ohos.demo'; let bundleName = 'com.ohos.demo';
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1 installFlag: 1
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.recover(bundleName, installParam, err => { data.recover(bundleName, installParam, (err: BusinessError) => {
if (err) { if (err) {
console.error('recover failed:' + err.message); console.error('recover failed:' + err.message);
} else { } else {
console.info('recover successfully.'); console.info('recover successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -623,18 +639,20 @@ recover(bundleName: string, callback: AsyncCallback&lt;void&gt;): void; ...@@ -623,18 +639,20 @@ recover(bundleName: string, callback: AsyncCallback&lt;void&gt;): void;
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.ohos.demo'; let bundleName = 'com.ohos.demo';
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.recover(bundleName, err => { data.recover(bundleName, (err: BusinessError) => {
if (err) { if (err) {
console.error('recover failed:' + err.message); console.error('recover failed:' + err.message);
} else { } else {
console.info('recover successfully.'); console.info('recover successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -679,22 +697,24 @@ recover(bundleName: string, installParam?: InstallParam) : Promise\<void\>; ...@@ -679,22 +697,24 @@ recover(bundleName: string, installParam?: InstallParam) : Promise\<void\>;
**示例:** **示例:**
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let bundleName = 'com.ohos.demo'; let bundleName = 'com.ohos.demo';
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1, installFlag: 1,
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.recover(bundleName, installParam) data.recover(bundleName, installParam)
.then((data) => { .then((data: void) => {
console.info('recover successfully: ' + JSON.stringify(data)); console.info('recover successfully: ' + JSON.stringify(data));
}).catch((error) => { }).catch((error: BusinessError) => {
console.error('recover failed:' + error.message); console.error('recover failed:' + error.message);
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -735,20 +755,22 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi ...@@ -735,20 +755,22 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
let uninstallParam = { import { BusinessError } from '@ohos.base';
bundleName : "com.ohos.demo",
let uninstallParam: installer.UninstallParam = {
bundleName: "com.ohos.demo",
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.uninstall(uninstallParam, err => { data.uninstall(uninstallParam, (err: BusinessError) => {
if (err) { if (err) {
console.error('uninstall failed:' + err.message); console.error('uninstall failed:' + err.message);
} else { } else {
console.info('uninstall successfully.'); console.info('uninstall successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -794,20 +816,22 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>; ...@@ -794,20 +816,22 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
let uninstallParam = { import { BusinessError } from '@ohos.base';
bundleName : "com.ohos.demo",
let uninstallParam: installer.UninstallParam = {
bundleName: "com.ohos.demo",
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.uninstall(uninstallParam, err => { data.uninstall(uninstallParam, (err: BusinessError) => {
if (err) { if (err) {
console.error('uninstall failed:' + err.message); console.error('uninstall failed:' + err.message);
} else { } else {
console.info('uninstall successfully.'); console.info('uninstall successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -864,23 +888,25 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, installParam: InstallParam, c ...@@ -864,23 +888,25 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, installParam: InstallParam, c
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1, installFlag: 1,
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.updateBundleForSelf(hapFilePaths, installParam, err => { data.updateBundleForSelf(hapFilePaths, installParam, (err: BusinessError) => {
if (err) { if (err) {
console.error('updateBundleForSelf failed:' + err.message); console.error('updateBundleForSelf failed:' + err.message);
} else { } else {
console.info('updateBundleForSelf successfully.'); console.info('updateBundleForSelf successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -935,18 +961,20 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, callback: AsyncCallback\<void ...@@ -935,18 +961,20 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, callback: AsyncCallback\<void
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.updateBundleForSelf(hapFilePaths, err => { data.updateBundleForSelf(hapFilePaths, (err: BusinessError) => {
if (err) { if (err) {
console.error('updateBundleForSelf failed:' + err.message); console.error('updateBundleForSelf failed:' + err.message);
} else { } else {
console.info('updateBundleForSelf successfully.'); console.info('updateBundleForSelf successfully.');
} }
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -1002,22 +1030,24 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, installParam?: InstallParam): ...@@ -1002,22 +1030,24 @@ updateBundleForSelf(hapFilePaths: Array\<string\>, installParam?: InstallParam):
```ts ```ts
import installer from '@ohos.bundle.installer'; import installer from '@ohos.bundle.installer';
import { BusinessError } from '@ohos.base';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
let installParam = { let installParam: installer.InstallParam = {
userId: 100, userId: 100,
isKeepData: false, isKeepData: false,
installFlag: 1, installFlag: 1,
}; };
try { try {
installer.getBundleInstaller().then(data => { installer.getBundleInstaller().then((data: installer.BundleInstaller) => {
data.updateBundleForSelf(hapFilePaths, installParam) data.updateBundleForSelf(hapFilePaths, installParam)
.then((data) => { .then((data: void) => {
console.info('updateBundleForSelf successfully: ' + JSON.stringify(data)); console.info('updateBundleForSelf successfully: ' + JSON.stringify(data));
}).catch((error) => { }).catch((error: BusinessError) => {
console.error('updateBundleForSelf failed:' + error.message); console.error('updateBundleForSelf failed:' + error.message);
}); });
}).catch(error => { }).catch((error: BusinessError) => {
console.error('getBundleInstaller failed. Cause: ' + error.message); console.error('getBundleInstaller failed. Cause: ' + error.message);
}); });
} catch (error) { } catch (error) {
......
...@@ -51,9 +51,11 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba ...@@ -51,9 +51,11 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100, (errData, data) => { launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100,
(errData: BusinessError, data: launcherBundleManager.LauncherAbilityInfo[]) => {
if (errData !== null) { if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
} else { } else {
...@@ -101,13 +103,15 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau ...@@ -101,13 +103,15 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau
**示例:** **示例:**
```typescript ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100).then(data => { launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100)
.then((data: launcherBundleManager.LauncherAbilityInfo[]) => {
console.log("data is " + JSON.stringify(data)); console.log("data is " + JSON.stringify(data));
}).catch (errData => { }).catch ((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}) })
} catch (errData) { } catch (errData) {
...@@ -151,7 +155,7 @@ getLauncherAbilityInfoSync(bundleName: string, userId: number) : Array\<[Launche ...@@ -151,7 +155,7 @@ getLauncherAbilityInfoSync(bundleName: string, userId: number) : Array\<[Launche
**示例:** **示例:**
```typescript ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try { try {
...@@ -198,9 +202,11 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch ...@@ -198,9 +202,11 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getAllLauncherAbilityInfo(100, (errData, data) => { launcherBundleManager.getAllLauncherAbilityInfo(100,
(errData: BusinessError, data: launcherBundleManager.LauncherAbilityInfo[]) => {
if (errData !== null) { if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
} else { } else {
...@@ -247,11 +253,13 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo] ...@@ -247,11 +253,13 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo]
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getAllLauncherAbilityInfo(100).then(data => { launcherBundleManager.getAllLauncherAbilityInfo(100)
.then((data: launcherBundleManager.LauncherAbilityInfo[]) => {
console.log("data is " + JSON.stringify(data)); console.log("data is " + JSON.stringify(data));
}).catch (errData => { }).catch ((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}); });
} catch (errData) { } catch (errData) {
...@@ -293,9 +301,11 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo ...@@ -293,9 +301,11 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getShortcutInfo("com.example.demo", (errData, data) => { launcherBundleManager.getShortcutInfo("com.example.demo",
(errData: BusinessError, data: launcherBundleManager.ShortcutInfo[]) => {
if (errData !== null) { if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
} else { } else {
...@@ -341,11 +351,13 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun ...@@ -341,11 +351,13 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getShortcutInfo("com.example.demo").then(data => { launcherBundleManager.getShortcutInfo("com.example.demo")
.then((data: launcherBundleManager.ShortcutInfo[]) => {
console.log("data is " + JSON.stringify(data)); console.log("data is " + JSON.stringify(data));
}).catch (errData => { }).catch ((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}); });
} catch (errData) { } catch (errData) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册