- 背景:
在debug Ahal时,需要在mixer.c添加debug信息.
18 cc_library {
19 name: "libtinyalsa",
20 host_supported: true,
21 vendor_available: true,
22 product_available: true,
23 vndk: {
24 enabled: true,
25 },
47}
机器中查看so的位置如下, android T, vndk version 33
adb shell "find -name libtinyalsa.so" 2>null
./apex/com.android.vndk.v32/lib64/libtinyalsa.so
./apex/com.android.vndk.v32/lib/libtinyalsa.so
./apex/com.android.vndk.v30/lib64/libtinyalsa.so
./apex/com.android.vndk.v30/lib/libtinyalsa.so
./apex/com.android.vndk.v32@1/lib64/libtinyalsa.so
./apex/com.android.vndk.v32@1/lib/libtinyalsa.so
./apex/com.android.vndk.v30@1/lib64/libtinyalsa.so
./apex/com.android.vndk.v30@1/lib/libtinyalsa.so
./apex/com.android.vndk.v31/lib64/libtinyalsa.so
./apex/com.android.vndk.v31/lib/libtinyalsa.so
./apex/com.android.vndk.v31@1/lib64/libtinyalsa.so
./apex/com.android.vndk.v31@1/lib/libtinyalsa.so
./apex/com.android.vndk.v33/lib64/libtinyalsa.so
./apex/com.android.vndk.v33/lib/libtinyalsa.so
./apex/com.android.vndk.v33@1/lib64/libtinyalsa.so
./apex/com.android.vndk.v33@1/lib/libtinyalsa.so
./mnt/scratch/overlay/system/upper/lib/libtinyalsa.so
./mnt/scratch/overlay/system/upper/lib64/libtinyalsa.so
./system/lib/libtinyalsa.so
./system/lib64/libtinyalsa.so
发现libtinyalsa在apex和system中均存在.
需要查看实际中使用的是哪个so.
可以在调用者的进程中查看.例如audiohal的进程名android.hardware.audio.service_64
adb shell "ps -A| grep audio"
media 364 1 12509920 5916 0 0 S audioadsprpcd
root 741 2 0 0 0 0 I [uaudio_svc]
root 1054 2 0 0 0 0 I [sdm_dp_audio_no]
audioserver 1446 1 13402808 29224 0 0 S android.hardware.audio.service_64**
mediacodec 1667 1 12722256 16200 0 0 S media.audio.qc.codec
audioserver 1696 1 13341008 40820 0 0 S audioserver
adb shell "cat /proc/1446/maps | grep libtinyalsa"
7687ca6000-7687caa000 r--p 00000000 07:50 440 /apex/com.android.vndk.v33/lib64/libtinyalsa.so
可以确认在调用的时候,使用的是/apex路径的vndk的so.所以在/external/tinyalsa中编译, 可以编译出共享库, 但不能直接push到apex目录下. 需要使用apex的安装方式
adb push libtinyalsa.so /apex/com.android.vndk.v33/lib
failed to copy 'libtinyalsa.so' to '/apex/com.android.vndk.v33/lib': remote couldn't create file: Read-only file system
查看编译生成包名,com.android.vndk.current.apex, 机器中并没有v33包名的apex.
adb shell ls /system/apex/
com.android.adbd.capex
com.android.adservices.capex
com.android.apex.cts.shim.apex
com.android.appsearch.capex
com.android.art.capex
com.android.cellbroadcast.capex
com.android.configinfrastructure.capex
com.android.conscrypt.capex
com.android.devicelock.apex
com.android.extservices.capex
com.android.healthfitness.apex
com.android.i18n.apex
com.android.ipsec.capex
com.android.media.capex
com.android.media.swcodec.capex
com.android.mediaprovider.capex
com.android.neuralnetworks.capex
com.android.ondevicepersonalization.capex
com.android.os.statsd.apex
com.android.permission.capex
com.android.resolv.capex
com.android.rkpd.apex
com.android.runtime.apex
com.android.scheduling.capex
com.android.sdkext.apex
com.android.tethering.capex
com.android.tzdata.apex
com.android.uwb.capex
com.android.virt.apex
com.android.vndk.current.apex
com.android.wifi.capex
/packages/modules/vndk/apex/Android.bp
19 apex_vndk {
20 name: "com.android.vndk.current",
21 manifest: "apex_manifest.current.json",
22 key: "com.android.vndk.current.key",
23 certificate: ":com.android.vndk.current.certificate",
24 file_contexts: ":com.android.vndk-file_contexts",
25 updatable: false,
26 generate_hashtree: false,
27 }
直接编译apex
mmm packages/modules/vndk/apex:com.android.vndk.current.apex -j32
然后将apexpush到上面路径
adb push "Z:\work\c\out\target\product\kalama\system\apex\com.android.vndk.current.apex" /system/apex/
重启, apex即可生效
(其他的apex包,例如com.android.media, 是会直接体现在make文件中.
73 cc_library {
74 name: "libmediatranscoding",
75
76 min_sdk_version: "29",
77 apex_available: [
78 "com.android.media",
79 "test_com.android.media",
80 ],
81
82 srcs: [
83 "TranscoderWrapper.cpp",
84 "TranscodingClientManager.cpp",
85 "TranscodingLogger.cpp",
86 "TranscodingResourcePolicy.cpp",
87 "TranscodingSessionController.cpp",
88 "TranscodingThermalPolicy.cpp",
89 "TranscodingUidPolicy.cpp",
90 ],
)