1e41f4b71Sopenharmony_ci# **Bundle Management**
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Introduction
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciThe Bundle Management subsystem allows you to query, install, update, and uninstall capabilities for application bundles as well as store bundle information.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciBelow is the architecture of the Bundle Management subsystem.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci![](figures/appexecfwk.png)
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Responsibilities of Modules
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci| Module      | Description                                                        |
15e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------------ |
16e41f4b71Sopenharmony_ci| Bundle management interface module  | 1. Provides external interfaces for installation, update, uninstallation, and notification.<br>2. Provides external interfaces for querying bundle, component, and permission information.<br>3. Provides external interfaces for querying application permissions.<br>4. Provides external interfaces for clearing data.|
17e41f4b71Sopenharmony_ci| Scanning module        | 1. Scans pre-installed applications.<br>2. Scans installed third-party applications.<br>3. Parses bundle configuration files.|
18e41f4b71Sopenharmony_ci| Security management module    | 1. Verifies signatures during installation.<br>2. Grants the permissions requested by the application during installation.<br>3. Verifies permissions during application running.|
19e41f4b71Sopenharmony_ci| DBMS module        | Obtains the ability information about a specified device.                                 |
20e41f4b71Sopenharmony_ci| Installation management module    | Provides installation, update, and uninstallation logic processing and result notification.                      |
21e41f4b71Sopenharmony_ci| Bundle information management module  | Stores and synchronizes bundle and component information.                            |
22e41f4b71Sopenharmony_ci| Device status listening module| Listens for the online and offline status changes of devices.                                        |
23e41f4b71Sopenharmony_ci| Installed module    | Provides privileged processes for:<br>(1) Creating and deleting directories<br>(2) Creating and deleting files<br>(3) Sandbox UID/GID operations in the device directory|
24e41f4b71Sopenharmony_ci| DFX              | Provides bundle maintenance and testing.                                              |
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci## Directory Structure
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci```
30e41f4b71Sopenharmony_cifoundation/bundlemanager/bundle_framework
31e41f4b71Sopenharmony_ci├── bundle_tool                        # bm code
32e41f4b71Sopenharmony_ci├── distributed_bundle_framework       # Framework code of the distributed bundle management service					   
33e41f4b71Sopenharmony_ci├── common
34e41f4b71Sopenharmony_ci│   └── log							   # Log component
35e41f4b71Sopenharmony_ci├── interfaces
36e41f4b71Sopenharmony_ci│   ├── inner_api                      # Internal APIs
37e41f4b71Sopenharmony_ci│   └── kits                           # Application APIs
38e41f4b71Sopenharmony_ci│       ├── js                         # JS APIs
39e41f4b71Sopenharmony_ci│       └── native                     # C/C++ APIs  					   
40e41f4b71Sopenharmony_ci├── services                           # Framework code of the bundle management service
41e41f4b71Sopenharmony_ci└── test						       # Testing
42e41f4b71Sopenharmony_ci```
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci### bm Commands
46e41f4b71Sopenharmony_cibm is a tool used to facilitate debugging. It is encapsulated in the HDC tool. You can use it by running bm commands in the HDC shell.
47e41f4b71Sopenharmony_ci| Command   | Description      |
48e41f4b71Sopenharmony_ci| ------- | ---------- |
49e41f4b71Sopenharmony_ci|  help | Displays the commands supported by the bm tool.|
50e41f4b71Sopenharmony_ci| install | Installs an application.|
51e41f4b71Sopenharmony_ci| uninstall | Uninstalls an application.|
52e41f4b71Sopenharmony_ci| dump | Queries application information.|
53e41f4b71Sopenharmony_ci| clean | Clears the cache and data of an application.|
54e41f4b71Sopenharmony_ci| enable | Enables an application.|
55e41f4b71Sopenharmony_ci| disable | Disables an application.|
56e41f4b71Sopenharmony_ci| get | Obtains the UDID of a device.|
57e41f4b71Sopenharmony_ci#### Help Command
58e41f4b71Sopenharmony_ci| Command   | Description      |
59e41f4b71Sopenharmony_ci| ------- | ---------- |
60e41f4b71Sopenharmony_ci| bm help | Displays the commands supported by the bm tool.|
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci* Example
63e41f4b71Sopenharmony_ci```Bash
64e41f4b71Sopenharmony_ci# Display help information.
65e41f4b71Sopenharmony_cibm help
66e41f4b71Sopenharmony_ci```
67e41f4b71Sopenharmony_ci#### Installation Command
68e41f4b71Sopenharmony_ciThis command can be run with different options to achieve different purposes. The table below lists some examples.
69e41f4b71Sopenharmony_ci| Command                               | Description                      |
70e41f4b71Sopenharmony_ci| ----------------------------------- | -------------------------- |
71e41f4b71Sopenharmony_ci| bm install -h | Displays the commands supported by **install**.|
72e41f4b71Sopenharmony_ci| bm install -p <hap-file-path>    | Installs HAPs. You can specify a path to install one or more HAPs at the same time.|
73e41f4b71Sopenharmony_ci| bm install -p <hap-file-path> -u <user-id>   |Installs a HAP for a specified user.|
74e41f4b71Sopenharmony_ci| bm install -r -p <hap-file-path> | Installs a HAP in overwrite mode.|
75e41f4b71Sopenharmony_ci| bm install -r -p <hap-file-path> -u <user-id> | Installs a HAP for a specified user in overwrite mode.|
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci* Example
78e41f4b71Sopenharmony_ci```Bash
79e41f4b71Sopenharmony_ci# Install a HAP.
80e41f4b71Sopenharmony_cibm install -p /data/app/ohosapp.hap
81e41f4b71Sopenharmony_ci# Install a HAP in overwrite mode.
82e41f4b71Sopenharmony_cibm install -p /data/app/ohosapp.hap -r
83e41f4b71Sopenharmony_ci```
84e41f4b71Sopenharmony_ci#### Uninstallation Command
85e41f4b71Sopenharmony_ciThis command can be run with different options to achieve different purposes. The table below lists some examples. If **-u** is not specified, the command applies to all users.
86e41f4b71Sopenharmony_ci| Command                         | Description                    |
87e41f4b71Sopenharmony_ci| ----------------------------- | ------------------------ |
88e41f4b71Sopenharmony_ci| bm uninstall -h | Displays the commands supported by **uninstall**.|
89e41f4b71Sopenharmony_ci| bm uninstall -n <bundle-name> | Uninstalls an application based on the specified bundle name.|
90e41f4b71Sopenharmony_ci| bm uninstall -n <bundle-name> -k | Uninstalls an application based on the specified bundle name, while retaining the data directory of the application.|
91e41f4b71Sopenharmony_ci| bm uninstall -n <bundle-name> -u <user-id>| Uninstalls an application based on the specified bundle name and user.|
92e41f4b71Sopenharmony_ci| bm uninstall -n <bundle-name> -m <moudle-name> | Uninstalls a specific module of an application based on the specified bundle name.|
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci* Example
95e41f4b71Sopenharmony_ci```Bash
96e41f4b71Sopenharmony_ci# Uninstall a HAP.
97e41f4b71Sopenharmony_cibm uninstall -n com.ohos.app
98e41f4b71Sopenharmony_ci# Uninstall a HAP while retaining its data directory.
99e41f4b71Sopenharmony_cibm uninstall -n com.ohos.app -k
100e41f4b71Sopenharmony_ci# Uninstall an ability of the HAP.
101e41f4b71Sopenharmony_cibm uninstall -n com.ohos.app -m com.ohos.app.MainAbility
102e41f4b71Sopenharmony_ci```
103e41f4b71Sopenharmony_ci#### Query Command
104e41f4b71Sopenharmony_ciThis command can be run with different options to achieve different purposes. The table below lists some examples. If **-u** is not specified, the command applies to all users.
105e41f4b71Sopenharmony_ci| Command      | Description                      |
106e41f4b71Sopenharmony_ci| ---------- | -------------------------- |
107e41f4b71Sopenharmony_ci| bm dump -h | Displays the commands supported by **dump**.|
108e41f4b71Sopenharmony_ci| bm dump -a | Queries all applications installed in the system.|
109e41f4b71Sopenharmony_ci| bm dump -n <bundle-name> | Queries details about a specified bundle.|
110e41f4b71Sopenharmony_ci| bm dump -n <bundle-name> -s | Queries the shortcut information of a specified bundle.|
111e41f4b71Sopenharmony_ci| bm dump -n <bundle-name> -d <device-id> | Queries information about a bundle on a remote device.|
112e41f4b71Sopenharmony_ci| bm dump -n <bundle-name> -u <user-id> | Queries details about a specified bundle of a specified user.|
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci* Example
115e41f4b71Sopenharmony_ci```Bash
116e41f4b71Sopenharmony_ci# Display the names of all applications installed in the system.
117e41f4b71Sopenharmony_cibm dump -a
118e41f4b71Sopenharmony_ci# Display details about a specific application.
119e41f4b71Sopenharmony_cibm dump -n com.ohos.app
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci#### Clean Command
122e41f4b71Sopenharmony_ci-If **-u** is not specified, the command applies to all active users.
123e41f4b71Sopenharmony_ci| Command      | Description                      |
124e41f4b71Sopenharmony_ci| ---------- | -------------------------- |
125e41f4b71Sopenharmony_ci| bm clean -h | Displays the commands supported by **clean**.|
126e41f4b71Sopenharmony_ci| bm clean -n <bundle-name> -c | Clears the cache data of the specified bundle.|
127e41f4b71Sopenharmony_ci| bm clean -n <bundle-name> -d | Clears the data directory of the specified bundle.|
128e41f4b71Sopenharmony_ci| bm clean -n <bundle-name> -c -u <user-id> | Clears the cached data of the specified bundle for the specified user.|
129e41f4b71Sopenharmony_ci| bm clean -n <bundle-name> -d -u <user-id> | Clears the data directory of the specified bundle for the specified user.|
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci* Example
132e41f4b71Sopenharmony_ci```Bash
133e41f4b71Sopenharmony_ci# Clear the cache data of the specified bundle.
134e41f4b71Sopenharmony_cibm clean -n com.ohos.app -c
135e41f4b71Sopenharmony_ci# Clear the user data of the specified bundle.
136e41f4b71Sopenharmony_cibm clean -n com.ohos.app -d
137e41f4b71Sopenharmony_ci```
138e41f4b71Sopenharmony_ci#### Enable Command
139e41f4b71Sopenharmony_ci-If **-u** is not specified, the command applies to all active users.
140e41f4b71Sopenharmony_ci| Command      | Description                      |
141e41f4b71Sopenharmony_ci| ---------- | -------------------------- |
142e41f4b71Sopenharmony_ci| bm enable -h | Displays the commands supported by **enable**.|
143e41f4b71Sopenharmony_ci| bm enable -n <bundle-name> | Enables the application that matches the specified bundle name.|
144e41f4b71Sopenharmony_ci| bm enable -n <bundle-name> -a <ability-name> | Enables a specific ability module of the application that matches the specified bundle name.|
145e41f4b71Sopenharmony_ci| bm enable -n <bundle-name> -u <user-id>| Enables the application that matches the specified bundle name for the specified user.|
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci* Example
148e41f4b71Sopenharmony_ci```Bash
149e41f4b71Sopenharmony_ci# Enable the specified application.
150e41f4b71Sopenharmony_cibm enable -n com.ohos.app
151e41f4b71Sopenharmony_ci```
152e41f4b71Sopenharmony_ci#### Disable Command
153e41f4b71Sopenharmony_ci-If **-u** is not specified, the command applies to all active users.
154e41f4b71Sopenharmony_ci| Command      | Description                      |
155e41f4b71Sopenharmony_ci| ---------- | -------------------------- |
156e41f4b71Sopenharmony_ci| bm disable -h | Displays the commands supported by **disable**.|
157e41f4b71Sopenharmony_ci| bm disable -n <bundle-name> | Disables the application that matches the specified bundle name.|
158e41f4b71Sopenharmony_ci| bm disable -n <bundle-name> -a <ability-name> | Disables a specific ability module of the application that matches the specified bundle name.|
159e41f4b71Sopenharmony_ci| bm disable -n <bundle-name> -u <user-id>| Disables the application that matches the specified bundle name for the specified user.|
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci* Example
162e41f4b71Sopenharmony_ci```Bash
163e41f4b71Sopenharmony_ci# Disable the specified application.
164e41f4b71Sopenharmony_cibm disable -n com.ohos.app
165e41f4b71Sopenharmony_ci```
166e41f4b71Sopenharmony_ci#### Command for Obtaining the UDID
167e41f4b71Sopenharmony_ci| Command      | Description                      |
168e41f4b71Sopenharmony_ci| ---------- | -------------------------- |
169e41f4b71Sopenharmony_ci| bm get -h | Displays the commands supported by **get**.|
170e41f4b71Sopenharmony_ci| bm get -u | Obtains the UDID of a device.|
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci* Example
173e41f4b71Sopenharmony_ci```Bash
174e41f4b71Sopenharmony_ci# Obtain the UDID of a device.
175e41f4b71Sopenharmony_cibm get -u
176e41f4b71Sopenharmony_ci```
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci## Repositories Involved
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ciBundle Management Subsystem
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci[**bundlemanager_bundle_framework**](https://gitee.com/openharmony/bundlemanager_bundle_framework)
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci[**bundlemanager_bundle_framework_lite**](https://gitee.com/openharmony/bundlemanager_bundle_framework_lite)
185e41f4b71Sopenharmony_ci[developtools_packing_tool](https://gitee.com/openharmony/developtools_packing_tool)
186