1

I've been trying to build an android automotive emulator to enable Bluetooth support. There are instructions at https://source.android.com/devices/automotive/start/passthrough. However, the instructions leave quite many blanks and I would need advice from someone who is more experienced in making android custom builds.

System:

I'm building on a separate Linux computer, but I'm planning to use the AVD image on windows. I'm building an x86 64-bit variant.

Current status:

I have built an android AVD image, and I have built a custom goldfish-kernel-54 (without modifications), as specified in the previous section of the linked instructions. I'm able to run the image in the emulator. Now I will need to add Bluetooth support.

Problems:

I will quote the instructions and explain what I have done. I will bold the parts which I'm unsure of or which got me stuck.

Kernel:

  1. Add the missing btusb.ko to your kernel:

There is no "goldfish_defconfig" file in that repo. However, there is file "common/arch/x86/configs/x86_64_defconfig". Is that the correct file?

Guest android:

  1. In the vendor.mk file, include the Linux native HIDL and several permissions:

Modified file "device/generic/goldfish/vendor.mk", should be ok.

  1. Create a one-way path property to switch out the HIDL such that it uses a Linux native HIDL implementation

The instructions tell me to modify files "selinux/common/domain.te" and "selinux/common/property_contexts". However, there is no folder "selinux". I modified files "device/generic/goldfish/sepolicy/common/property_contexts" and "device/generic/goldfish/sepolicy/common/property_contexts". Are these files correct?

  1. Whenever a property qemu.preferred.bt.service is set to pass through, you'll switch out the HIDL implementation
service btlinux-1.1 /vendor/bin/hw/android.hardware.bluetooth@1.1-service.btlinux
  class hal
  user bluetooth
  group bluetooth net_admin net_bt_admin
  capabilities NET_ADMIN NET_RAW SYS_NICE
  disabled

on property:qemu.preferred.bt.service=passthrough
  stop vendor.bluetooth-1-1
  start btlinux-1.1

This is the part where I'm completely stuck. What am I supposed to do with the provided code snippet? Should I modify some existing file or add new file, and where?

  1. Add a Bluetooth configuration file to get full features, such as on a real USB device
hal/bluetooth/bdroid_buildcfg.h

#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "gCar Emulator"
#define BTA_AV_SINK_INCLUDED TRUE
/* Handsfree device */
#define BTA_DM_COD {0x26, 0x04, 0x08}
#endif

Here I'm stuck as well. What should I do with the provided code? Which file should I modify?

  1. Modify the BoardConfig.mk file to determine where the configuration file is saved

I modified file "device/google_car/avd_car/avd_car_device/BoardConfig.mk" (created in earlier phase when following given instructions). Is that the correct file, or should I have modified some file in goldfish folder?

Thanks in advance for any advice!

Ganesh MB
  • 1,109
  • 2
  • 14
  • 27
wekso
  • 39
  • 7

1 Answers1

0

There are some modification you need to do

There is no "goldfish_defconfig" file in that repo. However, there is file "common/arch/x86/configs/x86_64_defconfig". Is that the correct file?

As per the document, it is mentioned goldfish_defconfig.fragment which is in common-modules/virtual-device

Modified file "device/generic/goldfish/vendor.mk", should be ok.

Yes, it is correct file if you are using google provided AAOS emulator

The instructions tell me to modify files "selinux/common/domain.te" and "selinux/common/property_contexts". However, there is no folder "selinux". I modified files "device/generic/goldfish/sepolicy/common/property_contexts" and "device/generic/goldfish/sepolicy/common/property_contexts". Are these files correct?

Yes, these are correct files

This is the part where I'm completely stuck. What am I supposed to do with the provided code snippet? Should I modify some existing file or add new file, and where?

There is a rc file named android.hardware.bluetooth@1.1-service.btlinux.rc which is in system/bt/vendor_libs/linux/interface/ folder

Here I'm stuck as well. What should I do with the provided code? Which file should I modify?

A file bdroid_buildcfg.h which is in build/make/target/board/mainline_arm64/bluetooth/bdroid_buildcfg.h

I modified file "device/google_car/avd_car/avd_car_device/BoardConfig.mk" (created in earlier phase when following given instructions). Is that the correct file, or should I have modified some file in goldfish folder?

You can use same vendor.mk file to have configuration which is in device/generic/goldfish/vendor.mk

After build goldfish kernel you need to copy drivers and kernel image

cp goldfish-android11-5.4/out/android11-5.4/dist/bzImage prebuilts/qemu-kernel/x86_64/5.4/kernel-qemu2
cp goldfish-android11-5.4/out/android11-5.4/dist/*.ko prebuilts/qemu-kernel/x86_64/5.4/ko/

Build emulator and run. I hope you will able to connect BT devices

Jitendra
  • 1,015
  • 9
  • 24