1e41f4b71Sopenharmony_ci# @ohos.bundle.distributedBundleManager (distributedBundleManager模块)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci本模块提供分布式应用的管理能力。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> 本模块为系统接口。
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## 导入模块
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci``` ts
14e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## 系统能力
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciSystemCapability.BundleManager.DistributedBundleFramework
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## 权限列表
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| 权限                                       | 权限等级     | 说明               |
24e41f4b71Sopenharmony_ci| ------------------------------------------ | ------------ | ------------------ |
25e41f4b71Sopenharmony_ci| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 允许查询应用的基本信息和其他敏感信息。 |
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci权限等级参考[权限APL等级说明](../../security/AccessToken/app-permission-mgmt-overview.md#权限机制中的基本概念)。
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAbilityInfo>): void
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci以异步方法获取由elementName指定的远程设备上的应用的AbilityInfo信息。使用callback异步回调。
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**参数:**
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| 参数名      | 类型                                                         | 必填 | 说明                                                         |
44e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
45e41f4b71Sopenharmony_ci| elementName | [ElementName](js-apis-bundleManager-elementName.md)          | 是   | ElementName信息。                                            |
46e41f4b71Sopenharmony_ci| callback    | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)> | 是   | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo对象;调用失败err为错误对象, data为undefined。 |
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci**错误码:**
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
53e41f4b71Sopenharmony_ci|----------|--------------------------------------|
54e41f4b71Sopenharmony_ci| 201 | Permission denied. |
55e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
56e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
57e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
58e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
59e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
60e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
61e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**示例:**
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci```ts
66e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
67e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_citry {
70e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
71e41f4b71Sopenharmony_ci        {
72e41f4b71Sopenharmony_ci            deviceId: '1',
73e41f4b71Sopenharmony_ci            bundleName: 'com.example.application',
74e41f4b71Sopenharmony_ci            abilityName: 'EntryAbility'
75e41f4b71Sopenharmony_ci        }, (err: BusinessError, data: distributedBundle.RemoteAbilityInfo) => {
76e41f4b71Sopenharmony_ci            if (err) {
77e41f4b71Sopenharmony_ci                console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
78e41f4b71Sopenharmony_ci            } else {
79e41f4b71Sopenharmony_ci                console.info('Operation succeed:' + JSON.stringify(data));
80e41f4b71Sopenharmony_ci            }
81e41f4b71Sopenharmony_ci        });
82e41f4b71Sopenharmony_ci} catch (err) {
83e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
84e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
85e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
86e41f4b71Sopenharmony_ci}
87e41f4b71Sopenharmony_ci```
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci以异步方法获取由elementName指定的远程设备上的应用的AbilityInfo信息。使用Promise异步回调。
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**参数:**
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci| 参数名       | 类型                                         | 必填 | 说明                    |
104e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------- | ---- | ----------------------- |
105e41f4b71Sopenharmony_ci| elementName | [ElementName](js-apis-bundleManager-elementName.md) | 是   | ElementName信息。 |
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci**返回值:**
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci| 类型                                                         | 说明                              |
110e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
111e41f4b71Sopenharmony_ci| Promise\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)> | Promise对象,调用成功返回RemoteAbilityInfo对象;调用失败返回错误对象。 |
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**错误码:**
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
118e41f4b71Sopenharmony_ci|----------|-------------------------|
119e41f4b71Sopenharmony_ci| 201 | Permission denied. |
120e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
121e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
122e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
123e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
124e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
125e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
126e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci**示例:**
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci```ts
131e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
132e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_citry {
135e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
136e41f4b71Sopenharmony_ci        {
137e41f4b71Sopenharmony_ci            deviceId: '1',
138e41f4b71Sopenharmony_ci            bundleName: 'com.example.application',
139e41f4b71Sopenharmony_ci            abilityName: 'EntryAbility'
140e41f4b71Sopenharmony_ci        }).then((data: distributedBundle.RemoteAbilityInfo) => {
141e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
142e41f4b71Sopenharmony_ci        }).catch((err: BusinessError) => {
143e41f4b71Sopenharmony_ci            console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
144e41f4b71Sopenharmony_ci        });
145e41f4b71Sopenharmony_ci} catch (err) {
146e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
147e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
148e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
149e41f4b71Sopenharmony_ci}
150e41f4b71Sopenharmony_ci```
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\<Array\<RemoteAbilityInfo>>): void
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci以异步方法获取由elementName指定的远程设备上的应用的AbilityInfo数组信息。使用callback异步回调。
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci**参数:**
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci| 参数名       | 类型                                                         | 必填 | 说明                                                         |
167e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
168e41f4b71Sopenharmony_ci| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)>   | 是   | ElementName信息,最大数组长度为10。                             |
169e41f4b71Sopenharmony_ci| callback     | AsyncCallback\<Array\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)>> | 是   | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo数组对象;调用失败err为错误对象, data为undefined。 |
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci**错误码:**
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
176e41f4b71Sopenharmony_ci|----------|-------------------------|
177e41f4b71Sopenharmony_ci| 201 | Permission denied. |
178e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
179e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
180e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
181e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
182e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
183e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
184e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**示例:**
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci```ts
189e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
190e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_citry {
193e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
194e41f4b71Sopenharmony_ci        [
195e41f4b71Sopenharmony_ci            {
196e41f4b71Sopenharmony_ci                deviceId: '1',
197e41f4b71Sopenharmony_ci                bundleName: 'com.example.application1',
198e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility1'
199e41f4b71Sopenharmony_ci            },
200e41f4b71Sopenharmony_ci            {
201e41f4b71Sopenharmony_ci                deviceId: '1',
202e41f4b71Sopenharmony_ci                bundleName: 'com.example.application2',
203e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility'
204e41f4b71Sopenharmony_ci            }
205e41f4b71Sopenharmony_ci        ], (err: BusinessError, data: distributedBundle.RemoteAbilityInfo[]) => {
206e41f4b71Sopenharmony_ci          if (err) {
207e41f4b71Sopenharmony_ci            console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
208e41f4b71Sopenharmony_ci          } else {
209e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
210e41f4b71Sopenharmony_ci          }
211e41f4b71Sopenharmony_ci        });
212e41f4b71Sopenharmony_ci} catch (err) {
213e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
214e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
215e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
216e41f4b71Sopenharmony_ci}
217e41f4b71Sopenharmony_ci```
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteAbilityInfo>>
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci以异步方法获取由elementName指定的远程设备上的应用的AbilityInfo数组信息。使用Promise异步回调。
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**参数:**
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci| 参数名        | 类型                                                | 必填 | 说明                    |
234e41f4b71Sopenharmony_ci| ------------ | --------------------------------------------------- | ---- | ----------------------- |
235e41f4b71Sopenharmony_ci| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是   | ElementName信息,最大数组长度为10。 |
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci**返回值:**
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci| 类型                                                         | 说明                              |
240e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
241e41f4b71Sopenharmony_ci| Promise\<Array<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)>> | Promise对象,调用成功返回RemoteAbilityInfo对象;调用失败返回错误对象。 |
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**错误码:**
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
248e41f4b71Sopenharmony_ci|----------|-------------------------|
249e41f4b71Sopenharmony_ci| 201 | Permission denied. |
250e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
251e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
252e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
253e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
254e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
255e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
256e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci**示例:**
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci```ts
261e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
262e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_citry {
265e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
266e41f4b71Sopenharmony_ci        [
267e41f4b71Sopenharmony_ci            {
268e41f4b71Sopenharmony_ci                deviceId: '1',
269e41f4b71Sopenharmony_ci                bundleName: 'com.example.application',
270e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility'
271e41f4b71Sopenharmony_ci            },
272e41f4b71Sopenharmony_ci            {
273e41f4b71Sopenharmony_ci                deviceId: '1',
274e41f4b71Sopenharmony_ci                bundleName: 'com.example.application2',
275e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility'
276e41f4b71Sopenharmony_ci            }
277e41f4b71Sopenharmony_ci        ]).then((data: distributedBundle.RemoteAbilityInfo[]) => {
278e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
279e41f4b71Sopenharmony_ci        }).catch((err: BusinessError) => {
280e41f4b71Sopenharmony_ci            console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
281e41f4b71Sopenharmony_ci        });
282e41f4b71Sopenharmony_ci} catch (err) {
283e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
284e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
285e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
286e41f4b71Sopenharmony_ci}
287e41f4b71Sopenharmony_ci```
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCallback\<RemoteAbilityInfo>): void
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci以异步方法获取由elementName和locale指定的远程设备上的应用的AbilityInfo信息。使用callback异步回调。
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**参数:**
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci| 参数名       | 类型                                                         | 必填 | 说明                                               |
304e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
305e41f4b71Sopenharmony_ci| elementName | [ElementName](js-apis-bundleManager-elementName.md)                 | 是   | ElementName信息。                            |
306e41f4b71Sopenharmony_ci| locale  | string |是 | 语言地区。 |
307e41f4b71Sopenharmony_ci| callback    | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)> | 是   | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo对象;调用失败err为错误对象, data为undefined。 |
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci**错误码:**
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
314e41f4b71Sopenharmony_ci|----------|-------------------------|
315e41f4b71Sopenharmony_ci| 201 | Permission denied. |
316e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
317e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
318e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
319e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
320e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
321e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
322e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci**示例:**
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci```ts
327e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
328e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_citry {
331e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
332e41f4b71Sopenharmony_ci        {
333e41f4b71Sopenharmony_ci            deviceId: '1',
334e41f4b71Sopenharmony_ci            bundleName: 'com.example.application',
335e41f4b71Sopenharmony_ci            abilityName: 'EntryAbility'
336e41f4b71Sopenharmony_ci        }, 'zh-Hans-CN', (err: BusinessError, data: distributedBundle.RemoteAbilityInfo) => {
337e41f4b71Sopenharmony_ci          if (err) {
338e41f4b71Sopenharmony_ci            console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
339e41f4b71Sopenharmony_ci          } else {
340e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
341e41f4b71Sopenharmony_ci          }
342e41f4b71Sopenharmony_ci        });
343e41f4b71Sopenharmony_ci} catch (err) {
344e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
345e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
346e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
347e41f4b71Sopenharmony_ci}
348e41f4b71Sopenharmony_ci```
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteAbilityInfo>
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci以异步方法获取由elementName和locale指定的远程设备上的应用的AbilityInfo信息。使用Promise异步回调。
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci**参数:**
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci| 参数名       | 类型                                         | 必填 | 说明                    |
365e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------- | ---- | ----------------------- |
366e41f4b71Sopenharmony_ci| elementName | [ElementName](js-apis-bundleManager-elementName.md) | 是   | ElementName信息。 |
367e41f4b71Sopenharmony_ci| locale  | string |是 | 语言地区。 |
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci**返回值:**
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci| 类型                                                         | 说明                              |
372e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
373e41f4b71Sopenharmony_ci| Promise\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)> | Promise对象,调用成功返回RemoteAbilityInfo对象;调用失败返回错误对象。 |
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci**错误码:**
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
380e41f4b71Sopenharmony_ci|----------|-------------------------|
381e41f4b71Sopenharmony_ci| 201 | Permission denied. |
382e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
383e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
384e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
385e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
386e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
387e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
388e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**示例:**
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci```ts
393e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
394e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_citry {
397e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
398e41f4b71Sopenharmony_ci        {
399e41f4b71Sopenharmony_ci            deviceId: '1',
400e41f4b71Sopenharmony_ci            bundleName: 'com.example.application',
401e41f4b71Sopenharmony_ci            abilityName: 'EntryAbility'
402e41f4b71Sopenharmony_ci        }, 'zh-Hans-CN').then((data: distributedBundle.RemoteAbilityInfo) => {
403e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
404e41f4b71Sopenharmony_ci        }).catch((err: BusinessError) => {
405e41f4b71Sopenharmony_ci            console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
406e41f4b71Sopenharmony_ci        });
407e41f4b71Sopenharmony_ci} catch (err) {
408e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
409e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
410e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
411e41f4b71Sopenharmony_ci}
412e41f4b71Sopenharmony_ci```
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback: AsyncCallback\<Array\<RemoteAbilityInfo>>): void
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci以异步方法获取由elementName和locale指定的远程设备上的应用的AbilityInfo数组信息。使用callback异步回调。
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci**参数:**
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci| 参数名        | 类型                                                         | 必填 | 说明                                               |
429e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
430e41f4b71Sopenharmony_ci| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)>          | 是   | ElementName信息,最大数组长度为10。                   |
431e41f4b71Sopenharmony_ci| locale  | string |是 | 语言地区。 |
432e41f4b71Sopenharmony_ci| callback     | AsyncCallback\<Array\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)>> | 是   | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo数组对象;调用失败err为错误对象, data为undefined。 |
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci**错误码:**
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci| 错误码ID        |    错误信息                   |
439e41f4b71Sopenharmony_ci|---------------|-------------------------|
440e41f4b71Sopenharmony_ci| 201 | Permission denied. |
441e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
442e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
443e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
444e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
445e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
446e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
447e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci**示例:**
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci```ts
452e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
453e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_citry {
456e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
457e41f4b71Sopenharmony_ci        [
458e41f4b71Sopenharmony_ci            {
459e41f4b71Sopenharmony_ci                deviceId: '1',
460e41f4b71Sopenharmony_ci                bundleName: 'com.example.application1',
461e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility1'
462e41f4b71Sopenharmony_ci            },
463e41f4b71Sopenharmony_ci            {
464e41f4b71Sopenharmony_ci                deviceId: '1',
465e41f4b71Sopenharmony_ci                bundleName: 'com.example.application2',
466e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility'
467e41f4b71Sopenharmony_ci            }
468e41f4b71Sopenharmony_ci        ], 'zh-Hans-CN', (err: BusinessError, data: distributedBundle.RemoteAbilityInfo[]) => {
469e41f4b71Sopenharmony_ci          if (err) {
470e41f4b71Sopenharmony_ci           console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
471e41f4b71Sopenharmony_ci          } else {
472e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
473e41f4b71Sopenharmony_ci          }
474e41f4b71Sopenharmony_ci        });
475e41f4b71Sopenharmony_ci} catch (err) {
476e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
477e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
478e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
479e41f4b71Sopenharmony_ci}
480e41f4b71Sopenharmony_ci```
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci## distributedBundle.getRemoteAbilityInfo
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_cigetRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise\<Array\<RemoteAbilityInfo>>
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci以异步方法获取由elementName和locale指定的远程设备上的应用的AbilityInfo数组信息。使用Promise异步回调。
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.BundleManager.DistributedBundleFramework
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci**参数:**
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci| 参数名        | 类型                                                | 必填 | 说明                    |
497e41f4b71Sopenharmony_ci| ------------ | --------------------------------------------------- | ---- | ----------------------- |
498e41f4b71Sopenharmony_ci| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是   | ElementName信息,最大数组长度为10。 |
499e41f4b71Sopenharmony_ci| locale  | string |是 | 语言地区。 |
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci**返回值:**
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci| 类型                                                         | 说明                              |
504e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
505e41f4b71Sopenharmony_ci| Promise\<Array<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo-sys.md)>> | Promise对象,调用成功返回RemoteAbilityInfo对象;调用失败返回错误对象。 |
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ci**错误码:**
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ci| 错误码ID |    错误信息                   |
512e41f4b71Sopenharmony_ci|----------|-------------------------|
513e41f4b71Sopenharmony_ci| 201 | Permission denied. |
514e41f4b71Sopenharmony_ci| 202 | Permission denied, non-system app called system api. |
515e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.|
516e41f4b71Sopenharmony_ci| 801 | Capability not supported. |
517e41f4b71Sopenharmony_ci| 17700001 | The specified bundle name is not found. |
518e41f4b71Sopenharmony_ci| 17700003 | The specified ability name is not found. |
519e41f4b71Sopenharmony_ci| 17700007 | The specified device ID is not found. |
520e41f4b71Sopenharmony_ci| 17700027 | The distributed service is not running. |
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**示例:**
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci```ts
525e41f4b71Sopenharmony_ciimport distributedBundle from '@ohos.bundle.distributedBundleManager';
526e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_citry {
529e41f4b71Sopenharmony_ci    distributedBundle.getRemoteAbilityInfo(
530e41f4b71Sopenharmony_ci        [
531e41f4b71Sopenharmony_ci            {
532e41f4b71Sopenharmony_ci                deviceId: '1',
533e41f4b71Sopenharmony_ci                bundleName: 'com.example.application',
534e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility'
535e41f4b71Sopenharmony_ci            },
536e41f4b71Sopenharmony_ci            {
537e41f4b71Sopenharmony_ci                deviceId: '1',
538e41f4b71Sopenharmony_ci                bundleName: 'com.example.application2',
539e41f4b71Sopenharmony_ci                abilityName: 'EntryAbility'
540e41f4b71Sopenharmony_ci            }
541e41f4b71Sopenharmony_ci        ], 'zh-Hans-CN').then((data: distributedBundle.RemoteAbilityInfo[]) => {
542e41f4b71Sopenharmony_ci            console.info('Operation succeed:' + JSON.stringify(data));
543e41f4b71Sopenharmony_ci        }).catch((err: BusinessError) => {
544e41f4b71Sopenharmony_ci            console.log(`Operation failed: error code is ${err.code}  and error message is ${err.message}`);
545e41f4b71Sopenharmony_ci        });
546e41f4b71Sopenharmony_ci} catch (err) {
547e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
548e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message;
549e41f4b71Sopenharmony_ci    console.log(`Operation failed: error code is ${code}  and error message is ${message}`);
550e41f4b71Sopenharmony_ci}
551e41f4b71Sopenharmony_ci```
552