提交 24d73b5a 编写于 作者: W wanghang

IssueNo:#I4UDBJ:add bms api reference

Description:add bms api reference
Sig:SIG_ApplicaitonFramework
Feature or Bugfix:Feature
Binary Source:No
Signed-off-by: Nwanghang <wanghang26@huawei.com>
Change-Id: I15d984c78156b1d0323f212af9e98da321b44001
上级 fd5272dc
......@@ -12,7 +12,11 @@ SystemCapability.BundleManager.BundleFramework
## 权限列表
| 权限 | 权限等级 | 描述 |
|-------| --------- | ---- |
| ohos.permission.GET_BUNDLE_INFO | normal | 仅限查询本应用信息 |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
## bundle.getApplicationInfo
......@@ -29,8 +33,8 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 要查询的应用程序包名称。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0 |
| userId | number | 是 | 用户ID |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
......@@ -41,41 +45,14 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
**示例:**
```js
bundle.getApplicationInfo('com.example.myapplicationInstall', 8, 0).then((data) => {
console.info("name: for begin");
console.info("name:" + data.name);
console.info("bundleName:" + data.bundleName);
console.info("description:" + data.description);
console.info("descriptionId:" + data.descriptionId);
console.info("iconPath:" + data.iconPath);
console.info("iconId:" + data.iconId);
console.info("label:" + data.label);
console.info("labelId:" + data.labelId);
console.info("deviceId:" + data.deviceId);
console.info("signatureKey:" + data.signatureKey);
console.info("process:" + data.process);
console.info("isSystemApp:" + data.isSystemApp);
console.info("isLauncherApp:" + data.isLauncherApp);
console.info("supportedModes:" + data.supportedModes);
console.info('getApplicationInfo permissions length [' + data.permissions.length + ']');
for (var j = 0; j < data.permissions.length; j++) {
console.info("permissions[" + j + "]:" + data.permissions[j]);
}
console.info('getApplicationInfo moduleSourceDirs length [' + data.moduleSourceDirs.length + ']');
for (var j = 0; j < data.moduleSourceDirs.length; j++) {
console.info("moduleSourceDirs[" + j + "]:" + data.moduleSourceDirs[j]);
}
console.info('getApplicationInfo moduleInfos length [' + data.moduleInfos.length + ']');
for (var j = 0; j < data.moduleInfos.length; j++) {
console.info("moduleInfos[" + j + "]moduleName:" + data.moduleInfos[j].moduleName);
console.info("moduleInfos[" + j + "]moduleSourceDir:" + data.moduleInfos[j].moduleSourceDir);
}
console.info("entryDir:" + data.entryDir);
console.info("codePath:" + data.codePath);
console.info("dataDir:" + data.dataDir);
console.info("dataBaseDir:" + data.dataBaseDir);
console.info("cacheDir:" + data.cacheDir);
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
bundle.getApplicationInfo(bundleName, bundleFlags, userId)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -96,58 +73,30 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 要查询的应用程序包名称。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0 |
| userId | number | 是 | 用户ID |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback\<ApplicationInfo> | 是 | 程序启动作为入参的回调函数,返回应用程序信息。 |
**示例:**
```js
bundle.getApplicationInfo('com.example.myapplicationInstall', 8, 0, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info("name: for begin");
console.info("name:" + data.name);
console.info("bundleName:" + data.bundleName);
console.info("description:" + data.description);
console.info("descriptionId:" + data.descriptionId);
console.info("iconPath:" + data.iconPath);
console.info("iconId:" + data.iconId);
console.info("label:" + data.label);
console.info("labelId:" + data.labelId);
console.info("deviceId:" + data.deviceId);
console.info("signatureKey:" + data.signatureKey);
console.info("process:" + data.process);
console.info("isSystemApp:" + data.isSystemApp);
console.info("isLauncherApp:" + data.isLauncherApp);
console.info("supportedModes:" + data.supportedModes);
console.info('getApplicationInfo permissions length [' + data.permissions.length + ']');
for (var j = 0; j < data.permissions.length; j++) {
console.info("permissions[" + j + "]:" + data.permissions[j]);
}
console.info('getApplicationInfo moduleSourceDirs length [' + data.moduleSourceDirs.length + ']');
for (var j = 0; j < data.moduleSourceDirs.length; j++) {
console.info("moduleSourceDirs[" + j + "]:" + data.moduleSourceDirs[j]);
}
console.info('getApplicationInfo moduleInfos length [' + data.moduleInfos.length + ']');
for (var j = 0; j < data.moduleInfos.length; j++) {
console.info("moduleInfos[" + j + "]moduleName:" + data.moduleInfos[j].moduleName);
console.info("moduleInfos[" + j + "]moduleSourceDir:" + data.moduleInfos[j].moduleSourceDir);
}
console.info("entryDir:" + data.entryDir);
console.info("codePath:" + data.codePath);
console.info("dataDir:" + data.dataDir);
console.info("dataBaseDir:" + data.dataBaseDir);
console.info("cacheDir:" + data.cacheDir);
}
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getAllBundleInfo
getAllBundleInfo(bundleFlag: BundleFlag): Promise<Array\<BundleInfo>>
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>>
以异步方法获取系统中所有可用的BundleInfo,使用Promise形式返回结果。
......@@ -159,7 +108,8 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ---------- | ---- | ----------------------------------------------------------- |
| bundleFlag | BundleFlag | 是 | 0:返回默认BundleInfo<br>1:返回包含abilityInfo的BundleInfo |
| bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
......@@ -170,69 +120,13 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**示例:**
```js
bundle.getAllBundleInfo(0).then((data) => {
for (var i = 0; i < data.length; i++) {
console.info("index[" + i + "].name: for begin");
console.info("index[" + i + "].name:" + data[i].name);
console.info("index[" + i + "].label:" + data[i].label);
console.info("index[" + i + "].description:" + data[i].description);
console.info("index[" + i + "].vendor:" + data[i].vendor);
console.info("index[" + i + "].versionCode:" + data[i].versionCode);
console.info("index[" + i + "].versionName:" + data[i].versionName);
console.info("index[" + i + "].jointUserId:" + data[i].jointUserId);
console.info("index[" + i + "].minSdkVersion:" + data[i].minSdkVersion);
console.info("index[" + i + "].maxSdkVersion:" + data[i].maxSdkVersion);
console.info("index[" + i + "].mainEntry:" + data[i].mainEntry);
console.info("index[" + i + "].cpuAbi:" + data[i].cpuAbi);
console.info("index[" + i + "].appId:" + data[i].appId);
console.info("index[" + i + "].compatibleVersion:" + data[i].compatibleVersion);
console.info("index[" + i + "].targetVersion:" + data[i].targetVersion);
console.info("index[" + i + "].releaseType:" + data[i].releaseType);
console.info("index[" + i + "].uid:" + data[i].uid);
console.info("index[" + i + "].gid:" + data[i].gid);
console.info("index[" + i + "].seInfo:" + data[i].seInfo);
console.info("index[" + i + "].entryModuleName:" + data[i].entryModuleName);
console.info("index[" + i + "].isKeepAlive:" + data[i].isKeepAlive);
console.info("index[" + i + "].isNativeApp:" + data[i].isNativeApp);
console.info("index[" + i + "].installTime:" + data[i].installTime);
console.info("index[" + i + "].updateTime:" + data[i].updateTime);
console.info("index[" + i + "].appInfo.name:" + data[i].applicationInfo.name);
console.info("index[" + i + "].appInfo.bundleName:" + data[i].applicationInfo.bundleName);
console.info('getAllBundleInfo reqPermissions length [' + data[i].reqPermissions.length + ']');
for (var j = 0; j < data[i].reqPermissions.length; j++) {
console.info("index[" + i + "]reqPermissions[" + j + "]:" + data[i].reqPermissions[j]);
}
console.info('getAllBundleInfo defPermissions length [' + data[i].defPermissions.length + ']');
for (var j = 0; j < data[i].defPermissions.length; j++) {
console.info("index[" + i + "]defPermissions[" + j + "]:" + data[i].defPermissions[j]);
}
console.info('getAllBundleInfo hapModuleNames length [' + data[i].hapModuleNames.length + ']');
for (var j = 0; j < data[i].hapModuleNames.length; j++) {
console.info("index[" + i + "]hapModuleNames[" + j + "]:" + data[i].hapModuleNames[j]);
}
console.info('getAllBundleInfo moduleNames length [' + data[i].moduleNames.length + ']');
for (var j = 0; j < data[i].moduleNames.length; j++) {
console.info("index[" + i + "]moduleNames[" + j + "]:" + data[i].moduleNames[j]);
}
console.info('getAllBundleInfo modulePublicDirs length [' + data[i].modulePublicDirs.length + ']');
for (var j = 0; j < data[i].modulePublicDirs.length; j++) {
console.info("index[" + i + "]modulePublicDirs[" + j + "]:" + data[i].modulePublicDirs[j]);
}
console.info('getAllBundleInfo moduleDirs length [' + data[i].moduleDirs.length + ']');
for (var j = 0; j < data[i].moduleDirs.length; j++) {
console.info("index[" + i + "]moduleDirs[" + j + "]:" + data[i].moduleDirs[j]);
}
console.info('getAllBundleInfo moduleResPaths length [' + data[i].moduleResPaths.length + ']');
for (var j = 0; j < data[i].moduleResPaths.length; j++) {
console.info("index[" + i + "]moduleResPaths[" + j + "]:" + data[i].moduleResPaths[j]);
}
console.info('getAllBundleInfo abilityInfo length [' + data[i].abilityInfos.length + ']');
for (var j = 0; j < data[i].abilityInfos.length; j++) {
console.info("index[" + i + "]abilityInfos[" + j + "]name:" + data[i].abilityInfos[j].name);
console.info("index[" + i + "]abilityInfos[" + j + "]package:" + data[i].abilityInfos[j].package);
}
}
let bundleFlag = 0;
let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -252,86 +146,60 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
| 名称 | 类型 | 必填 | 描述 |
| ---------- | --------------------------------- | ---- | ------------------------------------------------------------ |
| bundleFlag | BundleFlag | 是 | 0:返回默认BundleInfo<br/>1:返回包含abilityInfo的BundleInfo |
| bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。|
| callback | AsyncCallback<Array\<BundleInfo>> | 是 | 程序启动作为入参的回调函数,返回所有可用的BundleInfo。 |
**示例:**
```js
bundle.getAllBundleInfo(0, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info('xxx getAllBundleInfo data length [' + data.length + ']');
for (var i = 0; i < data.length; i++) {
console.info("index[" + i + "].name: for begin");
console.info("index[" + i + "].name:" + data[i].name);
console.info("index[" + i + "].label:" + data[i].label);
console.info("index[" + i + "].description:" + data[i].description);
console.info("index[" + i + "].vendor:" + data[i].vendor);
console.info("index[" + i + "].versionCode:" + data[i].versionCode);
console.info("index[" + i + "].versionName:" + data[i].versionName);
console.info("index[" + i + "].jointUserId:" + data[i].jointUserId);
console.info("index[" + i + "].minSdkVersion:" + data[i].minSdkVersion);
console.info("index[" + i + "].maxSdkVersion:" + data[i].maxSdkVersion);
console.info("index[" + i + "].mainEntry:" + data[i].mainEntry);
console.info("index[" + i + "].cpuAbi:" + data[i].cpuAbi);
console.info("index[" + i + "].appId:" + data[i].appId);
console.info("index[" + i + "].compatibleVersion:" + data[i].compatibleVersion);
console.info("index[" + i + "].targetVersion:" + data[i].targetVersion);
console.info("index[" + i + "].releaseType:" + data[i].releaseType);
console.info("index[" + i + "].uid:" + data[i].uid);
console.info("index[" + i + "].gid:" + data[i].gid);
console.info("index[" + i + "].seInfo:" + data[i].seInfo);
console.info("index[" + i + "].entryModuleName:" + data[i].entryModuleName);
console.info("index[" + i + "].isKeepAlive:" + data[i].isKeepAlive);
console.info("index[" + i + "].isNativeApp:" + data[i].isNativeApp);
console.info("index[" + i + "].installTime:" + data[i].installTime);
console.info("index[" + i + "].updateTime:" + data[i].updateTime);
console.info("index[" + i + "].appInfo.name:" + data[i].applicationInfo.name);
console.info("index[" + i + "].appInfo.bundleName:" + data[i].applicationInfo.bundleName);
console.info('getAllBundleInfo reqPermissions length [' + data[i].reqPermissions.length + ']');
for (var j = 0; j < data[i].reqPermissions.length; j++) {
console.info("index[" + i + "]reqPermissions[" + j + "]:" + data[i].reqPermissions[j]);
}
console.info('getAllBundleInfo defPermissions length [' + data[i].defPermissions.length + ']');
for (var j = 0; j < data[i].defPermissions.length; j++) {
console.info("index[" + i + "]defPermissions[" + j + "]:" + data[i].defPermissions[j]);
}
let bundleFlag = 0;
bundle.getAllBundleInfo(bundleFlag, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
console.info('getAllBundleInfo hapModuleNames length [' + data[i].hapModuleNames.length + ']');
for (var j = 0; j < data[i].hapModuleNames.length; j++) {
console.info("index[" + i + "]hapModuleNames[" + j + "]:" + data[i].hapModuleNames[j]);
}
console.info('getAllBundleInfo moduleNames length [' + data[i].moduleNames.length + ']');
for (var j = 0; j < data[i].moduleNames.length; j++) {
console.info("index[" + i + "]moduleNames[" + j + "]:" + data[i].moduleNames[j]);
}
console.info('getAllBundleInfo modulePublicDirs length [' + data[i].modulePublicDirs.length + ']');
for (var j = 0; j < data[i].modulePublicDirs.length; j++) {
console.info("index[" + i + "]modulePublicDirs[" + j + "]:" + data[i].modulePublicDirs[j]);
}
console.info('getAllBundleInfo moduleDirs length [' + data[i].moduleDirs.length + ']');
for (var j = 0; j < data[i].moduleDirs.length; j++) {
console.info("index[" + i + "]moduleDirs[" + j + "]:" + data[i].moduleDirs[j]);
}
console.info('getAllBundleInfo moduleResPaths length [' + data[i].moduleResPaths.length + ']');
for (var j = 0; j < data[i].moduleResPaths.length; j++) {
console.info("index[" + i + "]moduleResPaths[" + j + "]:" + data[i].moduleResPaths[j]);
}
console.info('getAllBundleInfo abilityInfo length [' + data[i].abilityInfos.length + ']');
for (var j = 0; j < data[i].abilityInfos.length; j++) {
console.info("index[" + i + "]abilityInfos[" + j + "]name:" + data[i].abilityInfos[j].name);
console.info("index[" + i + "]abilityInfos[" + j + "]package:" + data[i].abilityInfos[j].package);
}
}
}
## bundle.getAllBundleInfo
getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void
以异步方法获取系统中所有可用的BundleInfo,使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | --------------------------------- | ---- | ------------------------------------------------------------ |
| bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。|
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback<Array\<BundleInfo>> | 是 | 程序启动作为入参的回调函数,返回所有可用的BundleInfo。 |
**示例:**
```js
let bundleFlag = 0;
let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getBundleInfo
getBundleInfo(bundleName: string, bundleFlags: number): Promise\<BundleInfo>
getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo>
以异步方法根据给定的包名获取BundleInfo,使用Promise形式返回结果。
......@@ -344,7 +212,8 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 包名 |
| bundleFlags | number | 是 | 0:返回默认BundleInfo<br/>1:返回包含abilityInfo的BundleInfo |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
| options | BundleOptions | 否 | 包含userid和networkid。 |
**返回值:**
......@@ -355,66 +224,17 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
**示例:**
```js
bundle.getBundleInfo('com.example.myapplicationInstall', 1).then((data) => {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("vendor:" + data.vendor);
console.info("versionCode:" + data.versionCode);
console.info("versionName:" + data.versionName);
console.info("jointUserId:" + data.jointUserId);
console.info("minSdkVersion:" + data.minSdkVersion);
console.info("maxSdkVersion:" + data.maxSdkVersion);
console.info("mainEntry:" + data.mainEntry);
console.info("cpuAbi:" + data.cpuAbi);
console.info("appId:" + data.appId);
console.info("compatibleVersion:" + data.compatibleVersion);
console.info("targetVersion:" + data.targetVersion);
console.info("releaseType:" + data.releaseType);
console.info("uid:" + data.uid);
console.info("gid:" + data.gid);
console.info("seInfo:" + data.seInfo);
console.info("entryModuleName:" + data.entryModuleName);
console.info("isKeepAlive:" + data.isKeepAlive);
console.info("isNativeApp:" + data.isNativeApp);
console.info("installTime:" + data.installTime);
console.info("updateTime:" + data.updateTime);
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
console.info('getBundleInfo reqPermissions length [' + data.reqPermissions.length + ']');
for (var j = 0; j < data.reqPermissions.length; j++) {
console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]);
}
console.info('getBundleInfo defPermissions length [' + data.defPermissions.length + ']');
for (var j = 0; j < data.defPermissions.length; j++) {
console.info("defPermissions[" + j + "]:" + data.defPermissions[j]);
}
console.info('getBundleInfo hapModuleNames length [' + data.hapModuleNames.length + ']');
for (var j = 0; j < data.hapModuleNames.length; j++) {
console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]);
}
console.info('getBundleInfo moduleNames length [' + data.moduleNames.length + ']');
for (var j = 0; j < data.moduleNames.length; j++) {
console.info("moduleNames[" + j + "]:" + data.moduleNames[j]);
}
console.info('getBundleInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']');
for (var j = 0; j < data.modulePublicDirs.length; j++) {
console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]);
}
console.info('getBundleInfo moduleDirs length [' + data.moduleDirs.length + ']');
for (var j = 0; j < data.moduleDirs.length; j++) {
console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]);
}
console.info('getBundleInfo moduleResPaths length [' + data.moduleResPaths.length + ']');
for (var j = 0; j < data.moduleResPaths.length; j++) {
console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]);
}
console.info('getBundleInfo abilityInfo length [' + data.abilityInfos.length + ']');
for (var j = 0; j < data.abilityInfos.length; j++) {
console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name);
console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package);
}
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
"userId" : 100,
"networkId" : null
};
bundle.getBundleInfo(bundleName, bundleFlags, options)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -435,78 +255,61 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
| 名称 | 类型 | 必填 | 描述 |
| ----------- | -------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 包名 |
| bundleFlags | number | 是 | 0:返回默认BundleInfo<br/>1:返回包含abilityInfo的BundleInfo |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
| callback | AsyncCallback\<BundleInfo> | 是 | 程序启动作为入参的回调函数,返回包信息。 |
**示例:**
```js
bundle.getBundleInfo('com.example.myapplicationInstall', 1, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("vendor:" + data.vendor);
console.info("versionCode:" + data.versionCode);
console.info("versionName:" + data.versionName);
console.info("jointUserId:" + data.jointUserId);
console.info("minSdkVersion:" + data.minSdkVersion);
console.info("maxSdkVersion:" + data.maxSdkVersion);
console.info("mainEntry:" + data.mainEntry);
console.info("cpuAbi:" + data.cpuAbi);
console.info("appId:" + data.appId);
console.info("compatibleVersion:" + data.compatibleVersion);
console.info("targetVersion:" + data.targetVersion);
console.info("releaseType:" + data.releaseType);
console.info("uid:" + data.uid);
console.info("gid:" + data.gid);
console.info("seInfo:" + data.seInfo);
console.info("entryModuleName:" + data.entryModuleName);
console.info("isKeepAlive:" + data.isKeepAlive);
console.info("isNativeApp:" + data.isNativeApp);
console.info("installTime:" + data.installTime);
console.info("updateTime:" + data.updateTime);
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
console.info('getBundleInfo reqPermissions length [' + data.reqPermissions.length + ']');
for (var j = 0; j < data.reqPermissions.length; j++) {
console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]);
}
console.info('getBundleInfo defPermissions length [' + data.defPermissions.length + ']');
for (var j = 0; j < data.defPermissions.length; j++) {
console.info("defPermissions[" + j + "]:" + data.defPermissions[j]);
}
console.info('getBundleInfo hapModuleNames length [' + data.hapModuleNames.length + ']');
for (var j = 0; j < data.hapModuleNames.length; j++) {
console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]);
}
console.info('getBundleInfo moduleNames length [' + data.moduleNames.length + ']');
for (var j = 0; j < data.moduleNames.length; j++) {
console.info("moduleNames[" + j + "]:" + data.moduleNames[j]);
}
console.info('getBundleInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']');
for (var j = 0; j < data.modulePublicDirs.length; j++) {
console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]);
}
console.info('getBundleInfo moduleDirs length [' + data.moduleDirs.length + ']');
for (var j = 0; j < data.moduleDirs.length; j++) {
console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]);
}
console.info('getBundleInfo moduleResPaths length [' + data.moduleResPaths.length + ']');
for (var j = 0; j < data.moduleResPaths.length; j++) {
console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]);
}
console.info('getBundleInfo abilityInfo length [' + data.abilityInfos.length + ']');
for (var j = 0; j < data.abilityInfos.length; j++) {
console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name);
console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package);
}
}
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getBundleInfo
getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void
以异步方法根据给定的包名获取BundleInfo,使用callback形式返回结果。
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | -------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 包名 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
| options | BundleOptions | 是 | 包含userid和networkid。 |
| callback | AsyncCallback\<BundleInfo> | 是 | 程序启动作为入参的回调函数,返回包信息。 |
**示例:**
```js
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
"userId" : 100,
"networkId" : null
};
bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getAllApplicationInfo
......@@ -516,14 +319,14 @@ getAllApplicationInfo(bundleFlags: number, userId: number): Promise<Array\<Appli
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------ |
| bundleFlags | number | 是 | 0:返回默认应用信息<<br/>8:返回包含权限信息的应用信息 |
| userId | number | 是 | 用户ID |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
......@@ -534,44 +337,13 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
**示例:**
```js
bundle.getAllApplicationInfo(8, 0).then((data) => {
console.info('xxx getAllApplicationInfo data length [' + data.length + ']');
for (var i = 0; i < data.length; i++) {
console.info("index[" + i + "].name: for begin");
console.info("index[" + i + "].name:" + data[i].name);
console.info("index[" + i + "].bundleName:" + data[i].bundleName);
console.info("index[" + i + "].description:" + data[i].description);
console.info("index[" + i + "].descriptionId:" + data[i].descriptionId);
console.info("index[" + i + "].iconPath:" + data[i].iconPath);
console.info("index[" + i + "].iconId:" + data[i].iconId);
console.info("index[" + i + "].label:" + data[i].label);
console.info("index[" + i + "].labelId:" + data[i].labelId);
console.info("index[" + i + "].deviceId:" + data[i].deviceId);
console.info("index[" + i + "].signatureKey:" + data[i].signatureKey);
console.info("index[" + i + "].process:" + data[i].process);
console.info("index[" + i + "].isSystemApp:" + data[i].isSystemApp);
console.info("index[" + i + "].isLauncherApp:" + data[i].isLauncherApp);
console.info("index[" + i + "].supportedModes:" + data[i].supportedModes);
console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']');
for (var j = 0; j < data[i].permissions.length; j++) {
console.info("index[" + i + "]permissions[" + j + "]:" + data[i].permissions[j]);
}
console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']');
for (var j = 0; j < data[i].moduleSourceDirs.length; j++) {
console.info("index[" + i + "]moduleSourceDirs[" + j + "]:" + data[i].moduleSourceDirs[j]);
}
console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']');
for (var j = 0; j < data[i].moduleInfos.length; j++) {
console.info("index[" + i + "]moduleInfos[" + j + "]moduleName:" + data[i].moduleInfos[j].moduleName);
console.info("index[" + i + "]moduleInfos[" + j + "]moduleSourceDir:" + data[i].moduleInfos[j].moduleSourceDir);
}
console.info("index[" + i + "].entryDir:" + data[i].entryDir);
console.info("index[" + i + "].codePath:" + data[i].codePath);
console.info("index[" + i + "].dataDir:" + data[i].dataDir);
console.info("index[" + i + "].dataBaseDir:" + data[i].dataBaseDir);
console.info("index[" + i + "].cacheDir:" + data[i].cacheDir);
}
let bundleFlags = 8;
let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -585,60 +357,28 @@ getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallba
**需要权限:**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ----------- | -------------------------------------- | ---- | ------------------------------------------------------ |
| bundleFlags | number | 是 | 0:返回默认应用信息<<br/>8:返回包含权限信息的应用信息 |
| userId | number | 是 | 用户ID |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。|
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback<Array\<ApplicationInfo>> | 是 | 程序启动作为入参的回调函数,返回应用信息列表。 |
**示例:**
```js
bundle.getAllApplicationInfo(8, 0, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info('xxx getAllApplicationInfo data length [' + data.length + ']');
for (var i = 0; i < data.length; i++) {
console.info("index[" + i + "].name: for begin");
console.info("index[" + i + "].name:" + data[i].name);
console.info("index[" + i + "].bundleName:" + data[i].bundleName);
console.info("index[" + i + "].description:" + data[i].description);
console.info("index[" + i + "].descriptionId:" + data[i].descriptionId);
console.info("index[" + i + "].iconPath:" + data[i].iconPath);
console.info("index[" + i + "].iconId:" + data[i].iconId);
console.info("index[" + i + "].label:" + data[i].label);
console.info("index[" + i + "].labelId:" + data[i].labelId);
console.info("index[" + i + "].deviceId:" + data[i].deviceId);
console.info("index[" + i + "].signatureKey:" + data[i].signatureKey);
console.info("index[" + i + "].process:" + data[i].process);
console.info("index[" + i + "].isSystemApp:" + data[i].isSystemApp);
console.info("index[" + i + "].isLauncherApp:" + data[i].isLauncherApp);
console.info("index[" + i + "].supportedModes:" + data[i].supportedModes);
console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']');
for (var j = 0; j < data[i].permissions.length; j++) {
console.info("index[" + i + "]permissions[" + j + "]:" + data[i].permissions[j]);
}
console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']');
for (var j = 0; j < data[i].moduleSourceDirs.length; j++) {
console.info("index[" + i + "]moduleSourceDirs[" + j + "]:" + data[i].moduleSourceDirs[j]);
}
console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']');
for (var j = 0; j < data[i].moduleInfos.length; j++) {
console.info("index[" + i + "]moduleInfos[" + j + "]moduleName:" + data[i].moduleInfos[j].moduleName);
console.info("index[" + i + "]moduleInfos[" + j + "]moduleSourceDir:" + data[i].moduleInfos[j].moduleSourceDir);
}
console.info("index[" + i + "].entryDir:" + data[i].entryDir);
console.info("index[" + i + "].codePath:" + data[i].codePath);
console.info("index[" + i + "].dataDir:" + data[i].dataDir);
console.info("index[" + i + "].dataBaseDir:" + data[i].dataBaseDir);
console.info("index[" + i + "].cacheDir:" + data[i].cacheDir);
}
}
let bundleFlags = 8;
let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
......@@ -658,7 +398,7 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 包含要查询的应用程序包名称的意图。 |
| bundleFlags | number | 是 | 0:返回默认AbilityInfo<br/>2:返回包含权限信息的AbilityInfo<br/>4:返回包含应用信息的AbilityInfo |
| bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:大于等于0。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0 |
**返回值:**
......@@ -670,80 +410,17 @@ ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
**示例:**
```js
bundle.queryAbilityByWant({
want: {
action: "action.system.home",
entities: ["entity.system.home"],
elementName: {
deviceId: "0",
bundleName: "com.example.myapplicationInstall",
abilityName: "com.example.myapplication.MainAbility",
},
}
}, 1, 0,
}).then((data) => {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("iconPath:" + data.iconPath);
console.info("visible:" + data.visible);
console.info("kind:" + data.kind);
console.info("uri:" + data.uri);
console.info("process:" + data.process);
console.info("package:" + data.package);
console.info("bundleName:" + data.bundleName);
console.info("moduleName:" + data.moduleName);
console.info("applicationName:" + data.applicationName);
console.info("deviceId:" + data.deviceId);
console.info("codePath:" + data.codePath);
console.info("resourcePath:" + data.resourcePath);
console.info("libPath:" + data.libPath);
console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']');
for (var j = 0; j < data.permissions.length; j++) {
console.info("permissions[" + j + "]:" + data.permissions[j]);
}
console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']');
for (var j = 0; j < data.deviceTypes.length; j++) {
console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]);
}
console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']');
for (var j = 0; j < data.deviceCapabilities.length; j++) {
console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]);
}
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
// ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA
console.info("type:" + data.type);
// orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT,
console.info("orientation:" + data.orientation);
// launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD
console.info("launchMode:" + data.launchMode);
// the enum of AbilityType
console.info("AbilityType:" + bundle.AbilityType.UNKNOWN);
console.info("AbilityType:" + bundle.AbilityType.PAGE);
console.info("AbilityType:" + bundle.AbilityType.SERVICE);
console.info("AbilityType:" + bundle.AbilityType.DATA);
if (data.type == bundle.AbilityType.PAGE) {
console.info("this AbilityType is PAGE");
}
// the enum of DisplayOrientation
console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT);
if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) {
console.info("this DisplayOrientation is UNSPECIFIED");
}
// the enum of LaunchMode
console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON);
console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP);
console.info("LaunchMode:" + bundle.LaunchMode.STANDARD);
if (data.launchMode == bundle.LaunchMode.STANDARD) {
console.info("this LaunchMode is STANDARD");
}
let bundleFlags = 0;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryAbilityByWant(want, bundleFlags, userId)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -760,90 +437,26 @@ queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: As
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 指示包含要查询的应用程序包名称的意图。 |
| bundleFlags | number | 是 | 0:返回默认AbilityInfo<br/>2:返回包含权限信息的AbilityInfo<br/>4:返回包含应用信息的AbilityInfo |
| userId | number | 是 | 用户ID |
| bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:大于等于0。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0 |
| callback | AsyncCallback<Array\<AbilityInfo>> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 |
**示例:**
```js
bundle.queryAbilityByWant(
{
want: {
action: "action.system.home",
entities: ["entity.system.home"],
elementName: {
deviceId: "0",
bundleName: "com.example.myapplicationInstall",
abilityName: "com.example.myapplication.MainAbility",
},
}
}, 1, 0,
}, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("iconPath:" + data.iconPath);
console.info("visible:" + data.visible);
console.info("kind:" + data.kind);
console.info("uri:" + data.uri);
console.info("process:" + data.process);
console.info("package:" + data.package);
console.info("bundleName:" + data.bundleName);
console.info("moduleName:" + data.moduleName);
console.info("applicationName:" + data.applicationName);
console.info("deviceId:" + data.deviceId);
console.info("codePath:" + data.codePath);
console.info("resourcePath:" + data.resourcePath);
console.info("libPath:" + data.libPath);
console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']');
for (var j = 0; j < data.permissions.length; j++) {
console.info("permissions[" + j + "]:" + data.permissions[j]);
}
console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']');
for (var j = 0; j < data.deviceTypes.length; j++) {
console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]);
}
console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']');
for (var j = 0; j < data.deviceCapabilities.length; j++) {
console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]);
}
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
// ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA
console.info("type:" + data.type);
// orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT,
console.info("orientation:" + data.orientation);
// launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD
console.info("launchMode:" + data.launchMode);
// the enum of AbilityType
console.info("AbilityType:" + bundle.AbilityType.UNKNOWN);
console.info("AbilityType:" + bundle.AbilityType.PAGE);
console.info("AbilityType:" + bundle.AbilityType.SERVICE);
console.info("AbilityType:" + bundle.AbilityType.DATA);
if (data.type == bundle.AbilityType.PAGE) {
console.info("this AbilityType is PAGE");
}
// the enum of DisplayOrientation
console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT);
if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) {
console.info("this DisplayOrientation is UNSPECIFIED");
}
// the enum of LaunchMode
console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON);
console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP);
console.info("LaunchMode:" + bundle.LaunchMode.STANDARD);
if (data.launchMode == bundle.LaunchMode.STANDARD) {
console.info("this LaunchMode is STANDARD");
}
}
let bundleFlags = 0;
let userId = 100;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.queryAbilityByWant
......@@ -857,89 +470,24 @@ queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback<Arra
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
| want | Want | 是 | 指示包含要查询的应用程序包名称的意图。 |
| bundleFlags | number | 是 | 0:返回默认AbilityInfo<br/>2:返回包含权限信息的AbilityInfo<br/>4:返回包含应用信息的AbilityInfo |
| bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:大于等于0。 |
| callback | AsyncCallback<Array\<AbilityInfo>> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 |
**示例:**
```js
bundle.queryAbilityByWant(
{
want: {
action: "action.system.home",
entities: ["entity.system.home"],
elementName: {
deviceId: "0",
bundleName: "com.example.myapplicationInstall",
abilityName: "com.example.myapplication.MainAbility",
},
}
}, 1,
}, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("iconPath:" + data.iconPath);
console.info("visible:" + data.visible);
console.info("kind:" + data.kind);
console.info("uri:" + data.uri);
console.info("process:" + data.process);
console.info("package:" + data.package);
console.info("bundleName:" + data.bundleName);
console.info("moduleName:" + data.moduleName);
console.info("applicationName:" + data.applicationName);
console.info("deviceId:" + data.deviceId);
console.info("codePath:" + data.codePath);
console.info("resourcePath:" + data.resourcePath);
console.info("libPath:" + data.libPath);
console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']');
for (var j = 0; j < data.permissions.length; j++) {
console.info("permissions[" + j + "]:" + data.permissions[j]);
}
console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']');
for (var j = 0; j < data.deviceTypes.length; j++) {
console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]);
}
console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']');
for (var j = 0; j < data.deviceCapabilities.length; j++) {
console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]);
}
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
// ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA
console.info("type:" + data.type);
// orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT,
console.info("orientation:" + data.orientation);
// launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD
console.info("launchMode:" + data.launchMode);
// the enum of AbilityType
console.info("AbilityType:" + bundle.AbilityType.UNKNOWN);
console.info("AbilityType:" + bundle.AbilityType.PAGE);
console.info("AbilityType:" + bundle.AbilityType.SERVICE);
console.info("AbilityType:" + bundle.AbilityType.DATA);
if (data.type == bundle.AbilityType.PAGE) {
console.info("this AbilityType is PAGE");
}
// the enum of DisplayOrientation
console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT);
console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT);
if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) {
console.info("this DisplayOrientation is UNSPECIFIED");
}
// the enum of LaunchMode
console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON);
console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP);
console.info("LaunchMode:" + bundle.LaunchMode.STANDARD);
if (data.launchMode == bundle.LaunchMode.STANDARD) {
console.info("this LaunchMode is STANDARD");
}
}
let bundleFlags = 0;
let want = {
bundleName : "com.example.myapplication",
abilityName : "com.example.myapplication.MainAbility"
};
bundle.queryAbilityByWant(want, bundleFlags, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getBundleArchiveInfo
......@@ -953,7 +501,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise\<BundleI
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| hapFilePath | string | 是 | HAP文件路径 |
| bundleFlags | number | 是 | 0:返回默认BundleInfo<br/>1:返回包含abilityInfo的BundleInfo |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
**返回值:**
......@@ -964,65 +512,13 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise\<BundleI
**示例:**
```js
bundle.getBundleArchiveInfo('/data/test.hap', 1).then((data) => {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("vendor:" + data.vendor);
console.info("versionCode:" + data.versionCode);
console.info("versionName:" + data.versionName);
console.info("jointUserId:" + data.jointUserId);
console.info("minSdkVersion:" + data.minSdkVersion);
console.info("maxSdkVersion:" + data.maxSdkVersion);
console.info("mainEntry:" + data.mainEntry);
console.info("cpuAbi:" + data.cpuAbi);
console.info("appId:" + data.appId);
console.info("compatibleVersion:" + data.compatibleVersion);
console.info("targetVersion:" + data.targetVersion);
console.info("releaseType:" + data.releaseType);
console.info("uid:" + data.uid);
console.info("gid:" + data.gid);
console.info("seInfo:" + data.seInfo);
console.info("entryModuleName:" + data.entryModuleName);
console.info("isKeepAlive:" + data.isKeepAlive);
console.info("isNativeApp:" + data.isNativeApp);
console.info("installTime:" + data.installTime);
console.info("updateTime:" + data.updateTime);
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
console.info('getBundleArchiveInfo reqPermissions length [' + data.reqPermissions.length + ']');
for (var j = 0; j < data.reqPermissions.length; j++) {
console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]);
}
console.info('getBundleArchiveInfo defPermissions length [' + data.defPermissions.length + ']');
for (var j = 0; j < data.defPermissions.length; j++) {
console.info("defPermissions[" + j + "]:" + data.defPermissions[j]);
}
console.info('getBundleArchiveInfo hapModuleNames length [' + data.hapModuleNames.length + ']');
for (var j = 0; j < data.hapModuleNames.length; j++) {
console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]);
}
console.info('getBundleArchiveInfo moduleNames length [' + data.moduleNames.length + ']');
for (var j = 0; j < data.moduleNames.length; j++) {
console.info("moduleNames[" + j + "]:" + data.moduleNames[j]);
}
console.info('getBundleArchiveInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']');
for (var j = 0; j < data.modulePublicDirs.length; j++) {
console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]);
}
console.info('getBundleArchiveInfo moduleDirs length [' + data.moduleDirs.length + ']');
for (var j = 0; j < data.moduleDirs.length; j++) {
console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]);
}
console.info('getBundleArchiveInfo moduleResPaths length [' + data.moduleResPaths.length + ']');
for (var j = 0; j < data.moduleResPaths.length; j++) {
console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]);
}
console.info('getBundleArchiveInfo abilityInfo length [' + data.abilityInfos.length + ']');
for (var j = 0; j < data.abilityInfos.length; j++) {
console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name);
console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package);
}
let hapFilePath = "/data/test.hap";
let bundleFlags = 1;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -1037,74 +533,21 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCa
| 名称 | 类型 | 必填 | 描述 |
| ----------- | ------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePath | string | 是 | HAP文件路径 |
| bundleFlags | number | 是 | 0:返回默认BundleInfo<br/>1:返回包含abilityInfo的BundleInfo |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 |
| callback | AsyncCallback<BundleInfo> | 是 | 程序启动作为入参的回调函数,返回包信息。 |
**示例:**
```js
bundle.getBundleArchiveInfo('/data/test.hap', 1, OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.info("name:" + data.name);
console.info("label:" + data.label);
console.info("description:" + data.description);
console.info("vendor:" + data.vendor);
console.info("versionCode:" + data.versionCode);
console.info("versionName:" + data.versionName);
console.info("jointUserId:" + data.jointUserId);
console.info("minSdkVersion:" + data.minSdkVersion);
console.info("maxSdkVersion:" + data.maxSdkVersion);
console.info("mainEntry:" + data.mainEntry);
console.info("cpuAbi:" + data.cpuAbi);
console.info("appId:" + data.appId);
console.info("compatibleVersion:" + data.compatibleVersion);
console.info("targetVersion:" + data.targetVersion);
console.info("releaseType:" + data.releaseType);
console.info("uid:" + data.uid);
console.info("gid:" + data.gid);
console.info("seInfo:" + data.seInfo);
console.info("entryModuleName:" + data.entryModuleName);
console.info("isKeepAlive:" + data.isKeepAlive);
console.info("isNativeApp:" + data.isNativeApp);
console.info("installTime:" + data.installTime);
console.info("updateTime:" + data.updateTime);
console.info("appInfo.name:" + data.applicationInfo.name);
console.info("appInfo.bundleName:" + data.applicationInfo.bundleName);
console.info('getBundleArchiveInfo reqPermissions length [' + data.reqPermissions.length + ']');
for (var j = 0; j < data.reqPermissions.length; j++) {
console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]);
}
console.info('getBundleArchiveInfo defPermissions length [' + data.defPermissions.length + ']');
for (var j = 0; j < data.defPermissions.length; j++) {
console.info("defPermissions[" + j + "]:" + data.defPermissions[j]);
}
console.info('getBundleArchiveInfo hapModuleNames length [' + data.hapModuleNames.length + ']');
for (var j = 0; j < data.hapModuleNames.length; j++) {
console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]);
}
console.info('getBundleArchiveInfo moduleNames length [' + data.moduleNames.length + ']');
for (var j = 0; j < data.moduleNames.length; j++) {
console.info("moduleNames[" + j + "]:" + data.moduleNames[j]);
}
console.info('getBundleArchiveInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']');
for (var j = 0; j < data.modulePublicDirs.length; j++) {
console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]);
}
console.info('getBundleArchiveInfo moduleDirs length [' + data.moduleDirs.length + ']');
for (var j = 0; j < data.moduleDirs.length; j++) {
console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]);
}
console.info('getBundleArchiveInfo moduleResPaths length [' + data.moduleResPaths.length + ']');
for (var j = 0; j < data.moduleResPaths.length; j++) {
console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]);
}
console.info('getBundleArchiveInfo abilityInfo length [' + data.abilityInfos.length + ']');
for (var j = 0; j < data.abilityInfos.length; j++) {
console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name);
console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package);
}
}
let hapFilePath = "/data/test.hap";
let bundleFlags = 1;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.getBundleInstaller
......@@ -1113,6 +556,10 @@ getBundleInstaller(): Promise<BundleInstaller>
以异步方法获取BundleInstaller,使用Promise形式返回结果。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**返回值:**
| 类型 | 说明 |
......@@ -1122,20 +569,23 @@ getBundleInstaller(): Promise<BundleInstaller>
**示例:**
```js
bundle.getBundleInstaller().then((data) => {
data.install(['/data/test.hap'], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, OnReceiveinstallEvent);
function OnReceiveinstallEvent(err, data) {
console.info("name: for begin");
console.info("install result code:" + data.status);
console.info("install result msg:" + data.statusMessage);
}
let bundleFilePaths = ['/data/test.hap'];
let param = {
userId : 100,
installFlag : 1,
isKeepData : false
};
bundle.getBundleInstaller()
.then((installerObject) => {
console.info('Operation successful. ');
installerObject.install(bundleFilePaths, param)
.then((data) => {
console.info('Operation successful. Data:' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
......@@ -1145,6 +595,10 @@ getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void;
以异步方法获取BundleInstaller,使用callback形式返回结果。
**需要权限:**
ohos.permission.INSTALL_BUNDLE
**参数:**
| 名称 | 类型 | 必填 | 描述 |
......@@ -1154,121 +608,139 @@ getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void;
**示例:**
```js
bundle.getBundleInstaller((err, data)=>{
data.uninstall('com.example.myapplication', {
userId: 0,
installFlag: 1,
isKeepData: false
}, OnReceiveinstallEvent);
function OnReceiveinstallEvent(err, data) {
console.info("name: for begin");
console.info("uninstall result code:" + data.status);
console.info("uninstall result msg:" + data.statusMessage);
}
let bundleFilePaths = ['/data/test.hap'];
let param = {
userId : 100,
installFlag : 1,
isKeepData : false
};
bundle.getBundleInstaller((err, installerObject) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
}
console.info('Operation successful. Data:' + JSON.stringify(installerObject));
installerObject.install(bundleFilePaths, param, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
})
```
## bundle.getAllShortcutInfo
getAllShortcutInfo(bundleName: string): Promise<Array<ShortcutInfo>>
## bundle.getLaunchWantForBundle
getLaunchWantForBundle(bundleName: string): Promise\<Want>
以异步方法获取指定bundle的Shortcut信息,使用Promise形式返回结果。
以异步方法查询拉起指定应用的want对象,使用Promise形式返回结果。
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | -------- |
| bundleName | string | 是 | bundle名 |
| bundleName | string | 是 | 要查询的应用程序包名称。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------- | ---------------------------------------------------- |
| Promise\<Array<ShortcutInfo>> | 返回值为Promise对象,Promise中包含Shortcut信息列表。 |
| --------------------- | ------------------------------------------------------------ |
| Promise\<Want> | 返回值为Promise对象,Promise中包含拉起指定应用的Want对象。 |
**示例:**
```js
bundle.getAllShortcutInfo('com.example.third1').then((data) => {
console.log("getAllShortcutInfo data:" + data);
});
let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.getLaunchWantForBundle
getLaunchWantForBundle(bundleName: string, callback: AsyncCallback<Want>): void;
## bundle.getAllShortcutInfo
getAllShortcutInfo(bundleName: string, callback: AsyncCallback<Array\<ShortcutInfo>>): void
以异步方法获取指定bundle的Shortcut信息,使用callback形式返回结果。
以异步方法查询拉起指定应用的want对象,使用callback形式返回结果。
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------------------------------------ | ---- | -------------------------------------------------- |
| bundleName | string | 是 | bundle名 |
| callback | AsyncCallback<<Array\<ShortcutInfo>> | 是 | 程序启动作为入参的回调函数,返回Shortcut信息列表。 |
| ---------- | ------ | ---- | -------- |
| bundleName | string | 是 | 要查询的应用程序包名称。 |
| callback | AsyncCallback\<Want> | 是 | 程序启动作为入参的回调函数,返回拉起指定应用的want对象。 |
**示例:**
```js
bundle.getAllShortcutInfo('com.example.third1', OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.log("getAllShortcutInfo data:" + data);
}
let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## bundle.checkPermission
checkPermission(bundleName: string, permission: string): Promise\<GrantStatus>
## bundle.getNameForUid
getNameForUid(uid: number): Promise\<string>
以异步方法校验指定bundle是否具有指定权限,使用Promise形式返回结果。
以异步方法通过uid获取对应的包名,使用Promise形式返回结果。
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | ------ | ---- | -------- |
| bundleName | string | 是 | bundle名 |
| permission | string | 是 | 权限名 |
| uid | number | 是 | 要查询的uid。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------------------------------------------ |
| Promise\<GrantStatus> | 返回值为Promise对象,Promise中包含校验结果。<br/>-1: 未授权 <br/>0: 已授权 |
| Promise\<string> | 返回值为Promise对象,Promise中包含指定uid的包名。 |
**示例:**
```js
bundle.checkPermission('com.example.actsbmscheckpermissiontest', 'com.permission.CAMERA').then((data) => {
console.log("checkPermission data:" + data);
});
let uid = 20010005;
bundle.getNameForUid(uid)
.then((data) => {
console.info('Operation successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.checkPermission
## bundle.getNameForUid
checkPermission(bundleName: string, permission: string, callback: AsyncCallback\<GrantStatus>): void
getNameForUid(uid: number, callback: AsyncCallback<string>): void;
以异步方法校验指定bundle是否具有指定权限,使用callback形式返回结果。
以异步方法通过uid获取对应的包名,使用callback形式返回结果。
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------- | --------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | bundle名 |
| permission | string | 是 | 权限名 |
| callback | AsyncCallback\<GrantStatus> | 是 | 程序启动作为入参的回调函数,返回校验结果。<br/>-1: 未授权 <br/>0: 已授权 |
| ---------- | ------ | ---- | -------- |
| uid | number | 是 | 要查询的uid。 |
| callback | AsyncCallback\<string> | 是 | 程序启动作为入参的回调函数,返回指定uid的包名。 |
**示例:**
```js
bundle.checkPermission('com.example.actsbmscheckpermissiontest', 'com.permission.CAMERA', OnReceiveEvent);
function OnReceiveEvent(err, data) {
console.log("checkPermission data:" + data);
}
let uid = 20010005;
bundle.getNameForUid(uid, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
return;
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
```
## ElementName
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
......@@ -1283,3 +755,208 @@ function OnReceiveEvent(err, data) {
| ------------- | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| status | 只读 | InstallErrorCode | 是 | 安装结果code<br/>SUCCESS = 0<br/>STATUS_INSTALL_FAILURE = 1<br/>STATUS_INSTALL_FAILURE_ABORTED = 2,<br/>STATUS_INSTALL_FAILURE_INVALID = 3<br/>STATUS_INSTALL_FAILURE_CONFLICT = 4<br/>STATUS_INSTALL_FAILURE_STORAGE = 5<br/>STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6<br/>STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B<br/>STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C<br/>STATUS_ABILITY_NOT_FOUND = 0x40<br/>STATUS_BMS_SERVICE_ERROR = 0x41 |
| statusMessage | 只读 | string | 是 | 安装结果Message |
## BundleFlag
包的标志
| 名称 | 默认值 | 说明 |
| ------ | ------ | ------ |
| GET_BUNDLE_DEFAULT | 0x00000000 | 获取默认的应用信息 |
| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | 获取包括Ability信息的包信息 |
| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | 获取包括权限的Ability信息 |
| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | 获取包括应用的Ability信息 |
| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | 获取包括权限的应用信息 |
| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | 获取包括所需权限的包信息 |
| GET_ABILITY_INFO_WITH_METADATA | 0x00000020 | 获取ability的元数据信息 |
| GET_APPLICATION_INFO_WITH_METADATA | 0x00000040 | 获取应用的元数据信息 |
| GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | 获取仅包括系统应用的ability信息 |
| GET_ABILITY_INFO_WITH_DISABLE | 0x00000100 | 获取包括被禁用的ability信息 |
| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000200 | 获取包括被禁用的应用信息 |
## BundleOptions
包的选项
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| networkId | string | 是 | 是 | 网络Id,默认值:null。 |
## BundleInfo
应用包的信息。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| name | string | 是 | 否 | 应用包的名称 |
| type | string | 是 | 否 | 应用包类型 |
| appId | string | 是 | 否 | 应用包里应用程序的id |
| uid | number | 是 | 否 | 应用包里应用程序的uid |
| installTime | number | 是 | 否 | HAP包安装时间 |
| updateTime | number | 是 | 否 | HAP包更新时间 |
| appInfo | ApplicationInfo | 是 | 否 | 应用程序的配置信息 |
| abilityInfo | Array<AbilityInfo> | 是 | 否 | Ability的配置信息 |
| reqPermissions | Array<string> | 是 | 否 | 应用运行时需向系统申请的权限集合 |
| reqPermissionDetails | Array<ReqPermissionDetail> | 是 | 否 | 应用运行时需向系统申请的权限集合的详细信息 |
| vendor | string | 是 | 否 | 应用包的供应商 |
| versionCode | number | 是 | 否 | 应用包的版本号 |
| versionName | string | 是 | 否 | 应用包的版本文本描述信息 |
| compatibleVersion | number | 是 | 否 | 运行应用包所需要最低的SDK版本号 |
| targetVersion | number | 是 | 否 | 运行应用包所需要最高SDK版本号 |
| isCompressNativeLibs | boolean | 是 | 否 | 是否压缩应用包的本地库,默认为true |
| hapModuleInfo | Array<HapModuleInfo> | 是 | 否 | 模块的配置信息 |
| entryModuleName | string | 是 | 否 | Entry的模块名称 |
| cpuAbi | string | 是 | 否 | 应用包的cpuAbi信息 |
| isSilentInstallation | string | 是 | 否 | 是否通过静默安装 |
| minCompatibleVersionCode | number | 是 | 否 | 分布式场景下的应用包兼容的最低版本 |
| entryInstallationFree | boolean | 是 | 否 | Entry是否支持免安装 |
| reqPermissionStates | Array<number> | 是 | 否 | 申请权限的授予状态 |
## ApplicationInfo
应用程序信息。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| name | string | 是 | 否 | 应用程序的名称 |
| description | string | 是 | 否 | 应用程序的描述 |
| descriptionId | number | 是 | 否 | 应用程序的描述id |
| systemApp | boolean | 是 | 否 | 判断是否为系统应用程序,默认为false |
| enabled | boolean | 是 | 否 | 判断应用程序是否可以使用,默认为true |
| label | string | 是 | 否 | 应用程序的标签 |
| labelId | string | 是 | 否 | 应用程序的标签id |
| icon | string | 是 | 否 | 应用程序的图标 |
| iconId | string | 是 | 否 | 应用程序的图标id |
| process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称 |
| supportedModes | number | 是 | 否 | 应用程序支持的运行模式 |
| moduleSourceDirs | Array<string> | 是 | 否 | 应用程序的资源存放的相对路径 |
| permissions | Array<string> | 是 | 否 | 访问应用程序所需的权限 |
| moduleInfos | Array<ModuleInfo> | 是 | 否 | 应用程序的模块信息 |
| entryDir | string | 是 | 否 | 应用程序的文件保存路径 |
| customizeData | Map<string, Array<CustomizeData>> | 是 | 是 | 应用程序的自定义数据 |
| codePath | string | 是 | 否 | 应用程序的安装目录 |
| metaData | Map<string, Array<CustomizeData>> | 是 | 否 | 应用程序的自定义元信息 |
| removable | boolean | 是 | 否 | 应用程序是否可以被移除 |
| accessTokenId | number | 是 | 否 | 应用程序的accessTokenId |
| uid | number | 是 | 否 | 应用程序的uid |
## ModuleInfo
应用程序的模块信息。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| moduleName | string | 是 | 否 | 模块名称 |
| moduleSourceDir | string | 是 | 否 | 安装目录 |
## CustomizeData
自定义元数据。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ---------------- |
| name | string | 是 | 是 | 自定义元数据名称 |
| value | string | 是 | 是 | 自定义元数据值 |
| extra | string | 是 | 是 | 自定义资源 |
## HapModuleInfo
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| name | string | 是 | 否 | 模块名称 |
| description | string | 是 | 否 | 模块描述信息 |
| descriptionId | number | 是 | 否 | 描述信息ID |
| icon | string | 是 | 否 | 模块图标 |
| label | string | 是 | 否 | 模块标签 |
| labelId | number | 是 | 否 | 模块标签ID |
| iconId | number | 是 | 否 | 模块图标ID |
| backgroundImg | string | 是 | 否 | 模块背景图片 |
| supportedModes | number | 是 | 否 | 模块支持的模式 |
| reqCapabilities | Array<string> | 是 | 否 | 模块运行需要的能力 |
| deviceTypes | Array<string> | 是 | 否 | 支持运行的设备类型 |
| abilityInfo | Array<AbilityInfo> | 是 | 否 | Ability信息 |
| moduleName | string | 是 | 否 | 模块名 |
| mainAbilityName | string | 是 | 否 | 入口Ability名称 |
| installationFree | boolean | 是 | 否 | 是否支持免安装 |
| mainElementName | string | 是 | 否 | 入口ability信息 |
## ReqPermissionDetail
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| name | string | 是 | 是 | 需要使用的权限名称 |
| reason | string | 是 | 是 | 描述申请权限的原因 |
| usedScene | UsedScene | 是 | 是 | 权限使用的场景和时机 |
## UsedScene
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| abilities | Array<string> | 是 | 是 | 使用到该权限的Ability集合 |
| when | string | 是 | 是 | 使用该权限的时机 |
## AbilityInfo
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| bundleName | string | 是 | 否 | 应用包名 |
| name | string | 是 | 否 | Ability名称 |
| label | string | 是 | 否 | Ability对用户显示的名称 |
| description | string | 是 | 否 | Ability的描述 |
| icon | string | 是 | 否 | Ability的图标资源文件索引 |
| descriptionId | number | 是 | 否 | Ability的描述id |
| iconId | number | 是 | 否 | Ability的图标id |
| moduleName | string | 是 | 否 | Ability所属的HAP包的名称 |
| process | string | 是 | 否 | Ability的进程,如果不设置,默认为包的名称 |
| targetAbility | string | 是 | 否 | 当前Ability重用的目标Ability |
| backgroundModes | number | 是 | 否 | 表示后台服务的类型 |
| isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 |
| formEnabled | boolean | 是 | 否 | 判断Ability是否提供卡片能力 |
| type | AbilityType | 是 | 否 | Ability类型 |
| orientation | DisplayOrientation | 是 | 否 | Ability的显示模式 |
| launchMode | LaunchMode | 是 | 否 | Ability的启动模式 |
| permissions | Array<string> | 是 | 否 | 被其他应用Ability调用时需要申请的权限集合 |
| deviceTypes | Array<string> | 是 | 否 | Ability支持的设备类型 |
| deviceCapabilities | Array<string> | 是 | 否 | Ability需要的设备能力 |
| readPermission | string | 是 | 否 | 读取Ability数据所需的权限 |
| writePermission | string | 是 | 否 | 向Ability写数据所需的权限 |
| applicationInfo | ApplicationInfo | 是 | 否 | 应用程序的配置信息 |
| formEntity | number | 是 | 否 | 显示表单的位置 |
| minFormHeight | number | 是 | 否 | Ability的最小高度 |
| defaultFormHeight | number | 是 | 否 | Ability的默认高度 |
| minFormWidth | number | 是 | 否 | Ability的最小宽度 |
| defaultFormWidth | number | 是 | 否 | Ability的默认宽度 |
| uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI) |
| customizeData | Map<string, Array<CustomizeData>> | 是 | 是 | Ability的自定义数据 |
| labelId | number | 是 | 否 | Ability的标签id |
| subType | AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型 |
| metaData | Array<Metadata> | 是 | 否 | ability的自定义元信息 |
| enabled | boolean | 是 | 否 | ability是否可用 |
## AbilityType
| 名称 | 类型 | 说明 |
| ------- | ---- | --------------------------- |
| UNKNOWN | 无 | 未知Ability类型 |
| PAGE | 无 | Ability有一个UI界面 |
| SERVICE | 无 | Ability没有UI界面 |
| DATA | 无 | Ability用于提供数据访问服务 |
## DisplayOrientation
| 名称 | 类型 | 说明 |
| ------------- | ---- | ------------------------ |
| UNSPECIFIED | 无 | 屏幕方向--不指定 |
| LANDSCAPE | 无 | 屏幕方向--横屏 |
| PORTRAIT | 无 | 屏幕方向--竖屏 |
| FOLLOW_RECENT | 无 | 屏幕方向--紧跟上一个组件 |
## LaunchMode
| 名称 | 类型 | 说明 |
| ----------- | ---- | ------------------- |
| UNSPECIFIED | 0 | Ability只有一个示例 |
| STANDARD | 1 | Ability有多个示例 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册