常用指令

如果不清楚下述指令具体含义,可以去文档

https://docs.openharmony.cn/pages/v6.0/zh-cn/application-dev/tools/command-line-tools-overview.md

中检索

image.png

发送文件指令,发送到图库能显示,图库不是单个文件夹有图片就能显示

https://docs.openharmony.cn/pages/v6.0/zh-cn/application-dev/tools/mediatool.md

mediatool send /data/tmp/MyImage.jpg

电源常亮指令

hdc shell "power-shell setmode 602"

窗口指令

hdc shell hidumper -s WindowManagerService -a -a

hdc shell hidumper -s WindowManagerService -a '-w 28 -element -c' // 28 即为查找到的WinId

hdc shell "find data -name arkui.dump"

hdc file recv data/app/el2/100/base/com.netease.ohmail/haps/entry/files/arkui.dump

日志指令

hdc shell "hilog -p off"
hdc shell "hilog -b D"
hdc shell "hilog -Q pidoff"
hdc shell "power-shell setmode 602"

hdc shell "mount -o remount,rw /"
hdc shell "mount -o remount,rw /vendor"
hdc shell "power-shell setmode 602"

查找 so 推送 so

hdc shell "find system -name libapp_context.z.so"

hdc shell "mount -o remount,rw /"
hdc file send libapp_context.z.so system/lib64/platformsdk/libapp_context.z.so
hdc shell "sync"
hdc shell "reboot"

hdc file send libwm.z.so system/lib64/libwm.z.so

hdc file send  libapp_context_utils.z.so

编译指令

build/prebuilts_download.sh

./build.sh --product-name rk3568 --ccache --target-cpu arm64

./build.sh --product-name rk3568 --ccache --target-cpu arm64  --build-target libwms

tar -zcvf images0626test.tar.gz ~/oh5.1tag/out/rk3568/packages/phone/images/

推送 xml 配置文件

hdc shell "find system -name audio_policy_config.xml"

hdc shell "mount -o remount,rw /vendor"
hdc file send audio_policy_config.xml /vendor/etc/audio/audio_policy_config.xml

进程隔离

hdc shell param get persist.bms.supportIsolationMode
hdc shell param set persist.bms.supportIsolationMode true

支持多类型包

hdc shell param get const.bms.supportAppTypes
hdc shell param set const.bms.supportAppTypes default,2in1,tablet
hdc shell param get const.product.devicetype

替换系统应用(修改版本号便于验证是否替换成功)

hdc shell "mount -o remount,rw /"
hdc shell "rm -rf /system/app/com.ohos.amsdialog/ams_system_dialog.hap"
hdc file send ams_system_dialog.hap /system/app/com.ohos.amsdialog/
hdc shell "rm -rf /data/*/com.ohos.amsdialog"


hdc shell reboot

hdc shell "bm dump -n com.ohos.amsdialog | grep version"

hdc shell "rm -rf /data/*"


hdc shell "bm dump -n com.ohos.amsdialog | grep version"

hdc shell "rm -rf /data/*/com.ohos.photos"

web 独立渲染进程

hdc shell param set web.oop.gpu true
hdc shell param set web.oop.gpu None

视角(查看应用视角下文件是否存在)

hdc shell                         // 进入shell
ps -ef|grep [hapName]             // 通过ps命令找到对应应用的pid
nsenter -t [hapPid] -m /bin/sh    // 通过上一步找到的应用pid进入对应应用的沙箱环境中

替换 samgr

hdc shell "mount -o remount,rw /"
hdc shell service_contrl stop samgr
hdc shell rm -rf /system/bin/samgr
hdc file send samgr /system/bin/

挂载

hdc shell "mount -o remount,rw /"

证书(自下载证书)

hdc shell "mount -o remount,rw /"
hdc shell "mkdir -p /system/etc/ssl/certs/"
hdc file send cacert.pem /system/etc/ssl/certs/
pause

开启窗口模式

hdc file recv /system/etc/window/resources/window_manager_config.xml

    <decor enable="true">
        <!--supportedMode could be configed as fullscreen, floating, split or the combination of them-->
        <supportedMode>floating fullscreen</supportedMode>
    </decor>

    <defaultWindowMode>102</defaultWindowMode>

hdc shell mount -o remount,rw /
hdc file send window_manager_config.xml /system/etc/window/resources/window_manager_config.xml
pause
hdc shell reboot

横屏/dpi

hdc file recv /system/etc/window/resources/display_manager_config.xml

    <dpi>120</dpi>

    <!-- Indicates orientation of the built-in screen -->
    <!-- 0: Orientation::UNSPECIFIED -->
    <!-- 1: Orientation::VERTICAL         2: Orientation::HORIZONTAL-->
    <!-- 3: Orientation::REVERSE_VERTICAL 4: Orientation::REVERSE_HORIZONTAL -->

    <buildInDefaultOrientation>2</buildInDefaultOrientation>

hdc shell mount -o remount,rw /
hdc file send display_manager_config.xml /system/etc/window/resources/display_manager_config.xml
pause
hdc shell reboot

多进程

hdc shell param set persist.sys.abilityms.multi_process_model true

hdc shell param set persist.sys.abilityms.start_native_child_process true

hdc shell param set const.max_native_child_process 512

hdc shell param save // 保存修改

hdc shell param get persist.sys.abilityms.multi_process_model

hdc shell param get persist.sys.abilityms.start_native_child_process

hdc shell param get const.max_native_child_process

hdc shell reboot // 修改成功后重启生效

查看应用是系统应用还是普通应用

# bm dump -n com.demo.myapplication5 | grep appPrivilegeLevel
        "appPrivilegeLevel": "normal",

# bm dump -n ohos.samples.distributedcalc | grep appPrivilegeLevel
        "appPrivilegeLevel": "system_core"

是否为预制应用(首次启动后系统自动安装)

# bm dump -n com.demo.myapplication5 | grep isPreInstallApp
    "isPreInstallApp": false,
# bm dump -n ohos.samples.distributedcalc | grep isPreInstallApp
    "isPreInstallApp": true,

预制应用配置项,图标是否显示,是否可卸载,是否预授权,安装路径等信息

hdc file recv /system/etc/app

hdc shell mount -o remount,rw /
hdc shell rm -rf /system/etc/app
hdc file send app /system/etc/
pause
hdc shell rm -rf /data/*
pause
hdc shell reboot
pause

查看权限授权状态

bm dump -n 包名
最下面几段

查看 tokenId

#查询系统中所有的权限定义
atm dump -d

#按权限名查询权限定义
atm dump -d -p *********
# 执行结果
# {
#     "permissionName": "ohos.permission.KERNEL_ATM_SELF_USE",
#     "grantMode": SYSTEM_GRANT,
#     "availableLevel": SYSTEM_CORE,
#     "availableType": SYSTEM,
#     "provisionEnable": true,
#     "distributedSceneEnable": true,
#     "isKernelEffect": true,
#     "hasValue": true,
# }

#显示atm dump的帮助信息
atm dump -h

#查询系统中所有应用进程的tokenid和包名
atm dump -t

手动授权某个权限

# 显示atm perm的帮助信息
atm perm -h

# 为应用进程授予相机权限(-i 后面接tokenId)
atm perm -g -i ********* -p ohos.permission.CAMERA

# 为应用进程取消相机权限
atm perm -c -i ********* -p ohos.permission.CAMERA

注入触摸或者点击操作

#输入字母a
uinput -K -d 2017 -u 2017

查看通知栏是否有数据

# 打印活跃的通知信息
anm dump -A

工具

快速检索源码,方便定位文件及所属仓库,需注意代码更新时间

http://ci.openharmony.cn/workbench/coding/codeRetrieval

image.png

搜索演示,秒出结果,搜索性能比一般服务器好

image.png

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐