OpenHarmony bm工具命令

avatar
作者
猴君
阅读量:2

最近开始接触OpenHarmony, bm 工具命令就需要经常用到,把常用的记录下来,方便加深记忆。

bm是用来方便开发者调试的一个工具。bm工具被hdc工具封装,进入hdc shell命令后,就可以使用bm工具。

命令描述
help显示bm的帮助命令
install安装hap
uninstall卸载hap
dump查询应用相关信息
clean清理应用的缓存和数据
enable使能应用
disable禁用应用
get获取设备的udid

1、安装命令

常用命令如下

命令描述
bm install -h显示install支持的命令信息
bm install -p安装hap包,支持指定路径和多个hap同时安装
bm install -p -u给指定用户安装hap包
bm install -r -p覆盖安装
bm install -r -p -u给指定用户覆盖安装

示例:

C:\Users\test>hdc shell
# bm install -p /data/local/tmp/entry-default-signed.hap
install bundle successfully.

或者直接使用hdc命令安装

C:\Users\test>hdc app install D:\OHOS\entry\build\default\outputs\default\entry-default-signed.hap
[Info]App install path:D:\OHOS\entry\build\default\outputs\default\entry-default-signed.hap, queuesize:0, msg:install bundle successfully.
AppMod finish

2、卸载命令

命令可以组合,-u未指定的情况下,默认为所有用户。

命令描述
bm uninstall -h显示支持指令信息
bm uninstall -n通过指定包名卸载应用
bm uninstall -n -k通过指定包名卸载应用时保留数据目录
bm uninstall -n -u通过指定包名和用户卸载应用
bm uninstall -n -m通过指定包名卸载应用的一个模块

卸载指定应用

# ps -ef | grep hell
20010042      1289   233 0 09:45:30 ?     00:00:00 com.example.helloworld
root          1378  1370 11 09:49:04 pts/0 00:00:00 grep hell
# bm uninstall -n com.example.helloworld
uninstall bundle successfully.

3、查询命令

常用命令如下,-u未指定的情况下,默认为所有用户。

命令描述
bm dump -h显示dump支持的命令信息
bm dump -a查询系统已经安装的应用
bm dump -n查询指定包名的详细信息
bm dump -n -s查询指定包名下的快捷方式信息
bm dump -n -d跨设备查询包信息
bm dump -n -u查询指定用户下指定包名的详细信息

示例:

# bm dump -a
ID: 100:
        cn.openharmony.inputmethodchoosedialog
        cn.openharmony.pasteboarddialog
        com.example.kikakeyboard
        com.ohos.UserFile.ExternalFileManager
        com.ohos.amsdialog
        com.ohos.calendardata
        com.ohos.callui
        com.ohos.camera
        com.ohos.certmanager
        com.ohos.contacts
        com.ohos.contactsdataability
        com.ohos.devicemanagerui
        com.ohos.dlpmanager
        com.ohos.filepicker
        com.ohos.formrenderservice
        com.ohos.launcher
        com.ohos.medialibrary.medialibrarydata
        com.ohos.mms
        com.ohos.note
        com.ohos.notificationdialog
        com.ohos.nweb
        com.ohos.permissionmanager
        com.ohos.photos
        com.ohos.powerdialog
        com.ohos.screenshot
        com.ohos.settings
        com.ohos.settings.faceauth
        com.ohos.settingsdata
        com.ohos.sharepickerdialog
        com.ohos.smartperf
        com.ohos.spooler
        com.ohos.systemui
        com.ohos.telephonydataability
        com.ohos.updateapp
        com.ohos.useriam.authwidget
        com.usb.right
        ohos.backgroundtaskmgr.resources
        ohos.global.systemres
        ohos.samples.clock
        ohos.samples.distributedcalc
        ohos.samples.distributedmusicplayer
        ohos.telephony.resources

# bm dump -n ohos.samples.clock
ohos.samples.clock:
{
    "appId": "ohos.samples.clock_BNtg4JBClbl92Rgc3jm/RfcAdrHXaM8F0QOiwVEhnV5ebE5jNIYnAx+weFRT3QTyUjRNdhmc2aAzWyi+5t5CoBM=",
    "appIndex": 0,
    "applicationInfo": {
        "accessTokenId": 537519409,
        "accessTokenIdEx": 4832486705,
        "accessible": false,
        "allowCommonEvent": [],
        "apiCompatibleVersion": 8,
        "apiReleaseType": "Release",
        "apiTargetVersion": 10,
        "appDetailAbilityLibraryPath": "",
        "appDistributionType": "os_integration",
        "appPrivilegeLevel": "normal",
        "appProvisionType": "release"

4、清理命令

命令描述
bm clean -h显示clean支持的命令信息
bm clean -n -c清除指定包名的缓存数据
bm clean -n -d清除指定包名的数据目录
bm clean -n -c -u清除指定用户下包名的数据
bm clean -n -d -u清除指定用户下包名的目录

示例:

# bm clean -n ohos.samples.clock -c
clean bundle cache files successfully.
# bm clean -n ohos.samples.clock -d
clean bundle data files successfully.
#

5、使能命令

常用命令

命令描述
bm enable -h显示enable支持的命令信息
bm enable -n使能指定包名的应用
bm enable -n -a使能指定包名下的元能力模块
bm enable -n -u使能指定包名和用户的应用

示例

# bm enable -n ohos.samples.clock
enable bundle successfully.

6、禁用命令

命令 描述
bm disable -h显示disable支持的命令信息
bm disable -n禁用指定包名的应用
bm disable -n -a禁用指定包名下的元能力模块
bm disable -n -u禁用指定用户和包名下的应用

示例:

禁用后图标消失

# bm disable -n ohos.samples.clock
disable bundle successfully.

使能后图标出现
# bm enable -n ohos.samples.clock
enable bundle successfully.

6、获取udid命令

# bm get -u
udid of current device is :
86D62C4A2EF1EFDE5AFC17DB9545BB9534708622001D9270AF731BEB0508F3AC

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!