首页 > 解决方案 > 如何禁用功能:aosp_car_x86_64-userdebug(android 11 汽车模拟器)中的 android.hardware.bluetooth

问题描述

我想禁用该功能:android.hardware.bluetooth for android 汽车模拟器 11。

我与 repo 同步的版本:android-11.0.0_r3 我午餐的版本:aosp_car_x86_64-userdebug

更改文件以注释掉权限:

汽车.mk

#    frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \
#    frameworks/native/data/etc/android.hardware.bluetooth.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \

评论权限:

car_core_hardware.xml

<!--    <feature name="android.hardware.bluetooth" /> -->

如果我运行模拟器并询问包管理器,它仍然确信蓝牙功能已启用:

pm list features
feature:android.hardware.bluetooth
feature:android.hardware.bluetooth_le

标签: androidandroid-emulatorandroid-sourceandroid-automotive

解决方案


当我从out文件夹中删除文件(android.hardware.bluetooth.xml)时,它被禁用了。问题是汽车无法处理此禁用,因为它开始崩溃:

01-07 15:12:08.833  8509  8509 D PerUserCarService: onCreate()
01-07 15:12:08.834  8509  8509 E BluetoothAdapter: Bluetooth binder is null
01-07 15:12:08.835  8509  8509 D AndroidRuntime: Shutting down VM
01-07 15:12:08.835  8509  8509 E AndroidRuntime: FATAL EXCEPTION: main
01-07 15:12:08.835  8509  8509 E AndroidRuntime: Process: com.android.car, PID: 8509
01-07 15:12:08.835  8509  8509 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.android.car.PerUserCarService: java.lang.NullPointerException: Bluetooth adapter cannot be null
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4204)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.app.ActivityThread.access$1500(ActivityThread.java:237)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:223)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7656)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
01-07 15:12:08.835  8509  8509 E AndroidRuntime: Caused by: java.lang.NullPointerException: Bluetooth adapter cannot be null
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at java.util.Objects.requireNonNull(Objects.java:245)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at com.android.car.CarBluetoothUserService.<init>(CarBluetoothUserService.java:84)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at com.android.car.PerUserCarService.onCreate(PerUserCarService.java:66)
01-07 15:12:08.835  8509  8509 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4192)

推荐阅读