修复当安装的应用超过5个时,无法获取应用列表信息的问题 Created-by: toolsmanhehe Commit-by: toolsmanhehe Merged-by: openharmony_ci Description: **IssueNo**: [#165](https://gitcode.com/openharmony/bundlemanager_bundle_framework_lite/issues/165) ## 各平台影响分析 | 平台 | 内核类型 | `__LINUX__` 宏 | 编译的源文件 | 修改前行为 | 修改后行为 | 是否受影响 | | ------------------------- | -------- | -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ---------------- | | **标准系统** | Linux | **未定义** | 不编译此文件(使用 `bundle_framework` 而非 `bundle_framework_lite`) | N/A | N/A | **无影响** | | **LiteOS + Linux内核** | linux | **定义** | `src/bundle_manager.cpp` | `ObtainInnerBundleInfos` 一次性获取,多应用时 IPC 数据超 8KB 限制导致失败 | `ObtainBundleInfos` 分批获取(先取数量,再逐个取),每次 IPC 仅传单个 BundleInfo | **修复目标平台** | | **LiteOS + LiteOS-A内核** | liteos_a | **未定义** | `src/bundle_manager.cpp` | `ObtainInnerBundleInfos` 一次性获取 | `ObtainInnerBundleInfos` 一次性获取(走 `#else` 分支,与修改前完全一致) | **无影响** | | **LiteOS + LiteOS-M内核** | liteos_m | **未定义** | `src/slite/bundle_manager.cpp`(不同源文件) | N/A | N/A | **无影响** | ## 关键说明 1. **标准系统完全不受影响**:标准系统使用 `foundation/bundlemanager/bundle_framework/`(非 lite 版本),根本不编译 `bundle_framework_lite` 下的代码。 2. **LiteOS-M 完全不受影响**:`liteos_m` 内核编译的是 `src/slite/bundle_manager.cpp`,不是我们修改的 `src/bundle_manager.cpp`。 3. **LiteOS-A 不受影响**:`liteos_a` 内核虽然编译 `src/bundle_manager.cpp`,但 `__LINUX__` 未定义,走 `#else` 分支,逻辑与修改前完全一致。 4. **仅 LiteOS+Linux 内核受影响**:`__LINUX__` 宏仅在 `ohos_kernel_type == "linux"` 时由 `build/lite/config/BUILD.gn` 全局定义(`-D__LINUX__`),修改仅对此配置生效。 **Description**: **稳定性自检:** | 自检项 | 自检结果 | | ------------------------------------------------------------ | -------- | | 涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发 | | | 成员变量进行赋值或创建需要排查并发 | | | 谨慎在lambda表达式中使用引用捕获 | | | 谨慎在未经拷贝的情况下使用外部传入的string、C字符串 | | | map\vector\list\set等stl模板类使用时需要排查并发 | | | 谨慎考虑加锁范围 | | | 在IPC通信中谨慎使用同步通信方式 | | | 禁止传递this指针至其他模块或线程(特别是eventhandler任务) | | | 禁止将外部传入的裸指针在内部直接构造智能指针 | | | 禁止多个独立创建的智能指针管理同一地址 | | | 禁止在析构函数中抛异步任务 | | | 禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁 | | | 禁止在对外接口中未经判空直接使用外部传入的指针 | | | 禁止接口返回局部变量引用 | | | 禁止在信号函数中加锁 | | | 禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作 | | | 禁止将同一个cpp编译在不同的so中 | | **安全编码自检:** | 自检项 | 自检结果 | | -------------------------------------------------------------- | -------- | | 裸指针避免通过隐式转换构造为sptr | | | json对象在取值之前必须先判断类型,避免类型不匹配 | | | 序列化时必须对传入的数组大小进行校验,避免出现超大数组 | | | 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型 | | | 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 | | | 指针变量、表示资源描述符的变量、bool变量必须赋初值 | | | readParcelable获取的对象使用前需要判空 | | | 分配和释放内存的函数需要成对出现 | | | 申请内存后异常退出前需要及时进行内存释放 | | | 内存申请前必须对内存大小进行合法性校验 | | | 内存分配后必须判断是否成功 | | | 禁止使用realloc、alloca函数 | | | 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰 | | | 禁止打印内存地址 | | | 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0 | | | 禁止对有符号整数进行位操作符运算 | | | 禁止对指针进行逻辑或位运算 | | | 循环次数如果收外部数据控制,需要检验其合法性 | | | 禁止使用内存操作类危险函数,需要使用安全函数 | | | 谨慎使用不可重入函数 | | | 必须检查安全函数的返回值,并进行正确处理 | | | 禁止仅通过TokenType类型判断绕过权限校验 | | **TDD Result**: **XTS Result**: ### 是否已执行L0用例 - [x] 已验证 - [ ] 不涉及。如不涉及,请写明理由 See merge request: openharmony/bundlemanager_bundle_framework_lite!291
Bundle Management Framework
Introduction
The bundle management framework is provided by OpenHarmony for you to manage application bundles (installation packages). The following figure shows the architecture of the bundle management framework.
Figure 1 Bundle management framework architecture

-
BundleKit includes external APIs provided by the Bundle Manager Service, including the APIs for application installation and uninstallation, bundle information query, and bundle state change listeners.
-
The bundle scanning sub-module parses pre-installed or installed bundles on the local device and extracts information from them for the bundle management sub-module to manage and make the information persistent for storage.
-
The bundle installation sub-module installs, uninstalls, and updates a bundle.
-
The bundle installation service is an independent process used to create or delete installation directories and has high permissions.
-
The bundle management sub-module manages information related to application bundles and stores persistent bundle information.
-
The bundle security management sub-module verifies signatures, and grants and manages permissions.
Directory Structure
/foundation/bundlemanager/bundle_framework_lite
├── frameworks
│ └── bundle_lite # Client code used for communication between the BundleKit and Bundle Manager Service
├── interfaces
│ ├── kits
│ │ └── bundle_lite # BundleKit APIs exposed externally
│ └── inner_api
│ └── bundlemgr_lite # Core implementation code of BundleKit and internal APIs provided by the Bundle Manager Service for other subsystems
├── services
│ └── bundlemgr_lite # Implementation code of the Bundle Manager Service
└── utils
└── bundle_lite # Utility code used during the implementation of the Bundle Manager Service
- The Bundle Manager Service is running in the foundation process.
- The Bundle Manager Service is registered with sa_manager. sa_manager runs in the foundation process and sets up a thread runtime environment for the service. For details about how to create and use the Bundle Manager Service, see SA Framework.
- The Bundle Manager Service starts upon OS startup.
- You can use the bm tool to install the specified HAP. (Taking hispark_taurus as an example, you can obtain the bm tool from the out/hispark_taurus/ipcamera_hispark_taurus/dev_tools/bin directory after the version building.)
./bin/bm install -p /nfs/xxxx.hap
Repositories Involved
bundlemanager_bundle_framework_lite