หลังจากสร้างมิดเดิลแวร์และเขียนโค้ดที่กำหนดเองแล้ว คุณสามารถติดตั้งใช้งานแพ็กเกจบริการเป็นไฟล์ APEX ได้
สร้างไฟล์การกำหนดค่า SDV โดยทำดังนี้
Rust
สร้างไฟล์การกำหนดค่า 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 ในไลบรารี Comms ของ 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, }
หากต้องการรวมไฟล์ Make ใหม่ในอิมเมจ SDV ให้เพิ่มโมดูล APEX ใหม่ลงใน
PRODUCT_PACKAGESใน ไฟล์ Make ของผลิตภัณฑ์ ดูตัวอย่างได้ที่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 ของแพ็กเกจบริการเพื่อลดขนาด APEX และหน่วยความจำที่ใช้ของแพ็กเกจบริการ รวมถึงปรับปรุงเวลาเริ่มต้นของแพ็กเกจบริการ สถานการณ์เหล่านี้รวมถึง 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 เพื่อทำงานกับ
ทรัพยากร Dependency โปรดดู การอัปเดตแคตตาล็อกอัตโนมัติและการผสานรวม LSP