หลังจากสร้างมิดเดิลแวร์และเขียนโค้ดที่กำหนดเองแล้ว คุณจะ นำแพ็กเกจบริการไปใช้งานเป็นไฟล์ APEX ได้
สร้างไฟล์การกำหนดค่า SDV
สนิม
สร้างไฟล์การกำหนดค่า SDV โดยเรียกใช้คำสั่งต่อไปนี้
vsidlc -c /path/to/catalog -o /path/to/output --apexการเรียกใช้
vsidlcด้วยแฟล็ก--apexจะสร้างไฟล์การกำหนดค่าที่จำเป็นทั้งหมดโดยอัตโนมัติ ซึ่งรวมถึง- ไฟล์ Manifest ของ APEX (
apex_manifest.json) - ไฟล์ Manifest ของข้อมูลเมตา SDV (
sdv_service_bundles_manifest.textproto) - การกำหนดค่า Linker (
linker.config.json) - บริบทไฟล์ SELinux (
file_contexts) - คีย์สาธารณะและคีย์ส่วนตัว (
.avbpubkeyและ.pem) - การประกาศสิทธิ์และการกำหนดค่าการจัดระเบียบ
Android.bpไฟล์ที่กำหนดโมดูล Soong ที่จำเป็นทั้งหมด
คุณจะเห็นการกำหนดค่าที่สร้างขึ้นได้ในส่วนต่อไปนี้
/path/to/output/apex/และ
/path/to/output/configs/- ไฟล์ Manifest ของ APEX (
C++
สร้างไฟล์ Manifest ข้อมูลเมตา SDV
service_bundle.manifest.textprotoโดยใช้ช่องข้อมูลเมตาการดำเนินการที่จำเป็นต่อไปนี้- ชื่อของบริการตามรูปแบบการตั้งชื่อ
- การแสดงเวอร์ชันแพ็กเกจบริการเป็นจำนวนเต็มและสตริง
- เส้นทางไปยังไลบรารีที่สร้างไว้ก่อนหน้านี้
การเตรียมข้อมูลเมตาของแพ็กเกจบริการที่จำเป็นเป็นข้อบังคับสำหรับการจัดแพ็กเกจและการติดตั้งใช้งานแพ็กเกจบริการ
# proto-file: //system/software_defined_vehicle/core_services/service_bundles_registry/proto/sdv_service_bundles_manifest.proto # proto-message: SdvServiceBundleManifestEntry # SDV service bundle metadata definition with mandatory fields. sdv_service_bundle_metadata { # Service bundle name. name: "ServiceBundleName" # Service bundle integer version. version_number: 42 # Service bundle version as a string. version_name: "42.alpha" # Service bundle library path. native_library_path: "lib64/libservice_bundle.so" }สร้างไฟล์การกำหนดค่า Linker ใหม่
linker.config.json{ "visible": true }สร้างไฟล์ใหม่
apex_manifest.jsonโดยมีช่องต่อไปนี้- ชื่อแพ็กเกจ SDV ที่ไม่ซ้ำกัน
- เวอร์ชันของ APEX
- ทรัพยากร Dependency บนไลบรารีการสื่อสาร SDV
{ "name": "com.sdv.oem.apex_and_module_name", "version": 1, "requireNativeLibs": [ "libsdv_comms_ctx_ffi.so", "libsdv_comms_dt_ffi.so", "libsdv_comms_id_ffi.so", "libsdv_comms_sd_ffi.so" ] }สร้างคีย์สาธารณะ
apex_name.apex_key.avbpubkeyและคีย์ส่วนตัวapex_name.apex_key.pemสร้างบริบทไฟล์ SELinux ใหม่
apex_file_contexts(/.*)? u:object_r:system_file:s0ดูข้อมูลเพิ่มเติมได้ที่บริบทและหมวดหมู่ความปลอดภัย
สร้างเป้าหมายที่สร้างไว้ล่วงหน้าในไฟล์
Android.bpใหม่หรือที่มีอยู่// SDV manifest file prebuilt. prebuilt_etc { name: "com.sdv.oem.apex_and_module_name.service_bundles_manifest", // The source filename of the manifest file. src: "service_bundle.manifest.textproto", // The name of the installed file needs be `sdv_service_bundles_manifest.textproto`. filename: "sdv_service_bundles_manifest.textproto", // Disable direct installation of the prebuilt to one of the partitions. // The manifest is used only inside of an apex. installable: false, } // The linker config to allow libraries for the apex to be linkable. linker_config { name: "com.sdv.oem.apex_and_module_name. linker_config", src: "linker.config.json", // Disable direct installation of the prebuilt to one of the partitions. // The linker configuration is used only inside of an apex. installable: false, } // Key to be used for signing the apex. apex_key { name: "apex_name.apex_key", public_key: "apex_name.apex_key.avbpubkey", private_key: "apex_name.apex_key.pem", }สร้างโมดูล APEX ใหม่ในไฟล์
Android.bpใหม่หรือที่มีอยู่ ใช้ชื่อแพ็กเกจ SDV เป็นชื่อโมดูล APEXapex { name: "com.sdv.oem.apex_and_module_name", // The service bundle(s) to be included in the apex. native_shared_libs: [ "libservice_bundle", ], prebuilts: [ // SDV service bundles manifest file. "com.sdv.oem.apex_and_module_name.service_bundles_manifest", // Linker configuration to enable loading library from apex. "com.sdv.oem.apex_and_module_name.linker_config", ], // Json manifest file describes metadata of the APEX package. // The 'name' field from the JSON is used as a mounting point. manifest: "apex_manifest.json", // Setting the security contexts to files in this APEX bundle. file_contexts: "apex_file_contexts", // Name of the apex_key module that provides the private key to sign the APEX bundle. key: "apex_name.apex_key", // Mark apex as non-updatable for now, this might be revisited going forward. updatable: false, // Service bundle package is installed into /product partition. product_specific: true, }
หากต้องการรวม Makefile ใหม่ในอิมเมจ SDV ให้เพิ่มโมดูล APEX ใหม่ลงใน
PRODUCT_PACKAGESใน Makefile ของผลิตภัณฑ์ เช่น ดูsdv_samples_core_services.mkหากใช้ Cuttlefish ให้เรียกใช้คำสั่งต่อไปนี้เพื่อเริ่มอุปกรณ์
sdv-cf create --instance_name=instance1เรียกใช้แพ็กเกจบริการเมื่อระบบบูต
# Grant root access. adb root # Launch the new service bundle. adb shell sdv_service_bundle start \ local-vm:com.sdv.oem.apex_and_module_name.ServiceBundleName/instance-1
การจัดการทรัพยากร Dependency ของแพ็กเกจบริการ
ในบางสถานการณ์ คุณสามารถใช้การลิงก์แบบคงที่ของทรัพยากร Dependency ของ Service Bundle เพื่อลดขนาด APEX และหน่วยความจำที่ใช้ของ Service Bundle รวมถึงปรับปรุงเวลาเริ่มต้นของ Service Bundle สถานการณ์เหล่านี้รวมถึง APEX ที่มีลักษณะดังนี้
- แพ็กเกจบริการเดียว
- ชุดบริการหลายชุดที่ไม่ได้ใช้ทรัพยากร Dependency ร่วมกันมากนัก
หากต้องการเปิดใช้การลิงก์แบบคงที่ ให้เพิ่มพร็อพเพอร์ตี้ต่อไปนี้ลงในคำจำกัดความของไลบรารี ในแพ็กเกจบริการ
// Service bundle library.
rust_ffi_shared {
// See rust_ffi_shared basic template.
...
// uses static linking for the dependencies
prefer_rlib: true,
// needed to correctly resolve commstack deps
ld_flags: ["-Wl,--no-as-needed"],
}
ในแต่ละสถานการณ์ เราขอแนะนำให้คุณยืนยันว่าการลิงก์แบบคงที่กับทรัพยากร Dependency จะช่วยปรับปรุงหน่วยความจำที่ใช้และเวลาเริ่มต้นของแพ็กเกจบริการ
แก้ไขข้อบกพร่อง (dumpsys)
เครื่องมือจัดการวงจรจะใช้การติดตั้งใช้งานอินเทอร์เฟซ dumpsys อินเทอร์เฟซนี้
จะแสดงรายการแพ็กเกจบริการแก่ผู้ใช้ซึ่งอยู่ในสถานะcreatedหรือstarted นอกจากนี้ อินเทอร์เฟซยังแสดง FQIN หรือ UID ของ
กระบวนการรวมบริการด้วย
หากต้องการดูสถานะและตัวระบุปัจจุบันของแพ็กเกจบริการ ให้เรียกใช้คำสั่งต่อไปนี้
# Grant root access.
adb root
# Execute dumpsys to see service bundles state
adb shell dumpsys google.sdv.lifecycle.ILifecycleManager/default
ขั้นตอนถัดไป
หากต้องการเรียกใช้ vsidlc โดยอัตโนมัติและเปิดใช้ปลั๊กอิน IDE เพื่อทำงานกับ
การอ้างอิง โปรดดูการอัปเดตแคตตาล็อกอัตโนมัติและการผสานรวม LSP