代码太乱了先批量删除同步代码创建分支
1.批量删除分支
repo forall -c “git branch | sed -e /^*/d | xargs git branch -D”
2.批量创建分支
repo forall -c “repo start [分支名] –all”
repo sync -j8 && repo start mywrok --all
修改代码 单编
source
source ./build/envsetup.sh
lunch
选择合适选项
mm
编译framework
进入farmwork/base/
mmm core/res/ 生成framework-res.apk
然后再单独编译framework(上面一定要做,否则framwork编译失败)
mma
第一次编译要用mma,编译依赖的文件,后面用mm。
可能仍然报错,我的报在robottests。不清楚,就直接将其目录目录下的Android.mk删掉了。反正不用,报错就不编译了呗。
目前的平台第一次编译不会报错
编译netd
m netd -j8
编译高通data下netmgrd模块
m netmgrd -j8
push
在out目录下的framwork.jar push到终端即可
adb root
adb remount
adb push XXX\framework.jar /system/framework/framework.jar
在out\target\product\XXX\system\bin\netd取出来,用adb push 放到 system/bin/目录下替换
如果提示adb remount失败,则需要fastboot 解锁
解 bootloader 锁 :
- 开发者模式中 “允许OEM解锁”
- adb reboot bootloader
- fastboot flashing unlock --> 操作终端的音量加减键选择 “UNLOCK THE BOOTLOADER” --> 按Power键确认
- adb root
- adb disable-verity
- adb reboot
- adb root
- adb remount
fastboot 驱动安装–》找到合适驱动安装
有时仍然不识别,需要手动添加:
调试
抓取netd日志
adb logcat -v time netd:V > temp.txt
没有重新生成bin文件
修改netd目录下ndc模块,用m netd命令编译,发现没有重新生成netd库文件。原来是要用m ndc编译。
从system\netd\server\Android.bp文件,可知不是netd模块,是ndc模块
cc_binary {
name: "netd",
defaults: ["netd_defaults"],
include_dirs: [
"external/mdnsresponder/mDNSShared",
"system/netd/include",
],
init_rc: ["netd.rc"],
required: [
....
],
shared_libs: [
"android.system.net.netd@1.0",
"android.system.net.netd@1.1",
......
"oemnetd_aidl_interface-cpp",
],
static_libs: [
"libnetd_server",
],
srcs: [
....
"MDnsSdListener.cpp",
"NetdCommand.cpp",
...
"VirtualNetwork.cpp",
"main.cpp",
"oem_iptables_hook.cpp",
],
sanitize: {
cfi: true,
},
}
cc_binary {
name: "ndc",
defaults: ["netd_defaults"],
include_dirs: [
"system/netd/include",
],
header_libs: [
"libnetd_client_headers",
],
shared_libs: [
"libbase",
"libnetdutils",
......
"netd_aidl_interface-cpp",
],
srcs: [
"ndc.cpp",
"UidRanges.cpp",
"NdcDispatcher.cpp",
],
sanitize: {
cfi: true,
},
}
修改aidl后生成的interface cpp
./soong/.intermediates/system/netd/server/netd_aidl_interface-cpp-source/gen/android/net/INetd.cpp
代码调用出现异常
adb log:
--------- beginning of crash
05-24 15:58:02.614 F/libc ( 5173): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xffffffffffffffd8 in tid 5173 (ndc), pid 5173 (ndc)
05-24 15:58:02.712 I/crash_dump64( 5176): obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-24 15:58:02.715 I/tombstoned( 528): received crash request for pid 5173
05-24 15:58:02.715 I/crash_dump64( 5176): performing dump of process 5173 (target tid = 5173)
05-24 15:58:02.717 F/DEBUG ( 5176): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-24 15:58:02.717 F/DEBUG ( 5176): Build fingerprint: 'qti/xxx/xxx:11/RKQ1.211210.001/69:userdebug/test-keys'
05-24 15:58:02.717 F/DEBUG ( 5176): Revision: '0'
05-24 15:58:02.717 F/DEBUG ( 5176): ABI: 'arm64'
05-24 15:58:02.718 F/DEBUG ( 5176): Timestamp: 2024-05-24 15:58:02+0800
05-24 15:58:02.718 F/DEBUG ( 5176): pid: 5173, tid: 5173, name: ndc >>> ndc <<<
05-24 15:58:02.718 F/DEBUG ( 5176): uid: 0
05-24 15:58:02.718 F/DEBUG ( 5176): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xffffffffffffffd8
05-24 15:58:02.718 F/DEBUG ( 5176): x0 b4000070e64ade80 x1 0000007fed144bb0 x2 0000000000000000 x3 00496e76616c6964
05-24 15:58:02.718 F/DEBUG ( 5176): x4 0000000000000080 x5 101a151259531600 x6 8016535912151a10 x7 737278722e3c5dff
05-24 15:58:02.718 F/DEBUG ( 5176): x8 0000007fed144ba0 x9 ffffffffffffffd8 x10 0101010101010101 x11 0000000000000000
05-24 15:58:02.718 F/DEBUG ( 5176): x12 0000000000000038 x13 ffffffffffffffff x14 ff00000000000000 x15 ffffffffffffffff
05-24 15:58:02.718 F/DEBUG ( 5176): x16 0000005e53b60760 x17 0000007356764104 x18 00000073573b8000 x19 b4000070864a4250
05-24 15:58:02.718 F/DEBUG ( 5176): x20 b4000070e64ade80 x21 0000007fed144ba0 x22 0000007fed145523 x23 0000005e53b60198
05-24 15:58:02.718 F/DEBUG ( 5176): x24 b4000070d64afec0 x25 0000007356dfd000 x26 0000005e53b60188 x27 0000000000000000
05-24 15:58:02.718 F/DEBUG ( 5176): x28 0000000000000000 x29 0000007fed144bd0
05-24 15:58:02.718 F/DEBUG ( 5176): lr 0000005e53b57840 sp 0000007fed144b60 pc ffffffffffffffd8 pst 0000000060000000
05-24 15:58:02.724 F/DEBUG ( 5176): backtrace:
05-24 15:58:02.724 F/DEBUG ( 5176): #00 pc ffffffffffffffd8 <unknown>
05-24 15:58:02.724 F/DEBUG ( 5176): #01 pc 000000000000783c /system/bin/ndc (android::net::NdcDispatcher::ExBandwidthCommand::runCommand(android::net::NdcClient*, int, char**) const+456) (BuildId: 5bd716660adc1f2bab1c386ab029350b)
05-24 15:58:02.724 F/DEBUG ( 5176): #02 pc 000000000000fa8c /system/bin/ndc (android::net::NdcDispatcher::dispatchCommand(int, char**)+328) (BuildId: 5bd716660adc1f2bab1c386ab029350b)
05-24 15:58:02.724 F/DEBUG ( 5176): #03 pc 00000000000040c8 /system/bin/ndc (main.cfi+92) (BuildId: 5bd716660adc1f2bab1c386ab029350b)
05-24 15:58:02.724 F/DEBUG ( 5176): #04 pc 00000000000499e4 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: f4881cdb04823cc0d8c0fa3f95c4db2e)
出问题前最后调用的是 #01 pc 000000000000783c /system/bin/ndc (android::net::NdcDispatcher::ExBandwidthCommand::runCommand(android::net::NdcClient*, int, char**) const+456) (BuildId: 5bd716660adc1f2bab1c386ab029350b)
指针为000000000000783c。如下方法查看具体行:
所以最后问题出在system/netd/server/NdcDispatcher.cpp:1274 行。
$ ./prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-addr2line -e out/target/product/xxxxx/symbols/system/bin/ndc 000000000000783c
system/netd/server/NdcDispatcher.cpp:1274
提交代码
git add
git commit -F message.txt
git push origin HEAD:refs/for/mybranch