Android13-SystemUI_模拟器安装SystemUI.apk文件

435 阅读2分钟

直接安装是不行的,需要替换系统中SystemUI.apk文件

PS C:\Users\liam> adb install D:\workspace\common\vbUbuntuShare\SystemUI\SystemUI.apk
Performing Streamed Install
adb: failed to install D:\workspace\common\vbUbuntuShare\SystemUI\SystemUI.apk: Failure [INSTALL_FAILED_INVALID_APK: Package com.android.systemui is a persistent app. Persistent apps are not updateable.]

普通打开模拟器

PS C:\Users\liam> emulator -avd Pixel_6_API_33_2 -sysdir D:\workspace\Android\ASAll\sdk\system-images\selfSystemImages\x86_64

D:\workspace\Android\ASAll\sdk\system-images\selfSystemImages\x86_64目录是存放基于AOSP自己编译的镜像文件

adb remount会报错

PS C:\Users\liam> adb root
restarting adbd as root
PS C:\Users\liam> adb remount
avb_ops_user.cpp:217: ERROR: Error writing data.
Skipping /system for remount
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
Can not mount overlayfs for partitions: No such file or directory
failed to remount partition dev:/dev/block/dm-3 mnt:/vendor: Permission denied
failed to remount partition dev:/dev/block/dm-2 mnt:/product: Permission denied
failed to remount partition dev:/dev/block/dm-1 mnt:/system_ext: Permission denied
remount failed

加了-writable-system配置,参考,可以对system目录进行写入操作,adb remount不会报错

emulator -avd Pixel_6_API_33_2 -sysdir D:\workspace\Android\ASAll\sdk\system-images\selfSystemImages\x86_64 -writable-system

查看SystemUI的安装目录

PS C:\Users\liam> adb shell pm path com.android.systemui
package:/system_ext/priv-app/SystemUI/SystemUI.apk

移除原有的SystemUI.apk,替换自己要调试的

adb root
adb remount
adb shell rm /system_ext/priv-app/SystemUI/SystemUI.apk
adb push D:\workspace\common\vbUbuntuShare\SystemUI\SystemUI.apk /system_ext/priv-app/SystemUI/

D:\workspace\common\vbUbuntuShare\SystemUI\SystemUI.apk是自己要调试的SystemUI

重启,就可以替换原有的SytemUI了

adb reboot

Window构建一个简单的脚本

借助git bash,快速把SystemUI.apk更新到模拟器上

updateSystemUI.sh的内容,脚本和apk在同一个目录

adb root
adb remount
adb push SystemUI.apk //system_ext//priv-app//SystemUI//
echo "推送文件成功"
adb reboot
echo "reboot开始"

执行

./updateSystemUI.sh

ADB 操作命令详解及用法大全